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


C# Token.Type方法代码示例

本文整理汇总了C#中Token.Type方法的典型用法代码示例。如果您正苦于以下问题:C# Token.Type方法的具体用法?C# Token.Type怎么用?C# Token.Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Token的用法示例。


在下文中一共展示了Token.Type方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckEndMarker

		void CheckEndMarker(ref TokenType endMarker, ref Token end)
		{
			if ((endMarker != end.Type())) {
				if ((endMarker == default(TT))) {
					endMarker = end.Type();
				} else {
					Error(-1, "Unexpected separator: {0} should be {1}", ToString(end.TypeInt), ToString((int) endMarker));
				}
			}
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:10,代码来源:LesParserGrammar.cs

示例2: TokenToVSClassification

		protected override IClassificationType TokenToVSClassification(Token t)
		{
			var c = base.TokenToVSClassification(t);
			if (c == null && t.Kind == TokenKind.Other && t.Type() != TokenType.Unknown)
				return _preprocessorType;
			return c;
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:7,代码来源:EcsSyntaxForVS.cs

示例3: CheckEndMarker

		void CheckEndMarker(ref TokenType endMarker, ref Token end) {
			var endType = end.Type();
			if (endType == TokenType.Newline)
				endType = TokenType.Semicolon;
			if (endMarker != endType) {
				if (endMarker == default(TT)) {
					endMarker = endType;
				} else {
					Error(-1, "Unexpected separator: {0} should be {1}", ToString(end.TypeInt), ToString((int) endMarker));
				}
			}
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:12,代码来源:Les3Parser.out.cs

示例4: ToString

		/// <summary>Expresses an LES token as a string.</summary>
		/// <remarks>Note that some Tokens do not contain enough information to
		/// reconstruct a useful token string, e.g. comment tokens do not store the 
		/// comment but merely contain the location of the comment in the source code.
		/// For performance reasons, a <see cref="Token"/> does not have a reference 
		/// to its source file, so this method cannot return the original string.
		/// <para/>
		/// The results are undefined if the token was not produced by <see cref="LesLexer"/>.
		/// </remarks>
		public static string ToString(Token t)
		{
			StringBuilder sb = new StringBuilder();
			switch (t.Type()) {
				case TT.Newline: return "\n";
				case TT.SLComment: return "//\n";
				case TT.MLComment: return "/**/";
				case TT.Number: 
				case TT.String:
				case TT.SQString:
				case TT.Symbol:
				case TT.OtherLit: 
					return LesNodePrinter.PrintLiteral(t.Value, t.Style);
				case TT.BQString: 
					return LesNodePrinter.PrintString((t.Value ?? "").ToString(), '`', false);
				case TT.Id: 
					return LesNodePrinter.PrintId(t.Value as Symbol ?? GSymbol.Empty);
				case TT.LParen: return "(";
				case TT.RParen: return ")";
				case TT.LBrack: return "[";
				case TT.RBrack: return "]";
				case TT.LBrace: return "{";
				case TT.RBrace: return "}";
				//case TT.OpenOf: return ".[";
				case TT.Shebang: return "#!" + t.Value + "\n";
				case TT.Dot:
				case TT.Assignment:
				case TT.NormalOp:
				case TT.PreSufOp:
				case TT.PrefixOp:
				case TT.SuffixOp:
				case TT.Colon:
				case TT.At:
				case TT.Comma:
				case TT.Semicolon:
				case TT.Not:
					var name = (t.Value ?? "(punc missing value)").ToString();
					return name;
				case TT.Indent:
					return "@indent";
				case TT.Dedent:
					return "@dedent";
				default:
					return "@unknown_token";
			}
		}
开发者ID:default0,项目名称:LoycCore,代码行数:55,代码来源:TokenType.cs

示例5: Next

		/// <summary>
		/// </summary>
		/// <returns>Returns the next token in the stream, or null at EOS</returns>
		public override Token Next()
	
		{
			if ( ( token = input.Next() ) == null ) 
			{
				return null;
			}
				// Check the exclusiontable
			else if ( exclusions != null && exclusions.Contains( token.TermText() ) ) 
			{
				return token;
			}
			else 
			{
				String s = stemmer.Stem( token.TermText() );
				// If not stemmed, dont waste the time creating a new token
				if ( !s.Equals( token.TermText() ) ) 
				{
					return new Token( s, token.StartOffset(),
						token.EndOffset(), token.Type() );
				}
				return token;
			}
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:27,代码来源:GermanStemFilter.cs

示例6: ToString

		/// <summary>Expresses an EC# token as a string.</summary>
		/// <remarks>Note that some Tokens do not contain enough information to
		/// reconstruct a useful token string, e.g. comment tokens do not store the 
		/// comment but merely contain the location of the comment in the source code.
		/// For performance reasons, a <see cref="Token"/> does not have a reference 
		/// to its source file, so this method cannot return the original string.
		/// <para/>
		/// The results are undefined if the token was not produced by <see cref="EcsLexer"/>.
		/// </remarks>
		public static string ToString(Token t)
		{
			StringBuilder sb = new StringBuilder();
			if (t.Kind == TokenKind.Operator || t.Kind == TokenKind.Assignment || t.Kind == TokenKind.Dot)
			{
				if (t.Type() == TT.BQString)
					return EcsNodePrinter.PrintString((t.Value ?? "").ToString(), '`', false);
				string value = (t.Value ?? "(null)").ToString();
				return value;
			}
			switch (t.Type()) {
				case TT.EOF: return "/*EOF*/";
				case TT.Spaces: return " ";
				case TT.Newline: return "\n";
				case TT.SLComment: return "//\n";
				case TT.MLComment: return "/**/";
				case TT.Shebang: return "#!" + (t.Value ?? "").ToString() + "\n";
				case TT.Id:
				case TT.ContextualKeyword:
					return EcsNodePrinter.PrintId(t.Value as Symbol ?? GSymbol.Empty);
				case [email protected]: return "base";
				case [email protected]: return "this";
				case TT.Number:
				case TT.String:
				case TT.SQString:
				case TT.Symbol:
				case TT.OtherLit:
					return EcsNodePrinter.PrintLiteral(t.Value, t.Style);
				case TT.Comma: return ",";
				case TT.Semicolon: return ";";
				case TT.LParen: return "(";
				case TT.RParen: return ")";
				case TT.LBrack: return "[";
				case TT.RBrack: return "]";
				case TT.LBrace: return "{";
				case TT.RBrace: return "}";
				case TT.AttrKeyword:
					string value = (t.Value ?? "(null)").ToString();
					return value;
				case TT.TypeKeyword:
					Symbol valueSym = (t.Value as Symbol) ?? GSymbol.Empty;
					string result;
					if (EcsNodePrinter.TypeKeywords.TryGetValue(valueSym, out result))
						return result;
					else {
						Debug.Fail("Unexpected value for " + t.Type());
						return (t.Value ?? "(null)").ToString();
					}
				case [email protected]:     return "break";    
				case [email protected]:    	return "case";     
				case [email protected]:	return "checked";  
				case [email protected]:		return "class";    
				case [email protected]:	return "continue"; 
				case [email protected]:	return "default";  
				case [email protected]:	return "delegate"; 
				case [email protected]:		return "do";       
				case [email protected]:		return "enum";     
				case [email protected]:		return "event";    
				case [email protected]:		return "fixed";    
				case [email protected]:		return "for";      
				case [email protected]:	return "foreach";  
				case [email protected]:		return "goto";     
				case [email protected]:		return "if";       
				case [email protected]:	return "interface";
				case [email protected]:		return "lock";     
				case [email protected]:	return "namespace";
				case [email protected]:	return "return";   
				case [email protected]:	return "struct";   
				case [email protected]:	return "switch";   
				case [email protected]:		return "throw";    
				case [email protected]:		return "try";      
				case [email protected]:	return "unchecked";
				case [email protected]:		return "using";    
				case [email protected]:		return "while";    
										   
				case TT[email protected]:  return "operator"; 
				case [email protected]:    return "sizeof";   
				case [email protected]:    return "typeof";   
				case [email protected]:	    return "else";     
				case [email protected]:     return "catch";       
				case [email protected]:  	return "finally";  
				case [email protected]:       	return "in";       
				case [email protected]:       	return "as";       
				case [email protected]:       	return "is";       
				case [email protected]:      	return "new";      
				case [email protected]:      	return "out";
				case [email protected]:return "stackalloc";

				case TT.PPif       : return "#if";
				case TT.PPelse     : return "#else";
				case TT.PPelif     : return "#elif";
//.........这里部分代码省略.........
开发者ID:Shaykh,项目名称:Loyc,代码行数:101,代码来源:TokenType.cs


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