Example #1
0
def compile(re_str):
    lex = Lexer(tokenDefiniton)
    lex.run(re_str)
    tree = RegExParser(lex).regex()
    idg = IDGenerator()

    nfa = tree.get_nfa(idg)
    return nfa
Example #2
0
    def test_combination1_parser(self):
        re = "(0|1)*010"
        l = LexicalAnalyzer()
        l.run(re)

        parser = RegExParser(l)
        tree = parser.regex()

        print(tree)
        self.assertEqual(tree.__repr__() == re, True)
Example #3
0
    def test_star_parser(self):
        re = "a**"
        l = LexicalAnalyzer()
        l.run(re)

        parser = RegExParser(l)
        tree = parser.regex()

        print(tree)
        self.assertEqual(tree.__repr__() == re, True)
Example #4
0
def drawNFA(reInput, file=None):
    lex = LexicalAnalyzer()

    lex.run(reInput)

    parser = RegExParser(lex)

    tree = parser.regex()

    idgenerator = IDGenerator()
    nfa = tree.get_nfa(idgenerator)

    drawGraphNFA(nfa, file)