aboutsummaryrefslogtreecommitdiff
path: root/compilador/lexer.py
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-11-25 12:11:08 -0600
committerIván Ávalos <avalos@disroot.org>2022-11-25 12:11:08 -0600
commiteb4a3019bc0251e5b2b8229679e3c65d61d55336 (patch)
treef6b2a89dd35374272bd671933bfe87da4a587215 /compilador/lexer.py
parent6b4e9a4e95eb511c194200e38ee323091dc5d7d2 (diff)
downloadjavanol-eb4a3019bc0251e5b2b8229679e3c65d61d55336.tar.gz
javanol-eb4a3019bc0251e5b2b8229679e3c65d61d55336.tar.bz2
javanol-eb4a3019bc0251e5b2b8229679e3c65d61d55336.zip
Buen progreso, pero se cicla
Diffstat (limited to 'compilador/lexer.py')
-rw-r--r--compilador/lexer.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/compilador/lexer.py b/compilador/lexer.py
index 2106c3f..feac970 100644
--- a/compilador/lexer.py
+++ b/compilador/lexer.py
@@ -22,7 +22,8 @@ reservadas = {
'leer': 'READ',
'retorna': 'RETURN',
'vacio': 'VOID',
- 'mientras': 'WHILE'
+ 'mientras': 'WHILE',
+ 'funcion': 'FUNCTION'
}
class Selector(Enum):
@@ -60,6 +61,9 @@ class Lexer:
if r == Control.ERROR: return 1
self.numlinea += 1
+ # End of file (EOF)
+ self.insertar_tabla(Token.EOF, None, None)
+
# Exportar tabla de símbolos
self.tabla.exportar(self.input_file + '.tab')
return 0
@@ -154,11 +158,11 @@ class Lexer:
def procesar_caracter(self, c):
if len(self.recol_caracter) > 1:
- Error('L_CAR_LARGO', self.numlinea)
+ print(Error.lex('L_CAR_LARGO', self.numlinea).message)
return Control.ERROR
if c == '\'':
if len(self.recol_caracter) == 0:
- Error('L_CAR_VACIO', self.numlinea)
+ print(Error('L_CAR_VACIO', self.numlinea).message)
return Control.ERROR
self.insertar_tabla(Token.CHAR_LIT, None, self.recol_caracter)
self.selector = Selector.NINGUNO