private static void LoadFile(string fileName) { Console.WriteLine("Loading from file: {0}", fileName); if (!System.IO.File.Exists(fileName)) { Console.WriteLine("No such file!"); } var eNfa = AutomataBuilder.FromFile(fileName); Console.WriteLine("Loaded."); Console.WriteLine("=== NFA Primitive Infomation ==="); Console.WriteLine(eNfa.About()); Console.WriteLine("Epsilon Closures: "); foreach (var state in eNfa.States) { var eclosure = eNfa.GetEpsilonClosureOf(state); Console.WriteLine("{0}: {{{1}}}", state, string.Join(',', eclosure)); } Console.WriteLine("\nConverted.\n"); Console.WriteLine("=== DFA Infomation ==="); var dfa = AutomataConverter.EpsilonNfaToDFA(eNfa); Console.WriteLine(dfa.About()); }
private static void Example3() { var eNfa = new AutomataBuilder() .SetStates(new string[] { "p", "q", "r" }) .SetInputSymbols(new char[] { '0', '1', '$' }) .SetTransitionFunction(new string[] { "f(p,0)=p", "f(p,1)={p,q}", "f(q,0)=r", "f(q,1)=r", }) .SetInitialState("p") .SetFinalState("r") .Build(); Console.WriteLine("=== NFA Primitive Infomation ==="); Console.WriteLine(eNfa.About()); Console.WriteLine("Epsilon Closures: "); foreach (var state in eNfa.States) { var eclosure = eNfa.GetEpsilonClosureOf(state); Console.WriteLine("{0}: {{{1}}}", state, string.Join(',', eclosure)); } Console.WriteLine("\nConverted.\n"); Console.WriteLine("=== DFA Infomation ==="); var dfa = AutomataConverter.EpsilonNfaToDFA(eNfa); Console.WriteLine(dfa.About()); }