Package org.parboiled.matchers
Interface Matcher
- All Known Implementing Classes:
AbstractMatcher
,ActionMatcher
,AnyMatcher
,AnyOfMatcher
,CharIgnoreCaseMatcher
,CharMatcher
,CharRangeMatcher
,CustomMatcher
,EmptyMatcher
,FirstOfMatcher
,FirstOfStringsMatcher
,MemoMismatchesMatcher
,NothingMatcher
,OneOrMoreMatcher
,OptionalMatcher
,ProxyMatcher
,SequenceMatcher
,StringMatcher
,TestMatcher
,TestNotMatcher
,VarFramingMatcher
,ZeroOrMoreMatcher
A Matcher instance is responsible for "executing" a specific Rule instance, i.e. it implements the actual
rule type specific matching logic.
Since it extends the
GraphNode
interface it can have submatchers.-
Method Summary
Modifier and TypeMethodDescription<R> R
accept
(MatcherVisitor<R> visitor) Accepts the given matcher visitor.boolean
boolean
getLabel()
getSubContext
(MatcherContext context) Creates a context for the matching of this matcher using the given parent context.getTag()
Retrieves a previously set tag object.boolean
boolean
boolean
<V> boolean
match
(MatcherContext<V> context) Tries a match on the given MatcherContext.void
Associates an arbitrary object with this matcher.Methods inherited from interface org.parboiled.trees.GraphNode
getChildren
Methods inherited from interface org.parboiled.Rule
label, memoMismatches, skipNode, suppressNode, suppressSubnodes
-
Method Details
-
getLabel
String getLabel()- Returns:
- the label of the matcher (which is identical to the label of the Rule this matcher matches)
-
hasCustomLabel
boolean hasCustomLabel()- Returns:
- true if this matcher has been assigned a custom label
-
isNodeSuppressed
boolean isNodeSuppressed()- Returns:
- true if this matcher has been marked with @SuppressNode
-
areSubnodesSuppressed
boolean areSubnodesSuppressed()- Returns:
- true if this matcher has been marked with @SuppressSubnodes
-
isNodeSkipped
boolean isNodeSkipped()- Returns:
- true if this matcher has been marked with @SkipNode
-
areMismatchesMemoed
boolean areMismatchesMemoed()- Returns:
- true if this matcher has been marked with @MemoMismatches
-
getSubContext
Creates a context for the matching of this matcher using the given parent context.- Parameters:
context
- the parent context- Returns:
- the context this matcher is to be run in
-
match
Tries a match on the given MatcherContext.- Parameters:
context
- the MatcherContext- Returns:
- true if the match was successful
-
setTag
Associates an arbitrary object with this matcher. Used for example during profiling and packrat parsing. The matcher implementations themselves completely ignore the contents of this property. It purely serves as a performance optimization for ParseRunners and/or MatchHandlers and saves these from the need to use Map<Matcher, XYZ> structures for associating internal objects with matchers.- Parameters:
tagObject
- the tag object
-
getTag
Object getTag()Retrieves a previously set tag object.- Returns:
- the tag object or null if none set
-
accept
Accepts the given matcher visitor.- Parameters:
visitor
- the visitor- Returns:
- the value returned by the given visitor
-