Initial commit: Jolt — Clojure interpreter on Janet

- PEG-based Clojure reader (symbols, keywords, numbers, strings, lists,
  vectors, maps, sets, quote forms, reader macros, metadata)
- Tree-walking evaluator (quote, do, if, def, fn*, let*, loop*/recur,
  syntax-quote/unquote/unquote-splicing, macro system, ns/require/in-ns)
- 95+ clojure.core functions (predicates, math, collections, seq ops,
  higher-order, atoms, I/O)
- Public API (init, eval-string, eval-string*)
- REPL (jolt/main.janet)
- 7 test suites, all green
- MIT license
This commit is contained in:
Yogthos 2026-06-01 16:48:56 -04:00
commit cdcf569506
16 changed files with 2696 additions and 0 deletions

34
src/jolt/main.janet Normal file
View file

@ -0,0 +1,34 @@
# Jolt REPL
# Read-eval-print loop for Clojure expressions.
(use ./api)
(use ./types)
(def ctx (init))
(defn read-line [prompt]
(prin prompt)
(flush)
(let [line (file/read stdin :line)]
(if line (string/trim line) nil)))
(defn print-value [v]
(if (nil? v)
(print "nil")
(if (and (table? v) (= :jolt/var (v :jolt/type)))
(printf "#'%s/%s" (ctx-current-ns ctx) ((var-name v) :name))
(print v))))
(print "Jolt — Clojure on Janet")
(print "Type (exit) to quit.\n")
(var running true)
(while running
(let [line (read-line (string (ctx-current-ns ctx) "=> "))]
(if (nil? line) (set running false)
(if (= line "(exit)") (set running false)
(if (not (= "" line))
(try
(print-value (eval-string ctx line))
([err]
(eprint "Error: " err))))))))