Пример #1
0
    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)
Пример #2
0
Файл: lr.py Проект: palmerc/lab
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()