Reindent things
This commit is contained in:
parent
90f6fa8b19
commit
2a099298f0
|
@ -32,19 +32,14 @@
|
||||||
(= 0 (:length pattern) (dec (count value))) {:success true :ctx {}}
|
(= 0 (:length pattern) (dec (count value))) {:success true :ctx {}}
|
||||||
|
|
||||||
:else (let [members (:members pattern)]
|
:else (let [members (:members pattern)]
|
||||||
(loop [i (dec (:length pattern))
|
(loop [i (:length pattern)
|
||||||
ctx {}]
|
ctx {}]
|
||||||
(if (= 0 i)
|
(if (= 0 i)
|
||||||
{:success true :ctx ctx}
|
{:success true :ctx ctx}
|
||||||
(let [match? (match (nth members i) (nth value (inc i)) ctx-atom)]
|
(let [match? (match (nth members (dec i)) (nth value i) ctx-atom)]
|
||||||
(if (:success match?)
|
(if (:success match?)
|
||||||
(recur (dec i) (merge ctx (:ctx match?)))
|
(recur (dec i) (merge ctx (:ctx match?)))
|
||||||
{:success false :reason (str "Could not match " pattern " with " value)}
|
{:success false :reason (str "Could not match " pattern " with " value)})))))))
|
||||||
))
|
|
||||||
)
|
|
||||||
|
|
||||||
))
|
|
||||||
))
|
|
||||||
|
|
||||||
(defn- match [pattern value ctx-atom]
|
(defn- match [pattern value ctx-atom]
|
||||||
(let [ctx @ctx-atom]
|
(let [ctx @ctx-atom]
|
||||||
|
@ -74,6 +69,8 @@
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(defn- update-ctx [ctx new-ctx]
|
(defn- update-ctx [ctx new-ctx]
|
||||||
|
(println "Adding to context:")
|
||||||
|
(pp/pprint new-ctx)
|
||||||
(merge ctx new-ctx))
|
(merge ctx new-ctx))
|
||||||
|
|
||||||
;; TODO: get "if let" pattern working
|
;; TODO: get "if let" pattern working
|
||||||
|
@ -156,19 +153,20 @@
|
||||||
|
|
||||||
(do
|
(do
|
||||||
|
|
||||||
(def source "
|
(def source "
|
||||||
let (:foo, 1, :bar) = (:foo, 1, :bar)
|
let (foo, (_, baz)) = (1, (2, 3))
|
||||||
|
baz
|
||||||
")
|
")
|
||||||
|
|
||||||
(println "")
|
(println "")
|
||||||
(println "****************************************")
|
(println "****************************************")
|
||||||
(println "*** *** NEW INTERPRETATION *** ***")
|
(println "*** *** NEW INTERPRETATION *** ***")
|
||||||
(println "")
|
(println "")
|
||||||
|
|
||||||
(-> source
|
(-> source
|
||||||
(scanner/scan)
|
(scanner/scan)
|
||||||
(parser/parse)
|
(parser/parse)
|
||||||
(::parser/ast)
|
(::parser/ast)
|
||||||
(interpret {})
|
(interpret {})
|
||||||
(pp/pprint)
|
(pp/pprint)
|
||||||
))
|
))
|
Loading…
Reference in New Issue
Block a user