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"); }
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 testDfaOperation() { Console.WriteLine("--------------DFA AND--------------\nMerging 2 DFA's\n--------------DFA AND--------------"); GraphViz.PrintDFA(dfa1.and(dfa2), "dfa-and"); Console.WriteLine("--------------DFA OR-------------\nMerging 2 DFA's\n--------------DFA OR--------------"); GraphViz.PrintDFA(dfa1.or(dfa2), "dfa-or"); Console.WriteLine("--------------DFA NEGATIVE-------------\nNegative of a DFA\n--------------DFA NEGATIVE--------------"); GraphViz.PrintDFA(dfa1.negative(), "dfa-negative"); }
public static void TestDFA() { Console.WriteLine("--------------DFA--------------\nBegint met abb of eindigt op baab\n--------------DFA--------------"); // Begint met abb of eindigt op baab string test = "abbabaab"; tester(test, dfa.accept(test.ToCharArray())); test = "abbaaaaaa"; tester(test, dfa.accept(test.ToCharArray())); test = "abaaaaaabbbbbbabaab"; tester(test, dfa.accept(test.ToCharArray())); test = "abbaab"; tester(test, dfa.accept(test.ToCharArray())); test = "abaa"; tester(test, dfa.accept(test.ToCharArray())); test = "aaaaaaabbbbbb"; tester(test, dfa.accept(test.ToCharArray())); GraphViz.PrintDFA(dfa, "dfa"); }
public static void testMinimiseDFA() { Console.WriteLine("--------------MINIMISE DFA--------------\nminimise dfa\n--------------MINIMISE DFA--------------"); GraphViz.PrintDFA(ndfa2.toDFA().minimise(), "dfaMinimise"); }
public static void testSquashDFA() { Console.WriteLine("--------------SQUASH DFA--------------\nsquash dfa\n--------------SQUASH DFA--------------"); GraphViz.PrintDFA(dfa.squash(), "dfaSquash"); }
public static void testNDFAtoDFA() { Console.WriteLine("--------------NDFA TO DFA--------------\nNDFA to DFA\n--------------NDFA TO DFA--------------"); GraphViz.PrintDFA(ndfa2.toDFA(), "ndfaToDfa"); //GraphViz.PrintNDFA(ndfa2, "ndfa"); }
public static void testReverseDFA() { Console.WriteLine("--------------DFA REVERSE--------------\nReversing a DFA\n--------------DFA REVERSE--------------"); GraphViz.PrintNDFA(dfa.reverse('$'), "dfa-reverse"); }