combinator

object combinator

This module contains a huge number of pre-made combinators that are very useful for a variety of purposes.

This module contains a huge number of pre-made combinators that are very useful for a variety of purposes.

Since

2.2.0

class Object
trait Matchable
class Any

Value members

Concrete methods

def attemptChoice[A](ps: Parsley[A]*): Parsley[A]

attemptChoice(ps) tries to apply the parsers in the list ps in order, until one of them succeeds. Returns the value of the succeeding parser. Utilises attempt p <|> q vs choice's p <|> q.

attemptChoice(ps) tries to apply the parsers in the list ps in order, until one of them succeeds. Returns the value of the succeeding parser. Utilises attempt p <|> q vs choice's p <|> q.

def between[A](open: => Parsley[_], close: => Parsley[_], p: => Parsley[A]): Parsley[A]

between(open, close, p) parses open, followed by p and close. Returns the value returned by p.

between(open, close, p) parses open, followed by p and close. Returns the value returned by p.

def choice[A](ps: Parsley[A]*): Parsley[A]

choice(ps) tries to apply the parsers in the list ps in order, until one of them succeeds. Returns the value of the succeeding parser.

choice(ps) tries to apply the parsers in the list ps in order, until one of them succeeds. Returns the value of the succeeding parser.

def decide[A](p: => Parsley[Option[A]]): Parsley[A]

decide(p) removes the option from inside parser p, and if it returned None will fail.

decide(p) removes the option from inside parser p, and if it returned None will fail.

def decide[A](p: => Parsley[Option[A]], q: => Parsley[A]): Parsley[A]

decide(p, q) removes the option from inside parser p, if it returned None then q is executed.

decide(p, q) removes the option from inside parser p, if it returned None then q is executed.

def endBy[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]

endBy(p, sep) parses zero or more occurrences of p, separated and ended by sep. Returns a list of values returned by p.

endBy(p, sep) parses zero or more occurrences of p, separated and ended by sep. Returns a list of values returned by p.

def endBy1[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]

endBy1(p, sep) parses one or more occurrences of p, separated and ended by sep. Returns a list of values returned by p.

endBy1(p, sep) parses one or more occurrences of p, separated and ended by sep. Returns a list of values returned by p.

def many[A](p: => Parsley[A]): Parsley[List[A]]

many(p) executes the parser p zero or more times. Returns a list of the returned values of p.

many(p) executes the parser p zero or more times. Returns a list of the returned values of p.

Since

2.2.0

def manyN[A](n: Int, p: => Parsley[A]): Parsley[List[A]]

manyN(n, p) applies the parser p n or more times. Returns a list of the returned values of p.

manyN(n, p) applies the parser p n or more times. Returns a list of the returned values of p.

def manyUntil[A, B](p: => Parsley[A], end: => Parsley[B]): Parsley[List[A]]

manyUntil(p, end) applies parser p zero or more times until the parser end succeeds. Returns a list of values returned by p. This parser can be used to scan comments.

manyUntil(p, end) applies parser p zero or more times until the parser end succeeds. Returns a list of values returned by p. This parser can be used to scan comments.

def option[A](p: => Parsley[A]): Parsley[Option[A]]

option(p) tries to apply parser p. If p fails without consuming input, it returns None, otherwise it returns Some of the value returned by p.

option(p) tries to apply parser p. If p fails without consuming input, it returns None, otherwise it returns Some of the value returned by p.

def optional(p: => Parsley[_]): Parsley[Unit]

optional(p) tries to apply parser p. It will parse p or nothing. It only fails if p fails after consuming input. It discards the result of p.

optional(p) tries to apply parser p. It will parse p or nothing. It only fails if p fails after consuming input. It discards the result of p.

def optionally[A](p: => Parsley[_], x: => A): Parsley[A]

optionally(p, x) tries to apply parser p. It will always result in x regardless of whether or not p succeeded or p failed without consuming input.

optionally(p, x) tries to apply parser p. It will always result in x regardless of whether or not p succeeded or p failed without consuming input.

def repeat[A](n: Int, p: => Parsley[A]): Parsley[List[A]]

repeat(n, p) parses n occurrences of p. If n is smaller or equal to zero, the parser is pure(Nil). Returns a list of n values returned by p.

repeat(n, p) parses n occurrences of p. If n is smaller or equal to zero, the parser is pure(Nil). Returns a list of n values returned by p.

def sepBy[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]

sepBy(p, sep) parses zero or more occurrences of p, separated by sep. Returns a list of values returned by p.

sepBy(p, sep) parses zero or more occurrences of p, separated by sep. Returns a list of values returned by p.

def sepBy1[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]

sepBy1(p, sep) parses one or more occurrences of p, separated by sep. Returns a list of values returned by p.

sepBy1(p, sep) parses one or more occurrences of p, separated by sep. Returns a list of values returned by p.

def sepEndBy[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]

sepEndBy(p, sep) parses zero or more occurrences of p, separated and optionally ended by sep. Returns a list of values returned by p.

sepEndBy(p, sep) parses zero or more occurrences of p, separated and optionally ended by sep. Returns a list of values returned by p.

def sepEndBy1[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]

sepEndBy1(p, sep) parses one or more occurrences of p, separated and optionally ended by sep. Returns a list of values returned by p.

sepEndBy1(p, sep) parses one or more occurrences of p, separated and optionally ended by sep. Returns a list of values returned by p.

def skipMany[A](p: => Parsley[A]): Parsley[Unit]

skipMany(p) executes the parser p zero or more times and ignores the results. Returns ()

skipMany(p) executes the parser p zero or more times and ignores the results. Returns ()

Since

2.2.0

def skipManyN[A](n: Int, p: => Parsley[A]): Parsley[Unit]

skipManyN(n, p) applies the parser p n or more times, skipping its result.

skipManyN(n, p) applies the parser p n or more times, skipping its result.

def skipSome[A](p: => Parsley[A]): Parsley[Unit]

skipSome(p) applies the parser p one or more times, skipping its result.

skipSome(p) applies the parser p one or more times, skipping its result.

def some[A](p: => Parsley[A]): Parsley[List[A]]

some(p) applies the parser p one or more times. Returns a list of the returned values of p.

some(p) applies the parser p one or more times. Returns a list of the returned values of p.

def someUntil[A, B](p: => Parsley[A], end: => Parsley[B]): Parsley[List[A]]

someUntil(p, end) applies parser p one or more times until the parser end succeeds. Returns a list of values returned by p.

someUntil(p, end) applies parser p one or more times until the parser end succeeds. Returns a list of values returned by p.

def when(p: => Parsley[Boolean], q: => Parsley[Unit]): Parsley[Unit]

when(p, q) will first perform p, and if the result is true will then execute q or else return unit.

when(p, q) will first perform p, and if the result is true will then execute q or else return unit.

Value Params
p

The first parser to parse

q

If p returns true then this parser is executed

Returns

()

def whileP(p: => Parsley[Boolean]): Parsley[Unit]

whileP(p) will continue to run p until it returns false. This is often useful in conjunction with stateful parsers.

whileP(p) will continue to run p until it returns false. This is often useful in conjunction with stateful parsers.

Value Params
p

The parser to continuously execute

Returns

()

Concrete fields

val eof: Parsley[Unit]

This parser only succeeds at the end of the input. This is a primitive parser.

This parser only succeeds at the end of the input. This is a primitive parser.

val more: Parsley[Unit]

This parser only succeeds if there is still more input.

This parser only succeeds if there is still more input.