Class SequenceSeparatorRule
- java.lang.Object
-
- com.singularsys.extensions.structure.SequenceRule
-
- com.singularsys.extensions.structure.SequenceSeparatorRule
-
- All Implemented Interfaces:
GrammaticalRuleI,GrammarMatcher,java.io.Serializable
public class SequenceSeparatorRule extends SequenceRule
Parses a sequence of statements separated by a separator<SequenceRule> ::= <statement> (<sep> <statement>)* <sep>?A successful parses will return a SequenceNode with one child per statement. If there is only one child then just that child will be parsed.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SequenceSeparatorRule(GrammaticalRuleI statement, SymbolToken sep)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinit(Jep jep)Delayed initialisation, this methods is called whenever components of the jep instance are changed.Nodematch(Lookahead2Iterator<Token> it, GrammarParser parser)Attempt to parse the input using the ruleNodematch(Lookahead2Iterator<Token> it, SymbolToken end, GrammarParser parser)Repeatedly parse statements until end token is encountered or end of input
-
-
-
Constructor Detail
-
SequenceSeparatorRule
public SequenceSeparatorRule(GrammaticalRuleI statement, SymbolToken sep)
Constructor.- Parameters:
statement- rule for processing individual statementssep- separator between statements
-
-
Method Detail
-
match
public Node match(Lookahead2Iterator<Token> it, SymbolToken end, GrammarParser parser) throws ParseException
Description copied from class:SequenceRuleRepeatedly parse statements until end token is encountered or end of input- Overrides:
matchin classSequenceRule- Parameters:
it- the input list of tokensend- symbol marking end of sequenceparser- parser to parse individual statements- Returns:
- a SequenceNode
- Throws:
ParseException- if input cannot be parsed
-
match
public Node match(Lookahead2Iterator<Token> it, GrammarParser parser) throws ParseException
Description copied from interface:GrammaticalRuleIAttempt to parse the input using the rule- Specified by:
matchin interfaceGrammarMatcher- Specified by:
matchin interfaceGrammaticalRuleI- Overrides:
matchin classSequenceRule- Parameters:
it- iterator with tokens to parseparser- the parser to parse any components of the rule- Returns:
- successful parses should return a Node, null if unsuccessful
- Throws:
ParseException- if there is a syntactical error
-
init
public void init(Jep jep)
Description copied from interface:GrammarMatcherDelayed initialisation, this methods is called whenever components of the jep instance are changed.- Specified by:
initin interfaceGrammarMatcher- Overrides:
initin classSequenceRule- Parameters:
jep- the current jep instance.
-
-