def sintactico(): import mpaslex import sys lexer = mpaslex.make_lexer() parser = make_parser() program = parser.parse(open(sys.argv[1]).read()) program.pprint() program.semantico() print "Succeded" return program
def main(): import mpasparse import sys from errors import subscribe_errors lexer = mpaslex.make_lexer() parser = mpasparse.make_parser() with subscribe_errors(lambda msg: sys.stdout.write(msg+"\n")): program = parser.parse(open(sys.argv[1]).read()) # Revisa el programa check_program(program)
''' pass def p_error(p): if p: error(p.lineno, "Error de sintaxis en el token '%s'" % p.value) else: error("EOF","Error de sintaxis, fin de entrada.") def make_parser(): parser = yacc.yacc() return parser if __name__ == '__main__': import mpaslex import sys from errors import subscribe_errors lexer = mpaslex.make_lexer() parser = make_parser() with subscribe_errors(lambda msg: sys.stdout.write(msg+"\n")): program = parser.parse(open(sys.argv[1]).read()) print "listo parte uno" dot = DotVisitor() dot.visit(program) print "listo visitado" dot.graph.write_png("grafo.png") #dump_tree(program) #for depth,node in flatten(program): # print("%s%s" % (" "*(4*depth),node.__class__.__name__))
def make_parser(): lexer = mpaslex.make_lexer() parser = yacc.yacc(debug=1) return parser