Package org.parboiled.matchers
Class CustomMatcher
- java.lang.Object
-
- org.parboiled.trees.ImmutableGraphNode<Matcher>
-
- org.parboiled.matchers.AbstractMatcher
-
- org.parboiled.matchers.CustomMatcher
-
public abstract class CustomMatcher extends AbstractMatcher
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
Constructors Modifier Constructor Description protected
CustomMatcher(String label)
protected
CustomMatcher(Rule[] subRules, String label)
protected
CustomMatcher(Rule subRule, String label)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <R> R
accept(MatcherVisitor<R> visitor)
Accepts the given matcher visitor.abstract boolean
canMatchEmpty()
Determines whether this matcher instance allows empty matches.abstract char
getStarterChar()
Returns one of possibly several chars that a match can start with.abstract boolean
isSingleCharMatcher()
Determines whether this matcher instance always matches exactly one character.abstract boolean
isStarterChar(char c)
Determines whether this matcher instance can start a match with the given char.-
Methods inherited from class org.parboiled.matchers.AbstractMatcher
areMismatchesMemoed, areSubnodesSuppressed, getLabel, getSubContext, getTag, hasCustomLabel, isNodeSkipped, isNodeSuppressed, label, memoMismatches, setTag, skipNode, suppressNode, suppressSubnodes, toString
-
Methods inherited from class org.parboiled.trees.ImmutableGraphNode
getChildren
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.parboiled.trees.GraphNode
getChildren
-
-
-
-
Method Detail
-
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
public <R> R accept(MatcherVisitor<R> visitor)
Description copied from interface:Matcher
Accepts the given matcher visitor.- Parameters:
visitor
- the visitor- Returns:
- the value returned by the given visitor
-
-