Package eu.bandm.tools.paisley
Class Binary<A,B,C>
java.lang.Object
eu.bandm.tools.paisley.Pattern<C>
eu.bandm.tools.paisley.Binary<A,B,C>
- Type Parameters:
A
- the target type of the left subpatternB
- the target type of the right subpatternC
- the target type of the containing pattern
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
Pattern.Either
Abstract base class for patterns that contain two subpatterns.
Subpatterns are called left and right, in the
sense of the operands of a binary operator. Some methods have
default implementations that delegate to the subpatterns.
Subclasses must implement the Pattern.match(A)
method.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.bandm.tools.paisley.Pattern
Pattern.Either<A>
-
Field Summary
Modifier and TypeFieldDescriptionThe left subpattern.The right subpattern.Fields inherited from class eu.bandm.tools.paisley.Pattern
_left_matched, _target_save, none
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear
(boolean recursively) Disposes of all internal state related to results and nondeterminism.clone()
Makes a matching-state copy if this pattern.protected void
compileClear
(CompilationContext context, boolean recursively) protected void
compileCut
(CompilationContext context, boolean recursively) protected void
compileMatch
(CompilationContext context) protected void
compileMatchAgain
(CompilationContext context) void
cut
(boolean recursively) Disposes of all internal state related to nondeterminism.getLeft()
getRight()
toString()
protected String
Methods inherited from class eu.bandm.tools.paisley.Pattern
all, all, all, all, all, and, andThen, andThen, any, aside, binds, both, clear, compile, compileClear, compileCut, compileIsDeterministic, compileSubPattern, compileThis, compileUpTo, cut, DEBUG, either, enPassant, flatten, isDeterministic, limit, main, match, matchAgain, matchOnce, matchVar, narrow, newAll, noMatch, none, of, once, or, orElse, orElse, preserves, preserves, repeat, some, some, some, some, someMatch, startCompile, uniquely, variable, variable
-
Field Details
-
left
The left subpattern. -
right
The right subpattern.
-
-
Constructor Details
-
Binary
Creates a new pattern.- Throws:
IllegalArgumentException
- ifleft
orright
arenull
.
-
-
Method Details
-
getLeft
-
getRight
-
cut
public void cut(boolean recursively) Description copied from class:Pattern
Disposes of all internal state related to nondeterminism.The default implementation does nothing. Subclasses that override this method should also override
Pattern.clear(boolean)
and ensure that it implies the effect ofcut(false)
. -
clear
public void clear(boolean recursively) Description copied from class:Pattern
Disposes of all internal state related to results and nondeterminism.The default implementation does nothing.
-
clone
Description copied from class:Pattern
Makes a matching-state copy if this pattern.Subclasses must override this method if necessary to honour the following rules for all transitively reachable patterns:
- Subpatterns that are instances of
Variable
must be shared. This implies thatVariable.clone()
must returnthis
. - Fields that do not refer to
subpatterns, but to matching state (changed by invocations of
Pattern.match(A)
,Pattern.matchAgain()
,Pattern.cut()
orPattern.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. - Fields neither referring to subpatterns nor to matching state may be either shared or duplicated. The usage of such fields in a modifiable way (such that the distinction is relevant) is strongly deprecated.
- Patterns whose
fields need not be duplicated need not be duplicated themselves,
but may return
this
.
- Subpatterns that are instances of
-
toString
-
toStringOperator
-
compileMatch
- Overrides:
compileMatch
in classPattern<C>
-
compileMatchAgain
- Overrides:
compileMatchAgain
in classPattern<C>
-
compileCut
- Overrides:
compileCut
in classPattern<C>
-
compileClear
- Overrides:
compileClear
in classPattern<C>
-