本文整理汇总了C#中ParseContext.Recover方法的典型用法代码示例。如果您正苦于以下问题:C# ParseContext.Recover方法的具体用法?C# ParseContext.Recover怎么用?C# ParseContext.Recover使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseContext
的用法示例。
在下文中一共展示了ParseContext.Recover方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
internal override bool Parse(ParseContext context, ParseRule rule, out Token result)
{
SequenceMemento state;
if (context.Recovering)
state = (SequenceMemento)context.Recover();
else
state = new SequenceMemento(context);
context.BeginExpression(state);
// Parse each subexpression to find nested tokens
for (; state.Index < ExpressionCount; ++state.Index) {
var expr = Expression(state.Index);
Token t;
// Parsing failed on a subexpression - return an overall failure
if (!expr.Parse(context, rule, out t)) {
context.Offset = state.Offset;
context.EndExpression();
result = t;
return false;
}
// Skip blank tokens
if (t.Blank)
continue;
// Add the parsed token to our result
state.Result.Add(t);
}
if (state.Result.HasChildren)
state.Result.EndOffset = context.Offset;
context.EndExpression();
result = state.Result;
return true;
}
示例2: Parse
internal override bool Parse(ParseContext context, ParseRule rule, out Token result)
{
OrderedChoiceMemento state;
if (context.Recovering)
state = (OrderedChoiceMemento)context.Recover();
else
state = new OrderedChoiceMemento(context);
context.BeginExpression(state);
// Parse each subexpression until the first match
for (; state.index < ExpressionCount; ++state.index) {
var expr = Expression(state.index);
Token t;
// Parsing succeeded on a subexpression - return the result
if (expr.Parse(context, rule, out t)) {
context.EndExpression();
result = t;
return true;
}
context.Offset = state.offset;
}
context.EndExpression();
return context.Reject(rule, this, out result);
}