U e5d9@sVdZddlZedjZedjZedZedZedZ[Gdd d Z dS) zShared 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@seZdZdZddZddZddZdd Zd d Zd Z d dZ d#ddZ d$ddZ ddZ ddZddZddZddZddZd d!Zd"S)% ParserBaseziParser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.cCs|jtkrtddS)Nz)_markupbase.ParserBase must be subclassed) __class__r RuntimeErrorselfr#/usr/lib64/python3.8/_markupbase.py__init__s zParserBase.__init__cCs tddS)Nz.subclasses of ParserBase must override error())NotImplementedError)rmessagerrrerror szParserBase.errorcCsd|_d|_dS)Nrlinenooffsetrrrrreset$szParserBase.resetcCs |j|jfS)z&Return current line number and offset.rrrrrgetpos(szParserBase.getposcCsb||kr |S|j}|d||}|rN|j||_|d||}||d|_n|j|||_|S)N r )rawdatacountrrindexr)rijrZnlinesposrrr updatepos0s zParserBase.updateposc Cs|j}|d}|||dks&td|||ddkrB|dS|||ddkrZdSt|}|||ddkr||S||d kr||S|||\}}|d kr|S|d krd |_||kr||}|dkr||d|}|d kr||n |||dS|d kr)-rz--[rZdoctyperz"'Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ>linktypeattlistelementlinkz&unsupported '[' char in %s declarationz"unexpected '[' char in declarationz!unexpected %r char in declaration) rAssertionErrorlen parse_commentparse_marked_section _scan_name_decl_othercharsZ handle_decl unknown_decl_declstringlit_matchend_parse_doctype_subsetr ) rrrrnZdecltypecdatamnamerrrparse_declaration@s\                    zParserBase.parse_declarationr cCs|j}|||ddks"td||d|\}}|dkrB|S|dkr\t||d}n4|dkrvt||d}n|d||d||sdS|r|d}|||d|| dS) Nzrcdatatempignorecdatainclude>endifelseifz+unknown status keyword %r in marked sectionr ) rr&r*_markedsectionclosesearch_msmarkedsectioncloser startr,r.)rrreportrZsectNamermatchrrrr)s  zParserBase.parse_marked_sectioncCsj|j}|||ddkr$|dt||d}|sr$r#notationentityz)unknown declaration %r in internal subsetZ_parse_doctype_%;]rz%unexpected char after internal subsetz%unexpected char %r in internal subset)rr'rr r(r*getattrisspace) rr declstartposrr0rr1sr4Zmethrrrr/sp                  z ParserBase._parse_doctype_subsetcCsF|||\}}|dkrdS|j}d||dkrB|d|dSdS)Nr rr )r*rfind)rrrPr4rrrrr_parse_doctype_elementsz!ParserBase._parse_doctype_elementcCs|j}|||\}}|||d}|dkr2dS|dkrB|dS|||\}}|dkr^|S|||d}|dkrzdS|dkrd||dkr|d|d}ndS|||dr|d}q||dsdSn|||\}}|||d}|sdS|dkrDt||}|r&|}ndS|||d}|sDdS|d kr||dd krddS||d|\}}|dkr|S|||d}|sdS|dkrB|dSqBdS) Nr rr rr()'"#)rr*rRrOr-r.)rrrPrr4rr1r3rrr_parse_doctype_attlistsX       z!ParserBase._parse_doctype_attlistcCs|||\}}|dkr|S|j}|||d}|s:dS|dkrJ|dS|dkrnt||}|sddS|}q"|||\}}|dkr"|Sq"dS)Nrr r rrV)r*rr-r.)rrrPr4rrr1r3rrr_parse_doctype_notation=s"  z"ParserBase._parse_doctype_notationcCs|j}|||ddkrR|d}|||d}|s:dS|rP|d}q"qVq"n|}|||\}}|dkrr|S|j||d}|sdS|dkrt||}|r|}qdSqr|dkr|dS|||\}}|dkrr|SqrdS)Nr rKr rrVr)rrOr*r-r.)rrrPrrr1r4r3rrr_parse_doctype_entityTs4   z ParserBase._parse_doctype_entitycCs|j}t|}||krdSt||}|r\|}|}|t||krLdS||fS||||d|||ddS)N)Nr zexpected name token at %r) rr'_declname_matchgroupstriplowerr.rr )rrrPrr0r3rQr4rrrr*xs  zParserBase._scan_namecCsdS)Nr)rr2rrrr,szParserBase.unknown_declN)r )r )__name__ __module__ __qualname____doc__r r rrrr+r5r)r(r/rSrXrYrZr*r,rrrrrs" R  C 9$r) rcrecompilerDr\r-rGr?rArrrrrs