Liking cljdoc? Tell your friends :D

crustimoney.caches

Packrat caches for the core/parse function.

A single cache instance is not intended to be used for multiple texts. Create a new cache for each new text.

Caches are implemented using the Cache protocol. This way you can implement your own, if desired.

Packrat caches for the core/parse function.

A single cache instance is *not* intended to be used for multiple
texts. Create a new cache for each new text.

Caches are implemented using the Cache protocol. This way you can
implement your own, if desired.
raw docstring

crustimoney.combinators

Parsers combinator functions.

Each combinator functions creates a parser function that is suitable for use with core's main parse function, and many take other parser functions as their argument; they are composable.

If you want to implement your own parser combinator, read on. Otherwise, just look at the docstrings of the combinators themselves.

The parsers returned by the combinators do not call other parsers directly, as this could lead to stack overflows. So next to a ->success or ->error result, it can also return a ->push result. This pushes another parser onto the virtual stack.

For this reason, a parser function has the following signature:

(fn
  ([text index]
    ...)
  ([text index result state]
   ...))

The 2-arity variant is called when the parser was pushed onto the stack. It receives the entire text and the index it should begin parsing. If it returns a push result, the 4-arity variant is called when that parser is done. It again receives the text and the original index, but also the result of the pushed parser and any state that was pushed with it.

Both arities can return a success, a set of errors, or a push. The crustimoney.results namespace should be used for creating and reading these results.

Before you write your own combinator, do realise that the provided combinators are complete in the sense that they can parse any text.

Parsers combinator functions.

Each combinator functions creates a parser function that is suitable
for use with core's main parse function, and many take other parser
functions as their argument; they are composable.

If you want to implement your own parser combinator, read on.
Otherwise, just look at the docstrings of the combinators
themselves.

The parsers returned by the combinators do not call other parsers
directly, as this could lead to stack overflows. So next to a
`->success` or `->error` result, it can also return a `->push`
result. This pushes another parser onto the virtual stack.

For this reason, a parser function has the following signature:

    (fn
      ([text index]
        ...)
      ([text index result state]
       ...))

The 2-arity variant is called when the parser was pushed onto the
stack. It receives the entire text and the index it should begin
parsing. If it returns a `push` result, the 4-arity variant is
called when that parser is done. It again receives the text and the
original index, but also the result of the pushed parser and any
state that was pushed with it.

Both arities can return a success, a set of errors, or a push. The
`crustimoney.results` namespace should be used for creating and
reading these results.

Before you write your own combinator, do realise that the provided
combinators are complete in the sense that they can parse any text.
raw docstring

crustimoney.combinators.experimental

Experimental combinators. These may get promoted, or changed, or dismissed.

These combinators are not available in the string- or data-driven grammar (yet). To use them with those, you can use the other-parsers parameter of their respective create-parser functions, like:

(require '[crustimoney.combinators.experimental :as e])

(create-parser
  "root= <- stream
   expr= <- '{' [0-9]+ '}'"
  {:stream [::e/stream handle-expr
            [::e/recover [:ref :expr] [:regex ".*?}"]]})

Note that the other-parsers here is written in vector-grammar format. This is a little power-user trick, and allows you to declare refs that do not have to resolve immediatly on their creation.

Experimental combinators. These may get promoted, or changed,
or dismissed.

These combinators are not available in the string- or data-driven
grammar (yet). To use them with those, you can use the
`other-parsers` parameter of their respective `create-parser`
functions, like:

    (require '[crustimoney.combinators.experimental :as e])

    (create-parser
      "root= <- stream
       expr= <- '{' [0-9]+ '}'"
      {:stream [::e/stream handle-expr
                [::e/recover [:ref :expr] [:regex ".*?}"]]})

Note that the other-parsers here is written in vector-grammar
format. This is a little power-user trick, and allows you to declare
`ref`s that do not have to resolve immediatly on their creation.
raw docstring

crustimoney.core

The main parsing functions.

The main parsing functions.
raw docstring

crustimoney.data-grammar

Create a parser based on a data grammar. The data is translated into combinators.

Create a parser based on a data grammar. The data is translated into
combinators.
raw docstring

crustimoney.string-grammar

Create a parser based on a string grammar. The grammar is translated into combinators.

Create a parser based on a string grammar. The grammar is translated
into combinators.
raw docstring

crustimoney.vector-grammar

A basic vector-driven parser generator.

A basic vector-driven parser generator.
raw docstring

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

× close