示例#1
0
 def get_result(self, test):
     tokenizer = Tokenizer(text=test)
     parser = Parser(tokenizer)
     try:
         tree = parser.parse()
         return AstVizGen(tree).return_str_tree()
     except Error as e:
         return e.message
示例#2
0
def run(input_f, output_f):

    code = []

    file = open(input_f, "r")
    for line in file:
        line = line.replace('\n', '')
        if len(line) > 0:
            code.append(line)

    parser = Parser()
    gen = Generator()
    parser.set_code_lines(code)
    gen.generate(output_f, parser.parse())
示例#3
0
 def print_ast(self):
     tokenizer = Tokenizer(self.file)
     parser = Parser(tokenizer)
     tree = parser.parse()
     AstVizGen(tree).generate()