stand up pkgs
This commit is contained in:
parent
27b688b96d
commit
b86a25b5bc
|
@ -47,11 +47,18 @@
|
|||
:ref (stringify (value :^value))
|
||||
:fn (string "fn " (value :name))
|
||||
:function (string "builtin " (string value))
|
||||
# XXX: pkg
|
||||
:pkg (dict-str value)
|
||||
))
|
||||
|
||||
(set stringify stringify*)
|
||||
|
||||
(defn- show-pkg [x]
|
||||
(def tab (struct/to-table x))
|
||||
(set (tab :^name) nil)
|
||||
(set (tab :^type) nil)
|
||||
(string "pkg " (x :^name) " {" (stringify tab) "}")
|
||||
)
|
||||
|
||||
(defn show [x]
|
||||
(case (ludus/type x)
|
||||
:nil "nil"
|
||||
|
@ -60,7 +67,8 @@
|
|||
:list (string "[" (stringify x) "]")
|
||||
:dict (string "#{" (stringify x) "}")
|
||||
:set (string "${" (stringify x) "}")
|
||||
:ref (string "ref:" (x :name) "{" (x :value) "}")
|
||||
:ref (string "ref " (x :name) "{" (x :value) "}")
|
||||
:pkg (show-pkg x)
|
||||
(stringify x)))
|
||||
|
||||
(defn- show-patt [x]
|
||||
|
|
|
@ -458,7 +458,18 @@
|
|||
(call-fn last-fn [prev]))
|
||||
|
||||
# TODO for Computer Class
|
||||
(defn- pkg [ast ctx] (todo "pkgs"))
|
||||
(defn- pkg [ast ctx]
|
||||
(def members (ast :data))
|
||||
(def the-pkg @{:^name (ast :name) :^type :pkg})
|
||||
(each member members
|
||||
(def [key-ast value-ast] (member :data))
|
||||
(def key (interpret key-ast ctx))
|
||||
(def value (interpret value-ast ctx))
|
||||
(set (the-pkg key) value))
|
||||
(pp the-pkg)
|
||||
(def out (table/to-struct the-pkg))
|
||||
(set (ctx (ast :name)) out)
|
||||
out)
|
||||
|
||||
(defn- loopp [ast ctx]
|
||||
(print "looping!")
|
||||
|
@ -550,6 +561,7 @@
|
|||
:interpolated (interpolated ast ctx)
|
||||
:ref (ref ast ctx)
|
||||
:pkg (pkg ast ctx)
|
||||
:pkg-name (word ast ctx)
|
||||
|
||||
# patterned forms
|
||||
:let (lett ast ctx)
|
||||
|
@ -601,13 +613,10 @@
|
|||
|
||||
(do
|
||||
(set source `
|
||||
loop (10) with {
|
||||
(0) -> :done!
|
||||
(x) -> {
|
||||
print! (x)
|
||||
recur (dec (x))
|
||||
}
|
||||
}
|
||||
let foo = 42
|
||||
let bar = :bar
|
||||
pkg Baz {foo, bar}
|
||||
Baz :fool
|
||||
`)
|
||||
(def result (run))
|
||||
(b/show result)
|
||||
|
|
|
@ -1134,12 +1134,12 @@
|
|||
|
||||
(do
|
||||
# (comment
|
||||
(def source `recur (x)
|
||||
(def source `pkg Foo {}
|
||||
`)
|
||||
(def scanned (s/scan source))
|
||||
(print "\n***NEW PARSE***\n")
|
||||
(def a-parser (new-parser scanned))
|
||||
(def parsed (recur a-parser))
|
||||
(def parsed (pkg a-parser))
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user