public RemarkStateMachine(FileManager fileManager)
        {
            CurrentState = RemarkMachineState.START;
            transitions  = new Dictionary <RemarkStateTransition, RemarkMachineState>
            {
                { new RemarkStateTransition(RemarkMachineState.START, TokenType.END), RemarkMachineState.START },
                { new RemarkStateTransition(RemarkMachineState.START, TokenType.REMARK), RemarkMachineState.REMARK },

                { new RemarkStateTransition(RemarkMachineState.REMARK, TokenType.END), RemarkMachineState.START },
            };

            this.command = new RemarkCommand(fileManager);
        }
        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 RemarkStateTransition(RemarkMachineState currentState, TokenType token)
 {
     this.CurrentState = currentState;
     this.Token        = token;
 }
        public void MoveToNextState(Token token)
        {
            RemarkMachineState nextState = GetNext(token);

            this.CurrentState = nextState;
        }