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:
parent
b12cb3c00b
commit
c47ae7fd22
1 changed files with 13 additions and 0 deletions
|
|
@ -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))))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue