public boolean match(MatcherContext<?> context) { return context.getMatcher().match(context); } }
public List<Matcher> getFollowMatchers(MatcherContext currentContext) { followMatchers.clear(); context = currentContext.getParent(); while (context != null) { boolean complete = context.getMatcher().accept(this); if (complete) return followMatchers; context = context.getParent(); } return followMatchers; }
public boolean match(MatcherContext<?> context) { boolean matched = inner == null && context.getMatcher().match(context) || inner != null && inner.match(context); if (context.getCurrentIndex() == errorIndex) { if (matched && seeking) { seeking = false; } if (!matched && !seeking && context.getMatcher().accept(isSingleCharMatcherVisitor)) { failedMatchers.add(context.getPath()); } } return matched; } }
@Override public void beforeMatch(final PreMatchEvent<V> event) { final MatcherContext<V> context = event.getContext(); final Matcher matcher = context.getMatcher(); Integer id = matcherIds.get(matcher); if (id == null) { //noinspection UnnecessaryBoxing id = Integer.valueOf(nextMatcherId); matcherIds.put(matcher, id); final MatcherType type = typeProvider.getType(matcher.getClass()); final MatcherDescriptor descriptor = new MatcherDescriptor(nextMatcherId, type, matcher); matcherDescriptors.put(matcher, descriptor); nextMatcherId++; } final int level = context.getLevel(); nodeIds.put(level, nextNodeId); nextNodeId++; prematchMatcherIds.put(level, id); final int startIndex = Math.min(nrChars, context.getCurrentIndex()); prematchIndices.put(level, startIndex); prematchTimes.put(level, System.nanoTime()); }
@Override public boolean match(final MatcherContext<?> context) { boolean matched = inner == null && context.getMatcher().match(context) || inner != null && inner.match(context); if (context.getCurrentIndex() == errorIndex) { if (matched && seeking) { seeking = false; } Matcher matcher = context.getMatcher(); if (!matched && !seeking && matcher != null && matcher.accept(isSingleCharMatcherVisitor)) { failedMatchers.add(context.getPath()); } } return matched; } }
private boolean notTestNot(MatcherContext context) { return !(context.getMatcher() instanceof TestNotMatcher) && (context.getParent() == null || notTestNot(context.getParent())); } }
public boolean match(MatcherContext<?> context) { long timeStamp = System.nanoTime(); Matcher matcher = context.getMatcher(); RuleStats ruleStats = ((RuleStats) matcher.getTag()); int pos = context.getCurrentIndex();
@Override public <T> boolean match(final MatcherContext<T> context) { final Matcher matcher = context.getMatcher(); final PreMatchEvent<T> preMatchEvent = new PreMatchEvent<>(context); bus.post(preMatchEvent); if (throwable != null) throw new RuntimeException("parse listener error", throwable); // FIXME: is there any case at all where context.getMatcher() is null? @SuppressWarnings("ConstantConditions") final boolean match = matcher.match(context); final MatchContextEvent<T> postMatchEvent = match ? new MatchSuccessEvent<>(context) : new MatchFailureEvent<>(context); bus.post(postMatchEvent); if (throwable != null) throw new RuntimeException("parse listener error", throwable); return match; } }
@SuppressWarnings( {"unchecked"}) public boolean match(MatcherContext<?> context) { Matcher matcher = context.getMatcher(); boolean matched = matcher.match(context); if (getFilter().apply(new Tuple2<Context<?>, Boolean>(context, matched))) { line++; print(context, matched); // set line-dependent breakpoint here } return matched; }
public boolean match(MatcherContext<?> context) { if (inner == null && context.getMatcher().match(context) || inner != null && inner.match(context)) { if (errorIndex < context.getCurrentIndex() && notTestNot(context)) { errorIndex = context.getCurrentIndex(); } return true; } return false; }
public ParsingResult<V> run(InputBuffer inputBuffer) { checkArgNotNull(inputBuffer, "inputBuffer"); resetValueStack(); totalRuns++; MatcherContext<V> rootContext = createRootContext(inputBuffer, this, true); rootContext.getMatcher().accept(new DoWithMatcherVisitor(new DoWithMatcherVisitor.Action() { public void process(Matcher matcher) { RuleStats ruleStats = (RuleStats) matcher.getTag(); if (ruleStats == null) { ruleStats = new RuleStats(); matcher.setTag(ruleStats); } else { ruleStats.clear(); } } })); runMatches = 0; long timeStamp = System.nanoTime() - timeCorrection; boolean matched = rootContext.runMatcher(); totalNanoTime += System.nanoTime() - timeCorrection - timeStamp; getRootMatcher().accept(new DoWithMatcherVisitor(updateStatsAction)); return createParsingResult(matched, rootContext); }