Class CustomMatcher

  • All Implemented Interfaces:
    Cloneable, Matcher, Rule, GraphNode<Matcher>

    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 Detail

      • CustomMatcher

        protected CustomMatcher​(String label)
      • CustomMatcher

        protected CustomMatcher​(Rule subRule,
                                String label)
      • CustomMatcher

        protected CustomMatcher​(Rule[] subRules,
                                String label)
    • 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