U e5d9ã@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@seZdZdZdd„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|jtkrtdƒ‚dS)Nz)_markupbase.ParserBase must be subclassed)Ú __class__rÚ RuntimeError©Úself©rú#/usr/lib64/python3.8/_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…dkrBdSt|ƒ}|||d…dkrh| |¡S||dkr~| |¡S| ||¡\}}|dkrš|S|d kr¨d |_||kr¾||}|dkrø||d|…}|d kræ| |¡n | |¡|dS|d kr t||ƒ}|sdS|  ¡}n|d kr<| ||¡\} }nt||jkrR|d}n^|dkrž|d krx|  |d|¡}n$|d kr’|  d|¡n |  d¡n|  d||¡|dkr¨|Sq¨dS)Nér ú>)ú-réÿÿÿÿz--ú[rZdoctyperz"'Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ>ÚlinktypeÚattlistÚelementÚ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|dkr@t ||d¡}n4|dkrZt ||d¡}n| d||d|…¡|s|dS|r | d¡}| ||d|…¡| d¡S)Nér>ÚrcdataÚtempÚignoreÚcdataÚinclude>ÚendifÚelseÚ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@Zhandle_commentr,)rrrArrBrrrrr&¨s  zParserBase.parse_commentc Cs*|j}t|ƒ}|}||kr&||}|dkr0|||d…}|dkrJdS|dkrp| ||d¡| d|¡|d|kr€dS|d|krdS|||d…dkrÀ|j|d d }|d kr|Sq| |d|¡\}}|dkràdS|d kr| ||d¡| d |¡t|d |ƒ} | ||ƒ}|d kr$|Sq|dkr†|d|krLdS| |d|¡\}}|d krn|S||dkr$|d}q|dkrö|d}||kr¼|| ¡r¼|d}q˜||krð||dkrØ|S| ||¡| d¡ndSq| ¡r |d}q| ||¡| d|¡qdS)Núr#r"ÚnotationÚentityz)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/Úsr2Zmethrrrr-¶sp     ÿ             z ParserBase._parse_doctype_subsetcCsF| ||¡\}}|dkrdS|j}d||d…krB| d|¡dSdS)Nrrr )r(rÚfind)rrrNr2rrrrrÚ_parse_doctype_elementùsz!ParserBase._parse_doctype_elementcCs¶|j}| ||¡\}}|||d…}|dkr2dS|dkrB|dS| ||¡\}}|dkr^|S|||d…}|dkrzdS|dkrØd||d…kr¤| d|¡d}ndS|||d… ¡rÆ|d}q¨||d…sèdSn| ||¡\}}|||d…}|sdS|dkrDt||ƒ}|r&| ¡}ndS|||d…}|sDdS|d kr ||d…d krddS| |d|¡\}}|dkr†|S|||d…}|s dS|dkrB|dSqBdS) Nr rrrrú(ú)ú'"ú#)rr(rPrMr+r,)rrrNrr2rr/r1rrrÚ_parse_doctype_attlistsX       z!ParserBase._parse_doctype_attlistcCs| ||¡\}}|dkr|S|j}|||d…}|s:dS|dkrJ|dS|dkrnt||ƒ}|sddS| ¡}q"| ||¡\}}|dkr"|Sq"dS)Nrr rrrT)r(rr+r,)rrrNr2rrr/r1rrrÚ_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|dkr²t||ƒ}|r¬| ¡}qÞdSqr|dkrÂ|dS| ||¡\}}|dkrr|SqrdS)Nr rIrrrTr)rrMr(r+r,)rrrNrrr/r2r1rrrÚ_parse_doctype_entityTs4   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 )rrrNrr.r1rOr2rrrr(xs  ÿzParserBase._scan_namecCsdS)Nr)rr0rrrr*ŠszParserBase.unknown_declN)r )r )Ú__name__Ú __module__Ú __qualname__Ú__doc__r r rrrr)r3r'r&r-rQrVrWrXr(r*rrrrrs" R  C 9$r) raÚreÚcompilerBrZr+rEr=r?rrrrrÚs