oneOf

inline fun <T> ParserState.oneOf(vararg ps: Parser<T>): T

Tries the given parsers in order, returning the result of the first one to succeed. Fails with the error message of the last parser, if none of the given parsers succeed.


inline fun <T> ParserState.oneOf(vararg ps: Pair<String, Parser<T>>): T

Tries the given parsers in order, returning the result of the first one to succeed. Fails if none of the given parsers succeed.

ps is a list of label-parser pairs, where the labels are used to construct the error message in case of failure.


inline fun <T> oneOf(vararg ps: Parser<T>): ParserState.() -> T
inline fun <T> oneOf(vararg ps: Pair<String, Parser<T>>): ParserState.() -> T

Creates a ParserState.oneOf parser.