Class JavaIfRule
java.lang.Object
com.singularsys.extensions.structure.JavaIfRule
- All Implemented Interfaces:
GrammaticalRuleI,GrammarMatcher,Serializable
Parse a java style if statement:
if(expr) statement [ else statement ]
<JavaInRule> ::= || <if> <open> <expression> <close> <statement> || <if> <open> <expression> <close> <statement> <else> <statement>
- Author:
- Richard Morris
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJavaIfRule(SymbolToken ifToken, SymbolToken open, GrammaticalRuleI expression, SymbolToken close, GrammaticalRuleI statement, SymbolToken elseToken) -
Method Summary
Modifier and TypeMethodDescriptionvoidDelayed initialisation, this method is called whenever components of the jep instance are changed.match(Lookahead2Iterator<Token> it, GrammarParser parser) Attempt to parse the input using the rule
-
Constructor Details
-
JavaIfRule
public JavaIfRule(SymbolToken ifToken, SymbolToken open, GrammaticalRuleI expression, SymbolToken close, GrammaticalRuleI statement, SymbolToken elseToken) - Parameters:
ifToken- token representing "if"open- opening bracketexpression- rule for parsing expressionsclose- closing bracketstatement- rule for parsing statementselseToken- token representing "else"
-
-
Method Details
-
init
Description copied from interface:GrammarMatcherDelayed initialisation, this method is called whenever components of the jep instance are changed.- Specified by:
initin interfaceGrammarMatcher- Parameters:
jep- the current jep instance.
-
match
Description copied from interface:GrammaticalRuleIAttempt to parse the input using the rule- Specified by:
matchin interfaceGrammarMatcher- Specified by:
matchin 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
-