• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Runtime.BitSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetTokens

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


示例17: RecoverFromMismatchedSet

 public override object RecoverFromMismatchedSet(IIntStream input, RecognitionException e, BitSet follow)
 {
     throw e;
 }
开发者ID:parsnips,项目名称:Expressions,代码行数:4,代码来源:VisualBasicParser.cs


示例18: RecoverFromMismatchedSet

 public new void RecoverFromMismatchedSet(IIntStream input,
     RecognitionException e, BitSet follow)
 {
     throw e;
 }
开发者ID:zuzhu,项目名称:SPINA,代码行数:5,代码来源:InterpParser.cs


示例19: GetMissingSymbol

		protected override object GetMissingSymbol(IIntStream input,
										  RecognitionException e,
										  int expectedTokenType,
										  BitSet follow) {
			object o = base.GetMissingSymbol(input, e, expectedTokenType, follow);
			dbg.ConsumeNode(o);
			return o;
		}
开发者ID:Fedorm,项目名称:core-master,代码行数:8,代码来源:DebugTreeParser.cs


示例20: Match

		/// <summary>
		/// Match current input symbol against ttype.  Attempt
		/// single token insertion or deletion error recovery.  If
		/// that fails, throw MismatchedTokenException.
		/// </summary>
		/// <remarks>
		/// To turn off single token insertion or deletion error
		/// recovery, override RecoverFromMismatchedToken() and have it call
		/// pthrow an exception. See TreeParser.RecoverFromMismatchedToken().
		/// This way any error in a rule will cause an exception and
     	/// immediate exit from rule.  Rule would recover by resynchronizing
     	/// to the set of symbols that can follow rule ref.
		/// </remarks>
		public virtual object Match(IIntStream input, int ttype, BitSet follow) {
			object matchedSymbol = GetCurrentInputSymbol(input);
			if (input.LA(1) == ttype) {
				input.Consume();
				state.errorRecovery = false;
				state.failed = false;
				return matchedSymbol;
			}
			if (state.backtracking > 0) {
				state.failed = true;
				return matchedSymbol;
			}
			matchedSymbol = RecoverFromMismatchedToken(input, ttype, follow);
			return matchedSymbol;
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:28,代码来源:BaseRecognizer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Runtime.CommonToken类代码示例发布时间:2022-05-24
下一篇:
C# Runtime.BaseRecognizer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap