   (let [r (cond (= (safe-some-> args first) "local")
               (apply concat (apply
                 (partial map #(list :local 'set! %1 %2))
-                (map next (leave :odd (next args)))))
+                (map next (leave :even (next args)))))
               (= (safe-some-> args first first)
                  :varlist)
               `(do ~@(apply
                 (partial map #(list 'set! %1 %2))
-                (map next (leave :odd args))))
+                (map next (leave :even args))))
               (= "while" (first args))
               (get-while-statement args)
               (= "repeat" (first args))

   :exp exp-fn
   :prefixexp prefixexp-fn
   :var var-fn
   :explist explist-fn
   :varlist varlist-fn
   })

(comment
  (proteus/let-mutable
    [G__15153
     nil
     G__15154
     false
     i
     nil
     sum
     nil
     multi1
     nil
     multi2
     nil
     booleanValue
     nil
     _
     (do
       (clojure.core/when (clojure.core/not G__15154) (do (set! i 2)))
       (clojure.core/when
         (clojure.core/not G__15154)
         (do (set! booleanValue false)))
       (clojure.core/when
         (clojure.core/not G__15154)
         (do (set! multi1 1) (set! multi2 true)))
       (clojure.core/when
         (clojure.core/not G__15154)
         (clojure.core/while
           (< i 5)
           (clojure.core/when
             (clojure.core/not G__15154)
             (do (set! i (+ i 1))))))
       (clojure.core/when
         (clojure.core/not G__15154)
         ("repeat"
           (clojure.core/when
             (clojure.core/not G__15154)
             (do (set! i (+ i 1))))
           "until"
           (> i 10)))
       (clojure.core/when
         (clojure.core/not G__15154)
         (cond
           (> i 10)
           (clojure.core/when
             (clojure.core/not G__15154)
             (do (set! G__15154 true) (set! G__15153 "until")))
           (> i 3)
           (proteus/let-mutable
             [l
              "local_var"
              _
              (clojure.core/when
                (clojure.core/not G__15154)
                (do (set! G__15154 true) (set! G__15153 3)))])
           (== i 2)
           (clojure.core/when
             (clojure.core/not G__15154)
             (do (set! G__15154 true) (set! G__15153 44)))
           :else
           (clojure.core/when
             (clojure.core/not G__15154)
             (do (set! G__15154 true) (set! G__15153 55)))))
       (clojure.core/when (clojure.core/not G__15154) (do (set! sum 0)))
       (clojure.core/when
         (clojure.core/not G__15154)
         (clojure.core/doseq
           [j (clojure.core/range 1 100)]
           (clojure.core/when
             (clojure.core/not G__15154)
             (do (set! sum (+ sum j)))))))]
    G__15153)
(pprint (lua-parser (slurp "resources/test/basic.lua")))

(eval (insta/transform transform-map (lua-parser (slurp "resources/test/for.lua"))))


(defn get-repeat-statement [& args]
  (println "while-args:" args)
  (let [repeat-args (leave :odd (first args))]
    (println "repeat-args1:" repeat-args)
    `(repeat-until ~(second repeat-args)
       ~(first repeat-args))
    ))
(defn get-for-statement [& args]
  (println "for-args:" args)
  (let [for-args (leave :odd (first args))
        numeric? (not= (safe-some-> for-args first first) :namelist)
        for-body (if numeric?
                   (if (= (count for-args) 5)
                     (nth for-args 4)
                     (nth for-args 3))
                   (nth for-args 2))
        for-condition  (if numeric?
                         [(nth for-args 0) 
                        (if (= (count for-args) 5)
                           `(range ~(nth for-args 1) 
                                   ~(nth for-args 2)
                                   ~(nth for-args 3))
                           `(range ~(nth for-args 1) 
                                   ~(nth for-args 2)))]
                         [(vec (leave :even (next (first for-args))))
                          (unwrap (leave :even (next (second for-args))))
                          ]
                         )
        doseq-stmt `(doseq ~for-condition
                      ~for-body)
        ]
    (println "for-condition:" for-condition)
    (println "for-args1:" for-args)
    doseq-stmt
    ))

(defn get-if-statement [& args]
  (let [if-args (leave :odd (first args))
        if-args (mapcat identity
                        (map #(if (next %1) %1 [:else (first %1)])
                             (partition-all 2 if-args)))]
