aboutsummaryrefslogtreecommitdiff
path: root/arbol.py
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-11-15 00:34:55 -0600
committerIván Ávalos <avalos@disroot.org>2022-11-15 00:34:55 -0600
commita55cd744c6dae4bba01ec83c6d3603e4ec0627a3 (patch)
tree70e62cfdc755aa1b97ea9e6eaafec23377e95164 /arbol.py
parentde272f939f2ae0266a4ee363a854558ace5a59e2 (diff)
downloadjavanol-a55cd744c6dae4bba01ec83c6d3603e4ec0627a3.tar.gz
javanol-a55cd744c6dae4bba01ec83c6d3603e4ec0627a3.tar.bz2
javanol-a55cd744c6dae4bba01ec83c6d3603e4ec0627a3.zip
Primeras fases de análisis sintáctico
Diffstat (limited to 'arbol.py')
-rw-r--r--arbol.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/arbol.py b/arbol.py
new file mode 100644
index 0000000..7abcbe0
--- /dev/null
+++ b/arbol.py
@@ -0,0 +1,26 @@
+class Nodo:
+ def __init__(self, dato = None):
+ self.dato = dato
+ self.hijos = []
+
+ def print(self, n = 0):
+ s = ' ' * n + 'Nodo:' + "\n"
+ s += ' ' * n + "dato = " + str(self.dato) + "\n"
+ s += ' ' * n + "hijos =\n"
+ for h in self.hijos:
+ s += h.print(n + 1)
+ s += "\n"
+ return s
+
+ def __str__(self):
+ return self.print()
+
+
+class Arbol:
+ def __init__(self, raiz: Nodo = Nodo()):
+ self.raiz = raiz
+
+ def __str__(self):
+ if self.raiz:
+ return str(self.raiz)
+ return "None"