              (if (empty? @buffer-atom)
                (let [idx @index-atom]
                  (swap! index-atom inc)
-                 (nth s idx))
+                 (aget s idx))
                (let [buf @buffer-atom]
                  (swap! buffer-atom rest)
                  (first buf))))

(def float-pattern (re-pattern "([-+]?[0-9]+(\\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?"))
(def symbol-pattern (re-pattern "[:]?([^0-9/].*/)?([^0-9/][^/]*)"))

(defn- match-int
  [s]
  (let [groups (re-find int-pattern s)
        group3 (nth groups 2)]
    (if (coercive-not
         (or (undefined? group3)
             (< (.-length group3) 1)))
      0
      (let [negate (if (identical? "-" (nth groups 1)) -1 1)
            [n radix] (cond
                       (nth groups 3) [(nth groups 3) 10]
                       (nth groups 4) [(nth groups 4) 16]
                       (nth groups 5) [(nth groups 5) 8]
                       (nth groups 7) [(nth groups 7) (js/parseInt (nth groups 7))]
                       :default [nil nil])]
        (if (nil? n)
          nil
          (* negate (js/parseInt n radix)))))))


(defn- match-ratio
  [s]
  (let [groups (re-find* ratio-pattern s)
        numinator (aget groups 1)
        denominator (aget groups 2)]
    (/ (js/parseInt numinator) (js/parseInt denominator))))

(defn- match-float
  [s]
  (js/parseFloat s))

(defn- re-matches*
  [re s]
  (let [matches (.exec re s)]
    (when (and (coercive-not= matches nil)
               (identical? (aget matches 0) s))
      (if (== (alength matches) 1)
        (aget matches 0)
        matches))))

(defn- match-number
  [s]
  (cond
   (re-matches* int-pattern s) (match-int s)
   (re-matches* ratio-pattern s) (match-ratio s)
   (re-matches* float-pattern s) (match-float s)))

(defn escape-char-map [c]
  (case c
