Exemplo n.º 1
0
 private void DiscardToken()
 {
     _lookaheadFirst = _lookaheadSecond.Clone();
     _lookaheadSecond = _lookaheadThird.Clone();
     
     if (_tokenSequence.Any())
         _lookaheadThird = _tokenSequence.Pop();
     else
         _lookaheadThird = new ErrorToken(TokenType.SequenceTerminator, string.Empty);
 }
Exemplo n.º 2
0
        private void LoadSequenceStack(IList<ErrorToken> tokens)
        {
            _tokenSequence = new Stack<ErrorToken>();
            int count = tokens.Count;
            for (int i = count - 1; i >= 0; i--)
            {
                _tokenSequence.Push(tokens[i]);
            }

            _lookaheadFirst = tokens.Count >= 1 ? _tokenSequence.Pop() : CreateSequenceTerminator();
            _lookaheadSecond = tokens.Count >= 2 ? _tokenSequence.Pop() : CreateSequenceTerminator();
            _lookaheadThird = tokens.Count >= 3 ? _tokenSequence.Pop() : CreateSequenceTerminator();
        }