本文整理汇总了C#中Context.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Pop方法的具体用法?C# Context.Pop怎么用?C# Context.Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.Pop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchNext
public override bool MatchNext(Context context)
{
// Pull the starting state back off the stack and restore
// the state of the matching context
int key = context.Pop();
int offset = context.Pop();
context.RestoreCaptures(key);
context.offset = offset;
return false;
}
示例2: MatchNext
public bool MatchNext(Context context)
{
// Restore the previous offset
int offset = context.Pop();
context.offset = offset;
return false;
}
示例3: MatchNext
public override bool MatchNext(Context context)
{
// Restore the captures (removing anything we captured
// during the assertion) and fail
int maxKey = context.Pop();
context.RestoreCaptures(maxKey);
return false;
}
示例4: MatchNext
public override bool MatchNext(Context context)
{
var ci = context.Pop(groupId);
bool result = matchItem.MatchNext(context);
if (result)
context.Push(ci.beg, context.offset, groupId);
return result;
}
示例5: MatchNext
public override bool MatchNext(Context context)
{
// Pop off how many matches we've actually made.
int count = context.Pop();
// If we have not reached the maximum iterations and
// can match again, that's what we'll do.
if (count < max && matchItem.Match(context))
{
// Save state and succeed
context.Push(++count);
return true;
}
// Current iteration of the token failed, try alternatives
// backwards through the previously matched iterations
while (count > 0)
{
// If we find an alternative match then save state and exit
if (matchItem.MatchNext(context))
{
context.Push(count);
return true;
}
// Alternative failed, go back to a previous iteration
count--;
}
// At this point count == 0 so we have no other options
// We have to try backtracking into the base behavior.
// If that fails we're out of options.
if (!base.MatchNext(context))
return false;
// We've successfully matched at the base level.
// Behave lazily by saving this state and succeeding
context.Push(0);
return true;
}