validate dict patterns, by validating pairs
This commit is contained in:
parent
e767c319b1
commit
d249ee0b21
|
@ -144,9 +144,6 @@ Deferred until a later iteration of Ludus:
|
|||
(set (status :last) nil)
|
||||
validator)
|
||||
|
||||
### XXX: to do
|
||||
(defn- dict-pattern [validator])
|
||||
|
||||
(defn- word-pattern [validator]
|
||||
(def ast (validator :ast))
|
||||
(def name (ast :data))
|
||||
|
@ -210,6 +207,12 @@ Deferred until a later iteration of Ludus:
|
|||
(set (ast :compiled) (peg/compile grammar))
|
||||
(set (ast :bindings) bindings))
|
||||
|
||||
(defn- pair [validator]
|
||||
(def ast (validator :ast))
|
||||
(def [_ patt] (ast :data))
|
||||
(set (validator :ast) patt)
|
||||
(pattern validator))
|
||||
|
||||
(defn- pattern* [validator]
|
||||
(print "PATTERN*")
|
||||
(def ast (validator :ast))
|
||||
|
@ -224,9 +227,11 @@ Deferred until a later iteration of Ludus:
|
|||
:word (word-pattern validator)
|
||||
:list (simple-coll-pattern validator)
|
||||
:tuple (simple-coll-pattern validator)
|
||||
:dict (simple-coll-pattern validator)
|
||||
:splat (splattern validator)
|
||||
:typed (typed validator)
|
||||
:interpolated (str-pattern validator)
|
||||
:pair (pair validator)
|
||||
)))
|
||||
|
||||
(set pattern pattern*)
|
||||
|
@ -633,16 +638,11 @@ Deferred until a later iteration of Ludus:
|
|||
|
||||
(import ./base :as b)
|
||||
|
||||
# (do
|
||||
(comment
|
||||
(do
|
||||
# (comment
|
||||
(def source `
|
||||
fn foobar {
|
||||
(:foo, :bar) -> true
|
||||
(_, _) -> false
|
||||
}
|
||||
let bar = foobar (:foo, _)
|
||||
bar (:bar, 2)
|
||||
add ()
|
||||
let #{a, b} = #{:a 1}
|
||||
b
|
||||
`)
|
||||
(def scanned (s/scan source))
|
||||
(def parsed (p/parse scanned))
|
||||
|
|
Loading…
Reference in New Issue
Block a user