Change tuple representation
This commit is contained in:
parent
d02bc05209
commit
b5a5be9dd0
|
@ -3,7 +3,6 @@
|
||||||
[ludus.parser :as parser]
|
[ludus.parser :as parser]
|
||||||
[ludus.scanner :as scanner]
|
[ludus.scanner :as scanner]
|
||||||
[ludus.ast :as ast]
|
[ludus.ast :as ast]
|
||||||
[ludus.collections :as colls]
|
|
||||||
[ludus.prelude :as prelude]
|
[ludus.prelude :as prelude]
|
||||||
[ludus.data :as data]
|
[ludus.data :as data]
|
||||||
[clojure.pprint :as pp]))
|
[clojure.pprint :as pp]))
|
||||||
|
@ -26,7 +25,7 @@
|
||||||
(cond
|
(cond
|
||||||
(not (vector? value)) {:success false :reason "Could not match non-tuple value to tuple"}
|
(not (vector? value)) {:success false :reason "Could not match non-tuple value to tuple"}
|
||||||
|
|
||||||
(not (= ::colls/tuple (first value))) {:success false :reason "Could not match list to tuple"}
|
(not (= ::data/tuple (first value))) {:success false :reason "Could not match list to tuple"}
|
||||||
|
|
||||||
(not (= (:length pattern) (dec (count value))))
|
(not (= (:length pattern) (dec (count value))))
|
||||||
{:success false :reason "Cannot match tuples of different lengths"}
|
{:success false :reason "Cannot match tuples of different lengths"}
|
||||||
|
@ -220,17 +219,16 @@
|
||||||
(run! #(interpret % ctx) inner)
|
(run! #(interpret % ctx) inner)
|
||||||
(interpret last ctx))
|
(interpret last ctx))
|
||||||
|
|
||||||
;; note that the runtime representations of collections is
|
;; note that, excepting a tuple,
|
||||||
;; unboxed in the tree-walk interpreter
|
;; runtime representations are bare
|
||||||
;; tuples & lists are both vectors, the first element
|
;; tuples are vectors with a special first member
|
||||||
;; distinguishes them
|
|
||||||
::ast/tuple
|
::ast/tuple
|
||||||
(let [members (:members ast)]
|
(let [members (:members ast)]
|
||||||
(into [::colls/tuple] (map #(interpret % ctx)) members))
|
(into [::data/tuple] (map #(interpret % ctx)) members))
|
||||||
|
|
||||||
::ast/list
|
::ast/list
|
||||||
(let [members (:members ast)]
|
(let [members (:members ast)]
|
||||||
(into [::colls/list] (map #(interpret % ctx)) members))
|
(into [] (map #(interpret % ctx)) members))
|
||||||
|
|
||||||
::ast/set
|
::ast/set
|
||||||
(let [members (:members ast)]
|
(let [members (:members ast)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user