private bool DoTransition(char character) { StateList newStates = new StateList(); foreach (State state in currentStates.GetList()) { newStates.Add(state.Get(character)); } currentStates = newStates; if (currentStates == null) { throw new InvalidOperationException(); } DoEpsilon(); return(currentStates.GetList().Any(state => finalStates.Contains(state))); }
private void InitializeAutomatum() { initialStates = new StateList(); State state0 = new State(); State state1 = new State(); //State state2 = new State(); //State state4 = new State(); //State state5 = new State(); //State state6 = new State(); //State state7 = new State(); //State state8 = new State(); //ε state0.Add('a', state0); state0.Add('b', state0); state0.Add('b', state1); state0.Add('ε', state1); //state1.Add('a', state2); //state1.Add('b', state0); //state2.Add('a', state0); //state2.Add('b', state2); //state3.add('b', state8); //state3.add('a', state6); //state4.add('b', state1); //state4.add('a', state5); //state5.add('b', state1); //state5.add('a', state6); //state6.add('b', state1); //state6.add('a', state7); //state7.add('b', state1); //state7.add('a', state7); //state8.add('b', state1); //state8.add('a', state2); initialStates.Add(state0); finalStates.Add(state1); }