Generic

open class Generic : Node

A generic Node implementation that can hold arbitrary children.

Generic Nodes are useful when you don't need custom Node types for specific Grammar constructs. They simply store the captured children without additional semantic data.

Generic Nodes are used by the no-argument produces function which does not supply a custom production lambda.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open lateinit 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 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
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
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.