From a7142bce0e17b4fdd5cae33e6ef0140a109a496a Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sun, 6 Nov 2022 23:17:19 -0600 Subject: Se eliminan residuos --- lexer.py | 44 +------------------------------------------- main.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 43 deletions(-) diff --git a/lexer.py b/lexer.py index 49d75df..168858e 100644 --- a/lexer.py +++ b/lexer.py @@ -1,34 +1,9 @@ from enum import Enum from symbol import LexToken, TablaLex, tokens -t_boolean = 'booleano' -t_break = 'detener' -t_char = 'caracter' -t_double = 'doble' -t_else = 'si no' -t_for = 'por cada' -t_ident = r'[a-zA-Z_][a-zA-Z0-9_]?' -t_if = 'si' -t_int = 'entero' -t_print = 'imprimir' -t_read = 'leer' -t_return = 'retorna' -t_string = 'cadena' -t_void = 'vacio' -t_while = 'mientras' - -t_boolean_lit = r'verdadero|falso' -t_char_lit = r'\'[[:print:]]\'' -t_double_lit = r'\d+.\d+' -t_int_lit = r'\d+' -t_string_lit = r'"[[:print]]*"' - def inicio_lexer(data): tabla = TablaLex() - es_string = False - es_caracter = False - es_comentario = False selector = '' recol_string = '' recol_caracter = '' @@ -129,22 +104,5 @@ def inicio_lexer(data): recol_comentario = '' continue + # Imprimir tabla de símbolos print (str(tabla)) - - ''' - tabla = TablaLex() - # booleano ivan = verdadero - tabla.insertar(LexToken('BOOLEAN', None, None, 1)) - tabla.insertar(LexToken('IDENT', 'ivan', None, 1)) - tabla.insertar(LexToken('=', None, None, 1)) - tabla.insertar(LexToken('BOOLEAN_LIT', None, True, 1)) - print (str(tabla)) - - ident = tabla.buscar('ivan') - print (str(ident)) - - ident.valor = True - tabla.actualizar('ivan', ident) - ident = tabla.buscar('ivan') - print (str(ident)) - ''' diff --git a/main.py b/main.py index 1df4337..8432849 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,11 @@ from lexer import * class Main: input_file = None output_file = None + + # GUI widgets text = None + msgarea = None + symbols = None def abrir_archivo(self): self.input_file = filedialog.askopenfilename() @@ -34,9 +38,14 @@ class Main: def main_gui(self, argv): root = Tk() root.title ("Javañol") + root.columnconfigure(0, weight=1) + root.rowconfigure(0, weight=1) mainframe = ttk.Frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) + mainframe.columnconfigure(0, weight=1) + mainframe.rowconfigure(0, weight=1) + mainframe.rowconfigure(1, weight=0) # Menú win = Toplevel(root) @@ -56,9 +65,28 @@ class Main: win['menu'] = menubar + # Editor de código self.text = Text(mainframe) self.text.grid(column=0, row=0, sticky=(N, W, E, S)) + # Área de mensajes + msgarealf = LabelFrame(mainframe, text='Área de mensajes', height=10) + msgarealf.grid(column=0, row=1, sticky=(W, E, S)) + + self.msgarea = Text(msgarealf, height=10) + self.msgarea.grid(column=0, row=0, sticky=(N, W, E, S)) + self.msgarea.rowconfigure(0, weight=1) + self.msgarea.columnconfigure(0, weight=1) + + # Tabla de símbolos + symbolslf = LabelFrame(mainframe, text='Símbolos', width=100) + symbolslf.grid(column=1, row=0, rowspan=2, sticky=(N, W, E, S)) + + self.symbols = Text(symbolslf, width=20) + self.symbols.grid(column=0, row=0, sticky=(N, W, E, S)) + self.msgarea.rowconfigure(0, weight=1) + self.msgarea.columnconfigure(0, weight=1) + root.mainloop() if __name__ == "__main__": -- cgit v1.2.3