More library-compat fixes from porting the examples (markdown, malli)
Reader / loader:
- #?@ splicing reader conditionals now actually splice the matched collection's
items into the enclosing sequence; the splice flag was read but ignored, so a
binding vector like [a #?@(:clj [b (.foo b)])] lost its alignment.
- the file loader reads by position and skips a top-level form that reads as
nothing (a :cljs-only #?, a #_ discard, a trailing comment) instead of
treating it as EOF — which silently dropped the rest of a large .cljc file.
- jolt's reader feature set now includes :clj (was {:jolt :default}). jolt is a
Clojure/JVM-compatible host that emulates clojure.lang.* and java.* interop,
so it reads the :clj branch of a .cljc library, not :cljs. This also lets four
more reader-conditional corpus cases pass (floor 2726 -> 2730).
Backend:
- munge-name escapes ' (prime) -> _PRIME_; a Clojure symbol like f' otherwise
emitted a bare ' into Scheme, which is the quote reader macro and unbalanced
the output.
Host shims:
- clojure.java.io/writer (pass through a StringWriter, file-back a path) and a
readLine on the string reader, so line-seq over (io/reader …) works (markdown).
A better "unsupported destructuring pattern: <pat>" error message.
This commit is contained in:
parent
7e2704642b
commit
2de0543613
9 changed files with 93 additions and 18 deletions
|
|
@ -57,12 +57,21 @@
|
|||
;; Read every form from a file and compile+eval it in turn. The first form is
|
||||
;; normally (ns …), which expands to (in-ns …) and switches the current ns, so
|
||||
;; later forms compile in that namespace — (chez-current-ns) is re-read each step.
|
||||
;;
|
||||
;; Reads by POSITION rather than via __parse-next: a top-level form that reads as
|
||||
;; nothing — a :cljs-only #? with no matching branch, a #_ discard, a trailing
|
||||
;; comment — yields rdr-eof but still advances. parse-next collapses that to "no
|
||||
;; more forms", which would silently drop the entire rest of the file; here we
|
||||
;; skip the no-op form and continue to true end-of-string.
|
||||
(define (load-jolt-file path)
|
||||
(let loop ((src (read-file-string path)))
|
||||
(let ((pn (jolt-parse-next src)))
|
||||
(unless (jolt-nil? pn)
|
||||
(jolt-compile-eval-form (jolt-nth pn 0) (chez-current-ns))
|
||||
(loop (jolt-nth pn 1))))))
|
||||
(let* ((src (read-file-string path)) (end (string-length src)))
|
||||
(let loop ((i 0))
|
||||
(when (< i end)
|
||||
(let-values (((form j) (rdr-read-form src i end)))
|
||||
(when (> j i)
|
||||
(unless (rdr-eof? form)
|
||||
(jolt-compile-eval-form form (chez-current-ns)))
|
||||
(loop j)))))))
|
||||
|
||||
;; load-namespace: load `name`'s source once. Marked loaded BEFORE eval so a
|
||||
;; dependency cycle terminates (Clojure's behavior). The caller's current ns is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue