expand test
This commit is contained in:
1 parent
8116f2ca62
commit
02ec06609f
3 files changed
+46
-17
No files matched your search
+23
-14
@@ -215,7 +215,7 @@
|
||||
(for [x (cons f xs)]
|
||||
(expand (scm/rescope x stx) env store-atom))))))
|
||||
|
||||
(defn import-primitives+builtins [scopeholder env-atom store-atom]
|
||||
(defn- import-primitives+builtins [scopeholder env-atom store-atom]
|
||||
(let [scopes (scm/syntax-context scopeholder)
|
||||
additions (concat (for [p primitives]
|
||||
[p
|
||||
@@ -252,24 +252,33 @@
|
||||
(cons :begin)
|
||||
vec)))))))
|
||||
|
||||
(defn library->datum [lib]
|
||||
(cons 'define-library
|
||||
(cons (:library/name lib)
|
||||
(for [d (:library/declarations lib)]
|
||||
(match d
|
||||
[:begin & xs] (cons 'begin xs)
|
||||
[:import & xs] (cons 'import xs)
|
||||
[:export & xs] (cons 'export xs))))))
|
||||
|
||||
(defn library-syntax->datum [lib]
|
||||
(update lib :library/declarations
|
||||
(fn [decls]
|
||||
(for [decl decls]
|
||||
(match decl
|
||||
[:begin & xs] (->> xs
|
||||
(map scm/syntax->datum)
|
||||
(cons :begin)
|
||||
vec)
|
||||
:else decl)))))
|
||||
|
||||
(comment
|
||||
(-> "t.scm"
|
||||
slurp
|
||||
(scm/read-syntax :library? true)
|
||||
expand-library
|
||||
;; :library/declarations
|
||||
;; second
|
||||
;; second
|
||||
;; scm/syntax->datum
|
||||
(update :library/declarations
|
||||
(fn [decls]
|
||||
(for [decl decls]
|
||||
(match decl
|
||||
[:begin & xs] (->> xs
|
||||
(map scm/syntax->datum)
|
||||
(cons :begin)
|
||||
vec)
|
||||
:else decl)))))
|
||||
library-syntax->datum
|
||||
library->datum)
|
||||
(let [scopeholder (scm/new-scopeholder)
|
||||
env {[:global 'lambda] [:primitive 'lambda]}
|
||||
store-atom (atom {['lambda #{}] [:global 'lambda]})]
|
||||
|
||||
Reference in new issue
Block a user