Package eu.bandm.tools.paisley
Class Variable<A>
java.lang.Object
eu.bandm.tools.paisley.Pattern<A>
eu.bandm.tools.paisley.Variable<A>
- All Implemented Interfaces:
Extractor<A>
,Serializable
,Cloneable
Class of pattern variables.
A pattern variable is deterministic, matches any object and binds itself.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescription(package private) class
(package private) class
Nested classes/interfaces inherited from class eu.bandm.tools.paisley.Pattern
Pattern.Either<A>
-
Field Summary
Fields inherited from class eu.bandm.tools.paisley.Pattern
_left_matched, _target_save, none
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks whether a variable is bound by this pattern.void
clear
(boolean recursively) Disposes of all internal state related to results and nondeterminism.clone()
Subpatterns that are instances ofVariable
must be shared.protected void
compileCut
(CompilationContext context) protected void
compileCut
(CompilationContext context, boolean recursively) protected void
compileMatchAgain
(CompilationContext context) getName()
Returns the name of this variable.getValue()
Returns the current value bound to this variable.boolean
Attempts to match this pattern against a given object.Returns the "plus" variant of the Kleene fixpoint of a pattern as a function of this variable.boolean
Checks whether a variable is preserved by this pattern, unconditionally.boolean
Checks whether a variable is preserved by this pattern, conditionally on success or failure.Returns the "star" variant of the Kleene fixpoint of a pattern as a function of this variable.toString()
Methods inherited from class eu.bandm.tools.paisley.Pattern
all, all, all, all, all, and, andThen, andThen, any, aside, both, clear, compile, compileClear, compileClear, compileIsDeterministic, compileMatch, compileSubPattern, compileThis, compileUpTo, cut, cut, DEBUG, either, enPassant, flatten, isDeterministic, limit, main, matchAgain, matchOnce, matchVar, narrow, newAll, noMatch, none, of, or, orElse, orElse, repeat, some, some, some, some, someMatch, startCompile, uniquely, variable, variable
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface eu.bandm.tools.paisley.Extractor
bind, eagerBindings, lazyBindings
-
Constructor Details
-
Variable
public Variable()Creates a new anonymous variable. -
Variable
Creates a new named variable. Variable names are for user-level annotation purposes only, they have no effect on matching behaviour.- Parameters:
name
- the variable name.
-
-
Method Details
-
getName
Returns the name of this variable.- Returns:
- the name of this variable, or
null
if this variable is anonymous.
-
getValue
Returns the current value bound to this variable. The value is initiallynull
. It is set to a meaningful value by a successful match with a pattern that guarantees to bind the variable. It may be set to an unspecified value by a match with a pattern that does not guarantee to preserve the variable. -
clear
public void clear(boolean recursively) Disposes of all internal state related to results and nondeterminism.The default implementation does nothing. This implementation resets the variable value to
null
. -
match
Attempts to match this pattern against a given object. If the class of this pattern imposes a specific order on matches, the first one is chosen. This implementation sets the variable value totarget
. -
binds
Description copied from class:Pattern
Checks whether a variable is bound by this pattern.The default implementation returns
false
. -
preserves
Description copied from class:Pattern
Checks whether a variable is preserved by this pattern, conditionally on success or failure.The default implementation returns
false
. -
preserves
Description copied from class:Pattern
Checks whether a variable is preserved by this pattern, unconditionally.The default implementation returns
false
. -
toString
-
clone
Subpatterns that are instances ofVariable
must be shared. This implies thatclone()
must returnthis
. -
lambda
-
plus
Returns the "plus" variant of the Kleene fixpoint of a pattern as a function of this variable.Conceptually,
x.star(p)
is equivalent to the pattern arising fromp.clone()
by substitutingx.star(p)
forx
. Note that this cannot be used naively for implementation, since the ensuing recursive substitution would not terminate. The actual implementation guarantees to produce only as many new subpatterns as dynamically necessary. -
star
Returns the "star" variant of the Kleene fixpoint of a pattern as a function of this variable.Conceptually,
x.star(p)
is equivalent toeither(x, x.plus(p))
. -
compileMatchAgain
- Overrides:
compileMatchAgain
in classPattern<A>
-
compileCut
- Overrides:
compileCut
in classPattern<A>
-
compileCut
- Overrides:
compileCut
in classPattern<A>
-