Rule Builder
A DSL builder for defining production rules within a Grammar.
RuleBuilder provides a fluent API for constructing Rule instances by defining one or more productions. Each production is built by chaining PatternElement DSL constructor calls (token, reference, sequence, etc.), followed by a call to produces to finalize each Production.
All productions must include at least one element, and all Rules must include at least one production. If these conditions are not met, an IllegalStateException is thrown when finalizing the RuleBuilder.
Parameters
The type of node produced by this rule's productions
The name of this rule (unique within a Grammar), or null for anonymous rules
Functions
Adds an AlternationElement that matches any one of the specified alternatives.
Adds a OneOrMoreElement that matches 1 or more times.
Adds an AlternationElement that matches any one of the specified alternatives.
Adds a SequenceElement that matches all specified elements in order.
Adds a custom PatternElement to the current production.
Adds an anonymous inline nonterminal rule reference.
Marks the current production as left-recursive.
Adds an anonymous inline nonterminal rule reference.
Adds a nonterminal ReferenceElement that matches the given rule.
Adds a OneOrMoreElement that matches 1 or more times.
Adds an OptionalElement (matches 0 or 1 times).
Finalizes the current production with a default Generic node factory.
Finalizes the current Production with a Node factory function.
Adds a nonterminal ReferenceElement that matches the given rule.
Adds a RepeatableElement that matches between min and max occurrences.
Adds a SequenceElement that matches all specified elements in order.
Adds a TokenElement that matches tokens of type T.
Adds a TokenElement that matches tokens of type T satisfying the given predicate.
Adds a TokenElement that matches tokens produced by the specified lexeme.
Adds a RepeatableElement that matches 0 or more times.
Adds an OptionalElement (matches 0 or 1 times).