def main(): exit = False exit2 = False while not exit: file_name = raw_input("\n>Where is the Grammar =) ?: ") print "\nGrammar:" grammar = Grammar() grammar.init_grammar(file_name) print "\nNon Terminals: " + grammar.non_terminals.__str__() print "\nTerminals:" + grammar.terminals.__str__() grammar.define_first_sets() grammar.define_follow_sets() print "\nFirst and Follow Set of Productions:\n" print_table_first_follow_set(grammar) print "\nParse Table of the Grammar: \n" parse_table = build_parse_table(grammar) parse_table_with_sync_set(parse_table,grammar) is_ambiguous = print_parse_table(parse_table, grammar) if is_ambiguous: print "The Grammar is Ambiguous" else: print "The Grammar is not Ambiguous" while not exit2: input_string = raw_input("\nString to Analyze: ") if '$' in input_string: ll_parsing(parse_table, grammar, input_string) else: print "\nYou must enter the end of string character ($)" exit2 = raw_input("\nEnter another String to Analyze? ") != 'yes' exit = raw_input("\nEnter another Grammar? ") != 'yes' print "*"*100