accept newlines after arrows in fn clauses; make some asts mutable for validation
This commit is contained in:
parent
3225ea2472
commit
ec43aa3c67
|
@ -701,6 +701,7 @@
|
||||||
(print "parsed guard")
|
(print "parsed guard")
|
||||||
(expect parser :arrow) (advance parser)
|
(expect parser :arrow) (advance parser)
|
||||||
(print "parsed arrow")
|
(print "parsed arrow")
|
||||||
|
(accept-many parser :newline)
|
||||||
(def rhs (nonbinding parser))
|
(def rhs (nonbinding parser))
|
||||||
(print "parsed rhs")
|
(print "parsed rhs")
|
||||||
[[lhs guard rhs]]
|
[[lhs guard rhs]]
|
||||||
|
@ -718,6 +719,7 @@
|
||||||
(advance parser)
|
(advance parser)
|
||||||
(simple parser)))
|
(simple parser)))
|
||||||
(expect parser :arrow) (advance parser)
|
(expect parser :arrow) (advance parser)
|
||||||
|
(accept-many parser :newline)
|
||||||
(def rhs (nonbinding parser))
|
(def rhs (nonbinding parser))
|
||||||
(terminator parser)
|
(terminator parser)
|
||||||
[lhs guard rhs])
|
[lhs guard rhs])
|
||||||
|
@ -745,7 +747,7 @@
|
||||||
(defn- lambda [parser]
|
(defn- lambda [parser]
|
||||||
(def origin (current parser))
|
(def origin (current parser))
|
||||||
(expect parser :fn) (advance parser)
|
(expect parser :fn) (advance parser)
|
||||||
{:type :fn :data (fn-simple parser) :token origin})
|
@{:type :fn :data (fn-simple parser) :token origin})
|
||||||
|
|
||||||
(defn- fnn [parser]
|
(defn- fnn [parser]
|
||||||
(if (= :lparen (-> parser peek type)) (break (lambda parser)))
|
(if (= :lparen (-> parser peek type)) (break (lambda parser)))
|
||||||
|
@ -764,7 +766,7 @@
|
||||||
:lbrace (fn-clauses parser)
|
:lbrace (fn-clauses parser)
|
||||||
:lparen (fn-simple parser)
|
:lparen (fn-simple parser)
|
||||||
(panic parser (string "expected clause or clauses, got " (-> current parser type)))))
|
(panic parser (string "expected clause or clauses, got " (-> current parser type)))))
|
||||||
{:type :fn :name name :data data :token origin})
|
@{:type :fn :name name :data data :token origin})
|
||||||
([err] err)))
|
([err] err)))
|
||||||
|
|
||||||
### compoound forms
|
### compoound forms
|
||||||
|
@ -864,7 +866,7 @@
|
||||||
(expect parser :ns) (advance parser)
|
(expect parser :ns) (advance parser)
|
||||||
(def name (-> parser pkg-name (get :data)))
|
(def name (-> parser pkg-name (get :data)))
|
||||||
(def body (block parser))
|
(def body (block parser))
|
||||||
{:type :ns :data body :name name :token origin})
|
@{:type :ns :data body :name name :token origin})
|
||||||
([err] err)))
|
([err] err)))
|
||||||
|
|
||||||
(defn- importt [parser]
|
(defn- importt [parser]
|
||||||
|
@ -895,7 +897,7 @@
|
||||||
:lparen (fn-simple parser)
|
:lparen (fn-simple parser)
|
||||||
:lbrace (fn-clauses parser)
|
:lbrace (fn-clauses parser)
|
||||||
))
|
))
|
||||||
{:type :loop :data [args clauses] :token origin})
|
@{:type :loop :data [args clauses] :token origin})
|
||||||
|
|
||||||
(defn- recur [parser]
|
(defn- recur [parser]
|
||||||
(def origin (current parser))
|
(def origin (current parser))
|
||||||
|
@ -1091,7 +1093,7 @@
|
||||||
(do
|
(do
|
||||||
#(comment
|
#(comment
|
||||||
(def source `
|
(def source `
|
||||||
pkg Foo {:bar nil}
|
loop (1, 2) with (x, y) -> :bar
|
||||||
`)
|
`)
|
||||||
(def scanned (s/scan source))
|
(def scanned (s/scan source))
|
||||||
(print "\n***NEW PARSE***\n")
|
(print "\n***NEW PARSE***\n")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user