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


C# Parser.Token类代码示例

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


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


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