Compare commits
3 Commits
df274799be
...
4da846d8d7
Author | SHA1 | Date | |
---|---|---|---|
|
4da846d8d7 | ||
|
478bc8649e | ||
|
1842923fa3 |
|
@ -78,9 +78,15 @@
|
|||
:typed (string (show-patt (get-in x [:data 1])) " as " (show-patt (get-in x [:data 0])))
|
||||
:interpolated (get-in x [:token :lexeme])
|
||||
:string (get-in x [:token :lexeme])
|
||||
(error "cannot show pattern of unknown type " (x :type))))
|
||||
(error (string "cannot show pattern of unknown type " (x :type)))))
|
||||
|
||||
(defn- docstring [fnn] :todo)
|
||||
(defn doc! [fnn]
|
||||
(def {:name name :doc doc :body clauses} fnn)
|
||||
(print "doccing " name)
|
||||
(def patterns (map (fn [x] (-> x first show-patt)) clauses))
|
||||
(print name)
|
||||
(print (string/join patterns " "))
|
||||
(print doc))
|
||||
|
||||
(defn- conj-set [sett value]
|
||||
(def new (merge sett))
|
||||
|
@ -125,6 +131,9 @@
|
|||
:set (-> x (dissoc :^type) keys)
|
||||
@[x]))
|
||||
|
||||
(defn print! [& args]
|
||||
(print ;(map show args)))
|
||||
|
||||
(defn prn [x]
|
||||
(pp x)
|
||||
x)
|
||||
|
@ -140,7 +149,7 @@
|
|||
(defn set! [x] (set (x :value) x))
|
||||
|
||||
(def ctx {
|
||||
"print" print
|
||||
"print!" print!
|
||||
"prn" prn
|
||||
"eq" deep=
|
||||
"bool" bool
|
||||
|
@ -161,6 +170,7 @@
|
|||
"type" ludus/type
|
||||
"stringify" stringify
|
||||
"show" show
|
||||
"doc!" doc!
|
||||
"concat" concat
|
||||
"conj" conj
|
||||
"disj" disj
|
||||
|
@ -194,7 +204,6 @@
|
|||
Used in current prelude but not yet in base:
|
||||
|
||||
into/2
|
||||
doc
|
||||
to_dict
|
||||
)
|
||||
|
||||
|
|
|
@ -358,8 +358,8 @@
|
|||
# Depends on: good string representation of patterns
|
||||
# For now, this should be enough to tall the thing
|
||||
(defn- fnn [ast ctx]
|
||||
(def {:name name :data clauses} ast)
|
||||
(def the-fn @{:name name :^type :fn :body clauses :ctx ctx})
|
||||
(def {:name name :data clauses :doc doc} ast)
|
||||
(def the-fn @{:name name :^type :fn :body clauses :ctx ctx :doc doc})
|
||||
(set (ctx name) the-fn))
|
||||
|
||||
(defn- is_placeholder [x] (= x :_))
|
||||
|
@ -554,7 +554,7 @@
|
|||
# (def cleaned (get-in parsed [:ast :data 1]))
|
||||
# (pp cleaned)
|
||||
# (interpret (parsed :ast) @{:^parent b/ctx})
|
||||
(try (interpret (parsed :ast) @{})
|
||||
(try (interpret (parsed :ast) @{:^parent b/ctx})
|
||||
([e] (print "Ludus panicked!: "
|
||||
(if (struct? e) (error (e :msg)) (error e)))))
|
||||
)
|
||||
|
@ -562,13 +562,14 @@
|
|||
(do
|
||||
(set source `
|
||||
fn foo {
|
||||
"a foo, a bar"
|
||||
"a doc, another doc"
|
||||
() -> :foo
|
||||
(_) -> :bar
|
||||
}
|
||||
foo ()
|
||||
|
||||
doc! (foo)
|
||||
`)
|
||||
(def result (run))
|
||||
# (b/show result)
|
||||
(b/show result)
|
||||
)
|
||||
|
||||
|
|
|
@ -1132,15 +1132,14 @@
|
|||
)
|
||||
|
||||
|
||||
(do
|
||||
# (comment
|
||||
# (do
|
||||
(comment
|
||||
(def source `(foo as :bar, 12, :foo, _thing)
|
||||
`)
|
||||
(def scanned (s/scan source))
|
||||
(print "\n***NEW PARSE***\n")
|
||||
(def a-parser (new-parser scanned))
|
||||
(def parsed (pattern a-parser))
|
||||
(print (show-patt parsed))
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user