public GoMachineState GetNext(Token token) { GoMachineState nextState = this.CurrentState; GoStateTransition transition = new GoStateTransition(CurrentState, token.Type); if (!transitions.TryGetValue(transition, out nextState)) { throw new Exception("Invalid transition: " + CurrentState + " -> " + nextState + "\n" + token.Text + " " + token.Type); } if (nextState == GoMachineState.DESTINATION && token.Type != TokenType.END) { this.command.ConsumeToken(token); } Console.WriteLine("P: " + this.CurrentState + " -> " + nextState + ": " + token.Text); return(nextState); }
public override bool Equals(object obj) { GoStateTransition other = obj as GoStateTransition; return(other != null && this.CurrentState == other.CurrentState && this.Token == other.Token); }