Package-level declarations

Types

Link copied to clipboard

Implementation of StateCallbackBuilder that recursively composes itself to build a StateCallback

Link copied to clipboard

Builder for the description of a node. This typically should be used like this:

Link copied to clipboard

The builder for a single branch. This is the receiver type of every either branch.

Link copied to clipboard

The builder for the entire either construct. This is different from a single branch.

Link copied to clipboard

An expectation receiver is the receiver type for all expect DSL constructs. Use this if you want your own DSL to be able to have expect called on it.

Link copied to clipboard

A builder for state callbacks that get added to an expectation.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

DSL builder for a Niwen parser.

Link copied to clipboard

Builder class for an optional expectation.

Link copied to clipboard
class RepeatedBuilder<T, R>(minIterations: Int?, maxIterations: Int?, itemExpectationBuilder: ItemExpectationBuilder<R>, callback: StateCallback<T, List<R>, *>?) : Buildable<ExpectedRepeated<T, R>>

Builder class for ExpectedRepeated.

Link copied to clipboard

A builder for composing StateCallbacks.

Properties

Link copied to clipboard

Used with storeIn, allows placing some state as the item of the output list.

Functions

Link copied to clipboard
inline fun <T> EitherBuilder<T>.addBranch(branchInit: EitherBranchBuilder<T>.() -> Unit)

Add a branch to this builder. The branch is first initialized through the branchInit argument.

Link copied to clipboard

Build an "either" construct, with different branches the parsing process can take.

Link copied to clipboard

Adds an expectation that always succeeds and emits the provided value.

Link copied to clipboard

Adds an expectation to this node descriptor based on a node

Adds an expectation to this node descriptor based on a token type.

Link copied to clipboard

Expect the end-of-file to be reached at this point.

Link copied to clipboard

Create a lookahead expectation.

Link copied to clipboard

Main entry-point for the Niwen Parser DSL. A parser might typically look like this

Link copied to clipboard

Create an optional branch. If the optional branch matches, what it stores will is passed transparently, just like if the optional { } was not there. If the optional branch does not match, nothing happens, just like if the entire optional branch was not there.

Link copied to clipboard
infix inline fun <T> EitherBuilder<T>.or(branchInit: EitherBranchBuilder<T>.() -> Unit): EitherBuilder<T>

Adds a branch to the either construct. or can be used multiple times to get more than two branches, like so:

Link copied to clipboard
operator fun <T, R> ExpectationReceiver<T>.plusAssign(expectation: Expectation<T, R>)

Add an expectation directly instead of a builder. This is a shortcut for this += Buildable.of(expectation)

Link copied to clipboard
fun <T, R> ExpectationReceiver<T>.repeated(min: Int? = null, max: Int? = null, itemBuilder: ItemExpectationBuilder<R>.() -> Unit): ExpectationStateCallbackBuilder<T, List<R>>

Repeatedly runs the provided expectations until they no longer match, then collects the items (specified via storeIn item in one of the expectations in the repeated block) into a list that you can then store.

Link copied to clipboard

Repeatedly runs the provided expectations without storing anything.

Link copied to clipboard
inline fun <T, R : T> ExpectationReceiver<T>.self(): NodeParameterKey<T, R>

Used with storeIn self(), provides the actual value of a node declaration that is implemented with by subtype()

Link copied to clipboard
fun <T, R : T> selfKeyFor(type: KType): NodeParameterKey<T, R>

Returns a key for self and subtype.

Link copied to clipboard
inline fun <T> subtype(): ParserNodeDeclaration<T>

When paired with sealed classes and self, allows defining abstract nodes that only exist via their subtypes.