Compare commits
No commits in common. "df274799be2e1b961bb634f4f09d224e32423ce4" and "943e96203e149d775446c864a2929ab2c89f3f75" have entirely different histories.
df274799be
...
943e96203e
|
@ -47,7 +47,7 @@
|
||||||
: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
|
# XXX: pkg, fn
|
||||||
))
|
))
|
||||||
|
|
||||||
(set stringify stringify*)
|
(set stringify stringify*)
|
||||||
|
@ -63,25 +63,6 @@
|
||||||
:ref (string "ref:" (x :name) "{" (x :value) "}")
|
:ref (string "ref:" (x :name) "{" (x :value) "}")
|
||||||
(stringify x)))
|
(stringify x)))
|
||||||
|
|
||||||
(defn- show-patt [x]
|
|
||||||
(case (x :type)
|
|
||||||
:nil "nil"
|
|
||||||
:bool (string (x :data))
|
|
||||||
:number (string (x :data))
|
|
||||||
:keyword (string ":" (x :data))
|
|
||||||
:word (x :data)
|
|
||||||
:placeholder (get-in x [:token :lexeme])
|
|
||||||
:tuple (string "(" (string/join (map show-patt (x :data)) ", ") ")")
|
|
||||||
:list (string "[" (string/join (map show-patt (x :data)) ", ")"]")
|
|
||||||
:dict (string "#{" (string/join (map show-patt (x :data)) ", ") "}")
|
|
||||||
:pair (string (show-patt (get-in x [:data 0])) " " (show-patt (get-in x [:data 1])))
|
|
||||||
: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))))
|
|
||||||
|
|
||||||
(defn- docstring [fnn] :todo)
|
|
||||||
|
|
||||||
(defn- conj-set [sett value]
|
(defn- conj-set [sett value]
|
||||||
(def new (merge sett))
|
(def new (merge sett))
|
||||||
(set (new value) true)
|
(set (new value) true)
|
||||||
|
|
|
@ -561,12 +561,10 @@
|
||||||
|
|
||||||
(do
|
(do
|
||||||
(set source `
|
(set source `
|
||||||
fn foo {
|
fn foo
|
||||||
"a foo, a bar"
|
fn bar () -> foo ()
|
||||||
() -> :foo
|
fn foo () -> :foo
|
||||||
(_) -> :bar
|
bar ()
|
||||||
}
|
|
||||||
foo ()
|
|
||||||
`)
|
`)
|
||||||
(def result (run))
|
(def result (run))
|
||||||
# (b/show result)
|
# (b/show result)
|
||||||
|
|
|
@ -725,7 +725,7 @@
|
||||||
(accept-many parser :newline)
|
(accept-many parser :newline)
|
||||||
(def rhs (nonbinding parser))
|
(def rhs (nonbinding parser))
|
||||||
(print "parsed rhs")
|
(print "parsed rhs")
|
||||||
{:clauses [[lhs guard rhs]]}
|
[[lhs guard rhs]]
|
||||||
)
|
)
|
||||||
([err] err)
|
([err] err)
|
||||||
)
|
)
|
||||||
|
@ -757,18 +757,13 @@
|
||||||
(def origin (current parser))
|
(def origin (current parser))
|
||||||
(expect parser :lbrace) (advance parser)
|
(expect parser :lbrace) (advance parser)
|
||||||
(accept-many parser ;terminators)
|
(accept-many parser ;terminators)
|
||||||
(def doc (when (= :string ((current parser) :type))
|
|
||||||
(def docstring ((current parser) :literal))
|
|
||||||
(advance parser)
|
|
||||||
(accept-many parser ;terminators)
|
|
||||||
docstring))
|
|
||||||
(def data @[])
|
(def data @[])
|
||||||
(while (not (check parser :rbrace))
|
(while (not (check parser :rbrace))
|
||||||
(if (check parser :eof)
|
(if (check parser :eof)
|
||||||
(error {:type :error :token origin :data data :msg "unclosed brace"}))
|
(error {:type :error :token origin :data data :msg "unclosed brace"}))
|
||||||
(array/push data (capture fn-clause parser)))
|
(array/push data (capture fn-clause parser)))
|
||||||
(advance parser)
|
(advance parser)
|
||||||
{:clauses data :doc doc})
|
data)
|
||||||
|
|
||||||
(defn- lambda [parser]
|
(defn- lambda [parser]
|
||||||
(def origin (current parser))
|
(def origin (current parser))
|
||||||
|
@ -788,11 +783,11 @@
|
||||||
(def name (-> parser word-only (get :data)))
|
(def name (-> parser word-only (get :data)))
|
||||||
(print "function name: ")
|
(print "function name: ")
|
||||||
(pp name)
|
(pp name)
|
||||||
(def {:clauses data :doc doc} (case (-> parser current type)
|
(def data (case (-> parser current type)
|
||||||
:lbrace (fn-clauses parser)
|
:lbrace (fn-clauses parser)
|
||||||
:lparen (fn-simple parser)
|
:lparen (fn-simple parser)
|
||||||
{:clauses :nothing}))
|
:nothing))
|
||||||
@{:type :fn :name name :data data :token origin :doc doc})
|
@{:type :fn :name name :data data :token origin})
|
||||||
([err] err)))
|
([err] err)))
|
||||||
|
|
||||||
### compoound forms
|
### compoound forms
|
||||||
|
@ -1134,18 +1129,25 @@
|
||||||
|
|
||||||
(do
|
(do
|
||||||
# (comment
|
# (comment
|
||||||
(def source `(foo as :bar, 12, :foo, _thing)
|
(def source `
|
||||||
|
fn foo
|
||||||
|
fn bar
|
||||||
|
fn () -> :baz
|
||||||
`)
|
`)
|
||||||
(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 (script a-parser))
|
||||||
(print (show-patt parsed))
|
|
||||||
|
# (print (pp-ast parsed))
|
||||||
|
# (pp scanned)
|
||||||
|
(pp parsed)
|
||||||
|
# (def cleaned (get-in parsed [:data 2]))
|
||||||
|
# (pp cleaned)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# FIXME:
|
# FIXME:
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# DECIDE:
|
# DECIDE:
|
||||||
# - when to use a flat try/catch format, and when to use capture/expect-ret to get values instead of errors
|
# - when to use a flat try/catch format, and when to use capture/expect-ret to get values instead of errors
|
||||||
|
|
Loading…
Reference in New Issue
Block a user