public static function expectedToken(
        $expected,
        array $token = null,
        DocLexer $lexer = null
    ) {
        if ((null === $token) && $lexer) {
            $token = $lexer->lookahead;
        }

        $message = "Expected $expected, received ";

        if ($token) {
            $message .= "'{$token['value']}' at position {$token['position']}.";
        } else {
            $message .= 'end of string.';
        }

        return new self($message);
    }