Class ChainRule

java.lang.Object
cruise.umple.parser.rules.ChoiceRule
cruise.umple.parser.rules.ChainRule

public class ChainRule
extends ChoiceRule
name : [[rule]] [[rule]]* Similar to the Choice rule, except all sub rules must be successful when parsing(similar to an 'and' being performed on a hypotheical "isSuccess" for each rule) Because of the possibility for subrules to be optional, this Rule type must support back tracking, where after a failure, the rule will remove tokens from the growing return token when it needs to reconsider a sub rule as being parsable.
  • Constructor Details

    • ChainRule

      public ChainRule​(java.lang.String aName)
    • ChainRule

      public ChainRule​(java.lang.String name, ChoiceRule... rules)
      Overriding the corresponding constructor
  • Method Details

    • delete

      public void delete()
      Overrides:
      delete in class ChoiceRule
    • parse

      public int parse​(Token token, int from, int max, java.lang.String input, ParserDataPackage data)
      If each of the subtokens positively parses then this method will return the result of the last parsed sub ruled.
      Overrides:
      parse in class ChoiceRule
    • isOptional

      public boolean isOptional()
      If there exists a subrule that is not optional, this function will return false, otherwise it will return true(i.e. all sub tokens are optional)
      Overrides:
      isOptional in class ChoiceRule
    • getFirstValue

      public java.lang.String getFirstValue()
      Within the context of a chain rule this function means the very first rule's value, and if that rule is optional, the or of the next one, and so on.
      Overrides:
      getFirstValue in class ChoiceRule