Chez Phase 3 inc 5d: add jolt.reader/read-all; reader port logic complete

read-all reads every top-level form of a string (the parse-all the compile path
needs in inc 6). With this the portable reader covers everything reader.janet does
(atoms 5a, collections+quote/meta 5b, dispatch 5c, multi-form 5d).

Validated: reader-parity 149/149 (every construct); jolt.reader compiles and runs
on build/jolt ((require [jolt.reader]) (read-all …) works natively). The
interpreted reader overflows the eval stack on large/deeply-nested files, so real-
file/full-corpus validation happens when it's cross-compiled and run on Chez
(inc 7). Position tracking (checker) and the actual wire-in replacing reader.ss are
deferred — they ride inc 6 (jolt.reader on Chez). See new beads.
This commit is contained in:
Yogthos 2026-06-19 20:26:27 -04:00
parent b12cb3c00b
commit c47ae7fd22

View file

@ -455,3 +455,16 @@
"Read the first form of `s` (skipping leading trivia). Returns the form."
[s]
(first (read-next-form s 0)))
(defn read-all
"Read every top-level form of `s`, returning them in a vector (trivia skipped)."
[s]
(loop [pos 0 acc []]
(let [p (skip-whitespace s pos)]
(if (>= p (len s))
acc
(let [[kind payload np] (read-form s p)]
(case kind
:skip (recur np acc)
:splice (recur np (into acc payload))
:form (recur np (conj acc payload))))))))