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