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


C# IDocument.CreateReader方法代码示例

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


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

示例1: ParseStatement

 public override Statement ParseStatement(IDocument document)
 {
     var lexer = new CSharpLexer(document.CreateReader());
     var result = Parser.Parse(lexer, Grammar.StatementRule);
     var statement = (Statement)result.Root.Result;
     return statement;
 }
开发者ID:JerreS,项目名称:AbstractCode,代码行数:7,代码来源:CSharpLanguage.cs

示例2: FindBeginStatement

		static int FindBeginStatement(IDocument document, VBStatement statement, Location endLocation, out int length)
		{
			ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, document.CreateReader());
			
			Token currentToken = null;
			Token prevToken = null;
			
			int lookFor = statement.StatementToken;
			Stack<Token> tokens = new Stack<Token>();
			
			if (statement.EndStatement == "Next") {
				lookFor = Tokens.For;
			}
			
			Token result = null;
//			Token firstModifier = null;
			
			while ((currentToken = lexer.NextToken()).Kind != Tokens.EOF) {
				if (prevToken == null)
					prevToken = currentToken;
				
//				if (IsModifier(currentToken)) {
//					if (firstModifier == null)
//						firstModifier = currentToken;
//				} else
//					firstModifier = null;
				
				
				if (VBNetFormattingStrategy.IsBlockStart(lexer, currentToken, prevToken)) {
					tokens.Push(currentToken);
				}
				if (VBNetFormattingStrategy.IsBlockEnd(currentToken, prevToken)) {
					while (tokens.Count > 0 && !VBNetFormattingStrategy.IsMatchingEnd(tokens.Peek(), currentToken))
						tokens.Pop();
					if (tokens.Count > 0) {
						Token t = tokens.Pop();
						if (currentToken.Location.Line == endLocation.Line) {
							result = t;
							break;
						}
					}
				}
				
				prevToken = currentToken;
			}
			
			if (result != null) {
				int endOffset = document.PositionToOffset(result.EndLocation.Line, result.EndLocation.Column);
				int offset = document.PositionToOffset(result.Location.Line, result.Location.Column);
				length = endOffset - offset;
				return offset;
			}
			
			length = 0;
			
			return -1;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:57,代码来源:VBNetBracketSearcher.cs

示例3: Parse

 public override CompilationUnit Parse(IDocument document)
 {
     var lexer = new CSharpLexer(document.CreateReader());
     var result = Parser.Parse(lexer);
     var compilationUnit = (CompilationUnit) result.Root?.Result ?? new CompilationUnit();
     foreach (var error in result.SyntaxErrors)
         compilationUnit.Errors.Add(error);
     return compilationUnit;
 }
开发者ID:JerreS,项目名称:AbstractCode,代码行数:9,代码来源:CSharpLanguage.cs


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