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