def __parse_number(self):
        """Parse a numeric literal."""
        literal_buffer = []
        all_digits = True
    
        while not self.__scanner.at_end:
            peek = self.__scanner.peek_next_ubyte()
            if ((peek != '+') and (peek != '-') and (peek != 'e') and
                    (peek != 'E') and (peek != '.') and
                    (not '0' <= peek <= '9')):
                break
      
            if len(literal_buffer) >= 100:
                self.__error("numeric literal too long (limit 100 characters)")
      
            next_char = self.__scanner.read_ubyte()
            all_digits = all_digits and '0' <= next_char <= '9'
            literal_buffer.append(next_char)
    
        if all_digits and len(literal_buffer) <= 18:
            value = 0
            for digit in literal_buffer:
                value = (value * 10) + ord(digit) - ord('0')
            return value

        number_string = ''.join(literal_buffer)
        if (number_string.find('.') < 0 and
                number_string.find('e') < 0 and
                number_string.find('E') < 0):
            try:
                return long(number_string)
            except ValueError:
                self.__error(
                    "Could not parse number as long '%s'" % number_string)
        else:
            try:
                return float(number_string)
            except ValueError:
                self.__error(
                    "Could not parse number as float '%s'" % number_string)
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/json_lib/parser.py/JsonParser.__parse_number/original