diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-11-22 09:02:46 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-11-22 09:02:46 -0600 |
commit | 032fe000cfc2b36dc9c1f00c734fada41133403e (patch) | |
tree | cc489901762fe26dbe1253f7a4f2dca55956f89a /compilador/tabla.py | |
parent | 86c099629fad439402a51f031e3cb5507bc92278 (diff) | |
download | javanol-032fe000cfc2b36dc9c1f00c734fada41133403e.tar.gz javanol-032fe000cfc2b36dc9c1f00c734fada41133403e.tar.bz2 javanol-032fe000cfc2b36dc9c1f00c734fada41133403e.zip |
Se implementa semáforo (fases de compilación)
Diffstat (limited to 'compilador/tabla.py')
-rw-r--r-- | compilador/tabla.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compilador/tabla.py b/compilador/tabla.py index 637b9a6..ebe6225 100644 --- a/compilador/tabla.py +++ b/compilador/tabla.py @@ -70,7 +70,7 @@ class TablaLex: data.append({ 'tipo': t.tipo, 'nombre': t.nombre, - 'valor': str(t.valor), + 'valor': t.valor, 'numlinea': t.numlinea }) output = json.dumps(data) @@ -80,6 +80,15 @@ class TablaLex: f.truncate(0) f.write(output) + def importar(self, input_file): + with open(input_file, 'r') as f: + data = json.loads(f.read()) + for t in data: + self.insertar(LexToken(t['tipo'], + t['nombre'], + t['valor'], + t['numlinea'])) + def __str__(self): output = "" for t in self.tabla: |