improve syntax checking for defpath

This commit is contained in:
Nathan Marz 2016-01-10 10:35:38 -05:00
parent c9b78ce0d6
commit af7d76be97

View file

@ -113,10 +113,10 @@
with other selectors without knowing the parameters. When precompiled with other with other selectors without knowing the parameters. When precompiled with other
selectors, the resulting selector takes in parameters for all selectors in the path selectors, the resulting selector takes in parameters for all selectors in the path
that needed parameters (in the order in which they were declared)." that needed parameters (in the order in which they were declared)."
[params & impls] [params impl1 impl2]
(let [num-params (count params) (let [num-params (count params)
retrieve-params (make-param-retrievers params)] retrieve-params (make-param-retrievers params)]
(paramspath* retrieve-params num-params impls) (paramspath* retrieve-params num-params [impl1 impl2])
)) ))
(defmacro paramsfn [params [structure-sym] & impl] (defmacro paramsfn [params [structure-sym] & impl]
@ -153,7 +153,7 @@
paths as input. Those selector paths may require late-bound params, so this helper paths as input. Those selector paths may require late-bound params, so this helper
will create a parameterized selector if that is the case. If no late-bound params will create a parameterized selector if that is the case. If no late-bound params
are required, then the result is executable." are required, then the result is executable."
[bindings & impls] [bindings impl1 impl2]
(let [bindings (partition 2 bindings) (let [bindings (partition 2 bindings)
paths (mapv second bindings) paths (mapv second bindings)
names (mapv first bindings) names (mapv first bindings)
@ -165,14 +165,14 @@
latefns-sym latefns-sym
[latefn-syms latefns-sym] [latefn-syms latefns-sym]
(mapcat (fn [n l] [n `(~l ~PARAMS-SYM ~PARAMS-IDX-SYM)]) names latefn-syms) (mapcat (fn [n l] [n `(~l ~PARAMS-SYM ~PARAMS-IDX-SYM)]) names latefn-syms)
impls))) [impl1 impl2])))
(defmacro variable-pathed-path (defmacro variable-pathed-path
"This helper is used to define selectors that take in a variable number of other selector "This helper is used to define selectors that take in a variable number of other selector
paths as input. Those selector paths may require late-bound params, so this helper paths as input. Those selector paths may require late-bound params, so this helper
will create a parameterized selector if that is the case. If no late-bound params will create a parameterized selector if that is the case. If no late-bound params
are required, then the result is executable." are required, then the result is executable."
[[latepaths-seq-sym paths-seq] & impls] [[latepaths-seq-sym paths-seq] impl1 impl2]
(let [latefns-sym (gensym "latefns")] (let [latefns-sym (gensym "latefns")]
(pathed-path* (pathed-path*
paramspath* paramspath*
@ -181,7 +181,7 @@
[] []
[latepaths-seq-sym `(map (fn [l#] (l# ~PARAMS-SYM ~PARAMS-IDX-SYM)) [latepaths-seq-sym `(map (fn [l#] (l# ~PARAMS-SYM ~PARAMS-IDX-SYM))
~latefns-sym)] ~latefns-sym)]
impls [impl1 impl2]
))) )))
(defmacro pathed-collector (defmacro pathed-collector