def setUp(self): f = open("../grammars/" + self.file) G = f.read() f.close() f = open("../grammars/" + self.solution) G2 = f.read() f.close() self.grammar_one = Parser(G) t = Transform(self.grammar_one) t.pa() self.grammar_two = Parser(G2)
def main(argv): # open file try: filename = argv[0] except IndexError: print "Usage: %s grammar.yacc" % sys.argv[0] sys.exit(2) try: f = open(filename, "r") except IOError: print "Unable to open file", filename sys.exit(2) G = f.read() f.close() parse = Parser(G) t = Transform(parse) t.pa() parse.printer()