Example #1
0
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()
Example #2
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()