aboutsummaryrefslogtreecommitdiff
path: root/tabla.py
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-11-15 08:08:06 -0600
committerIván Ávalos <avalos@disroot.org>2022-11-15 08:08:06 -0600
commitc78465010691d45f5e5bfa6a36a96800d30962ac (patch)
tree93521b0c9788712823937e4c48212bc02f0b04b5 /tabla.py
parenta3097d32c66cbdff04de14481923c7464b0a8a29 (diff)
downloadjavanol-c78465010691d45f5e5bfa6a36a96800d30962ac.tar.gz
javanol-c78465010691d45f5e5bfa6a36a96800d30962ac.tar.bz2
javanol-c78465010691d45f5e5bfa6a36a96800d30962ac.zip
Se elimina código de interfaz y se reorganizan directorios
Diffstat (limited to 'tabla.py')
-rw-r--r--tabla.py70
1 files changed, 0 insertions, 70 deletions
diff --git a/tabla.py b/tabla.py
deleted file mode 100644
index c8ca424..0000000
--- a/tabla.py
+++ /dev/null
@@ -1,70 +0,0 @@
-from enum import Enum
-from dataclasses import dataclass
-from typing import Any
-
-reservadas = [
- 'BOOLEAN',
- 'BREAK',
- 'CHAR',
- 'DOUBLE',
- 'ELSE',
- 'FOR'
- 'IDENT',
- 'IF',
- 'INT',
- 'PRINT',
- 'READ',
- 'RETURN',
- 'STRING',
- 'VOID',
- 'WHILE'
-]
-
-literales = [
- 'BOOLEAN_LIT',
- 'CHAR_LIT',
- 'DOUBLE_LIT',
- 'INT_LIT',
- 'STRING_LIT'
-]
-
-tokens = reservadas + literales + [
- '{', '}', '(', ')', ',', '\'',
- '"', ';', '=', '*', '/', '+',
- '-', '>', '<', '>=', '<=', '&&',
- '||', '==', '!=', '++', '--', '//'
-]
-
-@dataclass
-class LexToken:
- tipo: str
- nombre: str
- valor: Any
- numlinea: int
-
- def __str__(self):
- return "LexToken(%s,%s,%s,%i)" % (
- self.tipo, self.nombre, self.valor, self.numlinea
- )
-
-class TablaLex:
- def __init__(self):
- self.tabla = []
-
- def insertar(self, tok: LexToken):
- self.tabla.append(tok)
-
- def buscar(self, nombre: str):
- return [t for t in self.tabla if t.nombre == nombre][0]
-
- def actualizar(self, nombre: str, tok: LexToken):
- for i, t in enumerate(self.tabla):
- if t.nombre == nombre:
- self.tabla[i] = tok
- return
-
- def __str__(self):
- output = ""
- for t in self.tabla:
- output += str(t) + "\n"
- return output