Class RepeatableRule

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

public class RepeatableRule
extends ChoiceRule
name: [[rule]](option) Repeatable rules are rules that are repeated sequencially one after the other in some form option: ? means either the rule does not parse or it does once and only once, i.e. that it is made optional means either the rule does not parse or it does any number of times + means the rule must parse at least once, and can parse any number of times after
  • Constructor Details

    • RepeatableRule

      public RepeatableRule​(java.lang.String aName, int aMin, int aMax)
    • RepeatableRule

      public RepeatableRule​(java.lang.String name, int min, int max, ChoiceRule rule)
      Takes one rule and the minimum number of repeats as well as the maximum
  • Method Details

    • setMin

      public boolean setMin​(int aMin)
    • setMax

      public boolean setMax​(int aMax)
    • getMin

      public int getMin()
      the minimum number of times the subrule can be parsed for this rule to be successful
    • getMax

      public int getMax()
      the maximum number of times the subrule should be considered to be able to parse(a max of 1 will not repeat more than once)
    • delete

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

      public int parse​(Token token, int from, int stop, java.lang.String input, ParserDataPackage data)
      Tries to parse the subrule min<=times<=max.
      Overrides:
      parse in class ChoiceRule
    • isOptional

      public boolean isOptional()
      returns true if optional, i.e. if the min is 0 or the sub rule is optional
      Overrides:
      isOptional in class ChoiceRule
    • optimizeCondition

      public boolean optimizeCondition()
      For optimization, this object will be removed if it has no sub rules.
      Overrides:
      optimizeCondition in class ChoiceRule
    • getFirstValue

      public java.lang.String getFirstValue()
      The size of a repeatable rule can be 0 or 1 and, therefore can have the value of either "" or the value of it's one and only rule
      Overrides:
      getFirstValue in class ChoiceRule
    • toDeclareString

      public java.lang.StringBuilder toDeclareString​(java.lang.StringBuilder builder)
      Overrides:
      toDeclareString in class ChoiceRule
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class ChoiceRule