Exemplo n.º 1
0
    input_file = open(input_path, "r")
    regex = input_file.readline()
    input_file.close()
    return regex


if __name__ == '__main__':
    input_path = sys.argv[1]
    output_path_nfa = sys.argv[2]
    output_path_dfa = sys.argv[3]

    # add concatenation symbol into the regex
    regex = precompute_regex(read_input(input_path))

    pda = PDA()
    nfa = NFA()

    # Construieste arborele de parsare
    parse_tree = pda.parseExpression(regex)

    # Adauga root-ul arboerlui de parsare in NFA
    nfa.transitions[0, parse_tree] = 1
    # Creeaza NFA
    nfa.create_NFA(0)

    # Scrie in fisier NFA-ul
    nfa.write_output(output_path_nfa)

    # Foloseste codul din tema2 pentru a transforma NFA-ul obtinut din regex in DFA
    #convert_to_dfa(output_path_nfa, output_path_dfa)