本文整理汇总了Java中org.parboiled.MatcherContext.markError方法的典型用法代码示例。如果您正苦于以下问题:Java MatcherContext.markError方法的具体用法?Java MatcherContext.markError怎么用?Java MatcherContext.markError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.parboiled.MatcherContext
的用法示例。
在下文中一共展示了MatcherContext.markError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: willMatchInsError
import org.parboiled.MatcherContext; //导入方法依赖的package包/类
private boolean willMatchInsError(MatcherContext context) {
int preSkipIndex = context.getCurrentIndex();
context.advanceIndex(1); // skip ins marker char
if (!runTestMatch(context)) {
// if we wouldn't succeed with the match do not swallow the ERROR char
context.setCurrentIndex(preSkipIndex);
return false;
}
context.setStartIndex(context.getCurrentIndex());
context.markError();
return true;
}
示例2: addError
import org.parboiled.MatcherContext; //导入方法依赖的package包/类
public void addError(String message) {
MatcherContext matcherContext = (MatcherContext) getContext();
matcherContext.markError();
List parseErrors = matcherContext.getParseErrors();
parseErrors.add(new BasicParseError(matcherContext.getInputBuffer(), parseErrors.size(), message));
}
示例3: resynchronize
import org.parboiled.MatcherContext; //导入方法依赖的package包/类
private boolean resynchronize(MatcherContext context) {
context.markError();
// create a node for the failed Sequence, taking ownership of all sub nodes created so far
context.createNode();
// by resyncing we flip an unmatched sequence to a matched one, so in order to keep the value stack
// consistent we go into a special "error action mode" and execute the minimal set of actions underneath
// the resync sequence
rerunAndExecuteErrorActions(context);
// skip over all characters that are not legal followers of the failed Sequence
switch (context.getCurrentChar()) {
case RESYNC:
// this RESYNC error is the last error, we establish the length of the bad sequence and
// change this RESYNC marker to a RESYNC_START / RESYNC_END block
context.advanceIndex(1); // gobble RESYNC marker
List<Matcher> followMatchers = new FollowMatchersVisitor().getFollowMatchers(context);
int endIndex = gobbleIllegalCharacters(context, followMatchers);
currentError.setEndIndex(endIndex);
buffer.replaceInsertedChar(currentError.getStartIndex() - 1, RESYNC_START);
buffer.insertChar(endIndex, RESYNC_END);
context.advanceIndex(1); // gobble RESYNC_END marker
break;
case RESYNC_START:
// a RESYNC error we have already recovered from before
context.advanceIndex(1); // gobble RESYNC_START
while (context.getCurrentChar() != RESYNC_END) {
context.advanceIndex(1); // skip all characters up to the RESYNC_END
checkState(context.getCurrentChar() != EOI); // we MUST find a RESYNC_END before EOI
}
context.advanceIndex(1); // gobble RESYNC_END marker
break;
case RESYNC_EOI:
// if we are resyncing on EOI we don't swallow anything
// we also do not have to update the currentError since we only hit this code here
// in the final run
break;
default:
throw new IllegalStateException();
}
return true;
}