[9@s}dZddlZejdjZejdjZejdZejdZejdZ[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 dddZ dddZ ddZ ddZddZddZddZddZd d!Zd"S)# ParserBaseziParser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.cCs"|jtkrtdndS)Nz)_markupbase.ParserBase must be subclassed) __class__r RuntimeError)selfr!/usr/lib/python3.4/_markupbase.py__init__szParserBase.__init__cCstddS)Nz.subclasses of ParserBase must override error())NotImplementedError)rmessagerrrerror szParserBase.errorcCsd|_d|_dS)Nr)linenooffset)rrrrreset$s zParserBase.resetcCs|j|jfS)z&Return current line number and offset.)r r)rrrrgetpos(szParserBase.getposcCs||kr|S|j}|jd||}|rm|j||_|jd||}||d|_n|j|||_|S)N r )rawdatacountr rindexr)rijrZnlinesposrrr updatepos0s  zParserBase.updateposc Cst|j}|d}|||dks5td|||ddkrW|dS|||ddkrudSt|}|||ddkr|j|S||d kr|j|S|j||\}}|d kr|S|d krd|_nxh||kro||}|dkro||d|}|d krZ|j|n |j||dS|d krt ||}|sdS|j }n|d kr|j||\} }n||jkr|d}nv|d krG|d kr|j |d|}q\|dkr7|j d|q\|j dn|j d|||d kr|SqWdS)Nz-rz--[rZdoctypez"'Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZattlistlinktypelinkelementz&unsupported '[' char in %s declarationz"unexpected '[' char in declarationz!unexpected %r char in declaration)rrr">relementrlinkr") rAssertionErrorlen parse_commentparse_marked_section _scan_name_decl_othercharsZ handle_decl unknown_decl_declstringlit_matchend_parse_doctype_subsetr ) rrrrnZdecltypecdatamnamerrrparse_declaration@sZ  "                 zParserBase.parse_declarationr cCs|j}|||ddks/td|j|d|\}}|dkr[|S|dkrtj||d}nD|dkrtj||d}n|jd ||d||sdS|r|jd}|j||d|n|j dS)Nzr7r:ignorer6r9>ifr=elser") rr%r)_markedsectionclosesearch_msmarkedsectioncloser startr+r-)rrreportrZsectNamermatchrrrr(s  &   zParserBase.parse_marked_sectioncCs|j}|||ddkr3|jdntj||d}|sSdS|r|jd}|j||d|n|jdS)Nz