Class AbstractRule<R,​M>

  • Type Parameters:
    R - Type of the product text parsing
    M - Type of the parent parsing rule
    All Implemented Interfaces:
    PegRule<R>

    public abstract class AbstractRule<R,​M>
    extends Object
    implements PegRule<R>
    Une règle peut être vue comme - la création d'une règle principale - la gestion du résultat du parsing
    Author:
    pchretien
    • Constructor Detail

      • AbstractRule

        protected AbstractRule​(PegRule<M> mainRule)
      • AbstractRule

        protected AbstractRule​(PegRule<M> mainRule,
                               String ruleName)
    • Method Detail

      • getMainRule

        protected final PegRule<M> getMainRule()
      • getRuleName

        protected final String getRuleName()
      • getExpression

        public final String getExpression()
        Specified by:
        getExpression in interface PegRule<R>
        Returns:
        Expression de la règle.
      • handle

        protected abstract R handle​(M parsing)
      • parse

        public final PegResult<R> parse​(String text,
                                        int start)
                                 throws PegNoMatchFoundException
        Parser produces an object

        or throw an exception. A parser analyzes a text, according some rules. A parser is responsible for moving the index position or throw an exception. Returns the result of the parsing operation.

        Specified by:
        parse in interface PegRule<R>
        Parameters:
        text - Text to parse
        start - Start of the element of text to parse
        Returns:
        the new index and the result
        Throws:
        PegNoMatchFoundException - if parsing has failed.