a �DOg9�@sVdZddlZe�d�jZe�d�jZe�d�Ze�d�Ze�d�Z[Gdd �d �Z dS) z�Shared support for scanning document type declarations in HTML and XHTML. This module is used as a foundation for the html.parser module. It has no documented public API and should not be used directly. �Nz[a-zA-Z][-_.a-zA-Z0-9]*\s*z(\'[^\']*\'|"[^"]*")\s*z--\s*>z ]\s*]\s*>z]\s*>c@s�eZdZdZdd�Zdd�Zdd�Zdd �Zd d �Zd Z d d�Z d#dd�Z d$dd�Z dd�Z dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)%� ParserBaseziParser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.cCs|jturtd��dS)Nz)_markupbase.ParserBase must be subclassed)� __class__r� RuntimeError��self�r�#/usr/lib64/python3.9/_markupbase.py�__init__s �zParserBase.__init__cCs td��dS)Nz.subclasses of ParserBase must override error())�NotImplementedError)r�messagerrr�error s�zParserBase.errorcCsd|_d|_dS)N�r��lineno�offsetrrrr�reset$szParserBase.resetcCs |j|jfS)z&Return current line number and offset.rrrrr�getpos(szParserBase.getposcCsb||kr |S|j}|�d||�}|rN|j||_|�d||�}||d|_n|j|||_|S)N� r )�rawdata�countr�rindexr)r�i�jrZnlines�posrrr� updatepos0s zParserBase.updatepos�c Cs�|j}|d}|||d�dkr*|dS|||d�dvrBdSt|�}|||d�dkrh|�|�S||dkr~|�|�S|�||�\}}|dkr�|S|d kr�d |_||k�r�||}|dkr�||d|�}|d kr�|�|�n |�|�|dS|d v�r t||�}|�sdS|� �}n�|d v�r<|�||�\} }nt||jv�rR|d}n^|dk�r�|d k�rx|� |d|�}n$|d v�r�|� d|�n |� d�n|� d||�|dkr�|Sq�dS)N�r �>)�-r�����z--�[rZdoctyperz"'Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ>�attlist�elementZlinktype�linkz&unsupported '[' char in %s declarationz"unexpected '[' char in declarationz!unexpected %r char in declaration) r�len� parse_comment�parse_marked_section� _scan_name�_decl_othercharsZ handle_decl� unknown_decl�_declstringlit_match�end�_parse_doctype_subsetr ) rrrr�nZdecltype�c�data�m�namerrr�parse_declaration@sZ                  �zParserBase.parse_declarationr cCs�|j}|�|d|�\}}|dkr&|S|dvr@t�||d�}n8|dvrZt�||d�}n|�d||d|��d}|s�dS|r�|�d�}|�||d|��|�d�S)N�r>�ignoreZrcdataZincludeZcdataZtemp>�elseZendif�ifz+unknown status keyword %r in marked sectionr) rr'�_markedsectionclose�search�_msmarkedsectioncloser �startr)r+)rr�reportrZsectNamer�matchrrrr&�s  zParserBase.parse_marked_sectioncCsj|j}|||d�dkr$|�d�t�||d�}|sr)r;>Znotationr!r"Zentityz)unknown declaration %r in internal subsetZ_parse_doctype_�%�;�]rz%unexpected char after internal subsetz%unexpected char %r in internal subset)rr$rr r%r'�getattr�isspace) rr� declstartposrr-rr.�sr1�methrrrr,�sp     �             z ParserBase._parse_doctype_subsetcCsF|�||�\}}|dkrdS|j}d||d�vrB|�d|�dSdS)Nrrr )r'r�find)rrrFr1rrrrr�_parse_doctype_element�sz!ParserBase._parse_doctype_elementcCs�|j}|�||�\}}|||d�}|dkr2dS|dkrB|dS|�||�\}}|dkr^|S|||d�}|dkrzdS|dkr�d||d�vr�|�d|�d}ndS|||d���r�|d}q�||d�s�dSn|�||�\}}|||d�}|�sdS|dv�rDt||�}|�r&|��}ndS|||d�}|�sDdS|d k�r�||d�d k�rddS|�|d|�\}}|dk�r�|S|||d�}|�s�dS|dkrB|dSqBdS) Nr rrrr�(�)�'"�#)rr'rIrEr*r+)rrrFrr1rr.r0rrr�_parse_doctype_attlistsX       z!ParserBase._parse_doctype_attlistcCs�|�||�\}}|dkr|S|j}|||d�}|s:dS|dkrJ|dS|dvrnt||�}|sddS|��}q"|�||�\}}|dkr"|Sq"dS)Nrr rrrM)r'rr*r+)rrrFr1rrr.r0rrr�_parse_doctype_notation>s"  z"ParserBase._parse_doctype_notationcCs�|j}|||d�dkrR|d}|||d�}|s:dS|��rP|d}q"qVq"n|}|�||�\}}|dkrr|S|j||d�}|s�dS|dvr�t||�}|r�|��}q�dSqr|dkr�|dS|�||�\}}|dkrr|SqrdS)Nr rArrrMr)rrEr'r*r+)rrrFrrr.r1r0rrr�_parse_doctype_entityUs4   z ParserBase._parse_doctype_entitycCs�|j}t|�}||krdSt||�}|r\|��}|��}|t|�|krLdS|��|��fS|�||�|�d|||d��dS)N)Nrzexpected name token at %r�) rr$�_declname_match�group�strip�lowerr+rr )rrrFrr-r0rGr1rrrr'ys  �zParserBase._scan_namecCsdS)Nr)rr/rrrr)�szParserBase.unknown_declN)r )r )�__name__� __module__� __qualname__�__doc__r r rrrr(r2r&r%r,rJrOrPrQr'r)rrrrrs" R  C 9$r) rZ�re�compiler<rSr*r?r7r9rrrrr�s