예제 #1
0
        public ArithmeticMachineState GetNext(Token token)
        {
            ArithmeticMachineState    nextState  = this.CurrentState;
            ArithmeticStateTransition transition = new ArithmeticStateTransition(CurrentState, token.Type);

            if (!transitions.TryGetValue(transition, out nextState))
            {
                throw new Exception("Arithmetic: Invalid transition: " + CurrentState + " -> " + nextState + "\n" + token.Text + " " + token.Type);
            }

            if (token.Type != TokenType.END)
            {
                this.command.ConsumeToken(token);
            }
            else
            {
                this.command.EndOfExpression();
            }

            Console.WriteLine("Arithmetic: " + this.CurrentState + " -> " + nextState + ": " + token.Text);

            return(nextState);
        }
예제 #2
0
            public override bool Equals(object obj)
            {
                ArithmeticStateTransition other = obj as ArithmeticStateTransition;

                return(other != null && this.CurrentState == other.CurrentState && this.Token == other.Token);
            }