Пример #1
0
    def Traducir_Alto_nivel(self):
        global traducir
        try:
            self.consola.clear()
            #self.tabla_cuadruplos.clear()
            tab = self.editor.widget(self.editor.currentIndex())
            items = tab.children()
            codigo = items[0].text()
            ast = Gramatica.parse(codigo)
            lst_errores = Gramatica.lst_errores
            errores = GraficarError(args=(lst_errores, "Errores"), daemon=True)
            errores.start()
            gda = GramaticaGDA.parse(codigo)
            nodo = GramaticaM.parse(codigo)
            g_ast = GraficarArbol(args=(nodo, "AST"), daemon=True)
            g_ast.start()
            g_gda = GraficarGDA(args=(gda, "GDA"), daemon=True)
            g_gda.start()

            self.codigo_3d.clear()
            self.codigo_3d_optimizado.clear()
            traducir = Traducir(
                args=(ast, self.tabla_cuadruplos, self.codigo_3d, self.consola,
                      self.tabla_simbolos, self.codigo_3d_optimizado),
                daemon=True)
            traducir.start()
        except:
            print("ERROR EN EJECUCION NORMAL")
Пример #2
0
def EjecutarASC(input):
    instrucciones = g.parse(input)
    global ts_global
    ts_global = TS.TablaDeSimbolos()
    if instrucciones is None:
        print('Unnable to Compile. Please Check the Code')
    else:
        grafo = Graficadora()
        grafo.Recorrer_Instrucciones_Inicio(instrucciones)
        Recorrer_Instrucciones(instrucciones, ts_global)
Пример #3
0
def DebuggerIniciar(input):
    global Terminar
    Terminar = False
    global instrdebug
    instrdebug = g.parse(input)
    global ts_global
    Globales.debug = 0
    ts_global = TS.TablaDeSimbolos()
    if instrdebug is None:
        print('Unnable to Compile. Please Check the Code')
    else:
        accion_LlenarTsEtiquetas(
            instrdebug, ts_global)  # tengo que llenar al iniciar mis etiquetas
Пример #4
0
Файл: AST.py Проект: mr8ug/tytus
def Analisar(input):
    instrucciones = g.parse(input)
    print(instrucciones)
    ts_global = TS.TablaDeSimbolos()
    procesar_instrucciones(instrucciones, ts_global)
Пример #5
0
    def ejecutar_analisis(self):

        #self.consola.setText("****** Preparando Analisis ******")
        self.consola.clear()
        indextab = self.editores.tabText(self.editores.currentIndex())
        ##self.consola.setText("Archivo a analizar: "+indextab)
        tab = self.editores.widget(self.editores.currentIndex())
        items = tab.children()
        codigo = items[0].toPlainText()
        ast = None
        analisis_semantico = False
        lst = []
        print(
            "___________INICIA PROCESO DE ANALISIS LEXICO Y SINTACTICO_______________"
        )
        try:
            if self.analizador_cambiado:
                gramaticaD.lst_errores = []
                ast = gramaticaD.parse(codigo)
                arbolparser = GramaticaDG.parse(codigo)
                graficaAST = GraficarArbol(args=(arbolparser,
                                                 "ASPDescendente"),
                                           daemon=True)
                graficaAST.start()
                graficaGramatical = GraficarGramatica(
                    args=(gramaticaD.lstGrmaticales, "ReporteGramatical"),
                    daemon=True)
                graficaGramatical.start()
                lst = gramaticaD.lst_errores
                gramaticaD.lstGrmaticales = []
            else:
                gramatica.lst_errores = []
                ast2 = gramatica.parse(codigo)
                ast = ast2.instruccion

                graficaAST = GraficarArbol(args=(ast2.nodo, "ASPAscendente"),
                                           daemon=True)
                graficaAST.start()
                graficaGramatical = GraficarGramatica(
                    args=(gramatica.lstGrmaticales, "ReporteGramatical"),
                    daemon=True)
                graficaGramatical.start()
                gramatica.lstGrmaticales = []
                lst = gramatica.lst_errores
        except:
            self.consola.append(
                "/\\/\\/\\/\\/\\ERROR DE LEXICO, SINTACTICO/\\/\\/\\/\\")
            self.consola.append("REVISAR REPORTE DE ERRORES")
        finally:
            if not self.analizador_cambiado:
                gramatica.graficarErrores()
            else:
                gramaticaD.graficarErrores()

        ts = TablaSimbolos()

        global in_console
        if self.debug_mode:
            in_console = Debuger(args=(ast if (ast != None) else ast, ts, lst,
                                       "", items[0], self.consola, self.GTS),
                                 daemon=True)
        else:
            in_console = Ejecutor(args=(ast if (ast != None) else ast, ts, lst,
                                        "", items[0], self.consola, self.GTS),
                                  daemon=True)
        if ast != None:
            try:
                print(
                    "___________INICIA PROCESO DE ANALISIS SEMANTICO_______________"
                )
                recolector = Recolectar(ast, ts, lst)
                print("******FIN CONSTRUCTOR**********")
                recolector.procesar()
                recolector.getErrores()
                print("******FIN RECOLECCION*******")
                print("********** FIN DE CONSTRUCTOR ********")
                in_console.start()
            except:
                self.consola.append(
                    "/\\/\\/\\/\\/\\ERROR DE EJECUCION/\\/\\/\\/\\")
                self.consola.append("REVISAR REPORTE DE ERRORES")
        ts.graficarSimbolos()