ReferenceElement

class ReferenceElement<N : Node>(val rule: () -> Rule<N>) : PatternElement

A PatternElement that matches a nonterminal Rule reference.

ReferenceElement invokes another rule's parsing logic at the current position. If the referenced rule matches, its resulting Node is added to the current capture.

The rule parameter is a lazily-evaluated lambda to support forward references to rules that haven't been defined yet.

Parameters

N

The type of Node produced by the referenced rule

Constructors

Link copied to clipboard
constructor(rule: () -> Rule<N>)

Properties

Link copied to clipboard
val rule: () -> Rule<N>

A lambda that returns the rule to match

Functions

Link copied to clipboard
open override fun captureAt(tokenIndex: Int, capture: Node.ParserCapture): Int