Package org.parboiled.matchers
Class ProxyMatcher
- java.lang.Object
-
- org.parboiled.matchers.ProxyMatcher
-
-
Constructor Summary
Constructors Constructor Description ProxyMatcher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Raccept(MatcherVisitor<R> visitor)Accepts the given matcher visitor.booleanareMismatchesMemoed()booleanareSubnodesSuppressed()voidarm(Matcher target)Supplies this ProxyMatcher with its underlying delegate.java.util.List<Matcher>getChildren()Returns the sub nodes of this node.java.lang.StringgetLabel()MatcherContextgetSubContext(MatcherContext context)Creates a context for the matching of this matcher using the given parent context.java.lang.ObjectgetTag()Retrieves a previously set tag object.booleanhasCustomLabel()booleanisNodeSkipped()booleanisNodeSuppressed()Rulelabel(java.lang.String label)Attaches a label to this Rule.<V> booleanmatch(MatcherContext<V> context)Tries a match on the given MatcherContext.RulememoMismatches()Enables memoization of rule mismatches for consecutive rule applications at the same input location.voidsetLabel(java.lang.String label)voidsetTag(java.lang.Object tagObject)Associates an arbitrary object with this matcher.RuleskipNode()Instructs parboiled to not create a parse tree node for this rule.RulesuppressNode()Instructs parboiled to not create a parse tree node for this rule and all subrules, which can significantly increase parsing performance.RulesuppressSubnodes()Instructs parboiled to not create parse tree nodes for the subrules of this rule, which can significantly increase parsing performance.java.lang.StringtoString()static Matcherunwrap(Matcher matcher)Retrieves the innermost Matcher that is not a ProxyMatcher.
-
-
-
Method Detail
-
getChildren
public java.util.List<Matcher> getChildren()
Description copied from interface:GraphNodeReturns the sub nodes of this node.- Specified by:
getChildrenin interfaceGraphNode<Matcher>- Returns:
- the sub nodes
-
setLabel
public void setLabel(java.lang.String label)
-
match
public <V> boolean match(MatcherContext<V> context)
Description copied from interface:MatcherTries a match on the given MatcherContext.
-
getLabel
public java.lang.String getLabel()
-
hasCustomLabel
public boolean hasCustomLabel()
- Specified by:
hasCustomLabelin interfaceMatcher- Returns:
- true if this matcher has been assigned a custom label
-
isNodeSuppressed
public boolean isNodeSuppressed()
- Specified by:
isNodeSuppressedin interfaceMatcher- Returns:
- true if this matcher has been marked with @SuppressNode
-
areSubnodesSuppressed
public boolean areSubnodesSuppressed()
- Specified by:
areSubnodesSuppressedin interfaceMatcher- Returns:
- true if this matcher has been marked with @SuppressSubnodes
-
isNodeSkipped
public boolean isNodeSkipped()
- Specified by:
isNodeSkippedin interfaceMatcher- Returns:
- true if this matcher has been marked with @SkipNode
-
areMismatchesMemoed
public boolean areMismatchesMemoed()
- Specified by:
areMismatchesMemoedin interfaceMatcher- Returns:
- true if this matcher has been marked with @MemoMismatches
-
setTag
public void setTag(java.lang.Object tagObject)
Description copied from interface:MatcherAssociates 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.
-
getTag
public java.lang.Object getTag()
Description copied from interface:MatcherRetrieves a previously set tag object.
-
accept
public <R> R accept(MatcherVisitor<R> visitor)
Description copied from interface:MatcherAccepts the given matcher visitor.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
label
public Rule label(java.lang.String label)
Description copied from interface:RuleAttaches a label to this Rule. Corresponds to the @Label annotation.
-
suppressNode
public Rule suppressNode()
Description copied from interface:RuleInstructs parboiled to not create a parse tree node for this rule and all subrules, which can significantly increase parsing performance. Corresponds to the @SuppressNode annotation.- Specified by:
suppressNodein interfaceRule- Returns:
- this Rule
-
suppressSubnodes
public Rule suppressSubnodes()
Description copied from interface:RuleInstructs parboiled to not create parse tree nodes for the subrules of this rule, which can significantly increase parsing performance. Corresponds to the @SuppressSubnodes annotation.- Specified by:
suppressSubnodesin interfaceRule- Returns:
- this Rule
-
skipNode
public Rule skipNode()
Description copied from interface:RuleInstructs parboiled to not create a parse tree node for this rule. The parse tree nodes of all subrules are directly attached to the parent of this rule (or more correctly: the first ancestor not having been marked skipNode(). Note that, even though a rule marked as skipNode() does not create a parse tree node of its own and is therefore "invisible" in the parse tree, the rule still exists as a regular rule in the rule tree and is accompanied by a "regular" ruleContextduring rule matching. Corresponds to the @SkipNode annotation.
-
memoMismatches
public Rule memoMismatches()
Description copied from interface:RuleEnables memoization of rule mismatches for consecutive rule applications at the same input location.- Specified by:
memoMismatchesin interfaceRule- Returns:
- this rule
-
arm
public void arm(Matcher target)
Supplies this ProxyMatcher with its underlying delegate.- Parameters:
target- the Matcher to delegate to
-
unwrap
public static Matcher unwrap(Matcher matcher)
Retrieves the innermost Matcher that is not a ProxyMatcher.- Parameters:
matcher- the matcher to unwrap- Returns:
- the given instance if it is not a ProxyMatcher, otherwise the innermost non-proxy Matcher
-
getSubContext
public MatcherContext getSubContext(MatcherContext context)
Description copied from interface:MatcherCreates a context for the matching of this matcher using the given parent context.- Specified by:
getSubContextin interfaceMatcher- Parameters:
context- the parent context- Returns:
- the context this matcher is to be run in
-
-