Member() public method

public Member ( int el ) : bool
el int
return bool
示例#1
0
        public bool MismatchIsMissingToken(IIntStream input, BitSet follow)
        {
            if (follow == null)
            {
                // we have no information about the follow; we can only consume
                // a single token and hope for the best
                return(false);
            }

            // compute what can follow this grammar element reference
            if (follow.Member(Token.EOR_TOKEN_TYPE))
            {
                BitSet viableTokensFollowingThisRule = ComputeContextSensitiveRuleFOLLOW();
                follow = follow.Or(viableTokensFollowingThisRule);
                if (state.followingStackPointer >= 0)
                {                 // remove EOR if we're not the start symbol
                    follow.Remove(Token.EOR_TOKEN_TYPE);
                }
            }

            // if current token is consistent with what could come after set
            // then we know we're missing a token; error recovery is free to
            // "insert" the missing token

            // BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR
            // in follow set to indicate that the fall of the start symbol is
            // in the set (EOF can follow).
            if (follow.Member(input.LA(1)) || follow.Member(Token.EOR_TOKEN_TYPE))
            {
                return(true);
            }
            return(false);
        }
        public virtual bool MismatchIsMissingToken(IIntStream input, BitSet follow)
        {
            if (follow == null)
            {
                // we have no information about the follow; we can only consume
                // a single token and hope for the best
                return(false);
            }
            // compute what can follow this grammar element reference
            if (follow.Member(TokenTypes.EndOfRule))
            {
                BitSet viableTokensFollowingThisRule = ComputeContextSensitiveRuleFOLLOW();
                follow = follow.Or(viableTokensFollowingThisRule);
                if (state._fsp >= 0)
                { // remove EOR if we're not the start symbol
                    follow.Remove(TokenTypes.EndOfRule);
                }
            }
            // if current token is consistent with what could come after set
            // then we know we're missing a token; error recovery is free to
            // "insert" the missing token

            //System.out.println("viable tokens="+follow.toString(getTokenNames()));
            //System.out.println("LT(1)="+((TokenStream)input).LT(1));

            // BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR
            // in follow set to indicate that the fall of the start symbol is
            // in the set (EOF can follow).
            if (follow.Member(input.LA(1)) || follow.Member(TokenTypes.EndOfRule))
            {
                //System.out.println("LT(1)=="+((TokenStream)input).LT(1)+" is consistent with what follows; inserting...");
                return(true);
            }
            return(false);
        }
示例#3
0
        protected internal virtual BitSet CombineFollows(bool exact)
        {
            int    top       = state.followingStackPointer;
            BitSet followSet = new BitSet();

            for (int i = top; i >= 0; i--)
            {
                BitSet localFollowSet = (BitSet)state.following[i];
                followSet.OrInPlace(localFollowSet);
                if (exact)
                {
                    // can we see end of rule?
                    if (localFollowSet.Member(Token.EOR_TOKEN_TYPE))
                    {
                        // Only leave EOR in set if at top (start rule); this lets
                        // us know if have to include follow(start rule); i.e., EOF
                        if (i > 0)
                        {
                            followSet.Remove(Token.EOR_TOKEN_TYPE);
                        }
                    }
                    else
                    {                     // can't see end of rule, quit
                        break;
                    }
                }
            }
            return(followSet);
        }
示例#4
0
        public virtual IList <IToken> GetTokens(int start, int stop, BitSet types)
        {
            if (this.p == -1)
            {
                this.FillBuffer();
            }
            if (stop >= this.tokens.Count)
            {
                stop = this.tokens.Count - 1;
            }
            if (start < 0)
            {
                start = 0;
            }
            if (start > stop)
            {
                return((IList <IToken>)null);
            }
            IList <IToken> tokenList = (IList <IToken>) new List <IToken>();

            for (int index = start; index <= stop; ++index)
            {
                IToken token = this.tokens[index];
                if (types == null || types.Member(token.Type))
                {
                    tokenList.Add(token);
                }
            }
            if (tokenList.Count == 0)
            {
                tokenList = (IList <IToken>)null;
            }
            return(tokenList);
        }
示例#5
0
        protected virtual BitSet CombineFollows(bool exact)
        {
            int    fsp    = this.state._fsp;
            BitSet bitSet = new BitSet();

            for (int index = fsp; index >= 0; --index)
            {
                BitSet a = this.state.following[index];
                bitSet.OrInPlace(a);
                if (exact)
                {
                    if (a.Member(1))
                    {
                        if (index > 0)
                        {
                            bitSet.Remove(1);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(bitSet);
        }
        // what is exact? it seems to only add sets from above on stack
        // if EOR is in set i.  When it sees a set w/o EOR, it stops adding.
        // Why would we ever want them all?  Maybe no viable alt instead of
        // mismatched token?
        protected virtual BitSet CombineFollows(bool exact)
        {
            int    top       = state._fsp;
            BitSet followSet = new BitSet();

            for (int i = top; i >= 0; i--)
            {
                BitSet localFollowSet = (BitSet)state.following[i];

                /*
                 * System.out.println("local follow depth "+i+"="+
                 *                 localFollowSet.toString(getTokenNames())+")");
                 */
                followSet.OrInPlace(localFollowSet);
                if (exact)
                {
                    // can we see end of rule?
                    if (localFollowSet.Member(TokenTypes.EndOfRule))
                    {
                        // Only leave EOR in set if at top (start rule); this lets
                        // us know if have to include follow(start rule); i.e., EOF
                        if (i > 0)
                        {
                            followSet.Remove(TokenTypes.EndOfRule);
                        }
                    }
                    else
                    { // can't see end of rule, quit
                        break;
                    }
                }
            }
            return(followSet);
        }
示例#7
0
 public virtual void ConsumeUntil(IIntStream input, BitSet set)
 {
     for (int el = input.LA(1); el != -1 && !set.Member(el); el = input.LA(1))
     {
         input.Consume();
     }
 }
示例#8
0
 public virtual bool MismatchIsMissingToken(IIntStream input, BitSet follow)
 {
     if (follow == null)
     {
         return(false);
     }
     if (follow.Member(1))
     {
         BitSet sensitiveRuleFollow = this.ComputeContextSensitiveRuleFOLLOW();
         follow = follow.Or(sensitiveRuleFollow);
         if (this.state._fsp >= 0)
         {
             follow.Remove(1);
         }
     }
     return(follow.Member(input.LA(1)) || follow.Member(1));
 }
示例#9
0
        /// <summary>Consume tokens until one matches the given token set </summary>
        public virtual void ConsumeUntil(IIntStream input, BitSet set)
        {
            int ttype = input.LA(1);

            while (ttype != Token.EOF && !set.Member(ttype))
            {
                input.Consume();
                ttype = input.LA(1);
            }
        }
        /** <summary>Consume tokens until one matches the given token set</summary> */
        public virtual void ConsumeUntil(IIntStream input, BitSet set)
        {
            //System.out.println("consumeUntil("+set.toString(getTokenNames())+")");
            int ttype = input.LA(1);

            while (ttype != TokenTypes.EndOfFile && !set.Member(ttype))
            {
                //System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]);
                input.Consume();
                ttype = input.LA(1);
            }
        }
        /** <summary>
         *  Given a start and stop index, return a List of all tokens in
         *  the token type BitSet.  Return null if no tokens were found.  This
         *  method looks at both on and off channel tokens.
         *  </summary>
         */
        public virtual IList <IToken> GetTokens(int start, int stop, BitSet types)
        {
            if (p == -1)
            {
                FillBuffer();
            }
            if (stop >= tokens.Count)
            {
                stop = tokens.Count - 1;
            }
            if (start < 0)
            {
                start = 0;
            }
            if (start > stop)
            {
                return(null);
            }

            // list = tokens[start:stop]:{Token t, t.getType() in types}
            IList <IToken> filteredTokens = new List <IToken>();

            for (int i = start; i <= stop; i++)
            {
                IToken t = tokens[i];
                if (types == null || types.Member(t.Type))
                {
                    filteredTokens.Add(t);
                }
            }
            if (filteredTokens.Count == 0)
            {
                filteredTokens = null;
            }
            return(filteredTokens);
        }
示例#12
0
		/// <summary>Consume tokens until one matches the given token set </summary>
		public virtual void ConsumeUntil(IIntStream input, BitSet set)
		{
			int ttype = input.LA(1);
			while (ttype != Token.EOF && !set.Member(ttype))
			{
				input.Consume();
				ttype = input.LA(1);
			}
		}
示例#13
0
		public bool MismatchIsMissingToken(IIntStream input, BitSet follow) {
			if (follow == null) {
				// we have no information about the follow; we can only consume
				// a single token and hope for the best
				return false;
			}

			// compute what can follow this grammar element reference
			if (follow.Member(Token.EOR_TOKEN_TYPE)) {
				BitSet viableTokensFollowingThisRule = ComputeContextSensitiveRuleFOLLOW();
				follow = follow.Or(viableTokensFollowingThisRule);
				if (state.followingStackPointer >= 0) { // remove EOR if we're not the start symbol
					follow.Remove(Token.EOR_TOKEN_TYPE);
				}
			}

			// if current token is consistent with what could come after set
			// then we know we're missing a token; error recovery is free to
			// "insert" the missing token

			// BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR
			// in follow set to indicate that the fall of the start symbol is
			// in the set (EOF can follow).
			if ( follow.Member(input.LA(1)) || follow.Member(Token.EOR_TOKEN_TYPE) ) {
				return true;
			}
			return false;
		}
示例#14
0
        /** <summary>
         *  Given a start and stop index, return a List of all tokens in
         *  the token type BitSet.  Return null if no tokens were found.  This
         *  method looks at both on and off channel tokens.
         *  </summary>
         */
        public virtual IList<IToken> GetTokens( int start, int stop, BitSet types )
        {
            if ( p == -1 )
            {
                FillBuffer();
            }
            if ( stop >= tokens.Count )
            {
                stop = tokens.Count - 1;
            }
            if ( start < 0 )
            {
                start = 0;
            }
            if ( start > stop )
            {
                return null;
            }

            // list = tokens[start:stop]:{Token t, t.getType() in types}
            IList<IToken> filteredTokens = new List<IToken>();
            for ( int i = start; i <= stop; i++ )
            {
                IToken t = tokens[i];
                if ( types == null || types.Member( t.Type ) )
                {
                    filteredTokens.Add( t );
                }
            }
            if ( filteredTokens.Count == 0 )
            {
                filteredTokens = null;
            }
            return filteredTokens;
        }
 public virtual List<IToken> GetTokens(int start, int stop, BitSet types)
 {
     if (this._p == -1)
     {
         this.Setup();
     }
     if (stop >= this._tokens.Count)
     {
         stop = this._tokens.Count - 1;
     }
     if (start < 0)
     {
         start = 0;
     }
     if (start > stop)
     {
         return null;
     }
     List<IToken> list = new List<IToken>();
     for (int i = start; i <= stop; i++)
     {
         IToken item = this._tokens[i];
         if ((types == null) || types.Member(item.Type))
         {
             list.Add(item);
         }
     }
     if (list.Count == 0)
     {
         list = null;
     }
     return list;
 }
 public virtual bool MismatchIsMissingToken(IIntStream input, BitSet follow)
 {
     if (follow == null)
     {
         return false;
     }
     if (follow.Member(1))
     {
         BitSet a = this.ComputeContextSensitiveRuleFOLLOW();
         follow = follow.Or(a);
         if (this.state._fsp >= 0)
         {
             follow.Remove(1);
         }
     }
     if (!follow.Member(input.LA(1)) && !follow.Member(1))
     {
         return false;
     }
     return true;
 }
示例#17
0
        /** Given a start and stop index, return a List of all tokens in
         *  the token type BitSet.  Return null if no tokens were found.  This
         *  method looks at both on and off channel tokens.
         */
        public virtual List<IToken> GetTokens(int start, int stop, BitSet types)
        {
            if (_p == -1)
                Setup();
            if (stop >= _tokens.Count)
                stop = _tokens.Count - 1;
            if (start < 0)
                start = 0;
            if (start > stop)
                return null;

            // list = tokens[start:stop]:{Token t, t.getType() in types}
            List<IToken> filteredTokens = new List<IToken>();
            for (int i = start; i <= stop; i++)
            {
                IToken t = _tokens[i];
                if (types == null || types.Member(t.Type))
                {
                    filteredTokens.Add(t);
                }
            }
            if (filteredTokens.Count == 0)
            {
                filteredTokens = null;
            }
            return filteredTokens;
        }
示例#18
0
        public virtual bool MismatchIsMissingToken( IIntStream input, BitSet follow )
        {
            if ( follow == null )
            {
                // we have no information about the follow; we can only consume
                // a single token and hope for the best
                return false;
            }
            // compute what can follow this grammar element reference
            if ( follow.Member( TokenTypes.EndOfRule ) )
            {
                BitSet viableTokensFollowingThisRule = ComputeContextSensitiveRuleFOLLOW();
                follow = follow.Or( viableTokensFollowingThisRule );
                if ( state._fsp >= 0 )
                { // remove EOR if we're not the start symbol
                    follow.Remove( TokenTypes.EndOfRule );
                }
            }
            // if current token is consistent with what could come after set
            // then we know we're missing a token; error recovery is free to
            // "insert" the missing token

            //System.out.println("viable tokens="+follow.toString(getTokenNames()));
            //System.out.println("LT(1)="+((TokenStream)input).LT(1));

            // BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR
            // in follow set to indicate that the fall of the start symbol is
            // in the set (EOF can follow).
            if ( follow.Member( input.LA( 1 ) ) || follow.Member( TokenTypes.EndOfRule ) )
            {
                //System.out.println("LT(1)=="+((TokenStream)input).LT(1)+" is consistent with what follows; inserting...");
                return true;
            }
            return false;
        }
示例#19
0
 /** <summary>Consume tokens until one matches the given token set</summary> */
 public virtual void ConsumeUntil( IIntStream input, BitSet set )
 {
     //System.out.println("consumeUntil("+set.toString(getTokenNames())+")");
     int ttype = input.LA( 1 );
     while ( ttype != TokenTypes.EndOfFile && !set.Member( ttype ) )
     {
         //System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]);
         input.Consume();
         ttype = input.LA( 1 );
     }
 }
 public virtual void ConsumeUntil(IIntStream input, BitSet set)
 {
     for (int i = input.LA(1); (i != -1) && !set.Member(i); i = input.LA(1))
     {
         input.Consume();
     }
 }