Exemplo n.º 1
0
 def p(self, x):
     import astpp
     import unparser
     try:
         print 'a>', astpp.sprint(x).strip()
         print 'c>', unparser.unparse(x)
     except: print x
     print
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
def unparse_src(node):
    return unparser.unparse(node)
Exemplo n.º 5
0
	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()