Beispiel #1
0
 /// <summary>
 /// Override the original Fetch method from BufferedTokenStream : same behavior,
 /// except that StopToken is replaced with EOF on the fly.
 /// </summary>
 protected override int Fetch(int n)
 {
     if (fetchedEOF)
     {
         return(0);
     }
     for (int i = 0; i < n; i++)
     {
         IToken t = TokenSource.NextToken();
         if (t is IWritableToken)
         {
             ((IWritableToken)t).TokenIndex = tokens.Count;
         }
         // >>> replacement added
         if (StopToken != null && StopToken.Equals(t))
         {
             t = stopTokenReplacedByEOF;
             indexOfStopTokenReplacedByEOF = tokens.Count;
         }
         // <<< end of replacement
         tokens.Add(t);
         if (t.Type == TokenConstants.Eof)
         {
             fetchedEOF = true;
             return(i + 1);
         }
     }
     return(n);
 }
Beispiel #2
0
 /** add n elements to buffer */
 protected virtual void Fetch(int n)
 {
     for (int i = 0; i < n; i++)
     {
         IToken t = TokenSource.NextToken();
         t.TokenIndex = _tokens.Count;
         _tokens.Add(t);
         if (t.Type == CharStreamConstants.EndOfFile)
         {
             break;
         }
     }
 }