Compare commits

..

No commits in common. "4da846d8d75e850e3447697da47308ef425074f6" and "df274799be2e1b961bb634f4f09d224e32423ce4" have entirely different histories.

3 changed files with 13 additions and 22 deletions

View File

@ -78,15 +78,9 @@
: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 (string "cannot show pattern of unknown type " (x :type)))))
(error "cannot show pattern of unknown type " (x :type))))
(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- docstring [fnn] :todo)
(defn- conj-set [sett value]
(def new (merge sett))
@ -131,9 +125,6 @@
:set (-> x (dissoc :^type) keys)
@[x]))
(defn print! [& args]
(print ;(map show args)))
(defn prn [x]
(pp x)
x)
@ -149,7 +140,7 @@
(defn set! [x] (set (x :value) x))
(def ctx {
"print!" print!
"print" print
"prn" prn
"eq" deep=
"bool" bool
@ -170,7 +161,6 @@
"type" ludus/type
"stringify" stringify
"show" show
"doc!" doc!
"concat" concat
"conj" conj
"disj" disj
@ -204,6 +194,7 @@
Used in current prelude but not yet in base:
into/2
doc
to_dict
)

View File

@ -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 :doc doc} ast)
(def the-fn @{:name name :^type :fn :body clauses :ctx ctx :doc doc})
(def {:name name :data clauses} ast)
(def the-fn @{:name name :^type :fn :body clauses :ctx ctx})
(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) @{:^parent b/ctx})
(try (interpret (parsed :ast) @{})
([e] (print "Ludus panicked!: "
(if (struct? e) (error (e :msg)) (error e)))))
)
@ -562,14 +562,13 @@
(do
(set source `
fn foo {
"a doc, another doc"
"a foo, a bar"
() -> :foo
(_) -> :bar
}
doc! (foo)
foo ()
`)
(def result (run))
(b/show result)
# (b/show result)
)

View File

@ -1132,14 +1132,15 @@
)
# (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))
)