/writer.clj

Format Cirru code with Clojure

Primary LanguageCirru

Cirru Writer in Clojure

generate human-readable code from vectors

Demo http://repo.cirru.org/writer.clj/

API Usage

Clojars Project

[cirru/writer "0.1.13"]
(cirru-writer.core/write-code [["define"
  "a"
  ["read" "cd"]
  ["if" [">" "a" "cd"] ["print" "demo"] ["print" "not demo"]]]
 ["say" ["print" "a" ["save" ["b" ["x" ["c" "8"]]]]]]
 ["print" "fun"]]
)

prints:

define a (read cd)
  if (> a cd)
    print demo
    print "not demo"

say $ print a
  save $ b (x $ c 8)

print fun

Added a inline mode:

(write-code [["a" ["b" "c"] ["d" "e"] ["g" "h"]]] {:inline? true})

which generates simple expressions as inline node:

a (c b) (d e) (g h)

Develop

Test:

yarn
yarn watch-test

# another terminal
node target/test.js

Workflow

https://github.com/mvc-works/coworkflow/

License

MIT