       fields
 
       :else
-      (let [attrs (->> loc zip/down zip/right fieldattrs)]
-        ;; do something with each node here
+      ;; 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))]
-      [name fields]))
+      (->Message name fields)))
 
 ;;(defn generateproto [intf ast template]
 ;;  (loop [loc ast]

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

(defn fieldattrs [ast]
  (loop [loc ast attrs {}]
    (if (nil? loc)
      attrs

;;

;;(deftype Field    [^String modifier ^String type ^String name ^Int index])
(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"))))
