Interface Rule

All Superinterfaces:
AstNodeType
All Known Subinterfaces:
CompilableGrammarRule
All Known Implementing Classes:
MutableParsingRule, RuleDefinition

public interface Rule extends AstNodeType

This interface is not intended to be implemented by clients.

  • Method Details

    • is

      Deprecated.
      in 1.19, use GrammarRuleBuilder.is(Object) instead.
      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 IllegalStateException will be thrown.

      Parameters:
      e - expression of grammar that defines this rule
      Returns:
      this (for method chaining)
      Throws:
      IllegalStateException - if definition has been already done
      IllegalArgumentException - if any of given arguments is not a parsing expression
    • override

      @Deprecated Rule override(Object... e)
      Deprecated.
      Allows to override definition of a grammar rule.

      This method has the same effect as

      invalid reference
      #is(Object)
      , except that it can be called more than once to redefine a rule from scratch.
      Parameters:
      e - expression of grammar that defines this rule
      Returns:
      this (for method chaining)
      Throws:
      IllegalArgumentException - if any of given arguments is not a parsing expression
    • skip

      @Deprecated void skip()
      Deprecated.
      in 1.19, use GrammarRuleBuilder.skip() instead.
      Indicates that grammar rule should not lead to creation of AST node - its children should be attached directly to its parent.
    • skipIfOneChild

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

      @Deprecated void mock()
      Deprecated.
      in 1.18, use override(Object...) instead.
      Utility method used for unit testing in order to dynamically replace the definition of the rule to match as soon as a token whose value equals the name of the rule is encountered.