protected function processReferencePartState(): int
    {
        $lexer = $this->getLexer();
        if ($lexer->isEnd()) {
            // Text is finished and so does current reference.
            $this->flushReferenceBuffer();
            return self::STATE_FINISH;
        }
        $token = $lexer->readToken();
        if ($token->isReferencePart()) {
            // Putting token to buffer and continue.
            $this
                ->getReferenceBuffer()
                ->addToken($token);
            return self::STATE_REFERENCE_PART;
        }
        // Token doesn't belong to current reference, so it's finished on previous token.
        $this->flushReferenceBuffer();
        $lexer->unreadToken();
        return self::STATE_POINTER_PART; // Expecting next part of a pointer
    }