/// <summary> /// Implements moving the current data pointer to a new line number /// </summary> /// <param name="lineNumber">line number to move to, null moves to beginning of program.</param> public void RestoreToLineNumber(int?lineNumber) { _currentDataLine = lineNumber.HasValue ? _programRepository.GetLine(lineNumber.Value) : _programRepository.GetFirstLine(); ReadInputParser.Clear(); _faulted = false; }
/// <summary> /// Initializes a new instance of the <see cref="Input"/> class. /// </summary> /// <param name="runEnvironment">Run time environment.</param> /// <param name="expressionEvaluator">Expression evaluator.</param> /// <param name="variableRepository">Variable repository.</param> /// <param name="teletype">Teletype to use.</param> public Input( IRunEnvironment runEnvironment, IExpressionEvaluator expressionEvaluator, IVariableRepository variableRepository, ITeletype teletype) : base("INPUT", TokenClass.Statement) { _runEnvironment = runEnvironment; _expressionEvaluator = expressionEvaluator; _variableRepository = variableRepository; _teletype = teletype; _readInputParser = new ReadInputParser(ReadLine); }
private void SetupSut() { _inputQueue = new Queue <string>(); _sut = new ReadInputParser(() => _inputQueue.Dequeue()); _sut.Clear(); _variableRepository = new VariableRepository(); _numericVariables[0] = _variableRepository.GetOrCreateVariable("A", new short[] { }); _numericVariables[1] = _variableRepository.GetOrCreateVariable("B", new short[] { }); _numericVariables[2] = _variableRepository.GetOrCreateVariable("C", new short[] { }); _stringVariables[0] = _variableRepository.GetOrCreateVariable("A$", new short[] { }); _stringVariables[1] = _variableRepository.GetOrCreateVariable("B$", new short[] { }); _stringVariables[2] = _variableRepository.GetOrCreateVariable("C$", new short[] { }); }
/// <summary> /// Initializes a new instance of the <see cref="DataStatementReader"/> class. /// </summary> /// <param name="runEnvironment">Run environment.</param> /// <param name="programRepository">Program repository to use.</param> public DataStatementReader(IRunEnvironment runEnvironment, IProgramRepository programRepository) { _runEnvironment = runEnvironment; _programRepository = programRepository; ReadInputParser = new ReadInputParser(GetNextDataStatement); }