Class CustomMatcher
java.lang.Object
org.parboiled.trees.ImmutableGraphNode<Matcher>
org.parboiled.matchers.AbstractMatcher
org.parboiled.matchers.CustomMatcher
Base class of custom matcher implementations. If you want to implement custom matchers they have to be derived
from this class. Instances of derived classes can be directly used in rule defining expressions.
Caution: For performance reasons the parsing engine delegates the task of taking and restoring value stack
snapshots to the matchers. If your custom matcher can run parser actions underneath it your custom matcher
implementation therefore has to take care of value stack managment itselves!
(See the implementation of the SequenceMatcher for hints on how to do this!)
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCustomMatcher(String label) protectedCustomMatcher(Rule[] subRules, String label) protectedCustomMatcher(Rule subRule, String label) -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(MatcherVisitor<R> visitor) Accepts the given matcher visitor.abstract booleanDetermines whether this matcher instance allows empty matches.abstract charReturns one of possibly several chars that a match can start with.abstract booleanDetermines whether this matcher instance always matches exactly one character.abstract booleanisStarterChar(char c) Determines whether this matcher instance can start a match with the given char.Methods inherited from class AbstractMatcher
areMismatchesMemoed, areSubnodesSuppressed, getLabel, getSubContext, getTag, hasCustomLabel, isNodeSkipped, isNodeSuppressed, label, memoMismatches, setTag, skipNode, suppressNode, suppressSubnodes, toStringMethods inherited from class ImmutableGraphNode
getChildrenMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface GraphNode
getChildren
-
Constructor Details
-
CustomMatcher
-
CustomMatcher
-
CustomMatcher
-
-
Method Details
-
isSingleCharMatcher
public abstract boolean isSingleCharMatcher()Determines whether this matcher instance always matches exactly one character.- Returns:
- true if this matcher always matches exactly one character
-
canMatchEmpty
public abstract boolean canMatchEmpty()Determines whether this matcher instance allows empty matches.- Returns:
- true if this matcher instance allows empty matches
-
isStarterChar
public abstract boolean isStarterChar(char c) Determines whether this matcher instance can start a match with the given char.- Parameters:
c- the char- Returns:
- true if this matcher instance can start a match with the given char.
-
getStarterChar
public abstract char getStarterChar()Returns one of possibly several chars that a match can start with.- Returns:
- a starter char
-
accept
Description copied from interface:MatcherAccepts the given matcher visitor.- Parameters:
visitor- the visitor- Returns:
- the value returned by the given visitor
-