ParserNodeDeclaration

fun interface ParserNodeDeclaration<T>

A node declaration. This simple interface provides a way to turn the description of a node into an actual node.

In most cases, Niwen can determine which constructors to use using reflection. Use the following:

class MyNodeType(val child: MyOtherNodeType) {
companion object : ParserNodeDeclaration<MyNodeType> by reflective()
}

You would typically implement it like so: TODO this is wrong

class MyNodeType(val child: MyOtherNodeType) {
companion object : ParserNodeDeclaration<MyNodeType> {
override fun make(args: TypeDescription) =
MyNodeType(args["child"])
}
}

See also

Inheritors

Functions

Link copied to clipboard
abstract fun make(args: TypeDescription<T>): T

This function creates a node of type T from the arguments.

Properties

Link copied to clipboard
open val name: String

Name for the provided node (usually the name of the class T).