From eb4a3019bc0251e5b2b8229679e3c65d61d55336 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Fri, 25 Nov 2022 12:11:08 -0600 Subject: Buen progreso, pero se cicla --- compilador/lexer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'compilador/lexer.py') 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 -- cgit v1.2.3