public void addError(String message) { MatcherContext matcherContext = (MatcherContext) getContext(); matcherContext.markError(); List parseErrors = matcherContext.getParseErrors(); parseErrors.add(new BasicParseError(matcherContext.getInputBuffer(), parseErrors.size(), message)); }
public void addError(String message) { MatcherContext matcherContext = (MatcherContext) getContext(); matcherContext.markError(); List parseErrors = matcherContext.getParseErrors(); parseErrors.add(new BasicParseError(matcherContext.getInputBuffer(), parseErrors.size(), message)); }
@SuppressWarnings({"unchecked"}) public <V> boolean match(MatcherContext<V> context) { if (skipInPredicates && context.inPredicate()) return true; // actions need to run in the parent context MatcherContext parentContext = context.getParent(); if (!contextAwares.isEmpty()) { for (ContextAware contextAware : contextAwares) { contextAware.setContext(parentContext); } } try { Object valueStackSnapshot = context.getValueStack().takeSnapshot(); if (!action.run(parentContext)) { // failing actions are not allowed to change the ValueStack context.getValueStack().restoreSnapshot(valueStackSnapshot); return false; } // since we initialize the actions own context only partially in getSubContext(MatcherContext) // (in order to be able to still access the previous subcontexts fields in action expressions) // we need to make sure to not accidentally advance the current index of our parent with some old // index from a previous subcontext, so we explicitly set the marker here context.setCurrentIndex(parentContext.getCurrentIndex()); return true; } catch (ActionException e) { context.getParseErrors().add(new ActionError(context.getInputBuffer(), context.getCurrentIndex(), e.getMessage(), context.getPath(), e)); return false; } }