aboutsummaryrefslogtreecommitdiff
path: root/compilador/lexer.py
diff options
context:
space:
mode:
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