allow shadowing of prelude
This commit is contained in:
parent
7467bc8867
commit
98421a9215
|
@ -51,14 +51,12 @@
|
||||||
(-> out j/encode string)
|
(-> out j/encode string)
|
||||||
)
|
)
|
||||||
|
|
||||||
# (comment
|
(comment
|
||||||
(do
|
# (do
|
||||||
# (def start (os/clock))
|
# (def start (os/clock))
|
||||||
(def source `
|
(def source `
|
||||||
let foo = :bar
|
let foo = :bar
|
||||||
{
|
let first = 1
|
||||||
let foo = :baz
|
|
||||||
}
|
|
||||||
`)
|
`)
|
||||||
(def out (-> source
|
(def out (-> source
|
||||||
ludus
|
ludus
|
||||||
|
|
|
@ -102,6 +102,11 @@ Deferred until a later iteration of Ludus:
|
||||||
(def node (get ctx name))
|
(def node (get ctx name))
|
||||||
(if node node (resolve-name (get ctx :^parent) name)))
|
(if node node (resolve-name (get ctx :^parent) name)))
|
||||||
|
|
||||||
|
(defn- resolve-name-in-script [ctx name]
|
||||||
|
(when (ctx :^toplevel) (break nil))
|
||||||
|
(def node (ctx name))
|
||||||
|
(if node node (resolve-name-in-script (ctx :^parent) name)))
|
||||||
|
|
||||||
(defn- word [validator]
|
(defn- word [validator]
|
||||||
(def ast (validator :ast))
|
(def ast (validator :ast))
|
||||||
(def name (ast :data))
|
(def name (ast :data))
|
||||||
|
@ -158,7 +163,7 @@ Deferred until a later iteration of Ludus:
|
||||||
(def name (ast :data))
|
(def name (ast :data))
|
||||||
(def ctx (validator :ctx))
|
(def ctx (validator :ctx))
|
||||||
### XXX TODO: this resolution should ONLY be for userspace, NOT prelude
|
### XXX TODO: this resolution should ONLY be for userspace, NOT prelude
|
||||||
(def resolved (resolve-name ctx name))
|
(def resolved (resolve-name-in-script ctx name))
|
||||||
(when resolved
|
(when resolved
|
||||||
(def {:line line :input input} resolved)
|
(def {:line line :input input} resolved)
|
||||||
(array/push (validator :errors)
|
(array/push (validator :errors)
|
||||||
|
@ -766,6 +771,7 @@ Deferred until a later iteration of Ludus:
|
||||||
|
|
||||||
(defn valid [ast &opt ctx]
|
(defn valid [ast &opt ctx]
|
||||||
(default ctx @{})
|
(default ctx @{})
|
||||||
|
(set (ctx :^toplevel) true)
|
||||||
(def validator (new-validator ast))
|
(def validator (new-validator ast))
|
||||||
(def base-ctx @{:^parent ctx})
|
(def base-ctx @{:^parent ctx})
|
||||||
(set (validator :ctx) base-ctx)
|
(set (validator :ctx) base-ctx)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user