diff --git a/src/expand.clj b/src/expand.clj index 8db34bf..7c91693 100644 --- a/src/expand.clj +++ b/src/expand.clj @@ -256,7 +256,20 @@ (-> "t.scm" slurp (scm/read-syntax :library? true) - expand-library) + 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))))) (let [scopeholder (scm/new-scopeholder) env {[:global 'lambda] [:primitive 'lambda]} store-atom (atom {['lambda #{}] [:global 'lambda]})] diff --git a/src/scm.clj b/src/scm.clj index 574ee79..8b2d4a1 100644 --- a/src/scm.clj +++ b/src/scm.clj @@ -79,6 +79,18 @@ (assert (not (syntax? datum)) "너는 이렇고 싶은가…") (->Syntax datum (syntax-context ctxt-donor)))) +(declare improper-list?) + +(defn syntax->datum [stx] + (cond (syntax? stx) (recur (syntax-e stx)) + (seq? stx) (map syntax->datum stx) + (improper-list? stx) (throw (Exception. "todo")) + (or (constant? stx) (symbol? stx)) stx + :else (throw (ex-info + nil + {:stx stx} + (IllegalArgumentException. "이것으로 할 것을 몰라"))))) + (defn rescope [stx ctxt-donor] (->Syntax (syntax-e stx) (syntax-context ctxt-donor)))