Ejemplo n.º 1
0
        public ReadMachineState GetNext(Token token)
        {
            ReadMachineState    nextState  = this.CurrentState;
            ReadStateTransition transition = new ReadStateTransition(CurrentState, token.Type);

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

            if (this.CurrentState == ReadMachineState.START)
            {
                this.variables.ResetReadVariables();
            }
            else if ((this.CurrentState == ReadMachineState.READ || this.CurrentState == ReadMachineState.COMMA) &&
                     (token.Type == TokenType.VAR || token.Type == TokenType.ARRAY))
            {
                this.command.ConsumeToken(token);
            }

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

            return(nextState);
        }
Ejemplo n.º 2
0
            public override bool Equals(object obj)
            {
                ReadStateTransition other = obj as ReadStateTransition;

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