microparsec/primitives

Funcs

func identity[T](x: T): T
Identity function.   Source Edit
func compose[R, S, T](f: R -> S; g: S -> T): R -> T {...}{.inline.}
Compose two functions.   Source Edit
func constant[S, T](x: T): (S -> T) {...}{.inline.}
Constant function.   Source Edit
func pure(): Parser[void] {...}{.inline, raises: [], tags: [].}

Create a Parser that returns nothing and consumes nothing. As such, it never fails.

This is required in both applicative and monadic parsers.

  Source Edit
func pure[T](x: T): Parser[T] {...}{.inline.}

Create a Parser that always return x, but consumes nothing. As such, it never fails.

This is required in both applicative and monadic parsers.

  Source Edit
func liftA2[R, S, T](f: (R, S) -> T; parser0: Parser[R]; parser1: Parser[S]): Parser[
    T] {...}{.inline.}
Lift a binary function to actions.   Source Edit
func flatMap[S, T](parser: Parser[S]; f: S -> Parser[T]): Parser[T] {...}{.inline.}

Pass the result of a Parser to a function that returns another Parser.

This is the equivalent to bind or >>= in Haskell, and is required in monadic parsing.

  Source Edit
func `<|>`[T](parser0, parser1: Parser[T]): Parser[T] {...}{.inline.}
Create a Parser as a choice combination between two other Parsers.   Source Edit
func many[T](parser: Parser[T]): Parser[seq[T]] {...}{.inline.}

Build a Parser that applies another Parser zero or more times and returns a sequence of the parsed values.

Note: This function is experimental.

  Source Edit
func `<$`[S, T](x: T; parser: Parser[S]): Parser[T] {...}{.inline.}
  Source Edit
func `<*`[T, S](parser0: Parser[T]; parser1: Parser[S]): Parser[T] {...}{.inline.}
  Source Edit
func `*>`[S, T](parser0: Parser[S]; parser1: Parser[T]): Parser[T] {...}{.inline.}
  Source Edit

Templates

template quoted(x: auto): string
Quote object x and return as string.   Source Edit
template `>>`[S; T](parser0: Parser[S]; parser1: Parser[T]): Parser[T]
  Source Edit