public boolean match(MatcherContext context) { subMatcher.getSubContext(context).runMatcher(); context.createNode(); return true; }
@SuppressWarnings( {"ForLoopReplaceableByForEach"}) public boolean match(MatcherContext context) { List<Matcher> children = getChildren(); int size = children.size(); for (int i = 0; i < size; i++) { Matcher matcher = children.get(i); if (matcher.getSubContext(context).runMatcher()) { context.createNode(); return true; } } return false; }
public ParsingResult<V> run(InputBuffer inputBuffer) { checkArgNotNull(inputBuffer, "inputBuffer"); resetValueStack(); MatcherContext<V> rootContext = createRootContext(inputBuffer, this, true); boolean matched = rootContext.runMatcher(); return createParsingResult(matched, rootContext); }
@Override protected ParsingResult<V> runBasicMatch(InputBuffer inputBuffer) { getLog().receive("Starting new parsing run\n"); lastPath = null; MatcherContext<V> rootContext = createRootContext(inputBuffer, this, true); boolean matched = rootContext.runMatcher(); return createParsingResult(matched, rootContext); }
public boolean match(MatcherContext context) { boolean matched = subMatcher.getSubContext(context).runMatcher(); if (!matched) return false; // collect all further matches as well int lastIndex = context.getCurrentIndex(); while (subMatcher.getSubContext(context).runMatcher()) { int currentIndex = context.getCurrentIndex(); if (currentIndex == lastIndex) { throw new GrammarException("The inner rule of OneOrMore rule '%s' must not allow empty matches", context.getPath()); } lastIndex = currentIndex; } context.createNode(); return true; }
public boolean match(MatcherContext context) { Object valueStackSnapshot = context.getValueStack().takeSnapshot(); List<Matcher> children = getChildren(); int size = children.size(); for (int i = 0; i < size; i++) { Matcher matcher = children.get(i); // remember the current index in the context, so we can access it for building the current follower set context.setIntTag(i); if (!matcher.getSubContext(context).runMatcher()) { // rule failed, so invalidate all stack actions the rule might have done context.getValueStack().restoreSnapshot(valueStackSnapshot); return false; } } context.createNode(); return true; }
@Override public ParsingResult<V> run(final InputBuffer inputBuffer) { Preconditions.checkNotNull(inputBuffer, "inputBuffer"); resetValueStack(); final MatcherContext<V> rootContext = createRootContext(inputBuffer, this, true); bus.post(new PreParseEvent<>(rootContext)); if (throwable != null) throw new RuntimeException("parse listener error", throwable); final boolean matched = rootContext.runMatcher(); final ParsingResult<V> result = createParsingResult(matched, rootContext); bus.post(new PostParseEvent<>(result)); if (throwable != null) throw new RuntimeException("parse listener error", throwable); return result; }
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); }
public boolean match(MatcherContext context) { int lastIndex = context.getCurrentIndex(); Object valueStackSnapshot = context.getValueStack().takeSnapshot(); if (!subMatcher.getSubContext(context).runMatcher()) return false; // reset location, Test matchers never advance context.setCurrentIndex(lastIndex); // erase all value stack changes the the submatcher could have made context.getValueStack().restoreSnapshot(valueStackSnapshot); return true; }
public boolean match(MatcherContext context) { int lastIndex = context.getCurrentIndex(); Object valueStackSnapshot = context.getValueStack().takeSnapshot(); if (subMatcher.getSubContext(context).runMatcher()) return false; // reset location, Test matchers never advance context.setCurrentIndex(lastIndex); // erase all value stack changes the the submatcher could have made context.getValueStack().restoreSnapshot(valueStackSnapshot); return true; }
public boolean match(MatcherContext context) { checkArgNotNull(context, "context"); int lastIndex = context.getCurrentIndex(); while (subMatcher.getSubContext(context).runMatcher()) { int currentLocation = context.getCurrentIndex(); if (currentLocation == lastIndex) { throw new GrammarException("The inner rule of ZeroOrMore rule '%s' must not allow empty matches", context.getPath()); } lastIndex = currentLocation; } context.createNode(); return true; }