public abstract class JoinMatcher extends CustomDefaultLabelMatcher<JoinMatcher>
Such a matcher has two submatchers: a "joined" matcher and a "joining" matcher.
This matcher will run cycles through both of these; the first will be a run of the "joined" matcher, subsequent cycles will be ("joining", "joined").
Therefore:
joined
;joined, joining, joined
;This matcher will correctly reset the index to the last successful
match; for instance, if the match sequence is joined, joining, joined,
joining
and two cycles are enough, it will reset the index to before the
last joining
so that subsequent matchers can proceed from there.
It is forbidden for the "joining" matcher to match an empty sequence. Unfortunately, due to current limitations, this can only be detected at runtime.
This matcher is not built directly; its build is initiated by a JoinMatcherBootstrap
. Example:
Rule threeDigitsExactly() { return join(digit()).using('.').times(3); }
JoinMatcherBootstrap
Modifier and Type | Field and Description |
---|---|
protected Matcher |
joined |
protected Matcher |
joining |
Modifier | Constructor and Description |
---|---|
protected |
JoinMatcher(Rule joined,
Rule joining) |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
enoughCycles(int cycles) |
MatcherType |
getType()
Returns the type of this matcher
|
<V> boolean |
match(MatcherContext<V> context)
Tries a match on the given MatcherContext.
|
protected <V> boolean |
matchCycle(MatcherContext<V> context,
int beforeCycle) |
protected abstract boolean |
runAgain(int cycles) |
getLabel, hasCustomLabel
getSubContext, label, toString
getChildren
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getChildren
public final MatcherType getType()
Matcher
MatcherType
public final <V> boolean match(MatcherContext<V> context)
context
- the MatcherContextprotected abstract boolean runAgain(int cycles)
protected abstract boolean enoughCycles(int cycles)
protected final <V> boolean matchCycle(MatcherContext<V> context, int beforeCycle)