if* -> if, let* -> let
This commit is contained in:
parent
85d4f99030
commit
faba605329
|
@ -342,7 +342,7 @@
|
||||||
(parse-let-expr (:parser assignment) parser)
|
(parse-let-expr (:parser assignment) parser)
|
||||||
(panic parser "Expected assignment"))))
|
(panic parser "Expected assignment"))))
|
||||||
|
|
||||||
(defn- parse-let* [parser]
|
(defn- parse-let [parser]
|
||||||
(let [pattern (parse-pattern (advance parser))]
|
(let [pattern (parse-pattern (advance parser))]
|
||||||
(parse-assignment pattern)))
|
(parse-assignment pattern)))
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@
|
||||||
(parse-else (accept ::token/newline (assoc expr ::ast (assoc ast :then then-expr)))))
|
(parse-else (accept ::token/newline (assoc expr ::ast (assoc ast :then then-expr)))))
|
||||||
then-kw-parser)))
|
then-kw-parser)))
|
||||||
|
|
||||||
(defn- parse-if* [parser]
|
(defn- parse-if [parser]
|
||||||
(let [if-expr (parse-expr (advance parser) #{::token/newline ::token/then})
|
(let [if-expr (parse-expr (advance parser) #{::token/newline ::token/then})
|
||||||
ast (assoc if-expr ::ast {::ast/type ::ast/if :if (::ast if-expr)})]
|
ast (assoc if-expr ::ast {::ast/type ::ast/if :if (::ast if-expr)})]
|
||||||
(parse-then (accept ::token/newline ast))
|
(parse-then (accept ::token/newline ast))
|
||||||
|
@ -405,9 +405,9 @@
|
||||||
|
|
||||||
::token/lbrace (parse-block parser)
|
::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)
|
::token/error (panic parser (:message token) sync-on)
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@
|
||||||
|
|
||||||
(do
|
(do
|
||||||
(def pp pp/pprint)
|
(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 lexed (scanner/scan source))
|
||||||
(def tokens (:tokens lexed))
|
(def tokens (:tokens lexed))
|
||||||
(def p (parser tokens))
|
(def p (parser tokens))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user