GraphQL\Language\Lexer::readToken PHP Method

readToken() private method

private readToken ( Token $prev ) : Token
$prev Token
return Token
    private function readToken(Token $prev)
    {
        $body = $this->source->body;
        $bodyLength = $this->source->length;
        $position = $this->positionAfterWhitespace($prev->end);
        $line = $this->line;
        $col = 1 + $position - $this->lineStart;
        if ($position >= $bodyLength) {
            return new Token(Token::EOF, $bodyLength, $bodyLength, $line, $col, $prev);
        }
        $code = Utils::charCodeAt($body, $position);
        // SourceCharacter
        if ($code < 0x20 && $code !== 0x9 && $code !== 0xa && $code !== 0xd) {
            throw new SyntaxError($this->source, $position, 'Cannot contain the invalid character ' . Utils::printCharCode($code));
        }
        switch ($code) {
            case 33:
                // !
                return new Token(Token::BANG, $position, $position + 1, $line, $col, $prev);
            case 35:
                // #
                return $this->readComment($position, $line, $col, $prev);
            case 36:
                // $
                return new Token(Token::DOLLAR, $position, $position + 1, $line, $col, $prev);
            case 40:
                // (
                return new Token(Token::PAREN_L, $position, $position + 1, $line, $col, $prev);
            case 41:
                // )
                return new Token(Token::PAREN_R, $position, $position + 1, $line, $col, $prev);
            case 46:
                // .
                if (Utils::charCodeAt($body, $position + 1) === 46 && Utils::charCodeAt($body, $position + 2) === 46) {
                    return new Token(Token::SPREAD, $position, $position + 3, $line, $col, $prev);
                }
                break;
            case 58:
                // :
                return new Token(Token::COLON, $position, $position + 1, $line, $col, $prev);
            case 61:
                // =
                return new Token(Token::EQUALS, $position, $position + 1, $line, $col, $prev);
            case 64:
                // @
                return new Token(Token::AT, $position, $position + 1, $line, $col, $prev);
            case 91:
                // [
                return new Token(Token::BRACKET_L, $position, $position + 1, $line, $col, $prev);
            case 93:
                // ]
                return new Token(Token::BRACKET_R, $position, $position + 1, $line, $col, $prev);
            case 123:
                // {
                return new Token(Token::BRACE_L, $position, $position + 1, $line, $col, $prev);
            case 124:
                // |
                return new Token(Token::PIPE, $position, $position + 1, $line, $col, $prev);
            case 125:
                // }
                return new Token(Token::BRACE_R, $position, $position + 1, $line, $col, $prev);
                // A-Z
            // A-Z
            case 65:
            case 66:
            case 67:
            case 68:
            case 69:
            case 70:
            case 71:
            case 72:
            case 73:
            case 74:
            case 75:
            case 76:
            case 77:
            case 78:
            case 79:
            case 80:
            case 81:
            case 82:
            case 83:
            case 84:
            case 85:
            case 86:
            case 87:
            case 88:
            case 89:
            case 90:
                // _
            // _
            case 95:
                // a-z
            // a-z
            case 97:
            case 98:
            case 99:
            case 100:
            case 101:
            case 102:
            case 103:
            case 104:
            case 105:
            case 106:
            case 107:
            case 108:
            case 109:
            case 110:
            case 111:
            case 112:
            case 113:
            case 114:
            case 115:
            case 116:
            case 117:
            case 118:
            case 119:
            case 120:
            case 121:
            case 122:
                return $this->readName($position, $line, $col, $prev);
                // -
            // -
            case 45:
                // 0-9
            // 0-9
            case 48:
            case 49:
            case 50:
            case 51:
            case 52:
            case 53:
            case 54:
            case 55:
            case 56:
            case 57:
                return $this->readNumber($position, $code, $line, $col, $prev);
                // "
            // "
            case 34:
                return $this->readString($position, $line, $col, $prev);
        }
        $errMessage = $code === 39 ? "Unexpected single quote character ('), did you mean to use " . 'a double quote (")?' : 'Cannot parse the unexpected character ' . Utils::printCharCode($code) . '.';
        throw new SyntaxError($this->source, $position, $errMessage);
    }