def main(): global input, grammar g = Grammar(grammar) g.parse() gotos = GotoGenerator(g) gotos.generate() gotos.display() g.first_follow.display() parsing_table = Table(g, gotos) parsing_table.generate() lr_parser = LR_Parser(g, parsing_table, input) lr_parser.parse()
def main(): pars_arg() args = parser.parse_args() if args.fileInput == args.fileOutput: print("ERROR: you must give different name of files", file=sys.stderr) return 1 raw_grammar = "" try: with open(args.fileInput, "r") as file: raw_grammar = file.read() except: print("ERROR: cannot open " + args.fileInput, file=sys.stderr) return 1 g = Grammar(raw_grammar) g.parse() gotos = GotoGenerator(g) gotos.generate() gotos.display(args.verbose) gotos.create_file(args.fileOutput, args.verbose) return 0
def main(*argv): global input, grammar if len(argv[0]) == 2: grammar = """""" with open(argv[0][0], 'r') as content_file: grammar = content_file.read() input = argv[0][1] g = Grammar(grammar) g.parse() gotos = GotoGenerator(g) gotos.generate() gotos.display() g.first_follow.display() parsing_table = Table(g, gotos) parsing_table.generate() lr_parser = LR_Parser(g, parsing_table, input) lr_parser.parse()