repeat

fun repeat(min: Int = 0, max: Int = Int.MAX_VALUE, pattern: RuleBuilder<*>.() -> Unit): RuleBuilder<N>

Adds a RepeatableElement that matches between min and max occurrences.

The pattern lambda defines the element(s) to repeat. The elements declared within the lambda are wrapped in a SequenceElement if there is more than one.

The pattern must match at least min times and at most max times for the repetition to succeed. Use Int.MAX_VALUE for max to allow unlimited repetitions.

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

Return

this RuleBuilder for chaining

Parameters

min

The minimum number of matches required (default: 0)

max

The maximum number of matches allowed (default: unlimited)

pattern

A lambda defining the element(s) to repeat

Throws

if the range is invalid