public class IntBranch<A> extends Pattern<A>
Constructor and Description |
---|
IntBranch() |
IntBranch(List<? extends Pattern<? super A>> branches) |
Modifier and Type | Method and Description |
---|---|
IntBranch<A> |
add(Pattern<? super A> pattern) |
boolean |
binds(Variable<?> v)
Checks whether a variable is bound by this pattern.
|
void |
clear(boolean recursively)
Disposes of all internal state related to results and
nondeterminism.
|
Pattern<A> |
clone()
Makes a matching-state copy if this pattern.
|
void |
cut(boolean recursively)
Disposes of all internal state related to nondeterminism.
|
int |
getKey() |
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.
|
boolean |
preserves(Variable<?> v)
Checks whether a variable is preserved by this pattern,
unconditionally.
|
boolean |
preserves(Variable<?> v,
boolean success)
Checks whether a variable is preserved by this pattern,
conditionally on success or failure.
|
all, all, all, all, all, and, andThen, andThen, any, any, aside, both, clear, compareTo, compile, compileClear, compileClear, compileCut, compileCut, compileIsDeterministic, compileMatch, compileMatchAgain, compileSubPattern, compileThis, compileUpTo, cut, DEBUG, either, enPassant, eq, eqNull, equal, filter, flatten, forInstancesOf, limit, main, matchOnce, matchVar, narrow, neq, neqNull, newAll, noMatch, none, or, orElse, orElse, repeat, some, some, some, some, someMatch, startCompile, test, transform, uniquely, variable, variable
public int getKey()
public boolean match(A target)
Pattern
match
in class Pattern<A>
target
- the object to match againsttrue
if the matching is successful, false
if it fails. Which Variable
s are bound by a
successful or failed match depends.Pattern.binds(Variable)
,
Pattern.preserves(Variable, boolean)
public boolean matchAgain()
Pattern
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()
.
matchAgain
in class Pattern<A>
true
if the matching is successful, false
if it fails. Which Variable
s 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)
Pattern
The 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)
Pattern
The default implementation does nothing.
public boolean binds(Variable<?> v)
Pattern
The default implementation returns false
.
public boolean preserves(Variable<?> v, boolean success)
Pattern
The default implementation returns false
.
public boolean preserves(Variable<?> v)
Pattern
The default implementation returns false
.
public boolean isDeterministic()
Pattern
The default implementation returns true
.
isDeterministic
in class Pattern<A>
true
if this pattern is guaranteed to match any
object at most once, false
otherwise.Pattern.matchAgain()
public Pattern<A> clone()
Pattern
Subclasses 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
.see also the complete user documentation .