Package io.vertigo.commons.peg
Class AbstractRule<R,M>
- java.lang.Object
-
- io.vertigo.commons.peg.AbstractRule<R,M>
-
- Type Parameters:
R
- Type of the product text parsingM
- 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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.vertigo.commons.peg.PegRule
PegRule.Dummy
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRule(PegRule<M> mainRule)
protected
AbstractRule(PegRule<M> mainRule, String ruleName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
getExpression()
protected PegRule<M>
getMainRule()
protected String
getRuleName()
protected abstract R
handle(M parsing)
PegResult<R>
parse(String text, int start)
Parser produces an object
-
-
-
Method Detail
-
getRuleName
protected final String getRuleName()
-
getExpression
public final String getExpression()
- Specified by:
getExpression
in interfacePegRule<R>
- Returns:
- Expression de la règle.
-
parse
public final PegResult<R> parse(String text, int start) throws PegNoMatchFoundException
Parser produces an objector 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 interfacePegRule<R>
- Parameters:
text
- Text to parsestart
- Start of the element of text to parse- Returns:
- the new index and the result
- Throws:
PegNoMatchFoundException
- if parsing has failed.
-
-