 
 ;; ast
 
-(def return
-  {:type :return})
-
 (defn pipe [id inputs & nodes]
   {:type :pipe
    :id id


(defn run-node [id->node node inputs output stack]
  (case (:type node)
    :return (run-return id->node node inputs output stack)
    :data (run-data id->node node inputs output stack)
    :ref (run-ref id->node node inputs output stack)
    :match (run-match id->node node inputs output stack)
    :replace (run-replace id->node node inputs output stack)
    :output (run-output id->node node inputs output stack)))

(defn run-return [id->node node inputs output stack]
  (assert (= 1 (count inputs)))
  (first inputs))

(defn run-data [id->node node inputs output stack]
  (assert (empty? inputs))

        (try
          (let [vars #js {}]
            (run-match-pattern id->node pattern (:path input) (:value input) output stack vars)
            (case (:type node)
              :match/return (do (assert (= 1 (count inputs)))
                              (aget vars (first inputs)))
              (run-node id->node node (map #(aget vars %) inputs) output stack)))
          (catch MatchFailure _
            (recur branches)))
        (throw (MatchFailure.))))))
