Package-level declarations

Types

Link copied to clipboard
typealias Parser<S, R> = (ParserInput<S>) -> ParserOutput<R>
Link copied to clipboard
typealias ParserInput<S> = Pair<List<S>, Int>
Link copied to clipboard
typealias ParserOutput<R> = List<Pair<R, Int>>

Properties

Link copied to clipboard

A parser that satisfies a condition on characters.

Link copied to clipboard

A parser that parses a string enclosed in double quotes with escaped characters with a backslash.

Link copied to clipboard

A parser that parses an identifier starting with a letter followed by letters or digits. (a-zA-Z0-9*)

Link copied to clipboard

A parser that parses an optional negative sign followed by a natural number, returning the integer value.

Link copied to clipboard

A parser that parses a sequence of digits and converts them to an integer.

Link copied to clipboard

A parser that converts a parsed digit character to its integer value.

Link copied to clipboard

A parser that parses one white space character. Uses Char.isWhitespace.

Link copied to clipboard

A parser that parses zero or more white space characters.

Functions

Link copied to clipboard
infix fun <S, A, B> Parser<S, (B) -> A>.and(other: Parser<S, B>): Parser<S, A>

Combines two parsers sequentially, applying the first parser and then the second parser.

Link copied to clipboard
infix fun <S, A, B : Any> Parser<S, A>.andL(q: Parser<S, B>): Parser<S, A>

Creates a parser that matches the first parser and then the second parser, returning the result of the first parser.

Link copied to clipboard
infix fun <S, A, B : Any> Parser<S, A>.andR(q: Parser<S, B>): Parser<S, B>

Creates a parser that matches the first parser and then the second parser, returning the result of the second parser.

Link copied to clipboard
fun <S> anySymbol(): Parser<S, S>

A parser that matches any symbol.

Link copied to clipboard
infix fun <S, A, B : Any> B.applyL(p: Parser<S, A>): Parser<S, B>

Creates a parser that applies a constant value and then matches the given parser.

Link copied to clipboard
infix fun <S, A, B> (A) -> B.applyWith(parser: Parser<S, A>): Parser<S, B>

Applies a function to the result of a parser.

Link copied to clipboard
infix fun <S, A> Parser<S, A>.biasedOr(other: Parser<S, A>): Parser<S, A>

Combines two parsers, trying the first parser and if it fails, trying the second parser. The second parser is only tried if the first parser returns an empty list.

Link copied to clipboard
fun <A : Any> braced(parser: Parser<Char, A>): (ParserInput<Char>) -> ParserOutput<A>

A parser that parses an expression enclosed in braces.

Link copied to clipboard
fun <A : Any> bracketed(parser: Parser<Char, A>): (ParserInput<Char>) -> ParserOutput<A>

A parser that parses an expression enclosed in brackets.

Link copied to clipboard
fun <S : Any, A : Any> choice(parsers: List<Parser<S, A>>): Parser<S, A>

Creates a parser that matches any one of the given parsers.

Link copied to clipboard
fun <A : Any> commaList(parser: Parser<Char, A>): (ParserInput<Char>) -> ParserOutput<List<A>>

A parser that parses a list of expressions separated by commas.

Link copied to clipboard
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> (P19) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> (P19) -> (P20) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> (P19) -> (P20) -> (P21) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> (P19) -> (P20) -> (P21) -> (P22) -> R
fun <P1, P2, R> (P1, P2) -> R.curried(): (P1) -> (P2) -> R
fun <P1, P2, P3, R> (P1, P2, P3) -> R.curried(): (P1) -> (P2) -> (P3) -> R
fun <P1, P2, P3, P4, R> (P1, P2, P3, P4) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> R
fun <P1, P2, P3, P4, P5, R> (P1, P2, P3, P4, P5) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> R
fun <P1, P2, P3, P4, P5, P6, R> (P1, P2, P3, P4, P5, P6) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> R
fun <P1, P2, P3, P4, P5, P6, P7, R> (P1, P2, P3, P4, P5, P6, P7) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, R> (P1, P2, P3, P4, P5, P6, P7, P8) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, R> (P1, P2, P3, P4, P5, P6, P7, P8, P9) -> R.curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> R
Link copied to clipboard
fun <S : Any, A : Any> empty(): Parser<S, A>

A parser that always fails.

Link copied to clipboard
fun <S, A> greedy(parser: Parser<S, A>): Parser<S, List<A>>

Creates a parser that matches the longest sequence of matches of the given parser.

Link copied to clipboard
fun <S, A> greedy1(parser: Parser<S, A>): Parser<S, List<A>>

Creates a parser that matches the longest sequence of matches of the given parser, but requires at least one match.

Link copied to clipboard
fun <A> look(): Parser<A, List<A>>

A parser that returns the current input without consuming any symbols.

Link copied to clipboard
fun <S, A> many(parser: Parser<S, A>): Parser<S, List<A>>

Creates a parser that matches zero or more occurrences of the given parser.

Link copied to clipboard
fun <S : Any, A : Any> option(parser: Parser<S, A>, default: A): Parser<S, A>

Creates a parser that matches the given parser or returns a default value.

Link copied to clipboard
fun <S, A> optional(parser: Parser<S, A>): Parser<S, A?>

Creates a parser that optionally matches the given parser.

Link copied to clipboard
infix fun <S, A> Parser<S, A>.or(other: Parser<S, A>): Parser<S, A>

Combines two parsers, trying the first parser and if it fails, trying the second parser.

Link copied to clipboard
fun <S, A, B : Any, C : Any> pack(p: Parser<S, A>, r: Parser<S, B>, q: Parser<S, C>): Parser<S, B>

Creates a parser that matches a sequence of three parsers, returning the result of the middle parser.

Link copied to clipboard

A parser that parses an expression enclosed in parentheses.

Link copied to clipboard
fun <S, R> parse(parser: Parser<S, R>, input: List<S>): List<R>

Parses the input using the given parser.

Link copied to clipboard
fun <S, A : Any, B : Any> parserListOf(parser: Parser<S, A>, separator: Parser<S, B>): Parser<S, List<A>>

Creates a parser that matches a list of parsers separated by separators.

Link copied to clipboard
fun <A : Any> quoted(parser: Parser<Char, A>): Parser<Char, A>
Link copied to clipboard
fun <S> satisfy(f: (S) -> Boolean): Parser<S, S>

A parser that matches a symbol satisfying a given predicate.

Link copied to clipboard
fun <A : Any> semiList(parser: Parser<Char, A>): (ParserInput<Char>) -> ParserOutput<List<A>>

A parser that parses a list of expressions separated by semicolons.

Link copied to clipboard
fun <S, A> sequence(parsers: List<Parser<S, A>>): Parser<S, List<A>>

Creates a parser that matches a sequence of parsers.

Link copied to clipboard
fun <S, A> some(parser: Parser<S, A>): Parser<S, List<A>>

Creates a parser that matches one or more occurrences of the given parser.

Link copied to clipboard
fun <S> List<S>.startsWith(otherList: List<S>): Boolean
Link copied to clipboard
fun <S, A> succeed(r: A): Parser<S, A>

A parser that always succeeds with a given result.

Link copied to clipboard
fun <S> symbol(s: S): Parser<S, S>

A parser that matches a specific symbol.

Link copied to clipboard
fun <S> token(input: List<S>): Parser<S, List<S>>

Creates a parser that matches a specific sequence of tokens.

Link copied to clipboard
fun <P1, P2, R> (P1) -> (P2) -> R.uncurried(): (P1, P2) -> R
fun <P1, P2, P3, R> (P1) -> (P2) -> (P3) -> R.uncurried(): (P1, P2, P3) -> R
fun <P1, P2, P3, P4, R> (P1) -> (P2) -> (P3) -> (P4) -> R.uncurried(): (P1, P2, P3, P4) -> R
fun <P1, P2, P3, P4, P5, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> R.uncurried(): (P1, P2, P3, P4, P5) -> R
fun <P1, P2, P3, P4, P5, P6, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> R.uncurried(): (P1, P2, P3, P4, P5, P6) -> R
fun <P1, P2, P3, P4, P5, P6, P7, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> (P19) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> (P19) -> (P20) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> (P19) -> (P20) -> (P21) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21) -> R
fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22, R> (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> (P6) -> (P7) -> (P8) -> (P9) -> (P10) -> (P11) -> (P12) -> (P13) -> (P14) -> (P15) -> (P16) -> (P17) -> (P18) -> (P19) -> (P20) -> (P21) -> (P22) -> R.uncurried(): (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22) -> R
Link copied to clipboard
fun <A : Any> whitespaced(parser: Parser<Char, A>): Parser<Char, A>

Pads the parser with zero or more whitespaces on the left and right side.