Class Rule

java.lang.Object
org.moeaframework.util.grammar.Rule

public class Rule extends Object
A context-free grammar rule.
See Also:
  • Constructor Details

    • Rule

      public Rule(Symbol symbol)
      Constructs a rule with the specified symbol. At least one production must be provided through the add(Production) method.
      Parameters:
      symbol - the non-terminal symbol of this rule
  • Method Details

    • getSymbol

      public Symbol getSymbol()
      Returns the non-terminal symbol of this rule.
      Returns:
      the non-terminal symbol of this rule
    • add

      public void add(Production production)
      Adds a production to this rule.
      Parameters:
      production - the production to be added
    • remove

      public void remove(Production production)
      Removes a production from this rule.
      Parameters:
      production - the production to be removed
    • size

      public int size()
      Returns the number of productions contained in this rule.
      Returns:
      the number of productions contained in this rule
    • get

      public Production get(int index)
      Returns the production at the specified index.
      Parameters:
      index - the index of the production to be returned
      Returns:
      the production at the specified index
      Throws:
      IndexOutOfBoundsException - if index is out of range ((index < 0) || (index >= size())