示例#1
0
        public bool NextInput(char input)
        {
            StateMachineEntry entry = _sm[ConvertInput(input), currentState];

            currentState = entry.NextState;
            return(entry.Accepted);
        }
示例#2
0
        public StateMachineTable()
        {
            _sm = new StateMachineEntry[4, 4];

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    _sm[i, j] = new StateMachineEntry()
                    {
                        NextState = 3, Accepted = false
                    };
                }
            }

            _sm[0, 0] = new StateMachineEntry()
            {
                NextState = 1, Accepted = true
            };                                                                      // state 0 input a (=0)
            _sm[1, 1] = new StateMachineEntry()
            {
                NextState = 2, Accepted = true
            };                                                                      // state 1 input b (=1)
            _sm[2, 2] = new StateMachineEntry()
            {
                NextState = 0, Accepted = true
            };                                                                      // state 2 input c (=2)
        }