Exemple #1
0
 def analize(self):
     entrada = self.txtEntrada.get("1.0", END)  # variable de almacenamiento de la entrada
     result = grammar.parse(entrada)
     self.lexicalErrors = grammar.returnLexicalErrors()
     self.sintacticErrors = grammar.returnSintacticErrors()
     self.semanticErrors = grammar.returnSemanticErrors()
     self.postgreSQL = grammar.returnPostgreSQLErrors()
     if len(self.lexicalErrors) + len(self.sintacticErrors) + len(self.semanticErrors) > 0:
         tkinter.messagebox.showerror( title="Error", message="El archivo contiene errores" )
Exemple #2
0
def execution(input):
    """
    docstring
    """
    querys = []
    messages = []
    result = grammar.parse(input)
    lexerErrors = grammar.returnLexicalErrors()
    syntaxErrors = grammar.returnSyntacticErrors()
    if len(lexerErrors) + len(syntaxErrors) == 0 and result:
        for v in result:
            if isinstance(v, Select):
                r = v.execute(None)
                if r:
                    list_ = r[0].values.tolist()
                    labels = r[0].columns.tolist()
                    querys.append([labels, list_])
                    messages.append("Select ejecutado con exito.")
                else:
                    querys.append(None)
                    messages.append("Error: Select.")
                print(r)
            else:
                r = v.execute(None)
                print(r)
                messages.append(r)
    semanticErrors = grammar.returnSemanticErrors()
    PostgresErrors = grammar.returnPostgreSQLErrors()
    symbols = symbolReport()
    obj = {
        "messages": messages,
        "querys": querys,
        "lexical": lexerErrors,
        "syntax": syntaxErrors,
        "semantic": semanticErrors,
        "postgres": PostgresErrors,
        "symbols": symbols,
    }
    astReport()
    #BnfGrammar.grammarReport()
    try:
        if len(querys) == 1:
            if len(querys[0][1]) == 1:
                if len(querys[0][1][0]) == 1:
                    return querys[0][1][0][0]
    except:
        return obj
    return obj
Exemple #3
0
def execution(input):
    """
    docstring
    """
    querys = []
    messages = []
    result = grammar.parse(input)
    with open("obj.pickle", "wb") as f:
        pickle.dump(result, f)
    lexerErrors = grammar.returnLexicalErrors()
    syntaxErrors = grammar.returnSyntacticErrors()
    if len(lexerErrors) + len(syntaxErrors) == 0 and result:
        for v in result:
            if isinstance(v, inst.Select) or isinstance(
                    v, inst.SelectOnlyParams):
                r = v.execute(None)
                if r:
                    list_ = r[0].values.tolist()
                    labels = r[0].columns.tolist()
                    querys.append([labels, list_])
                else:
                    querys.append(None)
            else:
                r = v.execute(None)
                messages.append(r)
    semanticErrors = grammar.returnSemanticErrors()
    PostgresErrors = grammar.returnPostgreSQLErrors()
    symbols = symbolReport()
    obj = {
        "messages": messages,
        "querys": querys,
        "lexical": lexerErrors,
        "syntax": syntaxErrors,
        "semantic": semanticErrors,
        "postgres": PostgresErrors,
        "symbols": symbols,
    }
    astReport()
    BnfGrammar.grammarReport()
    return obj
Exemple #4
0
def getc3d(input):
    """
    docstring
    """
    querys = []
    messages = []
    result = grammar.parse(input)
    lexerErrors = grammar.returnLexicalErrors()
    syntaxErrors = grammar.returnSyntacticErrors()
    tabla = Environment()
    if len(lexerErrors) + len(syntaxErrors) == 0 and result:
        for v in result:
            if isinstance(v, inst.Select) or isinstance(
                    v, inst.SelectOnlyParams):
                r = v.c3d(tabla)
                if r:
                    list_ = r[0].values.tolist()
                    labels = r[0].columns.tolist()
                    querys.append([labels, list_])
                else:
                    querys.append(None)
            else:
                r = v.c3d(tabla)
                messages.append(r)
    semanticErrors = grammar.returnSemanticErrors()
    PostgresErrors = grammar.returnPostgreSQLErrors()
    symbols = symbolReport()
    obj = {
        "messages": messages,
        "querys": querys,
        "lexical": lexerErrors,
        "syntax": syntaxErrors,
        "semantic": semanticErrors,
        "postgres": PostgresErrors,
        "symbols": symbols,
        "codigo": tabla.codigo,
    }
    astReport()
    BnfGrammar.grammarReport()
    return obj