 
 (defn -main []
   (let [smodel (read-model-file "src/cbfg/fence.cljs")
-        pmodel (cvt-top-level-forms smodel)]
+        pmodel (map cvt-top-level-form (:forms smodel))]
     (emit (:lines smodel) pmodel)))
 

(defn cvt-defn [name params body]
  ["func" (cvt-sym name) (rest (cvt-fn params body))])

(defn cvt-top-level-form [smodel form]
  (let [[op name & more] form]
    [(case (str op)
      "ns" (j ["package" (cvt-sym name)])
      "defn" (j (cvt-defn name (first more) (rest more)))
      "UNKNOWN-TOP-LEVEL-FORM")
     (line-range form)]))

(defn cvt-top-level-forms [smodel]
  (map #(cvt-top-level-form smodel %)
       (:forms smodel)))

(defn numbered-lines [lines beg end] ; beg and end are 1-based.
  (map vector

  (re-seq (re-pattern (str ".{0," width "}\\s")) (str s " ")))

(defn ljust [width s] ; Left justify a string.
  (format (str "%-" width "s") s))

(defn read-model-file [fname]
    {:fname fname
