Liking cljdoc? Tell your friends :D

crustimoney.experimental.combinators

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, combine them in a larger grammar like so:

(require '[crustimoney.combinators :as c]
         '[crustimoney.string-grammar :as sg]
         '[crustimoney.experimental.combinators :as ec])

(merge
 (sg/create-parser
   "root= <- stream
    expr= <- 'BEGIN' [0-9]+ 'END'")
 {:stream (ec/stream* {}
            (c/chain {}
              (ec/with-callback {:callback handle-expr}
                (c/ref {:to :expr}))
              :hard-cut))})

Above example also shows how to setup a streaming parser. The stream* ensures that the result tree does not grow, the with-callback passes chunks of results to a function, before it is hard-cut. The hard-cut ensures both the packrat cache and the streaming reader buffer (if used, see reader namespace) are kept small.

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, combine them in a larger
grammar like so:

    (require '[crustimoney.combinators :as c]
             '[crustimoney.string-grammar :as sg]
             '[crustimoney.experimental.combinators :as ec])

    (merge
     (sg/create-parser
       "root= <- stream
        expr= <- 'BEGIN' [0-9]+ 'END'")
     {:stream (ec/stream* {}
                (c/chain {}
                  (ec/with-callback {:callback handle-expr}
                    (c/ref {:to :expr}))
                  :hard-cut))})

Above example also shows how to setup a streaming parser. The
`stream*` ensures that the result tree does not grow, the
`with-callback` passes chunks of results to a function, before it is
hard-cut. The hard-cut ensures both the packrat cache and the
streaming reader buffer (if used, see `reader` namespace) are kept
small.
raw docstring

crustimoney.experimental.reader

This experimental reader is created for stream support.

It takes a Reader as input and implements a CharSequence, based on an internal buffer. It will fill its buffer on demand.

Support for matching a literal substring or a regular expression pattern has been implemented on top of this, via the MatchSupport protocol. Part of the internal buffer can be released by a cut operation, via the CutSupport protocol.

The MatchSupport protocol has been implemented for a normal String as well.

This experimental reader is created for stream support.

It takes a `Reader` as input and implements a `CharSequence`, based
on an internal buffer. It will fill its buffer on demand.

Support for matching a literal substring or a regular expression
pattern has been implemented on top of this, via the `MatchSupport`
protocol. Part of the internal buffer can be released by a cut
operation, via the `CutSupport` protocol.

The `MatchSupport` protocol has been implemented for a normal String
as well.
raw docstring

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

× close