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


C# ILexer.Peek方法代码示例

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


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

示例1: IsBlockStart

		internal static bool IsBlockStart(ILexer lexer, Token current, Token prev)
		{
			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;
					}
				}
				
				if (current.Kind == Tokens.Function) {
					lexer.StartPeek();
					
					if (lexer.Peek().Kind == Tokens.OpenParenthesis)
						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:siegfriedpammer,项目名称:SharpDevelop,代码行数:65,代码来源:VBNetFormattingStrategy.cs

示例2: 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

示例3: 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

示例4: FindNextEol

		static int FindNextEol(ILexer lexer)
		{
			lexer.StartPeek();
			
			Token t = lexer.Peek();
			
			while (t.Kind > Tokens.EOL) // break on EOF(0) or EOL(1)
				t = lexer.Peek();
			
			return t.Location.Line;
		}
开发者ID:rbrunhuber,项目名称:SharpDevelop,代码行数:11,代码来源:VBNetFormattingStrategy.cs

示例5: FindNextEol

		static int FindNextEol(ILexer lexer)
		{
			lexer.StartPeek();
			
			Token t = lexer.Peek();
			
			while (t.Kind != Tokens.EOL)
				t = lexer.Peek();
			
			return t.Location.Line;
		}
开发者ID:kleinux,项目名称:SharpDevelop,代码行数:11,代码来源:VBNetFormattingStrategy.cs


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