public static void TestNDFA() { Console.WriteLine("--------------NDFA--------------\nEnds with a, or bc\n--------------NDFA--------------"); // Ends with a, or bc string ndfaTest = "acb"; tester(ndfaTest, ndfa.accept(ndfaTest.ToCharArray())); ndfaTest = "bbabaabbbca"; tester(ndfaTest, ndfa.accept(ndfaTest.ToCharArray())); GraphViz.PrintNDFA(ndfa, "ndfa"); }
public static void TestRegExp() { a = new Regex("a"); b = new Regex("b"); // expr1: "baa" expr1 = new Regex("baa"); // expr2: "bb" expr2 = new Regex("bb"); // expr3: "baa | baa" expr3 = expr1.or(expr2); // all: "(a|b)*" all = (a.or(b)).star(); // expr4: "(baa | baa)+" expr4 = expr3.plus(); // expr5: "(baa | baa)+ (a|b)*" expr5 = expr4.dot(all); // converting to NDFA int i = 0; NDFA <int, char> ndfa = expr5.toNDFA(ref i); string ndfaTest = "baab"; tester(ndfaTest, ndfa.accept(ndfaTest.ToCharArray())); Console.WriteLine("-----NDFA Graph-----"); GraphViz.PrintNDFA(ndfa, "ndfa"); }