A - the target type of the contained subpatternB - the target type of the containing patternpublic abstract class Unary<A,B> extends Pattern<B>
Subclasses must implement the Pattern.match(A) method.
| Modifier | Constructor and Description |
|---|---|
protected |
Unary() |
protected |
Unary(Pattern<? super A> body)
Creates a new pattern.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
binds(Variable<?> var)
Checks whether a variable is bound by this pattern.
|
void |
clear(boolean recursively)
Disposes of all internal state related to results and
nondeterminism.
|
Pattern<B> |
clone()
Makes a matching-state copy if this pattern.
|
protected void |
compileClear(eu.bandm.tools.paisley.CompilationContext context,
boolean recursively) |
protected void |
compileCut(eu.bandm.tools.paisley.CompilationContext context,
boolean recursively) |
void |
cut(boolean recursively)
Disposes of all internal state related to nondeterminism.
|
Pattern<A> |
getBody() |
boolean |
isDeterministic()
Checks whether this pattern is deterministic.
|
boolean |
matchAgain()
Attempts to re-match this pattern against a previously matched
object.
|
boolean |
preserves(Variable<?> var)
Checks whether a variable is preserved by this pattern,
unconditionally.
|
boolean |
preserves(Variable<?> var,
boolean success)
Checks whether a variable is preserved by this pattern,
conditionally on success or failure.
|
protected void |
setBody(Pattern<A> body) |
String |
toString() |
all, all, all, all, all, and, andThen, andThen, any, any, aside, both, clear, compareTo, compile, compileClear, compileCut, compileIsDeterministic, compileMatch, compileMatchAgain, compileSubPattern, compileThis, compileUpTo, cut, DEBUG, either, enPassant, eq, eqNull, equal, filter, flatten, forInstancesOf, limit, main, match, matchOnce, matchVar, narrow, neq, neqNull, newAll, noMatch, none, or, orElse, orElse, repeat, some, some, some, some, someMatch, startCompile, test, transform, uniquely, variable, variableprotected Unary(Pattern<? super A> body)
body - IllegalArgumentException - if body is null.protected Unary()
public Pattern<B> clone()
PatternSubclasses must override this method if necessary to honour the following rules for all transitively reachable patterns:
Variable must
be shared. This implies that Variable.clone() must
return this.Pattern.match(A), Pattern.matchAgain(), Pattern.cut() or Pattern.clear()) must be duplicated. If matching state changes are
effected by modification of other objects, these must be
duplicated. In summary, matching operations on this pattern and
its copy must not interfere, with the exception of variable
bindings.this.public boolean matchAgain()
PatternPatterns classes that do not override this method are
deterministic. Pattern classes that overwrite this method to
provide additional matches should also override Pattern.isDeterministic().
matchAgain in class Pattern<B>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 void cut(boolean recursively)
PatternThe default implementation does nothing. Subclasses that override
this method should also override Pattern.clear(boolean) and
ensure that it implies the effect of cut(false).
public void clear(boolean recursively)
PatternThe default implementation does nothing.
public boolean binds(Variable<?> var)
PatternThe default implementation returns false.
public boolean preserves(Variable<?> var, boolean success)
PatternThe default implementation returns false.
public boolean preserves(Variable<?> var)
PatternThe default implementation returns false.
public boolean isDeterministic()
PatternThe default implementation returns true.
isDeterministic in class Pattern<B>true if this pattern is guaranteed to match any
object at most once, false otherwise.Pattern.matchAgain()protected void compileCut(eu.bandm.tools.paisley.CompilationContext context,
boolean recursively)
compileCut in class Pattern<B>protected void compileClear(eu.bandm.tools.paisley.CompilationContext context,
boolean recursively)
compileClear in class Pattern<B>see also the complete user documentation .