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
|
|
@ -247,7 +247,7 @@
|
|||
a
|
||||
(proc k `(get ~gm ~(get pat k)) a)))
|
||||
g3 (keys pat)))
|
||||
:else (throw (str "unsupported destructuring pattern"))))
|
||||
:else (throw (str "unsupported destructuring pattern: " (pr-str pat)))))
|
||||
ploop
|
||||
(fn* ploop [i acc]
|
||||
(if (< i (count bindings))
|
||||
|
|
|
|||
|
|
@ -120,7 +120,13 @@
|
|||
;; starts a datum in Scheme, so replace it with `_`. A name that collides with a
|
||||
;; Scheme keyword is prefixed with `_` so it can never shadow the emitted form.
|
||||
(defn- munge-name [s]
|
||||
(let [s (str/replace s "#" "_")]
|
||||
;; A Clojure symbol may contain chars that break a Scheme identifier: ' is the
|
||||
;; quote reader macro (a bare f' would read as f then 'rest), # already maps to
|
||||
;; _. Munge both to safe tokens; the same mapping applies at the binding and at
|
||||
;; every reference, so resolution stays consistent.
|
||||
(let [s (-> s
|
||||
(str/replace "#" "_")
|
||||
(str/replace "'" "_PRIME_"))]
|
||||
(if (contains? scheme-reserved s) (str "_" s) s)))
|
||||
|
||||
(declare emit)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue