Stub of let

This commit is contained in:
Scott Richmond 2022-02-15 13:17:01 -05:00
parent 84663d0952
commit 6b61a10349

View File

@ -223,17 +223,31 @@
(::token/number ::token/string ::token/keyword) (parse-atom parser curr)
::oops
(-> parser
(advance)
(assoc ::ast {::ast/type ::ast/poison :message "Expected pattern"}))
)))
(defn- parse-equals [parser])
(defn- parse-equals [parser]
(let [curr (current parser)
type (::token/type curr)]
(case type
::token/equals (advance parser)
(-> parser
(advance)
(assoc ::ast {::ast/type ::ast/poison :message "Expected assignment"}))
)))
(defn- parse-let [parser]
(let [
pattern (parse-pattern (advance parser))
equals (parse-equals pattern)
expr (parse-expr equals)
]))
results (map #(get-in % [::ast ::ast/type]) [pattern equals expr])
]
(pp/pprint results)
))
(defn- parse-expr [parser]
(loop [parser parser]
@ -269,6 +283,10 @@
::token/let (parse-let parser)
(-> parser
(advance)
(assoc ::ast {::ast/type ::ast/poison :message "Expected expression"}))
))))
(def source "{:foo}")