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
Nested ClassesModifier and TypeClassDescription(package private) class(package private) classNested 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether a variable is bound by this pattern.voidclear(boolean recursively) Disposes of all internal state related to results and nondeterminism.clone()Subpatterns that are instances ofVariablemust be shared.protected voidcompileCut(CompilationContext context) protected voidcompileCut(CompilationContext context, boolean recursively) protected voidcompileMatchAgain(CompilationContext context) getName()Returns the name of this variable.getValue()Returns the current value bound to this variable.booleanAttempts 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.booleanChecks whether a variable is preserved by this pattern, unconditionally.booleanChecks 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, once, or, orElse, orElse, repeat, some, some, some, some, someMatch, startCompile, uniquely, variable, variableMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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
nullif 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
Checks whether a variable is bound by this pattern.The default implementation returns
false. -
preserves
Checks whether a variable is preserved by this pattern, conditionally on success or failure.The default implementation returns
false. -
preserves
Description copied from class:PatternChecks whether a variable is preserved by this pattern, unconditionally.The default implementation returns
false. -
toString
-
clone
-
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.- See Also:
-
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)).- See Also:
-
compileMatchAgain
- Overrides:
compileMatchAgainin classPattern<A>
-
compileCut
- Overrides:
compileCutin classPattern<A>
-
compileCut
- Overrides:
compileCutin classPattern<A>
-