Parser

fun interface Parser<out T>

Type of a parsing function which takes the list of all tokens and the current working position.

Functions

Link copied to clipboard
fun <T> Parser<T>.debug(name: String? = null): Parser<T>
Link copied to clipboard
abstract fun invoke(tokens: List<Token>, pos: Int): ParsingResult<T>
Link copied to clipboard
fun <T, R> Parser<T>.map(transform: (T) -> R): Parser<R>
Link copied to clipboard
fun <T1, T2> Parser<T1>.then(f: (T1) -> Parser<T2>): Parser<T2>

Run a parser using result of the previous one

Link copied to clipboard
fun <T1, T2> Parser<T1>.unwindThen(f: (T1) -> Parser<T2>): Parser<T2>

Run T1 parser, if successful, go back and run the T2 parser from original position using the result of T1 for a kind of look ahead effect.