diff options
-rw-r--r-- | lexer.py | 44 | ||||
-rw-r--r-- | main.py | 28 |
2 files changed, 29 insertions, 43 deletions
@@ -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)) - ''' @@ -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__": |