aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-11-23 23:28:32 -0600
committerIván Ávalos <avalos@disroot.org>2022-11-23 23:28:32 -0600
commit549857003fd3c4411946db8a2ced846d8cbb825e (patch)
treeed74bce432b7a5e773405ba11d899a77dc687df7
parent02e70483ad490b83118ea43770c995c61ffa4ce7 (diff)
downloadjavanol-549857003fd3c4411946db8a2ced846d8cbb825e.tar.gz
javanol-549857003fd3c4411946db8a2ced846d8cbb825e.tar.bz2
javanol-549857003fd3c4411946db8a2ced846d8cbb825e.zip
Se cambia diseño de grafo
-rw-r--r--compilador/arbol.py1
-rw-r--r--compilador/parser.py3
-rw-r--r--pruebas/sintaxis.es3
3 files changed, 5 insertions, 2 deletions
diff --git a/compilador/arbol.py b/compilador/arbol.py
index 234d2e9..1ca2cd9 100644
--- a/compilador/arbol.py
+++ b/compilador/arbol.py
@@ -38,6 +38,7 @@ class Arbol:
dot = gv.Digraph()
dot.attr(rankdir='LR')
dot.attr('node', fontname='monospace')
+ dot.attr('node', shape='box')
self.raiz.render(dot, None)
dot.render(filename, view = view)
diff --git a/compilador/parser.py b/compilador/parser.py
index 951b517..f75f817 100644
--- a/compilador/parser.py
+++ b/compilador/parser.py
@@ -24,6 +24,7 @@ class Selector(Enum):
class Parser:
def __init__(self, input_file: str):
+ self.input_file = input_file
self.arbol = Arbol()
self.pila_selector = [
[Selector.NINGUNO, []] # selector, recolector
@@ -41,7 +42,7 @@ class Parser:
r = self.procesar(t)
if r == Control.ERROR: return 1
- print(str(self.arbol))
+ self.arbol.render(self.input_file + '.gv')
return 0
def procesar (self, t: LexToken):
diff --git a/pruebas/sintaxis.es b/pruebas/sintaxis.es
index 57ef350..923cc44 100644
--- a/pruebas/sintaxis.es
+++ b/pruebas/sintaxis.es
@@ -3,4 +3,5 @@ entero b = 20;
booleano c = verdadero;
caracter d;
imprimir a + b;
-imprimir "Hola, Mundo"; \ No newline at end of file
+imprimir "Hola, Mundo";
+leer a; \ No newline at end of file