Class JavaForRule
java.lang.Object
com.singularsys.extensions.structure.JavaForRule
- All Implemented Interfaces:
GrammaticalRuleI,GrammarMatcher,Serializable
Parses a java-style for loop
for(i=0;i<10;++i) x+=i;.
<JavaForRule> ::= <for> <open> <expression> <sep> <expression> <sep> <expression> <close> <statement>Any of the expressions can be empty Successful parse will return a
LoopNode.- Author:
- Richard Morris
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJavaForRule(SymbolToken forToken, SymbolToken open, GrammaticalRuleI expression, SymbolToken sep, SymbolToken close, GrammaticalRuleI statement) Constructor. -
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
-
JavaForRule
public JavaForRule(SymbolToken forToken, SymbolToken open, GrammaticalRuleI expression, SymbolToken sep, SymbolToken close, GrammaticalRuleI statement) Constructor.- Parameters:
forToken- token representing "for"open- opening bracketexpression- rule for parsing an expressionsep- separator between part of statementclose- closing bracketstatement- rule for parsing a statement
-
-
Method Details
-
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
-
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.
-