Chez Phase 3 inc 5b: reader collections + quote/deref/meta in jolt.reader
Ports list/vector/map literals and the quote family (' ` ~ ~@ @) + metadata (^)
to the portable Clojure reader. read-form now returns a [kind payload pos] control
triple (:form / :skip / :splice) instead of the Janet reader's :jolt/skip sentinel
FORMS — out-of-band control is collision-free and host-neutral (no tagged struct
to build or recognize). read-delimited dispatches the kinds; read-next-form skips
comments where a single datum is needed; read-map pairs k/v skipping trivia in
either slot. syntax-quote of a self-evaluating literal collapses at read time.
Four host constructors added to the contract (host_iface): form-make-list/vector/
map + form-sym-merge-meta (attach ^meta to a symbol). form-make-map reuses the
seed's reader-map (now public) for the source-order kv tracking. The portable
reader accumulates items in a jolt vector and the host builds its native form rep.
Gate: reader-parity 107/107 (lists/vectors/maps incl. nested + comments-in-coll,
quote/syntax-quote-collapse/unquote/deref, ^:dynamic/^Type/^{} meta). Full jpm gate
green (prelude cache pre-warmed — a cold cache races under the parallel gate when
the jolt-chez fingerprint changes; pre-existing, see new bead). jolt-sh1n.
This commit is contained in:
parent
afada6d4ff
commit
af64454f4e
4 changed files with 163 additions and 12 deletions
|
|
@ -79,5 +79,26 @@
|
|||
# characters
|
||||
(each i [`\a` `\Z` `\0` `\newline` `\tab` `\space` `\return` `\\` `\(` `\{` `\%` `A` `\o101`] (check i))
|
||||
|
||||
# --- inc 5b: collections + quote/deref/meta -----------------------------------
|
||||
# lists
|
||||
(each i ["(1 2 3)" "(a b c)" "()" "(foo (bar baz) qux)" "(+ 1 (* 2 3))"] (check i))
|
||||
(check "(1 ; c\n 2 3)") # comment inside a list
|
||||
# vectors
|
||||
(each i ["[1 2 3]" "[]" "[a [b c]]" "[1 [2 [3]]]" "[:a :b :c]"] (check i))
|
||||
# maps
|
||||
(each i ["{:a 1 :b 2}" "{}" "{:a {:b 1}}" "{:x [1 2] :y {:z 3}}" "{1 2 3 4}"] (check i))
|
||||
(check "{:a 1 ; c\n :b 2}") # comment inside a map (key/value slots)
|
||||
# mixed / nested forms (real code shapes)
|
||||
(each i ["(defn f [x] (+ x 1))" "{:list (1 2) :vec [3 4]}" "(let [a 1 b 2] (+ a b))"] (check i))
|
||||
# quote / syntax-quote / unquote / deref
|
||||
(each i ["'foo" "'(1 2 3)" "''x" "'[a b]" "'{:a 1}"] (check i))
|
||||
(each i ["`foo" "`(a b c)" "`[x y]"] (check i))
|
||||
(check "`\"meow\"") # syntax-quote of a literal collapses
|
||||
(each i ["~x" "~@xs" "@x" "@(atom 1)"] (check i))
|
||||
(check "`(a ~b ~@c)")
|
||||
# metadata
|
||||
(each i ["^:dynamic x" "^String s" "^:private foo" "^{:a 1} v" "^t/Ray r"] (check i))
|
||||
(check "(defn ^:private g [x] x)")
|
||||
|
||||
(printf "\n%d/%d ok" (- total fails) total)
|
||||
(when (> fails 0) (os/exit 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue