Пример #1
0
        public void fillTransition(byte state, MeanCS.MAction action)
        {
            byte actionIndex = 0;

            if (action != null)
            {
                actionIndex = addAction(action);
            }
            for (int i = 0; i < 256; i++)
            {
                tr[(state * 256) + i] = actionIndex;
            }
            //DEBUG(VR("New Transition filled: id ")X(actionIndex)XO);
        }
Пример #2
0
        public void transition(byte state, string input, MeanCS.MAction action)
        {
            byte actionIndex = 0;

            if (action != null)
            {
                actionIndex = addAction(action);
            }
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(input);
            int    i     = 0;

            while (i < input.Length)
            {
                tr[(state * 256) + bytes[i]] = actionIndex;
                i++;
            }
            //DEBUG(VR("New Transition added: id ")X(actionIndex)XO);
        }
Пример #3
0
        public bool step(byte input)
        {
            currentInput = input;
            int  index       = (currentState * 256) + input;
            byte actionIndex = tr[index];

            if (actionIndex == 0)
            {
                return(true);       // stay on same state and do nothing else
            }
            if (actionIndex == 0xff || actionIndex < 0)
            {
                ok = false;
                return(false); // end
            }
            MeanCS.MAction act = actions[actionIndex];
            if (act == null)
            {
                System.Diagnostics.Debug.Assert(false, "invalid action index");
            }
            act();
            return(true);
        }
Пример #4
0
 public byte addAction(MeanCS.MAction action)
 {
     actionCounter++;
     actions[actionCounter] = action;
     return(actionCounter);
 }