(?atomic p)
(?atomic p not-found)
Returns a parser that applies p
and 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 `p` and 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))`.
(atomic p)
Returns a parser that behaves like p
, except that it backtracks to
the original parser state when p
fails with changing the parser
state.
Returns a parser that behaves like `p`, except that it backtracks to the original parser state when `p` fails with changing the parser state.
(deref ref)
Returns a parser that forwards all calls to the parser returned
by @ref
. Useful to construct recursive parsers.
Returns a parser that forwards all calls to the parser returned by `@ref`. Useful to construct recursive parsers.
(end source reply)
This parser succeeds a the end of the input stream.
This parser succeeds a the end of the input stream.
(followed-by p)
(followed-by p label)
Returns a parser that succeeds if it is followed by p
, e.g. if p
succeeds next. Does not change the parser state.
Returns a parser that succeeds if it is followed by `p`, e.g. if `p` succeeds next. Does not change the parser state.
(fwd expr)
Returns a parser that forwards to expr
. Useful for recursive parsers
to use a parser that has been declared but not yet defined:
(def expr (p/alt c/digit
(p/between (p/fwd expr) (c/char \() (c/char \)))))
Warning: Left-recursive parsers are not supported and will lead to infinite loops / stack overflows.
Returns a parser that forwards to `expr`. Useful for recursive parsers to use a parser that has been declared but not yet defined: ```clojure (def expr (p/alt c/digit (p/between (p/fwd expr) (c/char \() (c/char \))))) ``` **Warning**: Left-recursive parsers are not supported and will lead to infinite loops / stack overflows.
(index source reply)
Returns the index of the next token in the input stream.
Returns the index of the next token in the input stream.
(label p label)
If p
does not change the parser state, the errors are
replaced with `(expected label).
If `p` does not change the parser state, the errors are replaced with `(expected label).
(map p f)
(map p1 p2 f)
(map p1 p2 p3 f)
(map p1 p2 p3 p4 & more)
Returns a parser that applies the provided parsers in sequence and returns
the return value of calling f
with the return values.
Returns a parser that applies the provided parsers in sequence and returns the return value of calling `f` with the return values.
(not-empty p)
Like p
, but fails when p
does not change the parser state.
Like `p`, but fails when `p` does not change the parser state.
(not-followed-by p)
(not-followed-by 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 a parser that succeeds if the parser `p` fails, and fails otherwise. In both cases, it does not change the parser state.
(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.
(pforce d)
Returns a parser that forwards to (force d)
.
Returns a parser that forwards to `(force d)`.
This parser always succeeds and returns nil
.
This parser always succeeds and returns `nil`.
(pos source reply)
Returns the current position in the input stream.
Returns the current position in the input stream.
(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 p/alt
or similar to eventually stop the
recursion.
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 `p/alt` or similar to eventually stop the recursion.
(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.
(set-user-state u)
Sets the user source to u
.
Sets the user source to `u`.
(swap-user-state f & args)
Sets ths user source to (apply f user-state args)
.
Sets ths user source to `(apply f user-state args)`.
(then p)
(then p1 p2)
(then p1 p2 p3)
(then p1 p2 p3 p4 & more)
Applies the parsers in sequence and returns the result of the last one.
Applies the parsers in sequence and returns the result of the last one.
(then-skip p)
(then-skip p1 p2)
(then-skip p1 p2 p3)
(then-skip p1 p2 p3 p4 & more)
Applies the parsers in sequence and returns the result of the first one.
Applies the parsers in sequence and returns the result of the first one.
(tuple* ps)
Applies the parsers ps
in sequence and returns a vector of
their return values.
Applies the parsers `ps` in sequence and returns a vector of their return values.
(user-state source reply)
Returns the current user state.
Returns the current user state.
(user-state-satisfy pred)
Succeeds if pred
returns logical true when called with the current
user source, otherwise it fails. Returns the return value of pred
.
Succeeds if `pred` returns logical true when called with the current user source, otherwise it fails. Returns the return value of `pred`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close