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

C# Parser.Token类代码示例

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

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



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

示例1: Expect

	void Expect(int expectedKind, Token la)
	{
		if (la.Kind != expectedKind) {
			Error(la);
			Console.WriteLine("expected: " + expectedKind);
		}
	}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:Parser.cs


示例2: TokenToStringDoesNotThrowException

		public void TokenToStringDoesNotThrowException()
		{
			Assert.DoesNotThrow(
				() => {
					string text = new Token(71, 1, 1).ToString();
				}
			);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:8,代码来源:TokenTests.cs


示例3: ApplyIndent

		void ApplyIndent(Token la)
		{
			Block current = indentationStack.PeekOrDefault() ?? Block.Empty;
			
			if (t.Location.Line < startLine.LineNumber)
				return;
			
			IDocumentLine firstLine = startLine.LineNumber > current.StartLine ? startLine : editor.Document.GetLine(current.StartLine);
			IDocumentLine currentLine = firstLine;
			
			while (currentLine.LineNumber < la.Location.Line) {
				editor.Document.SmartReplaceLine(currentLine, current.Indentation + currentLine.Text.Trim());
				
				if (currentLine.LineNumber == endLine.LineNumber)
					break;
				
				currentLine = editor.Document.GetLine(currentLine.LineNumber + 1);
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:19,代码来源:VBIndentationStrategy.cs


示例4: Error

	void Error(Token la) 
	{
		Console.WriteLine("not expected: " + la);
		errors.Add(la);
	}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:5,代码来源:Parser.cs


示例5: InformToken

	public void InformToken(Token la) 
	{
		switchlbl: switch (currentState) {
			case 0: {
				if (la == null) { currentState = 0; break; }
				if (set[0].Get(la.Kind)) {
					currentState = 0;
					break;
				} else {
					goto case 1;
				}
			}
			case 1: {
				if (la == null) { currentState = 1; break; }
				if (set[1].Get(la.Kind)) {
					stateStack.Push(2);
					goto case 3;
				} else {
					currentState = stateStack.Pop();
					goto switchlbl;
				}
			}
			case 2: {
				if (la == null) { currentState = 2; break; }
				if (set[2].Get(la.Kind)) {
					currentState = 2;
					break;
				} else {
					goto case 1;
				}
			}
			case 3: {
				if (la == null) { currentState = 3; break; }
				if (la.Kind == 160) {
					goto case 357;
				} else {
					if (set[3].Get(la.Kind)) {
						if (la.Kind == 84 || la.Kind == 155 || la.Kind == 209) {
							goto case 350;
						} else {
							if (la.Kind == 103) {
								currentState = 263;
								break;
							} else {
								if (la.Kind == 115) {
									goto case 261;
								} else {
									if (la.Kind == 142) {
										currentState = 5;
										break;
									} else {
										goto case 4;
									}
								}
							}
						}
					} else {
						goto case 4;
					}
				}
			}
			case 4: {
				Error(la);
				currentState = stateStack.Pop();
				goto switchlbl;
			}
			case 5: {
				if (la == null) { currentState = 5; break; }
				currentState = 6;
				break;
			}
			case 6: {
				if (la == null) { currentState = 6; break; }
				if (la.Kind == 37) {
					currentState = 354;
					break;
				} else {
					goto case 7;
				}
			}
			case 7: {
				stateStack.Push(8);
				goto case 13;
			}
			case 8: {
				Indent(la);
				goto case 9;
			}
			case 9: {
				if (la == null) { currentState = 9; break; }
				if (la.Kind == 140) {
					goto case 351;
				} else {
					goto case 10;
				}
			}
			case 10: {
				if (la == null) { currentState = 10; break; }
				if (set[4].Get(la.Kind)) {
					if (la.Kind == 84 || la.Kind == 155 || la.Kind == 209) {
//.........这里部分代码省略.........
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:101,代码来源:Parser.cs


示例6: IsBlockEnd

		internal static bool IsBlockEnd(Token current, Token prev)
		{
			if (current.Kind == Tokens.Next) {
				if (prev.Kind == Tokens.Resume)
					return false;
				else
					return true;
			}
			
			if (current.Kind == Tokens.Loop)
				return true;
			
			if (blockTokens.Contains(current.Kind)) {
				if (prev.Kind == Tokens.End)
					return true;
				else
					return false;
			}
			
			return IsSpecialCase(current, prev);
		}
开发者ID:siegfriedpammer,项目名称:SharpDevelop,代码行数:21,代码来源:VBNetFormattingStrategy.cs


示例7: IsTypeNameForTypeCast

 private bool IsTypeNameForTypeCast(ref Token pt)
 {
     if (pt.kind != 1)
     {
         return false;
     }
     pt = this.Peek();
     if (pt.kind == 10)
     {
         pt = this.Peek();
         if (pt.kind != 1)
         {
             return false;
         }
         pt = this.Peek();
     }
     while (pt.kind == 15)
     {
         pt = this.Peek();
         if (pt.kind != 1)
         {
             return false;
         }
         pt = this.Peek();
     }
     if (pt.kind == 0x17)
     {
         do
         {
             pt = this.Peek();
             if (!this.IsTypeNameOrKWForTypeCast(ref pt))
             {
                 return false;
             }
         }
         while (pt.kind == 14);
         if (pt.kind != 0x16)
         {
             return false;
         }
         pt = this.Peek();
     }
     if (pt.kind == 12)
     {
         pt = this.Peek();
     }
     return (((pt.kind != 6) && (pt.kind != 0x12)) || this.IsPointerOrDims(ref pt));
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:48,代码来源:Parser.cs


示例8: StartPeek

		/// <summary>
		/// Must be called before a peek operation.
		/// </summary>
		public void StartPeek()
		{
			peekToken = curToken;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:AbstractLexer.cs


示例9: SkipQuestionMark

 private bool SkipQuestionMark(ref Token pt)
 {
     if (pt.kind == 12)
     {
         pt = this.Peek();
     }
     return true;
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:8,代码来源:Parser.cs


示例10: Indent

		void Indent(Token la)
		{
			ApplyIndent(la);
			Block parent = indentationStack.PeekOrDefault() ?? Block.Empty;
			indentationStack.Push(new Block() { Indentation = parent.Indentation + editor.Options.IndentationString, StartLine = t.Location.Line + 1 } );
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:6,代码来源:VBIndentationStrategy.cs


示例11: TrackCurrentFrameAndExpression

 void TrackCurrentFrameAndExpression(Token token)
 {
     while (frame.bracketType == '<' && !Tokens.ValidInsideTypeName[token.Kind]) {
         frame.type = FrameType.Popped;
         frame = frame.parent;
     }
     switch (token.Kind) {
         case Tokens.OpenCurlyBrace:
             frame.lastExpressionStart = Location.Empty;
             frame = new Frame(frame, '{');
             frame.parent.ResetCurlyChildType();
             break;
         case Tokens.CloseCurlyBrace:
             while (frame.parent != null) {
                 if (frame.bracketType == '{') {
                     frame.type = FrameType.Popped;
                     frame = frame.parent;
                     break;
                 } else {
                     frame.type = FrameType.Popped;
                     frame = frame.parent;
                 }
             }
             break;
         case Tokens.OpenParenthesis:
             if (frame.lastExpressionStart.IsEmpty)
                 frame.lastExpressionStart = token.Location;
             frame = new Frame(frame, '(');
             frame.parent.ResetParenthesisChildType();
             break;
         case Tokens.OpenSquareBracket:
             frame = new Frame(frame, '[');
             frame.parent.ResetSquareBracketChildType();
             break;
         case Tokens.CloseParenthesis:
         case Tokens.CloseSquareBracket:
             if (frame.parent != null && (frame.bracketType == '(' || frame.bracketType == '[')) {
                 frame.type = FrameType.Popped;
                 frame = frame.parent;
             }
             break;
         case Tokens.LessThan:
             if (Tokens.ValidInsideTypeName[lastToken]) {
                 frame = new Frame(frame, '<');
                 if (frame.parent.InExpressionMode) {
                     frame.SetContext(ExpressionContext.Default);
                 } else if ((frame.parent.state == FrameState.TypeDecl
                             || frame.parent.state == FrameState.MethodDecl
                             || frame.parent.state == FrameState.FieldDeclAfterIdentifier)
                            && frame.parent.context == ExpressionContext.IdentifierExpected)
                 {
                     frame.type = FrameType.TypeParameterDecl;
                     frame.SetContext(ExpressionContext.IdentifierExpected);
                     frame.parent.SetContext(ExpressionContext.ConstraintsStart);
                 } else {
                     frame.SetContext(ExpressionContext.Type);
                 }
             }
             break;
         case Tokens.GreaterThan:
             if (frame.parent != null && frame.bracketType == '<') {
                 frame.type = FrameType.Popped;
                 frame = frame.parent;
             } else {
                 frame.lastExpressionStart = Location.Empty;
                 frame.SetDefaultContext();
             }
             break;
         case Tokens.Question:
             // do not reset context - TrackCurrentContext will take care of this
             frame.lastExpressionStart = Location.Empty;
             break;
         case Tokens.Pointer:
         case Tokens.Dot:
         case Tokens.DoubleColon:
             // let the current expression continue
             break;
         default:
             if (Tokens.IdentifierTokens[token.Kind]) {
                 if (lastToken != Tokens.Dot && lastToken != Tokens.DoubleColon && lastToken != Tokens.Pointer) {
                     if (Tokens.ValidInsideTypeName[lastToken]) {
                         frame.SetDefaultContext();
                     }
                     frame.lastExpressionStart = token.Location;
                 }
             } else if (Tokens.SimpleTypeName[token.Kind] || Tokens.ExpressionStart[token.Kind] || token.Kind == Tokens.Literal) {
                 frame.lastExpressionStart = token.Location;
             } else {
                 frame.lastExpressionStart = Location.Empty;
                 frame.SetDefaultContext();
             }
             break;
     }
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:94,代码来源:ExpressionFinder.cs


示例12: IsBlockStart

		static bool IsBlockStart(ILexer lexer, Token current, Token prev, out bool isMultiLineLambda)
		{
			isMultiLineLambda = false;
			
			if (blockTokens.Contains(current.Kind)) {
				if (current.Kind == Tokens.If) {
					if (prev.Kind != Tokens.EOL)
						return false;
					
					lexer.StartPeek();
					
					Token currentToken = null;
					
					while ((currentToken = lexer.Peek()).Kind > Tokens.EOL) {
						if (currentToken.Kind == Tokens.Then)
							return lexer.Peek().Kind == Tokens.EOL;
					}
				}
				
				// check if it is a lambda
				if (current.Kind == Tokens.Function || current.Kind == Tokens.Sub) {
					lexer.StartPeek();
					
					bool isSingleLineLambda = false;
					
					if (lexer.Peek().Kind == Tokens.OpenParenthesis) {
						isSingleLineLambda = true;
						
						int brackets = 1;
						
						// look for end of parameter list
						while (brackets > 0) {
							var t = lexer.Peek();
							if (t.Kind == Tokens.OpenParenthesis)
								brackets++;
							if (t.Kind == Tokens.CloseParenthesis)
								brackets--;
						}
						
						// expression is multi-line lambda if next Token is EOL
						if (brackets == 0)
							return isMultiLineLambda = (lexer.Peek().Kind == Tokens.EOL);
					}
					
					// do not indent if current token is start of single-line lambda
					if (isSingleLineLambda)
						return false;
				}
				
				if (current.Kind == Tokens.With && prev.Kind > Tokens.EOL)
					return false;
				
				if (current.Kind == Tokens.While && (prev.Kind == Tokens.Skip || prev.Kind == Tokens.Take))
					return false;
				
				if (current.Kind == Tokens.Select && prev.Kind > Tokens.EOL)
					return false;
				
				if (current.Kind == Tokens.Class || current.Kind == Tokens.Structure) {
					lexer.StartPeek();
					
					Token t = lexer.Peek();
					
					if (t.Kind == Tokens.CloseParenthesis || t.Kind == Tokens.CloseCurlyBrace || t.Kind == Tokens.Comma)
						return false;
				}
				
				if (current.Kind == Tokens.Module) {
					lexer.StartPeek();
					
					Token t = lexer.Peek();
					
					if (t.Kind == Tokens.Colon)
						return false;
				}
				
				if (prev.Kind == Tokens.End ||
				    prev.Kind == Tokens.Loop ||
				    prev.Kind == Tokens.Exit ||
				    prev.Kind == Tokens.Continue ||
				    prev.Kind == Tokens.Resume ||
				    prev.Kind == Tokens.GoTo ||
				    prev.Kind == Tokens.Do)
					return false;
				else
					return true;
			}
			
			return IsSpecialCase(current, prev);
		}
开发者ID:rbrunhuber,项目名称:SharpDevelop,代码行数:90,代码来源:VBNetFormattingStrategy.cs


示例13: IsBlockEnd

		internal static bool IsBlockEnd(Token current, Token prev)
		{
			if (current.Kind == Tokens.Next)
				return prev.Kind == Tokens.EOL || prev.Kind == Tokens.Colon;
			
			if (current.Kind == Tokens.Loop)
				return prev.Kind == Tokens.EOL || prev.Kind == Tokens.Colon;
			
			if (blockTokens.Contains(current.Kind))
				return prev.Kind == Tokens.End;
			
			return IsSpecialCase(current, prev);
		}
开发者ID:rbrunhuber,项目名称:SharpDevelop,代码行数:13,代码来源:VBNetFormattingStrategy.cs


示例14: IsAutomaticPropertyWithDefaultValue

		static bool IsAutomaticPropertyWithDefaultValue(ILexer lexer, Token currentToken, Token prevToken)
		{
			if (currentToken.Kind != Tokens.Property)
				return false;
			lexer.StartPeek();
			
			int parenthesesNesting = 0;
			
			// look for parameter list, = or EOL
			Token t;
			while ((t = lexer.Peek()).Kind != Tokens.EOF) {
				if (t.Kind == Tokens.OpenParenthesis)
					parenthesesNesting++;
				if (t.Kind == Tokens.CloseParenthesis)
					parenthesesNesting--;
				if (parenthesesNesting == 0 && t.Kind == Tokens.Assign)
					return true;
				if (t.Kind == Tokens.EOL)
					return false;
			}
			
			return false;
		}
开发者ID:rbrunhuber,项目名称:SharpDevelop,代码行数:23,代码来源:VBNetFormattingStrategy.cs


示例15: IsTypeNameOrKWForTypeCast

 private bool IsTypeNameOrKWForTypeCast(ref Token pt)
 {
     return (this.IsTypeKWForTypeCast(ref pt) || this.IsTypeNameForTypeCast(ref pt));
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:4,代码来源:Parser.cs


示例16: ApplyToken

 void ApplyToken(Token token)
 {
     TrackCurrentFrameAndExpression(token);
     TrackCurrentContext(token);
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:5,代码来源:ExpressionFinder.cs


示例17: Unindent

		void Unindent(Token la)
		{
			ApplyIndent(la);
			indentationStack.PopOrDefault();
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:5,代码来源:VBIndentationStrategy.cs


示例18: TrackCurrentContext

        void TrackCurrentContext(Token token)
        {
            if (frame.state == FrameState.ObjectCreation) {
                if (token.Kind == Tokens.CloseParenthesis) {
                    if (frame.context.IsObjectCreation) {
                        frame.context = ExpressionContext.Default;
                        frame.lastExpressionStart = frame.lastNewTokenStart;
                    }
                    // keep frame.state
                } else if (token.Kind == Tokens.GreaterThan
                           || token.Kind == Tokens.DoubleColon || token.Kind == Tokens.Dot
                           || Tokens.SimpleTypeName[token.Kind])
                {
                    // keep frame.state == FrameState.ObjectCreationInType
                } else {
                    frame.state = FrameState.Normal;
                    frame.ResetCurlyChildType();
                }
            } else if (frame.state == FrameState.UsingNamespace) {
                if (token.Kind != Tokens.Identifier && token.Kind != Tokens.Dot && token.Kind != Tokens.DoubleColon) {
                    frame.state = FrameState.Normal;
                    frame.SetDefaultContext();
                }
            }

            switch (token.Kind) {
                case Tokens.Using:
                    if (frame.type == FrameType.Global) {
                        frame.state = FrameState.UsingNamespace;
                        frame.SetDefaultContext();
                        break;
                    } else {
                        goto case Tokens.For;
                    }
                case Tokens.For:
                case Tokens.Foreach:
                case Tokens.Fixed:
                case Tokens.Catch:
                    if (frame.type == FrameType.Statements) {
                        frame.parenthesisChildType = FrameType.Statements;
                        frame.state = FrameState.StatementWithEmbeddedStatement;
                    }
                    break;
                case Tokens.If:
                case Tokens.While:
                case Tokens.Switch:
                case Tokens.Lock:
                    if (frame.type == FrameType.Statements) {
                        frame.state = FrameState.StatementWithEmbeddedStatement;
                    }
                    break;
                case Tokens.Throw:
                    frame.SetExpectedType(projectContent.SystemTypes.Exception);
                    break;
                case Tokens.New:
                    if (frame.InExpressionMode) {
                        frame.SetContext(ExpressionContext.TypeDerivingFrom(frame.expectedType, true));
                        frame.state = FrameState.ObjectCreation;
                        frame.curlyChildType = FrameType.ObjectInitializer;
                        frame.lastNewTokenStart = token.Location;
                    }
                    break;
                case Tokens.Namespace:
                    frame.SetContext(ExpressionContext.IdentifierExpected);
                    break;
                case Tokens.Assign:
                    if (frame.type == FrameType.Global) {
                        frame.SetContext(ExpressionContext.FullyQualifiedType);
                        break;
                    } else if (frame.type == FrameType.Enum) {
                        frame.SetContext(ExpressionContext.Default);
                        break;
                    } else if (frame.type == FrameType.TypeDecl) {
                        frame.SetContext(ExpressionContext.Default);
                        frame.state = FrameState.Initializer;
                        frame.ResetParenthesisChildType();
                        frame.ResetSquareBracketChildType();
                        frame.ResetCurlyChildType();
                        break;
                    } else if (frame.type == FrameType.ObjectInitializer) {
                        frame.state = FrameState.ObjectInitializerValue;
                        frame.SetDefaultContext();
                        break;
                    } else {
                        goto default;
                    }
                case Tokens.Colon:
                    if (frame.state == FrameState.MethodDecl && lastToken == Tokens.CloseParenthesis) {
                        frame.SetContext(ExpressionContext.BaseConstructorCall);
                        frame.parenthesisChildType = FrameType.Expression;
                    } else {
                        if (frame.curlyChildType == FrameType.TypeDecl || frame.curlyChildType == FrameType.Interface || frame.curlyChildType == FrameType.Enum) {
                            if (frame.state != FrameState.Constraints) {
                                frame.state = FrameState.InheritanceList;
                                frame.SetDefaultContext();
                            }
                        }
                    }
                    break;
                case Tokens.Class:
//.........这里部分代码省略.........
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:101,代码来源:ExpressionFinder.cs


示例19: NextToken

		/// <summary>
		/// Reads the next token and gives it back.
		/// </summary>
		/// <returns>An <see cref="Token"/> object.</returns>
		public virtual Token NextToken()
		{
			if (curToken == null) {
				curToken = Next();
				specialTracker.InformToken(curToken.kind);
				//Console.WriteLine(ICSharpCode.NRefactory.Parser.CSharp.Tokens.GetTokenString(curToken.kind) + " -- " + curToken.val + "(" + curToken.kind + ")");
				return curToken;
			}
			
			lastToken = curToken;
			
			if (curToken.next == null) {
				curToken.next = Next();
				if (curToken.next != null) {
					specialTracker.InformToken(curToken.next.kind);
				}
			}
			
			curToken  = curToken.next;
			//Console.WriteLine(ICSharpCode.NRefactory.Parser.CSharp.Tokens.GetTokenString(curToken.kind) + " -- " + curToken.val + "(" + curToken.kind + ")");
			return curToken;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:26,代码来源:AbstractLexer.cs


示例20: Dispose

		public virtual void Dispose()
		{
			reader.Close();
			reader = null;
			errors = null;
			lastToken = curToken = peekToken = null;
			specialCommentHash = null;
			tagComments = null;
			sb = originalValue = null;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:10,代码来源:AbstractLexer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Semantics.ResolveResult类代码示例发布时间:2022-05-26
下一篇:
C# Parser.ModifierList类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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