Beispiel #1
0
    regex = None
    method = None

    while opt != 0:
        print(main_menu)
        opt = input('> ')

        if opt == '1':
            print(type_regex_msg)
            regex = input('> ')

            try:
                reader = Reader(regex)
                tokens = reader.CreateTokens()
                parser = Parser(tokens)
                tree = parser.Parse()

                direct_reader = DirectReader(regex)
                direct_tokens = direct_reader.CreateTokens()
                direct_parser = Parser(direct_tokens)
                direct_tree = direct_parser.Parse()
                print('\n\tExpression accepted!')
                print('\tParsed tree:', tree)

            except AttributeError as e:
                print(f'\n\tERR: Invalid expression (missing parenthesis)')

            except Exception as e:
                print(f'\n\tERR: {e}')

        if opt == '2':