当前位置: 首页>>代码示例>>C#>>正文


C# Runtime.BitSet类代码示例

本文整理汇总了C#中Antlr.Runtime.BitSet的典型用法代码示例。如果您正苦于以下问题:C# BitSet类的具体用法?C# BitSet怎么用?C# BitSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BitSet类属于Antlr.Runtime命名空间,在下文中一共展示了BitSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MismatchedSetException

        protected MismatchedSetException(SerializationInfo info, StreamingContext context)
            : base(info, context) {
            if (info == null)
                throw new ArgumentNullException("info");

            this._expecting = (BitSet)info.GetValue("Expecting", typeof(BitSet));
        }
开发者ID:jjchaverra,项目名称:antlr3,代码行数:7,代码来源:MismatchedSetException.cs

示例2: GetMissingSymbol

		protected override object GetMissingSymbol(IIntStream input,
										  RecognitionException e,
										  int expectedTokenType,
										  BitSet follow)
		{
			String tokenText = null;
			if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>";
			else tokenText = "<missing " + TokenNames[expectedTokenType] + ">";
			CommonToken t = new CommonToken(expectedTokenType, tokenText);
			IToken current = ((ITokenStream)input).LT(1);
			if (current.Type == Token.EOF) {
				current = ((ITokenStream)input).LT(-1);
			}
			t.line = current.Line;
			t.CharPositionInLine = current.CharPositionInLine;
			t.Channel = DEFAULT_TOKEN_CHANNEL;
			return t;
		}
开发者ID:Fedorm,项目名称:core-master,代码行数:18,代码来源:Parser.cs

示例3: Match

 public override object Match(IIntStream input, int ttype, BitSet follow)
 {
     object currentInputSymbol = this.GetCurrentInputSymbol(input);
     DumpSymbol(currentInputSymbol);
     if (input.LA(1) == ttype)
     {
         input.Consume();
         this.state.errorRecovery = false;
         this.state.failed = false;
         return currentInputSymbol;
     }
     else
     {
         if (this.state.backtracking <= 0)
             return this.RecoverFromMismatchedToken(input, ttype, follow);
         this.state.failed = true;
         return currentInputSymbol;
     }
 }
开发者ID:QAMichaelPeng,项目名称:CoolCompiler,代码行数:19,代码来源:CalculatorParser.cs

示例4: GetMissingSymbol

 protected override object GetMissingSymbol( IIntStream input,
                                   RecognitionException e,
                                   int expectedTokenType,
                                   BitSet follow )
 {
     string tokenText = null;
     if ( expectedTokenType == TokenTypes.EndOfFile )
         tokenText = "<missing EOF>";
     else
         tokenText = "<missing " + TokenNames[expectedTokenType] + ">";
     CommonToken t = new CommonToken( expectedTokenType, tokenText );
     IToken current = ( (ITokenStream)input ).LT( 1 );
     if ( current.Type == TokenTypes.EndOfFile )
     {
         current = ( (ITokenStream)input ).LT( -1 );
     }
     t.Line = current.Line;
     t.CharPositionInLine = current.CharPositionInLine;
     t.Channel = DefaultTokenChannel;
     t.InputStream = current.InputStream;
     return t;
 }
开发者ID:biddyweb,项目名称:azfone-ios,代码行数:22,代码来源:Parser.cs

示例5: CombineFollows

 protected virtual BitSet CombineFollows(bool exact)
 {
     int num = this.state._fsp;
     BitSet set = new BitSet();
     for (int i = num; i >= 0; i--)
     {
         BitSet a = this.state.following[i];
         set.OrInPlace(a);
         if (exact)
         {
             if (!a.Member(1))
             {
                 return set;
             }
             if (i > 0)
             {
                 set.Remove(1);
             }
         }
     }
     return set;
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:22,代码来源:BaseRecognizer.cs

示例6: GetMissingSymbol

 protected override object GetMissingSymbol(IIntStream input, RecognitionException e, int expectedTokenType, BitSet follow)
 {
     string text = null;
     if (expectedTokenType == -1)
     {
         text = "<missing EOF>";
     }
     else
     {
         text = "<missing " + this.TokenNames[expectedTokenType] + ">";
     }
     CommonToken token = new CommonToken(expectedTokenType, text);
     IToken token2 = ((ITokenStream) input).LT(1);
     if (token2.Type == -1)
     {
         token2 = ((ITokenStream) input).LT(-1);
     }
     token.Line = token2.Line;
     token.CharPositionInLine = token2.CharPositionInLine;
     token.Channel = 0;
     return token;
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:22,代码来源:Parser.cs

示例7: PushFollow

		/// <summary>
		/// Push a rule's follow set using our own hardcoded stack 
		/// </summary>
		/// <param name="fset"></param>
		protected void PushFollow(BitSet fset)
		{
			if ((state.followingStackPointer + 1) >= state.following.Length)
			{
				BitSet[] f = new BitSet[state.following.Length * 2];
				Array.Copy(state.following, 0, f, 0, state.following.Length);
				state.following = f;
			}
			state.following[++state.followingStackPointer] = fset;
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:14,代码来源:BaseRecognizer.cs

示例8: CombineFollows

		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;
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:24,代码来源:BaseRecognizer.cs

示例9: RecoverFromMismatchedSet

		/** Not currently used */
		public virtual object RecoverFromMismatchedSet(IIntStream input, RecognitionException e, BitSet follow) {
			if (MismatchIsMissingToken(input, follow)) {
				ReportError(e);
				// we don't know how to conjure up a token for sets yet
				return GetMissingSymbol(input, e, Token.INVALID_TOKEN_TYPE, follow);
			}
			// TODO do single token deletion like above for Token mismatch
			throw e;
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:10,代码来源:BaseRecognizer.cs

示例10: MismatchIsMissingToken

		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;
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:28,代码来源:BaseRecognizer.cs

示例11: MismatchedNotSetException

 public MismatchedNotSetException(BitSet expecting, IIntStream input)
     : base(expecting, input)
 {
 }
开发者ID:EightPillars,项目名称:PathwayEditor,代码行数:4,代码来源:MismatchedNotSetException.cs

示例12: GetMissingSymbol

		protected override object GetMissingSymbol(IIntStream input,
										  RecognitionException e,
										  int expectedTokenType,
										  BitSet follow) {
			string tokenText = "<missing " + TokenNames[expectedTokenType] + ">";
			return new CommonTree(new CommonToken(expectedTokenType, tokenText));
		}	
开发者ID:sebasjm,项目名称:antlr,代码行数:7,代码来源:TreeParser.cs

示例13: RecoverFromMismatchedToken

		/// <summary>We have DOWN/UP nodes in the stream that have no line info; override.
		/// plus we want to alter the exception type. Don't try to recover
		/// from tree parser errors inline...
		/// </summary>
		protected internal override object RecoverFromMismatchedToken(IIntStream input, int ttype, BitSet follow) {
			throw new MismatchedTreeNodeException(ttype, (ITreeNodeStream)input);
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:7,代码来源:TreeParser.cs

示例14: GetTokens

 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;
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:33,代码来源:BufferedTokenStream.cs

示例15: GetTokens

        /** 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;
        }
开发者ID:antlr,项目名称:antlrcs,代码行数:31,代码来源:BufferedTokenStream.cs


注:本文中的Antlr.Runtime.BitSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。