aboutsummaryrefslogtreecommitdiff
path: root/compilador/lexer.py
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-11-25 19:07:58 -0600
committerIván Ávalos <avalos@disroot.org>2022-11-25 19:07:58 -0600
commit4b2fad150a292f882cee408d7f9746715225f7cb (patch)
treefe02aa65491aeec869e5c5427e2229fc1633bbf7 /compilador/lexer.py
parentea2d6ab3cc66e69d423e502407f272f634c3e070 (diff)
downloadjavanol-4b2fad150a292f882cee408d7f9746715225f7cb.tar.gz
javanol-4b2fad150a292f882cee408d7f9746715225f7cb.tar.bz2
javanol-4b2fad150a292f882cee408d7f9746715225f7cb.zip
Se añade `retornar', `detener' y `continuar'
Diffstat (limited to 'compilador/lexer.py')
-rw-r--r--compilador/lexer.py20
1 files changed, 2 insertions, 18 deletions
diff --git a/compilador/lexer.py b/compilador/lexer.py
index feac970..4d97b9d 100644
--- a/compilador/lexer.py
+++ b/compilador/lexer.py
@@ -1,5 +1,5 @@
from enum import Enum
-from tabla import LexToken, TablaLex, Token, tokens
+from tabla import LexToken, TablaLex, Token, tokens, reservadas
from parser import Parser
from shared import Control
from errors import Error
@@ -9,22 +9,6 @@ op_simples_a = ['=', '+', '-', '&', '|'] # pueden ir al final del op compuesto
op_simples_b = ['!', '<', '>'] # solo pueden ir al inicio del op compuesto
op_simples = op_simples_a + op_simples_b
otros_tokens = ['{', '}', '(', ')', ',', '.', ';']
-reservadas = {
- 'booleano': 'BOOLEAN',
- 'detener': 'BREAK',
- 'cadena': 'STRING',
- 'caracter': 'CHAR',
- 'sino': 'ELSE',
- 'porcada': 'FOR',
- 'si': 'IF',
- 'entero': 'INT',
- 'imprimir': 'PRINT',
- 'leer': 'READ',
- 'retorna': 'RETURN',
- 'vacio': 'VOID',
- 'mientras': 'WHILE',
- 'funcion': 'FUNCTION'
-}
class Selector(Enum):
NINGUNO = 0
@@ -186,7 +170,7 @@ class Lexer:
if c.isalnum() or c == '_':
self.recol_ident += c
else:
- if self.recol_ident in reservadas.keys():
+ if self.recol_ident in reservadas:
self.insertar_tabla(Token(self.recol_ident), None, None)
elif self.recol_ident == 'verdadero':
self.insertar_tabla(Token.BOOLEAN_LIT, None, True)