def arrparse(ts)
    ts = eat('[', ts)
    arr = []

    if ts[0][0] == ']'
      return arr, ts[1..-1]
    end

    v, ts = valparse(ts)
    arr << v

    if ts[0][0] == ']'
      return arr, ts[1..-1]
    end

    loop do
      ts = eat(',', ts)

      v, ts = valparse(ts)
      arr << v

      if ts[0][0] == ']'
        return arr, ts[1..-1]
      end
    end
  end
def arrparse(ts)
    ts = eat('[', ts)
    arr = []

    if ts[0][0] == ']'
      return arr, ts[1..-1]
    end

    v, ts = valparse(ts)
    arr << v

    if ts[0][0] == ']'
      return arr, ts[1..-1]
    end

    loop do
      ts = eat(',', ts)

      v, ts = valparse(ts)
      arr << v

      if ts[0][0] == ']'
        return arr, ts[1..-1]
      end
    end
  end
Parses an "array" in the sense of RFC 4627.
 Returns the parsed value and any trailing tokens.