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
public interface Matcher extends Rule, GraphNode<Matcher>
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 theGraphNode
interface it can have submatchers.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <R> R
accept(MatcherVisitor<R> visitor)
Accepts the given matcher visitor.boolean
areMismatchesMemoed()
boolean
areSubnodesSuppressed()
String
getLabel()
MatcherContext
getSubContext(MatcherContext context)
Creates a context for the matching of this matcher using the given parent context.Object
getTag()
Retrieves a previously set tag object.boolean
hasCustomLabel()
boolean
isNodeSkipped()
boolean
isNodeSuppressed()
<V> boolean
match(MatcherContext<V> context)
Tries a match on the given MatcherContext.void
setTag(Object tagObject)
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 Detail
-
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
MatcherContext getSubContext(MatcherContext context)
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
<V> boolean match(MatcherContext<V> context)
Tries a match on the given MatcherContext.- Parameters:
context
- the MatcherContext- Returns:
- true if the match was successful
-
setTag
void setTag(Object tagObject)
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
<R> R accept(MatcherVisitor<R> visitor)
Accepts the given matcher visitor.- Parameters:
visitor
- the visitor- Returns:
- the value returned by the given visitor
-
-