def p(self, x): import astpp import unparser try: print 'a>', astpp.sprint(x).strip() print 'c>', unparser.unparse(x) except: print x print
def main(): for test_num in range(len(test_files)): print('\n') test_file = test_files[test_num] print("testing file " + test_file) l_parse_tree = parse_file(test_file) asp_transformed_tree = transformer.transform(l_parse_tree) asp_translated_program = unparser.unparse(asp_transformed_tree) answers_out = parse_clingo_output(run_asp_program(asp_translated_program)) compare_answers(answers_out, test_outputs[test_num]) check_tree(asp_transformed_tree, asp_translated_program)
def unp(self, x): import unparser zs = [x] if hasattr(x, '__iter__'): zs = x xs = [] for z in zs: if hasattr(z, '__iter__'): xs.extend(z) else: xs.append(z) for x in xs: try: print 'c>', unparser.unparse(x) except: print x print
def unparse_src(node): return unparser.unparse(node)
def rewrite(self, path, tree): self.logger.debug('%s is dirty, file will be rewrite', path) file = open(path, 'w') file.write('# -*- coding:utf-8 -*-\n') unparser.unparse(tree, file) file.close()