Stub of let
This commit is contained in:
parent
84663d0952
commit
6b61a10349
|
@ -223,17 +223,31 @@
|
||||||
|
|
||||||
(::token/number ::token/string ::token/keyword) (parse-atom parser curr)
|
(::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]
|
(defn- parse-let [parser]
|
||||||
(let [
|
(let [
|
||||||
pattern (parse-pattern (advance parser))
|
pattern (parse-pattern (advance parser))
|
||||||
equals (parse-equals pattern)
|
equals (parse-equals pattern)
|
||||||
expr (parse-expr equals)
|
expr (parse-expr equals)
|
||||||
]))
|
results (map #(get-in % [::ast ::ast/type]) [pattern equals expr])
|
||||||
|
]
|
||||||
|
(pp/pprint results)
|
||||||
|
))
|
||||||
|
|
||||||
(defn- parse-expr [parser]
|
(defn- parse-expr [parser]
|
||||||
(loop [parser parser]
|
(loop [parser parser]
|
||||||
|
@ -269,6 +283,10 @@
|
||||||
|
|
||||||
::token/let (parse-let parser)
|
::token/let (parse-let parser)
|
||||||
|
|
||||||
|
(-> parser
|
||||||
|
(advance)
|
||||||
|
(assoc ::ast {::ast/type ::ast/poison :message "Expected expression"}))
|
||||||
|
|
||||||
))))
|
))))
|
||||||
|
|
||||||
(def source "{:foo}")
|
(def source "{:foo}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user