         match  (if sub (string/lower-case key) (string/lower-case nml))
         parent (if sub :nvseq :s)
         proxy  (if sub (str match "=0") (str "&" match " /"))
-        vnew   (if sub (fn [tree] (parse val :start :values)) #(nml-set % nml key val true))
+        vnew   (if sub (fn [tree] (nml-parse val :values)) #(nml-set % nml key val true))
         f      (fn
                  ([k v] (if (= (nml-str k) match) [child k (vnew v  )] [child k v]))
                  ([k  ] (if (= (nml-str k) match) [child k (vnew nil)] [child k  ])))]
     (insta/transform {child f} (nml-add tree parent child match proxy))))
 
 (defn nml-tree [s]
-  (let [result (parse s)
-        child  :nvseq
-        f      (fn [& v] (into [child] (nml-uniq v)))]
-    (if (insta/failure? result)
-      (let [{t :text l :line c :column} result]
-        (fail (str "Parse error at line " l " column " c ":")
-              t
-              (str (apply str (repeat (- c 1) " ")) "^")))
-      (insta/transform {child f} result))))
+  (let [tree  (nml-parse s :s)
+        child :nvseq
+        f     (fn [& v] (into [child] (nml-uniq v)))]
+      (insta/transform {child f} tree)))
 
 ;; main
 

  (alter-var-root #'*read-eval* (constantly false))
  (let [{:keys [options arguments summary]} (cli/parse-opts args cliopts)
        gets (:get options)
        sets (:set options)]
    (if (:help options) (usage summary))
    (if (:version options) (do (println version) (System/exit 0)))
    (if (and gets sets) (fail (msgs 3)))
    (if (and gets (:in-place options)) (warn (msgs 4)))
    (if (and sets (:no-prefix options)) (warn (msgs 2)))
    (let [file (first arguments)
          s    (if file
                 (try (slurp file)
                      (catch Exception e
                        (if (:in-place options)
                          ""
                          (fail (str "Could not read from file '" file "'.")))))
                 "")
          tree (nml-tree s)]
      (if (and gets (not file)) (fail (msgs 1)))
      (if (and (:in-place options) (not file)) (warn (msgs 0)))
      (if debug (println tree))
      (cond gets  (nml-gets tree gets (:no-prefix options))
            sets  (let [out (nml-str (nml-sets tree sets))]
                    (if (and file (:in-place options))
                      (try (spit file out)
                           (catch Exception e
                             (fail (str "Could not write to file '" file "'."))))
                      (println (string/trim out))))
            :else (println (string/trim (nml-str tree)))))))

    (let [val (nml-get tree nml key)]
      (println (if no-prefix val (str nml ":" key "=" val))))))

;;(defn- nml-map [tree]
;; (let [f (fn [& children] nil)]
;;       (insta/transform ))

(defn- nml-name [x]
  (nml-str (second x)))

(defn- nml-parse [s start]
  (let [result (parse s :start start)]
    (if (insta/failure? result)
      (let [{t :text l :line c :column} result]
        (fail (str "Parse error at line " l " column " c ":")
              t
              (str (apply str (repeat (- c 1) " ")) "^")))
      result)))
  
(defn- nml-sets [tree sets]
  (loop [t tree s sets]
    (if (empty? s)
