if* -> if, let* -> let

This commit is contained in:
Scott Richmond 2022-03-19 12:30:59 -04:00
parent 85d4f99030
commit faba605329

View File

@ -342,7 +342,7 @@
(parse-let-expr (:parser assignment) parser)
(panic parser "Expected assignment"))))
(defn- parse-let* [parser]
(defn- parse-let [parser]
(let [pattern (parse-pattern (advance parser))]
(parse-assignment pattern)))
@ -368,7 +368,7 @@
(parse-else (accept ::token/newline (assoc expr ::ast (assoc ast :then then-expr)))))
then-kw-parser)))
(defn- parse-if* [parser]
(defn- parse-if [parser]
(let [if-expr (parse-expr (advance parser) #{::token/newline ::token/then})
ast (assoc if-expr ::ast {::ast/type ::ast/if :if (::ast if-expr)})]
(parse-then (accept ::token/newline ast))
@ -405,9 +405,9 @@
::token/lbrace (parse-block parser)
::token/let (parse-let* parser)
::token/let (parse-let parser)
::token/if (parse-if* parser)
::token/if (parse-if parser)
::token/error (panic parser (:message token) sync-on)
@ -423,7 +423,7 @@
(do
(def pp pp/pprint)
(def source "if {foo} then bar else baz")
(def source "let quux = if {foo} then bar else baz")
(def lexed (scanner/scan source))
(def tokens (:tokens lexed))
(def p (parser tokens))