Liking cljdoc? Tell your friends :D

Edamame

EDN parser with location metadata and pluggable dispatch table.

CircleCI Clojars Project cljdoc badge

Features

  • Parse EDN values with location as metadata.
  • Pluggable dispatch table to extend EDN.

This library works with:

  • Clojure on the JVM
  • ClojureScript

Usage

(require '[edamame.core :refer [parse-string]])

Locations are attached as metadata:

(map meta (parse-string "[{:a 1} {:b 2}]))"
;;=> ({:row 1, :col 2} {:row 1, :col 9})

Dispatch on a character, even if it's unsupported in EDN:

(parse-string "@foo" {:dispatch {\@ (fn [val] (list 'deref val))}})
;;=> (deref foo)

Dispatch on dispatch characters:

(parse-string "#\"foo\"" {:dispatch {\# {\" #(re-pattern %)}}})
;;=> #"foo"

(parse-string "#(inc 1 2 %)" {:dispatch {\# {\( (fn [expr] (read-string (str "#" expr)))}}})
;;=> (fn* [p1__11574#] (inc 1 2 p1__11574#))

Test

script/test/jvm
script/test/node
script/test/all

Status

Experimental. Breaking changes are expected to happen at this phase.

Installation

Use as a dependency:

Clojars Project

Credits

The code is largely inspired by rewrite-clj and derived projects.

License

Copyright © 2019 Michiel Borkent

Distributed under the Eclipse Public License 1.0. This project contains code from Clojure and ClojureScript which are also licensed under the EPL 1.0. See LICENSE.

The directory inlined contains source from tools.reader which is licensed under the EPL license.

Can you improve this documentation?Edit on GitHub

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

× close