       (let [[k v] (zip/node loc)]
         (recur (zip/right loc) (assoc attrs k v))))))
 
-(defn buildfields [ast]
+(defn getfields [ast]
   (loop [loc ast fields {}]
     (cond
 

      fields

      :else
      (let [attrs (->> loc zip/down zip/right fieldattrs)]
        ;; do something with each node here
        (recur (zip/right loc) (assoc fields (:index attrs) attrs))))))

(defn buildmessage [ast]
  (let [name (->> ast zip/right zip/node)
        fields (buildfields (->> ast zip/right zip/right))]
      [name fields]))

;;(defn generateproto [intf ast template]
;;  (loop [loc ast]

  (let [interfaces (getinterfaces config)]
    (into {} (map #(vector % (compileintf path %)) interfaces))))

;;-----------------------------------------------------------------
;; getX - extracts fields from an AST message
;;-----------------------------------------------------------------
(defn getfieldattrs [ast]
  (loop [loc ast attrs {}]
    (if (nil? loc)
      attrs
