aboutsummaryrefslogtreecommitdiff
path: root/compilador/tabla.py
diff options
context:
space:
mode:
Diffstat (limited to 'compilador/tabla.py')
-rw-r--r--compilador/tabla.py11
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: