Class Cfg.Rule.Builder<T>

java.lang.Object
io.jenetics.ext.grammar.Cfg.Rule.Builder<T>
Type Parameters:
T - the terminal symbol value type
Enclosing class:
Cfg.Rule<T>

public static final class Cfg.Rule.Builder<T> extends Object
Builder class for building CFG rules.
Since:
8.2
  • Method Details

    • E

      public Cfg.Rule.Builder<T> E(Consumer<? super Cfg.Expression.Builder<T>> builder)
      Builder method for creating a rule expression.
      Parameters:
      builder - the expression builder
      Returns:
      this builder for method chaining
    • E

      @SafeVarargs public final Cfg.Rule.Builder<T> E(Cfg.Symbol<T>... symbols)
      Builder method for creating an expression with the given symbols.
      Parameters:
      symbols - the expression symbols
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if the list of symbols is empty
    • N

      public Cfg.Rule.Builder<T> N(String name, Object annotation)
      Add an expression which consists solely of the given non-terminal symbol.
      Parameters:
      name - the symbol name
      annotation - the symbol annotation
      Returns:
      this builder for method chaining
    • N

      public Cfg.Rule.Builder<T> N(String name)
      Add an expression which consists solely of the given non-terminal symbol.
      Parameters:
      name - the symbol name
      Returns:
      this builder for method chaining
    • T

      public Cfg.Rule.Builder<T> T(String name, T value, Object annotation)
      Add an expression which consists solely of the given terminal symbol.
      Parameters:
      name - the symbol name
      value - the symbol value
      annotation - the symbol annotation
      Returns:
      this builder for method chaining
    • T

      public Cfg.Rule.Builder<T> T(String name, T value)
      Add an expression which consists solely of the given terminal symbol.
      Parameters:
      name - the symbol name
      value - the symbol value
      Returns:
      this builder for method chaining
    • T

      public Cfg.Rule.Builder<T> T(T name)
      Add an expression which consists solely of the given terminal symbol.
      Parameters:
      name - the symbol name
      Returns:
      this builder for method chaining
    • at

      public Cfg.Rule.Builder<T> at(Object annotation)
      Sets the rule annotation.
      Parameters:
      annotation - the rule annotation
      Returns:
      this builder for method chaining
    • build

      public Cfg.Rule<T> build()
      Create a new rule object.
      Returns:
      a new rule object