Class SequenceRule
- java.lang.Object
-
- com.singularsys.extensions.structure.SequenceRule
-
- All Implemented Interfaces:
GrammaticalRuleI
,GrammarMatcher
,java.io.Serializable
- Direct Known Subclasses:
SequenceSeparatorRule
public class SequenceRule extends java.lang.Object implements GrammaticalRuleI
Parses a sequence of statements<SequenceRule> ::= (<statement>)*
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.- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SequenceRule(GrammaticalRuleI statement)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
init(Jep jep)
Delayed initialisation, this methods is called whenever components of the jep instance are changed.Node
match(Lookahead2Iterator<Token> it, GrammarParser parser)
Attempt to parse the input using the ruleNode
match(Lookahead2Iterator<Token> it, SymbolToken end, GrammarParser parser)
Repeatedly parse statements until end token is encountered or end of input
-
-
-
Constructor Detail
-
SequenceRule
public SequenceRule(GrammaticalRuleI statement)
- Parameters:
statement
- rule to parse individual statements
-
-
Method Detail
-
match
public Node match(Lookahead2Iterator<Token> it, SymbolToken end, GrammarParser parser) throws ParseException
Repeatedly parse statements until end token is encountered or end of input- 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:GrammaticalRuleI
Attempt to parse the input using the rule- Specified by:
match
in interfaceGrammarMatcher
- Specified by:
match
in interfaceGrammaticalRuleI
- 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:GrammarMatcher
Delayed initialisation, this methods is called whenever components of the jep instance are changed.- Specified by:
init
in interfaceGrammarMatcher
- Parameters:
jep
- the current jep instance.
-
-