             throw InternalError.NumberOverflow(offset: loc)
         }
         return value
-    }
-
-    private var numberIntoStringParser = NumberIntoStringParser()
-    private mutating func decodeNumberAsString(start: Int) throws -> JSON {
-        loc = start
-        try numberIntoStringParser.parse(input, start: &loc)
-
-        stringDecodingBuffer.removeAll(keepCapacity: true)
-        for i in start ..< loc {
-            stringDecodingBuffer.append(input[i])
-        }
-        stringDecodingBuffer.append(0)
-
-        guard let string = (stringDecodingBuffer.withUnsafeBufferPointer {
-            String.fromCString(UnsafePointer($0.baseAddress))
-        }) else {
-            // Should never fail - any problems with the number string should
-            // result in thrown errors above
-            fatalError("Internal error: Invalid numeric string")
-        }
-
-        return .String(string)
     }
 }
 

        }
    }

    private mutating func decodeNumberNegative(start: Int) throws -> JSON {
        loc = loc.successor()
        guard loc < input.count else {
            throw Error.EndOfStreamUnexpected
        }

        switch input[loc] {
        case Literal.zero:
            return try decodeNumberLeadingZero(start, sign: .Negative)

        case Literal.one...Literal.nine:
            return try decodeNumberPreDecimalDigits(start, sign: .Negative)

        default:
            throw Error.NumberSymbolMissingDigits(offset: start)
        }
    }

    private mutating func decodeNumberLeadingZero(start: Int, sign: Sign = .Positive) throws -> JSON {
        loc = loc.successor()
        guard loc < input.count else {
            return .Int(0)
        }

        switch (input[loc], sign) {
        case (Literal.PERIOD, _):
            return try decodeNumberDecimal(start, sign: sign, value: 0)

        case (_, .Negative):
            return .Double(-0.0)

        default:
            return .Int(0)
        }
    }

    private mutating func decodeNumberPreDecimalDigits(start: Int, sign: Sign = .Positive) throws -> JSON {
        var value = 0

        advancing: while loc < input.count {
            let c = input[loc]
            switch c {
            case Literal.zero...Literal.nine:
                guard case let (exponent, false) = Int.multiplyWithOverflow(10, value) else {
                    throw InternalError.NumberOverflow(offset: start)
                }

                guard case let (newValue, false) = Int.addWithOverflow(exponent, Int(c - Literal.zero)) else {
                    throw InternalError.NumberOverflow(offset: start)
                }

                value = newValue
                loc = loc.successor()

            case Literal.PERIOD:
                return try decodeNumberDecimal(start, sign: sign, value: Double(value))

            case Literal.e, Literal.E:
                return try detectingFloatingPointErrors(start) {
                    try decodeNumberExponent(start, sign: sign, value: Double(value))
                }

            default:
                break advancing
            }
        }

        guard case let (signedValue, false) = Int.multiplyWithOverflow(sign.rawValue, value) else {
            throw InternalError.NumberOverflow(offset: start)
        }

        return .Int(signedValue)
    }

    private mutating func decodeNumberDecimal(start: Int, sign: Sign, value: Double) throws -> JSON {
        loc = loc.successor()
        guard loc < input.count else {
            throw Error.EndOfStreamUnexpected
        }

        switch input[loc] {
        case Literal.zero...Literal.nine:
            return try detectingFloatingPointErrors(start) {
                try decodeNumberPostDecimalDigits(start, sign: sign, value: value)
            }

        default:
            throw Error.NumberMissingFractionalDigits(offset: start)
        }
    }

    private mutating func decodeNumberPostDecimalDigits(start: Int, sign: Sign, value inValue: Double) throws -> JSON {
        var value = inValue
        var position = 0.1

        advancing: while loc < input.count {
            let c = input[loc]
            switch c {
            case Literal.zero...Literal.nine:
                value += position * Double(c - Literal.zero)
                position /= 10
                loc = loc.successor()

            case Literal.e, Literal.E:
                return try decodeNumberExponent(start, sign: sign, value: value)

            default:
                break advancing
            }
        }

        return .Double(Double(sign.rawValue) * value)
    }

    private mutating func decodeNumberExponent(start: Int, sign: Sign, value: Double) throws -> JSON {
        loc = loc.successor()
        guard loc < input.count else {
            throw Error.EndOfStreamUnexpected
        }

        switch input[loc] {
        case Literal.zero...Literal.nine:
            return try decodeNumberExponentDigits(start, sign: sign, value: value, expSign: .Positive)

        case Literal.PLUS:
            return try decodeNumberExponentSign(start, sign: sign, value: value, expSign: .Positive)

        case Literal.MINUS:
            return try decodeNumberExponentSign(start, sign: sign, value: value, expSign: .Negative)

        default:
            throw Error.NumberSymbolMissingDigits(offset: start)
        }
    }

    private mutating func decodeNumberExponentSign(start: Int, sign: Sign, value: Double, expSign: Sign) throws -> JSON {
        loc = loc.successor()
        guard loc < input.count else {
            throw Error.EndOfStreamUnexpected
        }

        switch input[loc] {
        case Literal.zero...Literal.nine:
            return try decodeNumberExponentDigits(start, sign: sign, value: value, expSign: expSign)

        default:
            throw Error.NumberSymbolMissingDigits(offset: start)
        }
    }

    private mutating func decodeNumberExponentDigits(start: Int, sign: Sign, value: Double, expSign: Sign) throws -> JSON {
        var exponent: Double = 0

        advancing: while loc < input.count {
            let c = input[loc]
            switch c {
            case Literal.zero...Literal.nine:
                exponent = exponent * 10 + Double(c - Literal.zero)
                loc = loc.successor()

            default:
                break advancing
            }
        }

        return .Double(Double(sign.rawValue) * value * pow(10, Double(expSign.rawValue) * exponent))
    }

    private func detectingFloatingPointErrors<T>(loc: Int, @noescape _ f: () throws -> T) throws -> T {

    }
}

public extension JSONParser {

    /// Creates a `JSONParser` ready to parse UTF-8 encoded `NSData`.
