Liking cljdoc? Tell your friends :D

paco.core


*clj/s

(* p)

Returns a parser that parses zero or more occurrances of p, and returns a collection of the return values.

This is a 'sequence expression' parser, see cat.

Similar to:

  • parsec, fparsec: many
Returns a parser that parses zero or more occurrances of `p`, and returns
a collection of the return values.

This is a 'sequence expression' parser, see `cat`.

Similar to:
- parsec, fparsec: `many`
sourceraw docstring

*sep-byclj/s

(*sep-by p psep)
(*sep-by p psep sep-may-end?)

Returns a parser that parses p zero or more times, separated by the parser psep. Returns a collection of the return values of p. The return value of psep is discarded.

When sep-may-end? is true, allows the sequence to end with psep. Otherwise, expects p to succeed after every psep.

This is a 'sequence expression' parser, see cat.

Similar to:

  • parsec, fparsec: sepBy, sepEndBy
Returns a parser that parses `p` zero or more times, separated by
the parser `psep`.  Returns a collection of the return values of `p`.
The return value of `psep` is discarded.

When `sep-may-end?` is true, allows the sequence to end with `psep`.
Otherwise, expects `p` to succeed after every `psep`.

This is a 'sequence expression' parser, see `cat`.

Similar to:
- parsec, fparsec: `sepBy`, `sepEndBy`
sourceraw docstring

*skipclj/s

(*skip p)

Like *, but discards p's results and returns nil.

Simillar to:

  • fparsec: skipMany
Like `*`, but discards `p`'s results and returns `nil`.

Simillar to:
- fparsec: `skipMany`
sourceraw docstring

*skip-sep-byclj/s

(*skip-sep-by p psep)
(*skip-sep-by p psep end?)

Like *sep-by, but discards all results and returns nil.

Similar to:

  • fparsec: skipSepBy, skipSepEndBy
Like `*sep-by`, but discards all results and returns `nil`.

Similar to:
- fparsec: `skipSepBy`, `skipSepEndBy`
sourceraw docstring

*skip-untilclj/s

(*skip-until p pend)

Like *until, but discards all results and returns nil.

Similar to:

  • fparsec: skipManyTill
Like `*until`, but discards all results and returns `nil`.

Similar to:
- fparsec: `skipManyTill`
sourceraw docstring

*untilclj/s

(*until p pend)
(*until p pend include-end?)

Returns a parser that repeatedly applies the parser p for as long as pend fails (without changing the parser state). It returns a collection of the results returned by p.

When include-end? is true, also includes the result of pend in the returned collection.

Similar to:

  • parsec, fparsec: manyTill
Returns a parser that repeatedly applies the parser `p` for as long
as `pend` fails (without changing the parser state).  It returns a collection
of the results returned by `p`.

When `include-end?` is true, also includes the result of `pend` in the
returned collection.

Similar to:
- parsec, fparsec: `manyTill`
sourceraw docstring

+clj/s

(+ p)

Returns a parser that parses one or more occurrances of p, and returns a collection of the return values.

This is a 'sequence expression' parser, see cat.

Similar to:

  • parsec, fparsec: many1
Returns a parser that parses one or more occurrances of `p`, and returns
a collection of the return values.

This is a 'sequence expression' parser, see `cat`.

Similar to:
- parsec, fparsec: `many1`
sourceraw docstring

+sep-byclj/s

(+sep-by p psep)
(+sep-by p psep sep-may-end?)

Like *sep-by, but requires p to suceed at least once.

Similar to:

  • parsec, fparsec: sepBy1, sepEndBy1
Like `*sep-by`, but requires `p` to suceed at least once.

Similar to:
- parsec, fparsec: `sepBy1`, `sepEndBy1`
sourceraw docstring

+skipclj/s

(+skip p)

Like +, but discards p's results and returns nil.

Simillar to:

  • fparsec: skipMany1
Like `+`, but discards `p`'s results and returns `nil`.

Simillar to:
- fparsec: `skipMany1`
sourceraw docstring

+skip-sep-byclj/s

(+skip-sep-by p psep)
(+skip-sep-by p psep end?)

Like +sep-by, but discards all results and returns nil.

Similar to:

  • fparsec: skipSepBy1, skipSepEndBy1
Like `+sep-by`, but discards all results and returns `nil`.

Similar to:
- fparsec: `skipSepBy1`, `skipSepEndBy1`
sourceraw docstring

+skip-untilclj/s

(+skip-until p pend)

Like +until, but discards all results and returns nil.

Similar to:

  • fparsec: skipMany1Till
Like `+until`, but discards all results and returns `nil`.

Similar to:
- fparsec: `skipMany1Till`
sourceraw docstring

+untilclj/s

(+until p pend)
(+until p pend include-end?)

Like *until, but requires p to succeed at least once.

Similar to:

  • fparsec: many1Till
Like `*until`, but requires `p` to succeed at least once.

Similar to:
- fparsec: `many1Till`
sourceraw docstring

?clj/s

(? p)
(? p not-found)

Returns a parser that parses an optional occurrence of p.

When p fails without changing parser state, (? p) succeeds with nil. When p fails after changing parser state, so will (? p).

This is a 'sequence expression' parser, see cat.

Similar to:

  • parsec, fparsec: option, optional
Returns a parser that parses an optional occurrence of `p`.

When `p` fails without changing parser state, `(? p)` succeeds with `nil`.
When `p` fails after changing parser state, so will `(? p)`.

This is a 'sequence expression' parser, see `cat`.

Similar to:
- parsec, fparsec: `option`, `optional`
sourceraw docstring

?atomicclj/s

(?atomic p)
(?atomic p not-found)

Returns a parser that applies the optional parser p. If p fails, backtracks to the original state and succeeds with value not-found (default: nil).

(?atomic p) is an optimized implementation of (? (atomic p)).

Returns a parser that applies the _optional_ parser `p`. If `p` fails,
backtracks to the original state and _succeeds_ with value `not-found`
(default: `nil`).

`(?atomic p)` is an optimized implementation of `(? (atomic p))`.
sourceraw docstring

altclj/s

(alt p1)
(alt p1 p2)
(alt p1 p2 p3)
(alt p1 p2 p3 & more)

Returns a parser that applies the parsers until the first one succeeds or fails after changing the parser state.

Similar to:

  • parsec, fparsec: <|>, choice
Returns a parser that applies the parsers until the first one succeeds
or fails after changing the parser state.

Similar to:
- parsec, fparsec: `<|>`, `choice`
sourceraw docstring

altsclj/s

(alts ps)
(alts ps label')

Like alt, but takes a sequence of parsers.

Providing a label is slightly faster, because the parser doesn't have to aggregate error messages.

  • choice, choiceL (parsec, fparsec)
Like `alt`, but takes a sequence of parsers.

Providing a `label` is slightly faster, because the parser doesn't
have to aggregate error messages.

- `choice`, `choiceL` (parsec, fparsec)
sourceraw docstring

any-tokenclj/s

(any-token source reply)

This parser accepts and returns any token from the input stream.

This parser accepts and returns any token from the input stream.
sourceraw docstring

atomicclj/s

(atomic p)

Returns a parser that behaves like p, but is atomic: When p fails after changing the parser state, backtracks to undo the change.

Similar to:

  • parsec: try
  • fparsec: attempt
Returns a parser that behaves like `p`, but is atomic: When `p` fails
after changing the parser state, backtracks to undo the change.

Similar to:
- parsec: `try`
- fparsec: `attempt`
sourceraw docstring

betweenclj/s

(between p pdelim)
(between p popen pclose)

Returns a parser that applies the parsers popen, p and pclose in sequence and returns the result of p.

When called with two args, uses pdelim for both popen and pclose.

Returns a parser that applies the parsers `popen`, `p` and `pclose` in sequence
and returns the result of `p`.

When called with two args, uses `pdelim` for both `popen` and `pclose`.
sourceraw docstring

bindclj/s

(bind p f)

Returns a parser that first applies the parser p to the input, then calls the function f with the result value of p and finally applies the parser returned by f to the input.

Similar to:

  • >>= (parsec, fparsec)
Returns a parser that first applies the parser `p` to the input, then
calls the function `f` with the result value of `p` and finally applies
the parser returned by `f` to the input.

Similar to:
- `>>=` (parsec, fparsec)
sourceraw docstring

catclj/s

(cat & ps)

Returns a parser that applies the given parsers in sequence, and returns a collection of their result values (concatenation).

This is a 'sequence expression' parser: the result of nested sequence expressions are flattened in this parser's return value. (cat p1 (cat p2 p3)) is logically equivalent to (cat p1 p2 p3).

Returns a parser that applies the given parsers in sequence,
and returns a collection of their result values (concatenation).

This is a 'sequence expression' parser: the result of nested sequence
expressions are flattened in this parser's return value.
`(cat p1 (cat p2 p3))` is logically equivalent to `(cat p1 p2 p3)`.
sourceraw docstring

catsclj/s

(cats ps)

Like cat, but takes a sequence of parsers.

Like `cat`, but takes a sequence of parsers.
sourceraw docstring

condclj/s

(cond p pthen)
(cond p pthen pelse)

Returns a parser that first applies p. If p succeeds, applies pthen. Otherwise, when p fails without changing the parser state, applies pelse.

Returns a parser that first applies `p`.  If `p` succeeds,
applies `pthen`.  Otherwise, when `p` fails without changing the parser
state, applies `pelse`.
sourceraw docstring

cond-bindclj/s

(cond-bind p then-fn)
(cond-bind p then-fn pelse)

Returns a parser that first applies p. If p succeeds, applies the parser returned by calling f with the result of p. Otherwise, when p fails without changing the parser state, applies pelse.

Returns a parser that first applies `p`.  If `p` succeeds,
applies the parser returned by calling `f` with the result of `p`.
Otherwise, when `p` fails without changing the parser state, applies
`pelse`.
sourceraw docstring

derefclj/s

(deref ref)

Returns a parser that de-references ref on demand, allowing for recursive or mutable parsers.

Similar to:

  • fparsec: createParserForwardedToRef
Returns a parser that de-references `ref` on demand, allowing for
recursive or mutable parsers.

Similar to:
- fparsec: `createParserForwardedToRef`
sourceraw docstring

endclj/s

(end source reply)

The end parser only succeeds a the end of the input stream and returns nil.

Similar to:

  • parsec, fparsec: eof
The `end` parser only succeeds a the end of the input stream and
returns `nil`.

Similar to:
- parsec, fparsec: `eof`
sourceraw docstring

epsclj/s

The eps(ilon) parser accepts the empty word (i.e. it always succeeds) and returns nil.

Similar to:

  • fparsec: pzero (but succeeds)
The eps(ilon) parser accepts the empty word (i.e. it always succeeds) and
returns `nil`.

Similar to:
- fparsec: `pzero` (but succeeds)
sourceraw docstring

failclj/s

(fail message)

Returns a parser that always fails with given error message.

Returns a parser that always fails with given error message.
sourceraw docstring

followed-byclj/s

(followed-by p)
(followed-by p label)

EXPERIMENTAL: The difference between followed-by and peek (lookAhead) is subtle: fparsec's followedBy is an assertion and returns nothing, while lookAhead returns the wrapped parser's result. Do we need both?

Returns a parser that succeeds if p succeeds, but does not change the parser state. Returns nil.

Similar to:

  • fparsec: followedBy, followedByL
EXPERIMENTAL: The difference between `followed-by` and `peek` (`lookAhead`)
is subtle: fparsec's `followedBy` is an assertion and returns nothing, while
`lookAhead` returns the wrapped parser's result.  Do we need both?

Returns a parser that succeeds if `p` succeeds, but does not change
the parser state.  Returns `nil`.

Similar to:
- fparsec: `followedBy`, `followedByL`
sourceraw docstring

forceclj/s

(force d)

Returns a parser that realizes and applies a delayed parser on demand.

Returns a parser that realizes and applies a delayed parser on demand.
sourceraw docstring

fwdclj/smacro

(fwd expr)

Returns a parser that applies the parser obtained by evaluating expr, delaying evaluation until it is needed.

Useful for recursive parsers, to use a parser that has been declared but not yet defined, usually in a var:

(def expr (alt digit (between (fwd expr) (char \() (char \)))))

Warning: Left-recursive parsers are not supported and will lead to infinite loops / stack overflows.

Returns a parser that applies the parser obtained by evaluating `expr`,
delaying evaluation until it is needed.

Useful for recursive parsers, to use a parser that has been declared but not
yet defined, usually in a var:

```clojure
(def expr (alt digit (between (fwd expr) (char \() (char \)))))
```

**Warning**: Left-recursive parsers are not supported and will lead to
infinite loops / stack overflows.
sourceraw docstring

groupclj/s

(group p)
(group p1 p2 & ps)

Like cat, but returns a collection that will not be flattened into surrounding sequence expressions.

Like `cat`, but returns a collection that will not be flattened into
surrounding sequence expressions.
sourceraw docstring

indexclj/s

(index source reply)

This parser returns the index of the next token in the input stream.

This parser returns the index of the next token in the input stream.
sourceraw docstring

labelclj/s

(label p label)

Returns a parser that behaves like p, but replaces errors with (expected label) when p not change the parser state.

Similar to:

  • fparsec: `<?>
Returns a parser that behaves like `p`, but replaces errors with
`(expected label)` when `p` not change the parser state.

Similar to:
- fparsec: `<?>
sourceraw docstring

label-compoundclj/s

(label-compound p label)

Returns a parser that behaves like (label p), but generates a "compund error" message with both the given string label and the error messages generated by p.

Similar to:

  • fparsec: `<??>
Returns a parser that behaves like `(label p)`, but generates
a "compund error" message with both the given string label and the
error messages generated by p.

Similar to:
- fparsec: `<??>
sourceraw docstring

lazyclj/smacro

(lazy & body)

Returns a parser that evaluates body the first time it is needed, and caches the resulting parser.

Returns a parser that evaluates `body` the first time it is needed,
and caches the resulting parser.
sourceraw docstring

let-parserclj/smacro

(let-parser bindings & body)

Similar to let, but for parsers. The expressions in bindings must evaluate to parsers. The returned parser sequentially applies these parsers to the input, and binds their result values to their binding forms. Every expression can use the preceding bindings.

Finally, it evaluates body with all bindings, which must yield a parser that is then applied to the input.

Expands to a chain of bind calls.

Use this to create parsers dynamically depending on the return value of a previously succeeded parser. If you don't need this functionality, consider using let-return instead.

Similar to `let`, but for parsers.  The expressions in `bindings` must
evaluate to parsers.  The returned parser sequentially applies these parsers
to the input, and binds their result values to their binding forms.  Every
expression can use the preceding bindings.

Finally, it evaluates `body` with all bindings, which must yield a parser that
is then applied to the input.

Expands to a chain of `bind` calls.

Use this to create parsers dynamically depending on the return value of a
previously succeeded parser.  If you don't need this functionality, consider
using `let-return` instead.
sourceraw docstring

let-returnclj/smacro

(let-return bindings & body)

Like let-parser, but evaluates body as the resulting parser's result value, instead of expecting a final parser to apply.

The parser (let-return [x p] (f x)) is an optimised version of (let-parser [x p] (return (f x))).

Like `let-parser`, but evaluates `body` as the resulting parser's result
value, instead of expecting a final parser to apply.

The parser `(let-return [x p] (f x))` is an optimised version of
`(let-parser [x p] (return (f x)))`.
sourceraw docstring

mapclj/s

(map p f)
(map p1 p2 f)
(map p1 p2 p3 f)
(map p1 p2 p3 p4 & more)

Returns a parser that applies the parser p and returns the return value of calling f with the result value of p.

When multiple parsers are given, applies them in sequence and calls f with all result values. The arity of f must match the number of supplied parsers.

Similar to:

  • parsec : fmap
  • fparsec: |>>, pipe2, pipe3, pipe4, pipe5
Returns a parser that applies the parser `p` and returns the return value
of calling `f` with the result value of `p`.

When multiple parsers are given, applies them in sequence and calls `f` with
all result values.  The arity of `f` must match the number of supplied
parsers.

Similar to:
- parsec : `fmap`
- fparsec: `|>>`, `pipe2`, `pipe3`, `pipe4`, `pipe5`
sourceraw docstring

maxclj/s

(max p n)

Returns a parser that applies p at most n times, and returns a collection of the result values.

This is a 'sequence expression' parser, see cat.

Returns a parser that applies `p` at most `n` times, and returns a
collection of the result values.

This is a 'sequence expression' parser, see `cat`.
sourceraw docstring

minclj/s

(min p n)

Returns a parser that applies p n or more times, and returns a collection of the result values.

This is a 'sequence expression' parser, see cat.

Returns a parser that applies `p` `n` or more times, and returns a
collection of the result values.

This is a 'sequence expression' parser, see `cat`.
sourceraw docstring

notclj/s

(not p)
(not p label)

Returns a parser that succeeds if the parser p fails, and fails otherwise. In both cases, it does not change the parser state. Returns nil.

Similar to:

  • parsec: notFollowedBy
  • fparsec: notFollowedBy, notFollowedByL
Returns a parser that succeeds if the parser `p` fails, and fails otherwise.
In both cases, it does not change the parser state.  Returns `nil`.

Similar to:
- parsec: `notFollowedBy`
- fparsec: `notFollowedBy`, `notFollowedByL`
sourceraw docstring

not-emptyclj/s

(not-empty p)

Returns a parser that behaves like p, but fails when p does not change the parser state.

Returns a parser that behaves like `p`, but fails when `p` does not
change the parser state.
sourceraw docstring

parseclj/s

(parse p input & {:as opts})

Applies the parser p to input and returns its result value. Throws an exception when p fails.

Applies the parser `p` to `input` and returns its result value.  Throws
an exception when `p` fails.
sourceraw docstring

peekclj/s

(peek p)

Returns a parser that behaves like p, but always restores the parser state.

  • lookAhead (parsec, fparsec)
Returns a parser that behaves like `p`, but always restores the parser
state.

- `lookAhead` (parsec, fparsec)
sourceraw docstring

recclj/s

(rec f)

Creates a recursive parser. Calls f with one arg, a parser to recur, and returns the parser returned by f.

It is assumed that f uses alt or similar to eventually stop the recursion. For example:

(def parens (rec #(? (between % (char \() (char \))))))
Creates a recursive parser.  Calls `f` with one arg, a parser to recur,
and returns the parser returned by `f`.

It is assumed that `f` uses `alt` or similar to eventually stop the
recursion.  For example:

```clojure
(def parens (rec #(? (between % (char \() (char \))))))
```
sourceraw docstring

repeatclj/s

(repeat p n)
(repeat p min max)

When called with two args, returns a parser that applies p n times.

When called with three args, returns a parser that applies p at least min times and at most max times (until it fails).

This is a 'sequence expression' parser, see cat.

Similar to:

  • fparsec: parray
When called with two args, returns a parser that applies `p` `n` times.

When called with three args, returns a parser that applies `p` at least
`min` times and at most `max` times (until it fails).

This is a 'sequence expression' parser, see `cat`.

Similar to:
- fparsec: `parray`
sourceraw docstring

returnclj/s

(return x)
(return p x)

With one arg, returns a parser that consumes nothing and returns x.

With two args, returns a parser that behaves like p, but returns x when p succeeds.

Similar to:

  • fparsec: preturn, >>%
With one arg, returns a parser that consumes nothing and returns `x`.

With two args, returns a parser that behaves like `p`, but returns `x`
when `p` succeeds.

Similar to:
- fparsec: `preturn`, `>>%`
sourceraw docstring

runclj/s

(run p input & {:as opts})

Applies the parser p to input and returns a map representing the parser result.

Applies the parser `p` to `input` and returns a map representing the
parser result.
sourceraw docstring

set-user-stateclj/s

(set-user-state u)

Returns a parser that unconditionally sets the user state to x and returns swapped-in user state.

Returns a parser that unconditionally sets the user state to `x`
and returns swapped-in user state.
sourceraw docstring

skip-any-tokenclj/s

(skip-any-token source reply)

This parser skips the next token from the input stream and returns nil.

This parser skips the next token from the input stream and returns `nil`.
sourceraw docstring

swap-user-stateclj/s

(swap-user-state f & args)

Returns a parser that sets ths user state to (apply f user-state args), and returns the swapped-in user state.

Returns a parser that sets ths user state to `(apply f user-state args)`,
and returns the swapped-in user state.
sourceraw docstring

thenclj/s

(then p)
(then p1 p2)
(then p1 p2 p3)
(then p1 p2 p3 p4 & more)

Returns a parser that applies the parsers ps in sequence and returns the result of the last one.

Similar to:

  • parsec: >>
  • fparsec: >>.
Returns a parser that applies the parsers `ps` in sequence and returns the
result of the last one.

Similar to:
- parsec: `>>`
- fparsec: `>>.`
sourceraw docstring

then-skipclj/s

(then-skip p)
(then-skip p1 p2)
(then-skip p1 p2 p3)
(then-skip p1 p2 p3 p4 & more)

Returns a parser that applies the parsers ps in sequence and returns the result of the first one.

Similar to:

  • fparsec: .>>
Returns a parser that applies the parsers `ps` in sequence and
returns the result of the first one.

Similar to:
- fparsec: `.>>`
sourceraw docstring

tokenclj/s

(token token)

Returns a parser that accepts and returns token.

Returns a parser that accepts and returns `token`.
sourceraw docstring

token-returnclj/s

(token-return token value)

Returns a parser that expects token to come next in the input stream and returns value.

Returns a parser that expects `token` to come next in the input stream
and returns `value`.
sourceraw docstring

tupleclj/s

(tuple p)
(tuple p1 p2)
(tuple p1 p2 p3)
(tuple p1 p2 p3 p4 & more)

Returns a parser that applies the parsers in sequence and returns a vector of their return values.

Similar to:

  • parsec: <*>
  • fparsec: .>>., tuple2, tuple3, tuple4, tuple5
Returns a parser that applies the parsers in sequence and returns a
vector of their return values.

Similar to:
- parsec: `<*>`
- fparsec: `.>>.`, `tuple2`, `tuple3`, `tuple4`, `tuple5`
sourceraw docstring

tuplesclj/s

(tuples ps)

Returns a parser that applies the parsers ps in sequence and returns a vector of their return values.

Returns a parser that applies the parsers `ps` in sequence and returns a
vector of their return values.
sourceraw docstring

user-stateclj/s

(user-state source reply)

This parser returns the current user state.

This parser returns the current user state.
sourceraw docstring

user-state-satisfyclj/s

(user-state-satisfy pred)

Returns a parser that succeeds if pred returns logical true when called with the current user state, otherwise it fails. Returns the return value of pred.

Returns a parser that succeeds if `pred` returns logical
true when called with the current user state, otherwise it fails.
Returns the return value of `pred`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close