Class ControlRule

java.lang.Object
com.singularsys.extensions.structure.ControlRule
All Implemented Interfaces:
GrammaticalRuleI, GrammarMatcher, Serializable

public class ControlRule extends Object implements GrammaticalRuleI
Parses break and continue statements
 <ControlRule> ::=
   | <word> <separator>
 
A successful parse returns a ControlNode
Author:
Richard Morris
See Also:
  • Constructor Details

    • ControlRule

      public ControlRule(SymbolToken word, SymbolToken separator, Object code)
      Constructor.
      Parameters:
      word - token representing "break" or "continue"
      separator - separator at end of
      code - the control code to return
  • Method Details

    • match

      public Node match(Lookahead2Iterator<Token> it, GrammarParser parser)
      Description copied from interface: GrammaticalRuleI
      Attempt to parse the input using the rule
      Specified by:
      match in interface GrammarMatcher
      Specified by:
      match in interface GrammaticalRuleI
      Parameters:
      it - iterator with tokens to parse
      parser - the parser to parse any components of the rule
      Returns:
      successful parses should return a Node, null if unsuccessful
    • init

      public void init(Jep jep)
      Description copied from interface: GrammarMatcher
      Delayed initialisation, this method is called whenever components of the jep instance are changed.
      Specified by:
      init in interface GrammarMatcher
      Parameters:
      jep - the current jep instance.