def parser(input): """ docstring """ grammar.parse(input) lexerErrors = grammar.returnLexicalErrors() syntaxErrors = grammar.returnSyntacticErrors() obj = { "lexical": lexerErrors, "syntax": syntaxErrors, } astReport() BnfGrammar.grammarReport() return obj
def execution(input): global semanticErrorsL """ 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() if len(semanticErrors) > 0: semanticErrorsL.append(semanticErrors) PostgresErrors = grammar.returnPostgreSQLErrors() symbols = symbolReport() obj = { "messages": messages, "querys": querys, "lexical": lexerErrors, "syntax": syntaxErrors, "semantic": semanticErrorsL, "postgres": PostgresErrors, "symbols": symbols, } astReport() BnfGrammar.grammarReport() return obj
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
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