Interface GrammarRuleBuilder


public interface GrammarRuleBuilder
This interface contains methods used to describe rule of grammar.

This interface is not intended to be implemented by clients.

Since:
1.18
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Allows to provide definition of a grammar rule.
    is(Object e, Object... rest)
    Convenience method equivalent to calling is(grammarBuilder.sequence(e, rest)).
    Allows to override definition of a grammar rule.
    override(Object e, Object... rest)
    Convenience method equivalent to calling override(grammarBuilder.sequence(e, rest)).
    void
    Indicates that grammar rule should not lead to creation of AST node - its children should be attached directly to its parent.
    void
    Indicates that grammar rule should not lead to creation of AST node if it has exactly one child.
  • Method Details

    • is

      Allows to provide definition of a grammar rule.

      Note: this method can be called only once for a rule. If it is called more than once, an GrammarException will be thrown.

      Parameters:
      e - expression of grammar
      Returns:
      this (for method chaining)
      Throws:
      GrammarException - if definition has been already done
      IllegalArgumentException - if given argument is not a parsing expression
    • is

      GrammarRuleBuilder is(Object e, Object... rest)
      Convenience method equivalent to calling is(grammarBuilder.sequence(e, rest)).
      Parameters:
      e - expression of grammar
      rest - rest of expressions
      Returns:
      this (for method chaining)
      Throws:
      GrammarException - if definition has been already done
      IllegalArgumentException - if any of given arguments is not a parsing expression
      See Also:
    • override

      Allows to override definition of a grammar rule.

      This method has the same effect as is(Object), except that it can be called more than once to redefine a rule from scratch.

      Parameters:
      e - expression of grammar
      Returns:
      this (for method chaining)
      Throws:
      IllegalArgumentException - if given argument is not a parsing expression
    • override

      GrammarRuleBuilder override(Object e, Object... rest)
      Convenience method equivalent to calling override(grammarBuilder.sequence(e, rest)).
      Parameters:
      e - expression of grammar
      rest - rest of expressions
      Returns:
      this (for method chaining)
      Throws:
      IllegalArgumentException - if any of given arguments is not a parsing expression
      See Also:
    • skip

      void skip()
      Indicates that grammar rule should not lead to creation of AST node - its children should be attached directly to its parent.
    • skipIfOneChild

      void skipIfOneChild()
      Indicates that grammar rule should not lead to creation of AST node if it has exactly one child.