Interface ExpressionMatcher<T extends PatternExpression>
- Type Parameters:
T
- the type of expression matched
- All Known Implementing Classes:
AbstractExpressionMatcher
,AnyMatcher
,BinaryExpressionMatcher
,BinaryExpressionMatcher.Commutative
,ConstantValueMatcher
,FieldSizeMatcher
,OperandValueMatcher
,UnaryExpressionMatcher
Some solvers may need to apply sophisticated heuristics to recognize certain forms that commonly
occur in pattern expressions. These can certainly be programmed manually, but for many cases, the
form recognition can be accomplished by describing the form as an expression matcher. For a
shorter syntax to construct such matchers. See ExpressionMatcher.Context
.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A context for defining expression matcher succinctly -
Method Summary
Modifier and TypeMethodDescriptiondefault T
get
(Map<ExpressionMatcher<?>, PatternExpression> results) Retrieve the expression substituted for this matcher from a previous successful matchdefault Map
<ExpressionMatcher<?>, PatternExpression> match
(PatternExpression expression) Attempt to match the given expression, recording the substitutions if successfulboolean
match
(PatternExpression expression, Map<ExpressionMatcher<?>, PatternExpression> result) Attempt to match the given expression, recording substitutions in the given map
-
Method Details
-
match
Attempt to match the given expression, recording the substitutions if successful- Parameters:
expression
- the expression to match- Returns:
- a map of matchers to substituted expressions
-
get
Retrieve the expression substituted for this matcher from a previous successful matchCalling this on the root matcher is relatively useless, as it would simply return the expression passed to
match(PatternExpression)
. Instead, sub-matchers should be saved in a variable, allowing their values to be retrieved. SeeExpressionMatcher.Context
, for an example.- Parameters:
results
- the previous match results- Returns:
- the substituted expression
-
match
Attempt to match the given expression, recording substitutions in the given mapEven if the match was unsuccessful, the result map may contain attempted substitutions. Thus, the map should be discarded if unsuccessful.
- Parameters:
expression
- the expression to matchresult
- a map to store matchers to substituted expressions- Returns:
- true if successful, false if not
-