         f0  (fn [[dataref values]]
               (let [v (eq values)]
                 (str "'" dataref "') echo \"" v "\";;")))
-        f1  (fn [[name nvseq]]
-              (let [x (strmap f0 nvseq)]
+        f1  (fn [[name nv_sequence]]
+              (let [x (strmap f0 nv_sequence)]
                 (str "'" name "') case " k " in " x "*) echo '';;esac;;" )))]
     (str "nmlquery(){ case " n " in " (strmap f1 ms) "*) echo '';;esac; }\n")))
 

(defn- fmt-ksh [m]
  (fmt-sh m #(str "\"$(echo $" % " | tr [:upper:] [:lower:])\"")))

;;(defn- fmt-namelist [m]
;; (let [f0 (fn [[dataref values]] (str "  " dataref "=" values "\n"))
;;       f1 (fn [[name nvseq]] (str "&" name "\n" (strmap f0 (sort nvseq)) "/\n"))]
;;   (strmap f1 (sort m))))

(defn f0 [x]
  (println (str "#PM# 1 " x))
  (let [[dataref values] x]
    (println (str "#PM# 2 " dataref))
    (println (str "#PM# 3 " values))
    (str "  " dataref "=" values "\n")))
(defn f1 [[name nvseq]] (str "&" name "\n" (strmap f0 (sort nvseq)) "/\n"))
(defn- fmt-namelist [m]
  (println (str "#PM# 0 " m))
  (strmap f1 (sort m)))

;; defs



(defn- nml-parse [s start src]
  (let [result (parse s :start start)]
;;   (let [parses (insta/parses parse s :start start :unhide :all :trace true)]
;;     (binding [*out* *err*]
;;       (doseq [parse parses] (println (str "----\n" parse)))
;;       (println (str "### " (count parses)))))
;;   (println (str "@@@ " result))
    (if (insta/failure? result)
      (let [{t :text l :line c :column} result]
        (fail (str "Error parsing " src " at line " l " column " c ":")
