Liking cljdoc? Tell your friends :D

crustimoney.results

Result constructors, accessors and predicates. Includes transformation utilities.

Result constructors, accessors and predicates. Includes
transformation utilities.
raw docstring

->errorclj

(->error key index)
(->error key index detail)

Create an error result, given an error key and an index. An extra detail object can be added.

Create an error result, given an error key and an index. An extra
detail object can be added.
sourceraw docstring

->pushclj

(->push parser index)
(->push parser index state)

Create a push value, given a parser function and an index. Optionally a state object can be added.

Create a push value, given a parser function and an index. Optionally
a state object can be added.
sourceraw docstring

->successclj

(->success start end)
(->success start end children)

Create a success result, given a start index (inclusive) and end index (exclusive). Optionally a collection of success children can be given. The name of the success is nil.

Create a success result, given a start index (inclusive) and end
index (exclusive). Optionally a collection of success children can
be given. The name of the success is nil.
sourceraw docstring

coercecljmacro

(coerce f)
(coerce binding & body)

Transformer for use with transform. It applies function f to the matched text of the success node, or it binds the matched text to the binding vector and executes body. For example:

(coerce parse-long)

(coerce [s] (-> s upper-case reverse str))
Transformer for use with `transform`. It applies function `f` to the
matched text of the success node, or it binds the matched text to
the `binding` vector and executes `body`. For example:

    (coerce parse-long)

    (coerce [s] (-> s upper-case reverse str))
sourceraw docstring

collectcljmacro

(collect f)
(collect binding & body)

Transformer for use with transform. It applies function f to the children of the success node, or it binds the children to the binding vector and executes body. For example:

(collect first)

(collect [[val1 op val2]] (op val1 val2))
Transformer for use with `transform`. It applies function `f` to the
children of the success node, or it binds the children to the
`binding` vector and executes `body`. For example:

    (collect first)

    (collect [[val1 op val2]] (op val1 val2))
sourceraw docstring

error->detailclj

(error->detail error)

Return the detail object of an error.

Return the detail object of an error.
sourceraw docstring

error->indexclj

(error->index error)

Return the index of an error

Return the index of an error
sourceraw docstring

error->keyclj

(error->key error)

Return the key of an error.

Return the key of an error.
sourceraw docstring

errors->line-columnclj

(errors->line-column result text)

If result is a set of errors, each error gets a :line and :column entry added. Otherwise, the result is returned as is.

If `result` is a set of errors, each error gets a `:line` and
`:column` entry added. Otherwise, the `result` is returned as is.
sourceraw docstring

postwalkclj

(postwalk f result)

If the result is a success, perform a postwalk on its children and itself. If the result is not a success, it is returned as is.

If the result is a success, perform a postwalk on its children and
itself. If the result is not a success, it is returned as is.
sourceraw docstring

push->indexclj

(push->index push)

Returns the index of a push value.

Returns the index of a push value.
sourceraw docstring

push->parserclj

(push->parser push)

Returns the parser of a push value.

Returns the parser of a push value.
sourceraw docstring

push->stateclj

(push->state push)

Returns the state of a push value.

Returns the state of a push value.
sourceraw docstring

push?clj

(push? obj)

Returns obj if obj is a push value.

Returns obj if obj is a push value.
sourceraw docstring

success->childrenclj

(success->children success)

Returns the children of a success.

Returns the children of a success.
sourceraw docstring

success->endclj

(success->end success)

Return the end index of a success.

Return the end index of a success.
sourceraw docstring

success->nameclj

(success->name success)

Return the name of a success.

Return the name of a success.
sourceraw docstring

success->startclj

(success->start success)

Return the start index of a success.

Return the start index of a success.
sourceraw docstring

success->textclj

(success->text success text)

Returns the matched text of a success, given the full text.

Returns the matched text of a success, given the full text.
sourceraw docstring

success?clj

(success? obj)

Returns obj if obj is a success value, nil otherwise.

Returns obj if obj is a success value, nil otherwise.
sourceraw docstring

transformclj

(transform result text transformations)

If result is a success, it applies the map of transformations functions in postwalk order based on the node's name. A transformation function receives the node and the full text. See also coerce and collect for helpers, for example:

(-> (parse ... text)
    (transform text
      {:number    (coerce parse-long)
       :operand   (coerce {"+" + "-" - "*" * "/" /})
       :operation (collect [[v1 op v2]] (op v1 v2))
       nil        (collect first)}))

The transformations map can contain a * entry, which acts as a default. If a node has no transformer and there is no default, the node is left untouched.

If result is not a success, it is returned as is.

If `result` is a success, it applies the map of `transformations`
functions in postwalk order based on the node's name. A
transformation function receives the node and the full `text`. See
also `coerce` and `collect` for helpers, for example:

    (-> (parse ... text)
        (transform text
          {:number    (coerce parse-long)
           :operand   (coerce {"+" + "-" - "*" * "/" /})
           :operation (collect [[v1 op v2]] (op v1 v2))
           nil        (collect first)}))

The `transformations` map can contain a `*` entry, which acts as a
default. If a node has no transformer and there is no default, the
node is left untouched.

If `result` is not a success, it is returned as is.
sourceraw docstring

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

× close