Ejemplo n.º 1
0
 /// <summary>
 /// Executes the NEW command.
 /// </summary>
 public void Execute()
 {
     _variableRepository.Clear();
     _runEnvironment.Clear();
     _dataStatementReader.RestoreToLineNumber(null);
     _programRepository.Clear();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the RUN command.
        /// </summary>
        /// <param name="tokeniser">Tokeniser used by the load command.</param>
        public void Execute(ITokeniser tokeniser)
        {
            var nextToken = _runEnvironment.CurrentLine.NextToken();

            if (nextToken.TokenClass == TokenClass.String)
            {
                // Since we have a tokeniser, we can just fake being the executor/interpreter
                // and create our own LOAD command and call it.
                var oldLine = _runEnvironment.CurrentLine;
                _runEnvironment.CurrentLine = tokeniser.Tokenise($"LOAD {nextToken}");
                var loadToken = _runEnvironment.CurrentLine.NextToken() as ITokeniserCommand;
                loadToken.Execute(tokeniser);
                _runEnvironment.CurrentLine = oldLine;
            }
            else
            {
                _runEnvironment.CurrentLine.PushToken(nextToken);
            }

            _variableRepository.Clear();
            _runEnvironment.Clear();
            _dataStatementReader.RestoreToLineNumber(null);
            int?startingLineNumber = _runEnvironment.CurrentLine.GetLineNumber();

            _runEnvironment.CurrentLine = startingLineNumber.HasValue ?
                                          _programRepository.GetLine(startingLineNumber.Value) :
                                          _programRepository.GetFirstLine();
        }
Ejemplo n.º 3
0
 public void SetupSut()
 {
     _variableRepository.Clear();
     _expressionEvaluator = new ExpressionEvaluator(_variableRepository, _runEnvironment);
 }