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