本文整理汇总了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;
}
示例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;
}
示例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;
}