Interpret ns
This commit is contained in:
parent
9eecce77bc
commit
be2d291fd3
|
@ -232,6 +232,19 @@
|
|||
(let [[k v] kv]
|
||||
[k (f v)]))))
|
||||
|
||||
(defn- interpret-ns [ast ctx]
|
||||
(let [members (:members ast)
|
||||
name (:name ast)]
|
||||
(if (contains? @ctx name)
|
||||
(throw (ex-info (str "ns name " name "is already bound") {}))
|
||||
(let [ns (into
|
||||
{::data/struct true ::data/type ::data/ns ::data/name name}
|
||||
(map-values #(interpret-ast % ctx))
|
||||
members)]
|
||||
(do
|
||||
(swap! ctx update-ctx {name ns})
|
||||
ns)))))
|
||||
|
||||
(defn interpret-ast [ast ctx]
|
||||
(case (::ast/type ast)
|
||||
|
||||
|
@ -255,6 +268,8 @@
|
|||
|
||||
::ast/placeholder ::data/placeholder
|
||||
|
||||
::ast/ns (interpret-ns ast ctx)
|
||||
|
||||
::ast/block
|
||||
(let [exprs (:exprs ast)
|
||||
inner (pop exprs)
|
||||
|
@ -313,6 +328,12 @@
|
|||
else -> :oops
|
||||
}
|
||||
|
||||
ns bar {
|
||||
foo
|
||||
}
|
||||
|
||||
bar :foo
|
||||
|
||||
")
|
||||
|
||||
(println "")
|
||||
|
|
Loading…
Reference in New Issue
Block a user