Exemplo n.º 1
0
        if opt == '2':
            if not regex:
                print('\n\tERR: You need to set a regular expression first!')
                opt = None
            else:
                print(submenu)
                method = input('> ')

                if method == '1':
                    print(thompson_msg)
                    print(type_string_msg)
                    regex_input = input('> ')

                    nfa = NFA(tree, reader.GetSymbols(), regex_input)
                    start_time = process_time()
                    nfa_regex = nfa.EvalRegex()
                    stop_time = process_time()

                    print('\nTime to evaluate: {:.5E} seconds'.format(
                        stop_time - start_time))
                    print('Does the string belongs to the regex (NFA)?')
                    print('>', nfa_regex)

                    dfa = DFA(nfa.trans_func, nfa.symbols, nfa.curr_state,
                              nfa.accepting_states, regex_input)
                    dfa.TransformNFAToDFA()
                    start_time = process_time()
                    dfa_regex = dfa.EvalRegex()
                    stop_time = process_time()
                    print('\nTime to evaluate: {:.5E} seconds'.format(
                        stop_time - start_time))