Created
September 9, 2016 17:54
-
-
Save MichaelDrogalis/c66fc7c8db6367d9907caf200d5746fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(s/def :flow/predicate | |
(s/or :and (s/cat :op (partial = :and) :exprs (s/+ :flow/predicate)) | |
:or (s/cat :op (partial = :or) :exprs (s/+ :flow/predicate)) | |
:not (s/cat :op (partial = :not) :exprs (s/cat :pred :flow/predicate)) | |
:fn keyword? | |
:fn-and-args (s/cat :fn (λ [x] | |
(and (keyword? x) | |
(not (some #{x} #{:and :or :not})))) | |
:args (s/* keyword?)))) | |
(s/conform :flow/predicate [:and [:f :x] [:or [:not [:g :a :b :c]] [:h :z]]]) | |
;; => | |
[:and | |
{:op :and, | |
:exprs | |
[[:fn-and-args {:fn :f, :args [:x]}] | |
[:or | |
{:op :or, | |
:exprs | |
[[:not | |
{:op :not, | |
:exprs {:pred [:fn-and-args {:fn :g, :args [:a :b :c]}]}}] | |
[:fn-and-args {:fn :h, :args [:z]}]]}]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment