Transforms a river stream from raw input into parsed input using zetta parsers
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


zetta-river is a bridge that allows the developer to use zetta-parser parser combinators to transform streams from river's producers.

This library provides one consumer and one filter:

  • parse is a consumer that will use the stream from a river producer and return the result of the given zetta parser.

  • parse* is a filter that will transform the stream of a river producer into a seq of results from the given zetta parser.


Once you know how to use [river]{} and the [zetta-parser]{}, it is really easy to get started. An example:

(ns numbers
  (:require [river.core :as river]
            [zetta.core :as zetta])

  (:use [river.seq
          [produce-seq mapcat* consume]]



          [number spaces]]


(def number-between-spaces (sep-by number spaces))

; This will return a list of parsed numbers
(println (river/run (produce-seq "34   57  99  130   45")
                      (parse number-between-spaces)))

; This will return the same list, but using a filter
; and the river.seq/consume consumer
(println (river/run (produce-seq "34   57  99  130   45"
                      (parse* number-between-spaces
                        (mapcat* id

; Say for example you want to use the same consumer on a File
; instead of string in the source code
;(println (river/run (produce-reader-chars "path/to/input.txt"
;                      (parse* number-between-spaces
;                        (mapcat* id
;                          consume)))))


Copyright (C) 2012 Roman Gonzalez

Distributed under the Eclipse Public License, the same as Clojure.