private void  consumeFirst()
        {
            consume();             // get first token of input stream

            // Handle situation where hidden or discarded tokens
            // appear first in input stream
            IHiddenStreamToken p = null;

            // while hidden or discarded scarf tokens
            while (hideMask.member(LA(1).Type) || discardMask.member(LA(1).Type))
            {
                if (hideMask.member(LA(1).Type))
                {
                    if (p == null)
                    {
                        p = LA(1);
                    }
                    else
                    {
                        p.setHiddenAfter(LA(1));
                        LA(1).setHiddenBefore(p);                         // double-link
                        p = LA(1);
                    }
                    lastHiddenToken = p;
                    if (firstHidden == null)
                    {
                        firstHidden = p;                         // record hidden token if first
                    }
                }
                consume();
            }
        }
Esempio n. 2
0
 /*Consume tokens until one matches the given token set */
 public virtual void  consumeUntil(BitSet bset)
 {
     while (LA(1) != Token.EOF_TYPE && !bset.member(LA(1)))
     {
         consume();
     }
 }
 /*Make sure current lookahead symbol matches the given set
  * Throw an exception upon mismatch, which is catch by either the
  * error handler or by the syntactic predicate.
  */
 public virtual void  match(AST t, BitSet b)
 {
     if (t == null || t == ASTNULL || !b.member(t.Type))
     {
         throw new MismatchedTokenException(getTokenNames(), t, b, false);
     }
 }
Esempio n. 4
0
 /*Consume chars until one matches the given set */
 public virtual void  consumeUntil(BitSet bset)
 {
     while (cached_LA1 != EOF_CHAR && !bset.member(cached_LA1))
     {
         consume();
     }
 }
Esempio n. 5
0
 public virtual void  match(BitSet b)
 {
     if (!b.member(cached_LA1))
     {
         throw new MismatchedCharException(cached_LA1, b, false, this);
     }
     consume();
 }
        public virtual IToken nextToken()
        {
            IToken tok = input.nextToken();

            while (tok != null && discardMask.member(tok.Type))
            {
                tok = input.nextToken();
            }
            return(tok);
        }
Esempio n. 7
0
 /*Make sure current lookahead symbol matches the given set
  * Throw an exception upon mismatch, which is catch by either the
  * error handler or by the syntactic predicate.
  */
 public virtual void  match(BitSet b)
 {
     if (!b.member(LA(1)))
     {
         throw new MismatchedTokenException(tokenNames, LT(1), b, false, getFilename());
     }
     else
     {
         consume();
     }
 }