 ;;
 
 ;;(deftype Field    [^String modifier ^String type ^String name ^Int index])
-;;(deftype Message  [^String name ^ArrayList fields])
+(deftype Message  [^String name ^ArrayList fields])
 
 (def grammar (insta/parser (io/resource "parsers/interface/grammar.bnf")
                            :auto-whitespace (insta/parser (io/resource "parsers/interface/skip.bnf"))))

      (let [[k v] (zip/node loc)]
        (recur (zip/right loc) (assoc attrs k v))))))

(defn buildfields [ast]
  (loop [loc ast fields {}]
    (cond


      fields

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

;;-----------------------------------------------------------------
;; buildX - build our ST friendly objects from the AST
;;-----------------------------------------------------------------
(defn buildfields [ast]
  (let [rawfields (getfields ast)]
      rawfields))

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

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