コード例 #1
0
        private void  consumeFirst()
        {
            consume();             // get first token of input stream

            // Handle situation where hidden or discarded tokens
            // appear first in input stream
            CommonHiddenStreamToken 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();
            }
        }
コード例 #2
0
 public override void initialize(Token tok)
 {
     CommonHiddenStreamToken t = (CommonHiddenStreamToken) tok;
     base.initialize(t);
     hiddenBefore = t.getHiddenBefore();
     hiddenAfter = t.getHiddenAfter();
 }
コード例 #3
0
        override public void  initialize(Token tok)
        {
            CommonHiddenStreamToken t = (CommonHiddenStreamToken)tok;

            base.initialize(t);
            hiddenBefore = t.getHiddenBefore();
            hiddenAfter  = t.getHiddenAfter();
        }
コード例 #4
0
        /*Return the next monitored token.
         *  Test the token following the monitored token.
         *  If following is another monitored token, save it
         *  for the next invocation of nextToken (like a single
         *  lookahead token) and return it then.
         *  If following is unmonitored, nondiscarded (hidden)
         *  channel token, add it to the monitored token.
         *
         *  Note: EOF must be a monitored Token.
         */
        override public Token nextToken()
        {
            // handle an initial condition; don't want to get lookahead
            // token of this splitter until first call to nextToken
            if (LA(1) == null)
            {
                consumeFirst();
            }

            // we always consume hidden tokens after monitored, thus,
            // upon entry LA(1) is a monitored token.
            CommonHiddenStreamToken monitored = LA(1);

            // point to hidden tokens found during last invocation
            monitored.setHiddenBefore(lastHiddenToken);
            lastHiddenToken = null;

            // Look for hidden tokens, hook them into list emanating
            // from the monitored tokens.
            consume();
            CommonHiddenStreamToken p = monitored;

            // while hidden or discarded scarf tokens
            while (hideMask.member(LA(1).Type) || discardMask.member(LA(1).Type))
            {
                if (hideMask.member(LA(1).Type))
                {
                    // attach the hidden token to the monitored in a chain
                    // link forwards
                    p.setHiddenAfter(LA(1));
                    // link backwards
                    if (p != monitored)
                    {
                        //hidden cannot point to monitored tokens
                        LA(1).setHiddenBefore(p);
                    }
                    p = (lastHiddenToken = LA(1));
                }
                consume();
            }
            return(monitored);
        }
コード例 #5
0
 protected internal virtual void setHiddenBefore(CommonHiddenStreamToken t)
 {
     hiddenBefore = t;
 }
コード例 #6
0
 protected internal virtual void setHiddenAfter(CommonHiddenStreamToken t)
 {
     hiddenAfter = t;
 }
コード例 #7
0
 /*Return a ptr to the hidden token appearing immediately before
 *  token t in the input stream.
 */
 public virtual CommonHiddenStreamToken getHiddenBefore(CommonHiddenStreamToken t)
 {
     return t.getHiddenBefore();
 }
コード例 #8
0
 /*Return a ptr to the hidden token appearing immediately after
 *  token t in the input stream.
 */
 public virtual CommonHiddenStreamToken getHiddenAfter(CommonHiddenStreamToken t)
 {
     return t.getHiddenAfter();
 }
コード例 #9
0
        private void consumeFirst()
        {
            consume(); // get first token of input stream

            // Handle situation where hidden or discarded tokens
            // appear first in input stream
            CommonHiddenStreamToken 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();
            }
        }
コード例 #10
0
 protected internal virtual void consume()
 {
     nextMonitoredToken = (CommonHiddenStreamToken) input.nextToken();
 }
コード例 #11
0
        /*Return the next monitored token.
        *  Test the token following the monitored token.
        *  If following is another monitored token, save it
        *  for the next invocation of nextToken (like a single
        *  lookahead token) and return it then.
        *  If following is unmonitored, nondiscarded (hidden)
        *  channel token, add it to the monitored token.
        *
        *  Note: EOF must be a monitored Token.
        */
        public override Token nextToken()
        {
            // handle an initial condition; don't want to get lookahead
            // token of this splitter until first call to nextToken
            if (LA(1) == null)
            {
                consumeFirst();
            }

            // we always consume hidden tokens after monitored, thus,
            // upon entry LA(1) is a monitored token.
            CommonHiddenStreamToken monitored = LA(1);
            // point to hidden tokens found during last invocation
            monitored.setHiddenBefore(lastHiddenToken);
            lastHiddenToken = null;

            // Look for hidden tokens, hook them into list emanating
            // from the monitored tokens.
            consume();
            CommonHiddenStreamToken p = monitored;
            // while hidden or discarded scarf tokens
            while (hideMask.member(LA(1).Type) || discardMask.member(LA(1).Type))
            {
                if (hideMask.member(LA(1).Type))
                {
                    // attach the hidden token to the monitored in a chain
                    // link forwards
                    p.setHiddenAfter(LA(1));
                    // link backwards
                    if (p != monitored)
                    {
                        //hidden cannot point to monitored tokens
                        LA(1).setHiddenBefore(p);
                    }
                    p = (lastHiddenToken = LA(1));
                }
                consume();
            }
            return monitored;
        }
コード例 #12
0
 protected internal virtual void  setHiddenBefore(CommonHiddenStreamToken t)
 {
     hiddenBefore = t;
 }
コード例 #13
0
 protected CommonASTWithHiddenTokens(CommonASTWithHiddenTokens another)
     : base(another)
 {
     hiddenBefore	= another.hiddenBefore;
     hiddenAfter		= another.hiddenAfter;
 }
コード例 #14
0
 protected internal virtual void  consume()
 {
     nextMonitoredToken = (CommonHiddenStreamToken)input.nextToken();
 }
コード例 #15
0
 public virtual void resetState()
 {
     firstHidden        = null;
     lastHiddenToken    = null;
     nextMonitoredToken = null;
 }
コード例 #16
0
 /*Return a ptr to the hidden token appearing immediately before
  *  token t in the input stream.
  */
 public virtual CommonHiddenStreamToken getHiddenBefore(CommonHiddenStreamToken t)
 {
     return(t.getHiddenBefore());
 }
コード例 #17
0
 protected CommonASTWithHiddenTokens(CommonASTWithHiddenTokens another) : base(another)
 {
     hiddenBefore = another.hiddenBefore;
     hiddenAfter  = another.hiddenAfter;
 }
コード例 #18
0
 /*Return a ptr to the hidden token appearing immediately after
  *  token t in the input stream.
  */
 public virtual CommonHiddenStreamToken getHiddenAfter(CommonHiddenStreamToken t)
 {
     return(t.getHiddenAfter());
 }
コード例 #19
0
 protected internal virtual void  setHiddenAfter(CommonHiddenStreamToken t)
 {
     hiddenAfter = t;
 }