GraphQL\Language\Lexer::readNumber PHP Метод

readNumber() приватный Метод

Int: -?(0|[1-9][0-9]*) Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
private readNumber ( integer $start, string $firstCode, integer $line, integer $col, Token $prev ) : Token
$start integer
$firstCode string
$line integer
$col integer
$prev Token
Результат Token
    private function readNumber($start, $firstCode, $line, $col, Token $prev)
    {
        $code = $firstCode;
        $body = $this->source->body;
        $position = $start;
        $isFloat = false;
        if ($code === 45) {
            // -
            $code = Utils::charCodeAt($body, ++$position);
        }
        // guard against leading zero's
        if ($code === 48) {
            // 0
            $code = Utils::charCodeAt($body, ++$position);
            if ($code >= 48 && $code <= 57) {
                throw new SyntaxError($this->source, $position, "Invalid number, unexpected digit after 0: " . Utils::printCharCode($code));
            }
        } else {
            $position = $this->readDigits($position, $code);
            $code = Utils::charCodeAt($body, $position);
        }
        if ($code === 46) {
            // .
            $isFloat = true;
            $code = Utils::charCodeAt($body, ++$position);
            $position = $this->readDigits($position, $code);
            $code = Utils::charCodeAt($body, $position);
        }
        if ($code === 69 || $code === 101) {
            // E e
            $isFloat = true;
            $code = Utils::charCodeAt($body, ++$position);
            if ($code === 43 || $code === 45) {
                // + -
                $code = Utils::charCodeAt($body, ++$position);
            }
            $position = $this->readDigits($position, $code);
        }
        return new Token($isFloat ? Token::FLOAT : Token::INT, $start, $position, $line, $col, $prev, mb_substr($body, $start, $position - $start, 'UTF-8'));
    }