A - the target type.public abstract class Search<A> extends Pattern<A>
Subclasses must implement the initAlternatives(A) and
nextAlternative() methods.
| Modifier and Type | Field and Description |
|---|---|
protected Pattern<? super A> |
alt
The current alternative.
|
protected A |
arg
The target for the current alternative.
|
| Constructor and Description |
|---|
Search() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
initAlternatives(A target)
Sets up the dynamic enumeration of alternatives for a target.
|
boolean |
isDeterministic()
Checks whether this pattern is deterministic.
|
boolean |
match(A target)
Attempts to match this pattern against a given object.
|
boolean |
matchAgain()
Attempts to re-match this pattern against a previously matched
object.
|
protected abstract boolean |
nextAlternative()
Enumerates an alternative.
|
all, all, all, all, all, and, andThen, andThen, any, any, aside, binds, both, clear, clear, clone, compareTo, compile, compileClear, compileClear, compileCut, compileCut, compileIsDeterministic, compileMatch, compileMatchAgain, compileSubPattern, compileThis, compileUpTo, cut, cut, DEBUG, either, enPassant, eq, eqNull, equal, filter, flatten, forInstancesOf, limit, main, matchOnce, matchVar, narrow, neq, neqNull, newAll, noMatch, none, or, orElse, orElse, preserves, preserves, repeat, some, some, some, some, someMatch, startCompile, test, transform, uniquely, variable, variableprotected A arg
protected abstract void initAlternatives(A target)
target - the object to be matched against.protected abstract boolean nextAlternative()
initAlternatives(A).
If an alternative is found, alt and arg must
be set to non-null values accordingly.
true if an(other) alternative has been found;
false otherwise.public boolean match(A target)
This implementation uses initAlternatives(A) and nextAlternative() to find the first matching alternative for the
target, and succeeds if one is found. Alternative matching is
done by alt.match(arg).
match in class Pattern<A>target - the object to match againsttrue if the matching is successful, false if it fails. Which Variables are bound by a
successful or failed match depends.Pattern.binds(Variable),
Pattern.preserves(Variable, boolean)public boolean matchAgain()
Patterns classes that do not override this method are
deterministic. Pattern classes that overwrite this method to
provide additional matches should also override Pattern.isDeterministic().
This implementation first tries to match the last m,atching
alternative again. On failure it uses nextAlternative() to
find the next matching alternative for the target, and succeeds
if one is found. Alternative matching is done by alt.match(arg).
matchAgain in class Pattern<A>true if the matching is successful, false if it fails. Which Variables are bound by a
successful match depends. The default implementation
always returns false.Pattern.binds(Variable),
Pattern.preserves(Variable, boolean)public boolean isDeterministic()
The default implementation returns true.
This implementation returns false.
isDeterministic in class Pattern<A>true if this pattern is guaranteed to match any
object at most once, false otherwise.Pattern.matchAgain()see also the complete user documentation .