parseq.utils

Helpers for dealing with parsers and their results.

->failure

(->failure msg)(->failure msg data)
Constructs a parser Failure with optional data.

all-input-parsed?

(all-input-parsed? parse-result)
Checks that the result of a parse has successfully parsed all the input.

complete-success?

Alias to `all-input-parsed?`

failure?

Checks if the result of a parse has failed.

match-parse

macro

(match-parse parse-result success?-binds success?-body failure?-bind failure?-body)
Evaluates `parse-result` once. If it is a `success?`, destructures the parse result
with `success?-binds` and evaluates `success?-body`. If it is a `failure?`,
destructures the parse result with `failure?-binds` and evaluates `failure?-body`.

parse

(parse p input)
Apply parser `p` to `input` (i.e. helper to run the parse).

success?

(success? parse-result)
Checks that the result of a parse has succeeded.

value

(value parse-result)
Extracts the value from a successful parse result.