def compile(re_str): lex = Lexer(tokenDefiniton) lex.run(re_str) tree = RegExParser(lex).regex() idg = IDGenerator() nfa = tree.get_nfa(idg) return nfa
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)
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)
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)