RepeatableCapture

A ParserCapture subclass produced by RepeatableElement.

This capture records how many times the repeated element matched.

Properties

Link copied to clipboard
open override var children: List<Node>

The child nodes and tokens captured by this node's production.

Link copied to clipboard

Returns true if this node is an AlternationCapture.

Link copied to clipboard

Returns true if the element was not repeated (repetitions == 0).

Link copied to clipboard

Returns true if the element was repeated at least once.

Link copied to clipboard

Returns true if this node is a RepeatableCapture.

Link copied to clipboard
open val nodes: <Error class: unknown class>

Returns only the child subnodes, excluding tokens.

Link copied to clipboard

The number of times the element was repeated

Link copied to clipboard
open lateinit var stack: List<ParserContext.Frame>

The parser stack frames active when this Node was created.

Link copied to clipboard
open val tokens: <Error class: unknown class>

Returns only the tokens directly captured by this node, excluding tokens captured by subnodes.

Functions

Link copied to clipboard

Adds a node to this capture's children.

Link copied to clipboard

Adds a token to this capture's children.

Link copied to clipboard
fun <R> asAlternation(block: Node.AlternationCapture.() -> R): R?

Executes the block with this node as an AlternationCapture receiver if it is one.

Link copied to clipboard
fun <R> asRepeatable(block: Node.RepeatableCapture.() -> R): R?

Executes the block with this node as a RepeatableCapture receiver if it is one.

Link copied to clipboard
fun isNodeAt(index: Int): Boolean

Returns true if the child at index is a node (excluding TokenNode).

fun isNodeAt(index: Int, predicate: (node: Node) -> Boolean): Boolean

Returns true if the child at index is a node that satisfies the predicate.

Link copied to clipboard
inline fun <N : Node> isNodeAtAs(index: Int): Boolean

Returns true if the child at index is a node of type N.

inline fun <N : Node> isNodeAtAs(index: Int, noinline predicate: (node: N) -> Boolean): Boolean

Returns true if the child at index is a node of type N that satisfies the predicate.

Link copied to clipboard
fun isTokenAt(index: Int): Boolean

Returns true if the child at index is a token (i.e. a TokenNode).

fun isTokenAt(index: Int, predicate: (token: Token) -> Boolean): Boolean

Returns true if the child at index is a token that satisfies the predicate.

Link copied to clipboard
inline fun <T : Token> isTokenAtAs(index: Int): Boolean

Returns true if the child at index is a token of type T.

inline fun <T : Token> isTokenAtAs(index: Int, noinline predicate: (token: T) -> Boolean): Boolean

Returns true if the child at index is a token of type T that satisfies the predicate.

Link copied to clipboard
fun nodeAt(index: Int): Node

Returns the child node at the specified index in this node's children.

Link copied to clipboard
inline fun <N : Node> nodeAtAs(index: Int): N

Returns the child node at the specified index, cast to type N.

Link copied to clipboard
open fun tokenAt(index: Int): Token

Returns the Token at the specified index in this node's children.

Link copied to clipboard
inline fun <T : Token> tokenAtAs(index: Int): T

Returns the Token at the specified index, cast to type T.

Link copied to clipboard
open fun tokensRecursively(): <Error class: unknown class>

Returns all tokens captured by this Node, and its descendant subnodes, recursively.