Make (_)
a parsing error
This commit is contained in:
parent
e248be16cf
commit
1caddfacbc
|
@ -139,19 +139,24 @@
|
||||||
(defn- contains-placeholder? [members]
|
(defn- contains-placeholder? [members]
|
||||||
(< 0 (count (filter #(= ::ast/placeholder (::ast/type %1)) members))))
|
(< 0 (count (filter #(= ::ast/placeholder (::ast/type %1)) members))))
|
||||||
|
|
||||||
|
(defn unary-placeholder? [tuple]
|
||||||
|
(and (:partial tuple) (= (:length tuple) 1)))
|
||||||
|
|
||||||
(defn- parse-fn-tuple [origin]
|
(defn- parse-fn-tuple [origin]
|
||||||
(loop [parser (accept-many #{::token/newline ::token/comma} (advance origin))
|
(loop [parser (accept-many #{::token/newline ::token/comma} (advance origin))
|
||||||
members []
|
members []
|
||||||
current_member nil]
|
current_member nil]
|
||||||
(let [curr (current parser)]
|
(let [curr (current parser)]
|
||||||
(case (token-type parser)
|
(case (token-type parser)
|
||||||
::token/rparen (let [ms (add-member members current_member)]
|
::token/rparen (let [ms (add-member members current_member)
|
||||||
(assoc (advance parser) ::ast
|
ast {::ast/type ::ast/tuple
|
||||||
{::ast/type ::ast/tuple
|
|
||||||
:length (count ms)
|
:length (count ms)
|
||||||
:members ms
|
:members ms
|
||||||
:token (current origin)
|
:token (current origin)
|
||||||
:partial (contains-placeholder? ms)}))
|
:partial (contains-placeholder? ms)}]
|
||||||
|
(if (unary-placeholder? ast)
|
||||||
|
(panic parser "You may not use a placeholder in a tuple of length 1. You may only partially apply functions that take more than one argument.")
|
||||||
|
(assoc (advance parser) ::ast ast)))
|
||||||
|
|
||||||
(::token/comma ::token/newline)
|
(::token/comma ::token/newline)
|
||||||
(recur
|
(recur
|
||||||
|
|
Loading…
Reference in New Issue
Block a user