Compare commits
No commits in common. "4da846d8d75e850e3447697da47308ef425074f6" and "df274799be2e1b961bb634f4f09d224e32423ce4" have entirely different histories.
4da846d8d7
...
df274799be
|
@ -78,15 +78,9 @@
|
||||||
: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 (string "cannot show pattern of unknown type " (x :type)))))
|
(error "cannot show pattern of unknown type " (x :type))))
|
||||||
|
|
||||||
(defn doc! [fnn]
|
(defn- docstring [fnn] :todo)
|
||||||
(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))
|
||||||
|
@ -131,9 +125,6 @@
|
||||||
: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)
|
||||||
|
@ -149,7 +140,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
|
||||||
|
@ -170,7 +161,6 @@
|
||||||
"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
|
||||||
|
@ -204,6 +194,7 @@
|
||||||
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 :doc doc} ast)
|
(def {:name name :data clauses} ast)
|
||||||
(def the-fn @{:name name :^type :fn :body clauses :ctx ctx :doc doc})
|
(def the-fn @{:name name :^type :fn :body clauses :ctx ctx})
|
||||||
(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) @{:^parent b/ctx})
|
(try (interpret (parsed :ast) @{})
|
||||||
([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,14 +562,13 @@
|
||||||
(do
|
(do
|
||||||
(set source `
|
(set source `
|
||||||
fn foo {
|
fn foo {
|
||||||
"a doc, another doc"
|
"a foo, a bar"
|
||||||
() -> :foo
|
() -> :foo
|
||||||
(_) -> :bar
|
(_) -> :bar
|
||||||
}
|
}
|
||||||
|
foo ()
|
||||||
doc! (foo)
|
|
||||||
`)
|
`)
|
||||||
(def result (run))
|
(def result (run))
|
||||||
(b/show result)
|
# (b/show result)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1132,14 +1132,15 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# (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