static void Main(string[] args) { //DFARulebook rulebook = new DFARulebook(); //rulebook.AddRule(2, 'b', 3); //rulebook.AddRule(2, 'a', 3); //rulebook.AddRule(1, 'b', 1); //rulebook.AddRule(1, 'a', 1); //rulebook.AddRule(1, 'b', 2); //rulebook.AddRule(3, 'a', 4); //rulebook.AddRule(3, 'b', 4); List <int> startState = new List <int>(); startState.Add(1); //List<int> state = new List<int>(); //state.Add(4); //NFA dfa = new NFA(startState, state, rulebook); //dfa.ReadString("bbabb"); //if (dfa.Accepting()) //{ // Console.WriteLine("True"); // Console.ReadLine(); //} //else //{ // Console.WriteLine("False"); // Console.ReadLine(); //} string alphabet = "абвгдеёжзийклмнопрстуфхцчшщъэьэюя"; DFARulebook alfbook = new DFARulebook(); alfbook.AddRule(1, 'a', 2); alfbook.AddRule(1, 'о', 2); alfbook.AddRule(1, 'и', 2); alfbook.AddRule(1, 'е', 3); foreach (char c in alphabet) { alfbook.AddRule(1, c, 1); } List <int> stateEnd = new List <int>(); stateEnd.Add(3); NFA alfNfa = new NFA(startState, stateEnd, alfbook); List <string> words = new List <string>(); words.Add("большое"); words.Add("тигр"); words.Add("большие"); words.Add("серый"); words.Add("урожае"); alfNfa.CheckAndPrintWords(words); }
public NFA(List <int> startStates, List <int> acceptStates, DFARulebook rulebook) { CurrentStates = startStates; AcceptStates = acceptStates; Rulebook = rulebook; }