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