(def parse-format (str)
  (rev (accum a
         (with (chars nil  i -1)
           (w/instring s str
             (whilet c (readc s)
               (case c 
                 #\# (do (a (coerce (rev chars) 'string))
                         (wipe chars)
                         (a (read s)))
                 #\~ (do (a (coerce (rev chars) 'string))
                         (wipe chars)
                         (readc s)
                         (a (list argsym (++ i))))
                     (push c chars))))
            (when chars
              (a (coerce (rev chars) 'string)))))))

From arc.arc ©