ns: accept vector reference clauses; add Compiler/specials
Two general fixes shaken out by clojure/tools.macro. - The ns macro now accepts a vector reference clause [:require …] / [:use …], not just the list form (:require …). Clojure dispatches on (first clause) and accepts both; jolt silently dropped vector clauses, so a ns written with them loaded with nothing required/used (tools.macro's test ns uses [:use …]). - clojure.lang.Compiler/specials is now a static whose keys are the special-form symbols (matching Clojure 1.2/1.3). Macroexpansion tooling reads (keys Compiler/specials) to know which heads not to expand. tools.macro itself isn't fully passing yet — its mexpand-all works, but the macrolet/symbol-macrolet tests need letfn to macroexpand to letfn* (jolt models letfn as a special form, not a macro over letfn*), so it stays off the list. make test green (+1 corpus row, 0 new divergences), shakesmoke byte-identical. One re-mint (the ns macro).
This commit is contained in:
parent
1ba79aa223
commit
192ef66e7e
4 changed files with 17 additions and 3 deletions
|
|
@ -34,7 +34,18 @@
|
|||
;; forms, so this is rarely hit). Updated per top-level form, like *current-source*.
|
||||
(define compiler-line-cell (jolt-atom-new 0))
|
||||
(define compiler-column-cell (jolt-atom-new 0))
|
||||
(let ((members (list (cons "LINE" compiler-line-cell) (cons "COLUMN" compiler-column-cell))))
|
||||
;; clojure.lang.Compiler/specials — the JVM's special-form table (sym -> parser).
|
||||
;; tools.macro reads (keys Compiler/specials) to know which heads NOT to expand.
|
||||
;; Only the keys matter here; values are #t. The set matches Clojure 1.2/1.3.
|
||||
(define compiler-specials
|
||||
(let ((unq '("def" "loop*" "recur" "if" "case*" "let*" "letfn*" "do" "fn*"
|
||||
"quote" "var" "." "set!" "try" "monitor-enter" "monitor-exit"
|
||||
"throw" "new" "&" "catch" "finally" "reify*" "deftype*")))
|
||||
(fold-left (lambda (m s) (jolt-assoc1 m (jolt-symbol #f s) #t))
|
||||
(jolt-assoc1 (jolt-hash-map) (jolt-symbol "clojure.core" "import*") #t)
|
||||
unq)))
|
||||
(let ((members (list (cons "LINE" compiler-line-cell) (cons "COLUMN" compiler-column-cell)
|
||||
(cons "specials" compiler-specials))))
|
||||
(register-class-statics! "Compiler" members)
|
||||
(register-class-statics! "clojure.lang.Compiler" members))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue