parse docstrings
This commit is contained in:
parent
943e96203e
commit
3081af60b2
|
@ -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")
|
||||||
[[lhs guard rhs]]
|
{:clauses [[lhs guard rhs]]}
|
||||||
)
|
)
|
||||||
([err] err)
|
([err] err)
|
||||||
)
|
)
|
||||||
|
@ -757,13 +757,18 @@
|
||||||
(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)
|
||||||
data)
|
{:clauses data :doc doc})
|
||||||
|
|
||||||
(defn- lambda [parser]
|
(defn- lambda [parser]
|
||||||
(def origin (current parser))
|
(def origin (current parser))
|
||||||
|
@ -783,11 +788,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 data (case (-> parser current type)
|
(def {:clauses data :doc doc} (case (-> parser current type)
|
||||||
:lbrace (fn-clauses parser)
|
:lbrace (fn-clauses parser)
|
||||||
:lparen (fn-simple parser)
|
:lparen (fn-simple parser)
|
||||||
:nothing))
|
{:clauses :nothing}))
|
||||||
@{:type :fn :name name :data data :token origin})
|
@{:type :fn :name name :data data :token origin :doc doc})
|
||||||
([err] err)))
|
([err] err)))
|
||||||
|
|
||||||
### compoound forms
|
### compoound forms
|
||||||
|
@ -1130,9 +1135,9 @@
|
||||||
(do
|
(do
|
||||||
# (comment
|
# (comment
|
||||||
(def source `
|
(def source `
|
||||||
fn foo
|
fn foo {
|
||||||
fn bar
|
() -> :clause
|
||||||
fn () -> :baz
|
}
|
||||||
`)
|
`)
|
||||||
(def scanned (s/scan source))
|
(def scanned (s/scan source))
|
||||||
(print "\n***NEW PARSE***\n")
|
(print "\n***NEW PARSE***\n")
|
||||||
|
@ -1148,6 +1153,7 @@ fn () -> :baz
|
||||||
|
|
||||||
|
|
||||||
# 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