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); }
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); }
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); }
public byte addAction(MeanCS.MAction action) { actionCounter++; actions[actionCounter] = action; return(actionCounter); }