Class PegAbstractRule<R,M>

java.lang.Object
io.vertigo.commons.peg.rule.PegAbstractRule<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 PegAbstractRule<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 Details

    • PegAbstractRule

      protected PegAbstractRule(PegRule<M> mainRule)
    • PegAbstractRule

      protected PegAbstractRule(PegRule<M> mainRule, String ruleName)
  • Method Details

    • 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.