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