alternation

fun alternation(pattern: RuleBuilder<*>.() -> Unit): RuleBuilder<N>

Adds an AlternationElement that matches any one of the specified alternatives.

The pattern lambda receives a RuleBuilder where PatternElements can be added. The alternation succeeds if any one of the alternatives matches. Alternatives are tried in the order they are declared. If only one element is defined, it is added directly without wrapping in an alternation.

Do not call produces from within the pattern lambda; the built alternation does not produce a Node.

Return

this RuleBuilder for chaining

Parameters

pattern

A lambda defining the alternative elements