public void ProgramLineToStringWithOutLineNumber()
        {
            var tokens = new List <IToken>
            {
                new Token("PRINT", TokenClass.Statement),
                new Token("HELLO", TokenClass.String),
                new Token(",", TokenClass.Seperator, TokenType.Comma),
                new Token("W", TokenClass.Variable),
                new Token("$", TokenClass.Seperator, TokenType.Dollar),
            };

            ProgramLine programLine = new ProgramLine(null, tokens);
            var         line        = programLine.ToString();

            Assert.AreEqual("  PRINT \"HELLO\",W$", line);
        }
예제 #2
0
        /// <summary>
        /// Lists a single line.
        /// </summary>
        /// <returns>returns false if last line printed.</returns>
        public bool Execute()
        {
            if (_currentLine != null)
            {
                if (_currentLine.LineNumber > _endLine)
                {
                    return(true);
                }

                _teletype.Write(_currentLine.ToString());
                _teletype.Write(Environment.NewLine);
                _currentLine = _programRepository.GetNextLine(_currentLine.LineNumber.Value);
            }

            return(_currentLine == null);
        }
예제 #3
0
 public override string ToString()
 {
     return(ProgramLine.ToString());
 }