U e5dGh@sdZddlZddlZddlTeehZeee hZ e e hZ eehZeeehBZdZddeDZejfddZd d Zd d Zd,d dZejdZde>dZdZeefddZ ddZ!ddZ"ddZ#ddZ$ddZ%ddZ&d d!Z'd"d#Z(d$d%Z)d&d'Z*d(d)Z+d-d*d+Z,dS).zInternal support module for sreN)*))ii1)si)i)iEii)ii)ii)ii)ii)ii)ii)ii)ii)ii)ii)iai)iics.i|]&}|D]tfdd|Dq qS)c3s|]}|kr|VqdSN).0jir#/usr/lib64/python3.8/sre_compile.py >sz.)tuple)rtrr r >s rcCs ||@r||M}||B|@Srr)flags add_flags del_flags TYPE_FLAGSrrr _combine_flagsAs rcCs|j}t}t}t}t}t}d} d} d} |t@r\|t@s\|t@rPt j } t j } t } n t j } t j} |D]|\} } | |krr|t@s|| || n|t@r|t| || n| | s|| || n| | }| s|t| ||n|| kr|t| ||nh|t||}|d| tkr2|t|f| |D]}|t||q@|t|||||<q`| tkrt| | | | \}}|t@r|t@r|tn(|s|tn| s|tn|t||}|dt||||||||<q`| tkr*|t@r |tn|tq`| |kr6|t@rLt d| ft!| dr| t"krn|t#n|t$||}|d|| d|| dt%|| d||t&|||||<nl|t'||}|d|| d|| dt%|| d||||||<| t"kr,|t(n|t)q`| t*kr| \}}}}|rj|t+||ddt%||t,||||r|t+||dddq`| |kr|| q`| |krD|| ||}|d| ddkr|dn*| d-\}}||krt d||t%|| d||t&|||||<q`| t.kr|| ||}|dt%|| ||t&|||||<q`| t/kr|| |t0@rt12| | } |t@rt32| | } n|t@rt42| | } || q`| t5kr|| g}|j}| dD]N} ||}|dt%|| ||t6||||d|||||<q|t|D]}|||||<qlq`| t7kr|| |t@rt8| } n|t@rt9| } || q`| t:kr |t@s|| n,|t@r|t;n| s |t<n|t=|| dq`| t>kr|| || dd||}|dt%|| d|| dr|t6||}|d|||d||<t%|| d||||||<n|||d||<q`t d| fq`dS)Nrz*internal: unsupported template operator %rz(look-behind requires fixed-width patternz%internal: unsupported operand type %r)?appendlen_LITERAL_CODES_REPEATING_CODES_SUCCESS_CODES _ASSERT_CODESSRE_FLAG_IGNORECASESRE_FLAG_LOCALESRE_FLAG_UNICODE_sreunicode_iscasedunicode_tolower_ignorecase_fixes ascii_iscased ascii_tolowerOP_LOCALE_IGNORE OP_IGNOREOP_UNICODE_IGNORE IN_UNI_IGNORE NOT_LITERALNEGATELITERALFAILUREIN_optimize_charset IN_LOC_IGNORE IN_IGNORE_compile_charsetANYSRE_FLAG_DOTALLANY_ALLSRE_FLAG_TEMPLATEerror_simple MAX_REPEAT REPEAT_ONEMIN_REPEAT_ONE_compileSUCCESSREPEAT MAX_UNTIL MIN_UNTIL SUBPATTERNMARKrgetwidthCALLATSRE_FLAG_MULTILINE AT_MULTILINEget AT_LOCALE AT_UNICODEBRANCHJUMPCATEGORY CH_LOCALE CH_UNICODEGROUPREFGROUPREF_LOC_IGNOREGROUPREF_IGNOREGROUPREF_UNI_IGNOREGROUPREF_EXISTS)codepatternremit_len LITERAL_CODESREPEATING_CODES SUCCESS_CODES ASSERT_CODESiscasedtolowerfixesopavloskipkcharsethascasedgrouprrphitail tailappendskipyesskipnorrr r=GsV                                                                 r=cCs|j}|D]\}}|||tkr$q |tkr6||q |tksF|tkr`||d||dq |tkrt||q |tkr||q |tkr|t @r|t |q|t @r|t |q||q t d|fq |tdS)Nrrz%internal: unsupported set operator %r)rr,r-RANGERANGE_UNI_IGNORECHARSETextend BIGCHARSETrNrrOr rPr8r.)rfrrVrXrarbrrr r3s,      r3c Csg}g}td}d}|D]\}} z,|tkr|rv|| } d|| <|rd| |krd|| D] } d|| <qV|s~|| r~d}nd|| <n|tkr&t| d| dd} |r|rt|| D]*} d|| <| |kr|| D] } d|| <qqnt|| D] } d|| <q|s$tt|| }n| D]} d|| <qn(|tkr@||| fn||| fWnZtk rt |dkr|dd7}Yq"|rd}|tkrt }||| fYnXqq"qg}d}| d|}|dkrԐq(t |dkrd}q(| d|}|dkr||t |fq(|||fq|dk r|D]>\}}||dkr\|t|fn|t||dffq6||7}|st |t |kr||fS||fSt |dkrt |}|t |f||7}||fSt|}i}td}d}t}tdd dD]V} || | d}||kr4|||| d<n$||| d<||<|d7}||7}qt |}|gt||dd<|t|f||7}||fS) NFrTriri) bytearrayr-rorangemapanyr,r IndexErrorrrpfind _mk_bitmaprqbytes_bytes_to_codesrs)rfr^fixupr`outrkcharmaprgrarbrcrerr runsqridatacompsmappingblockchunkrrr r0s                   r0rs0111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111cs8|tdddfddttd DS)Ncs"g|]}||dqS)rr)rr  _CODEBITS_intsrr sz_mk_bitmap..r) translate _BITS_TRANSrwr)bitsrrrrr r|sr|cCst|d}|S)NI) memoryviewcasttolist)barrr r~sr~cCsDt|dkrdS|d\}}|tkr<|ddko:t|dS|tkS)NrFrr)rrBr9 _UNIT_CODES)rirarbrrr r9s   r9cCsndgt|}tdt|D]L}||d}||||kr\|dkrNd||<q||d}q,|d||<q|S)aj Generate an overlap table for the following prefix. An overlap table is a table of the same size as the prefix which informs about the potential self-overlap for each index in the prefix: - if overlap[i] == 0, prefix[i:] can't overlap prefix[0:...] - if overlap[i] == k with 0 < k <= i, prefix[i-k+1:i+1] overlaps with prefix[0:k] rr)rrw)prefixtabler idxrrr _generate_overlap_tables  rcCs$|t@s dS|t@rtjStjSdSr)rr r!r"r%)rrrr _get_iscaseds rcCsg}|j}d}t|}|jD]\}}|tkrF|r<||r<q||q|tkr|\}} } } t|| | } | t@rz| t@rzqt| | \} }}|dkr|dk rt |}n|dk rt ||}| | |sqqqq||dfS||dfS)NTF) rrrr-rBrrr_get_literal_prefixrrr)rWrr prefixappend prefix_skipr^rarbrhrrriflags1prefix1 prefix_skip1got_allrrr rs4        rc Csd|js dS|jd\}}|tk r"qP|\}}}}t|||}|t@r|t@rdSqt|}|tkrz|rp||rpdS||fgS|tkrg}|j} |dD]B} | sdS| d\}}|tkr|r||s| ||fqdSq|S|t kr`|}|r\|D]f\}}|tkr||rZdSq|t kr|ddkr4dSt t |t |d|ddrdSq|SdS)Nrri)rrBrrrrr-rLrr/roryrxrw) rWrrarbrhrrr^rf charsetappendrirrr _get_charset_prefixsN           rc Csr|\}}|tkrt}|dkr8|tdd||gdSg}d}g}|t@rT|t@srt||\}}}|srt||}|j} | tt |} | dd} |rt } |dkr|r| t B} n |r| t B} | | |tkr| |n| t|dt}| t |t|r@| t ||dkrt |}| ||||t|n|r^t|\}} t|||t || || <dS)Nr)rDMAXCODErrINFOrrrrrrSRE_INFO_PREFIXSRE_INFO_LITERALSRE_INFO_CHARSETminrr0r3) rVrWrrcrjrrrfrrXrdmaskrgrrr _compile_infosR           rcCst|ttfSr) isinstancestrr})objrrr isstringSsrcCs8|jj|B}g}t|||t||j||t|Sr)staterrr=rrr>)rirrVrrr _codeVs    rcCsdddd|DS)N[%s], css$|]}dtjdd|fVqdS)z%#0*xrN)r!CODESIZErxrrr r fsz_hex_code..)joinrVrrr _hex_codeesrcsNddltdtttdfdddtdS)Nrrc sddfdd }fdd}d7}||kr||}|d7}t|}|tttttttfkrx||q2|tt t t t t ttfkr|}|d7}||d|t|fq2|tkr|}|d7}tt|}|||ddq2|tkr*|}|d7}tt|}|||d dq2|ttttfkrr|}|||||d|d||||7}q2|ttfkr||d \}} |d 7}||d || t|t| fq2|tkr||t||d t|d t7}q2|tkr|}|d7}t d !fdd||d t"j#D} |||| |d t"j#7}d7t$|D].} |t||d t|d t7}qdd8q2|t%t&t't(t)fkrΈ|}|d7}|||q2|t*kr|}|||||d|d7}q2|t+kr||}|||||d|rr|d||||7}||}|rf|d|||dn|tq |d7}q2|t,t-t.fkr||d\}} } | t/krd} |||| | ||d|d||||7}q2|t0kr||d \}}||||||d|d 7}q2|t1t2fkrp||d \}}||||||d|d ||||7}q2|t3kr||d\}}} } | t/krd} |||t4|| | ||d|d|t5@r^|d|d\}}|d||d|}|ddd!dd|Ddd!t6t||7|d||7|t7@rd7|d||d8||7}q2t8|q2d8dS)N)tocsX|dk r"||d|ff7}tdkr6dndfdddt|dS)Nz(to %d)z%*d%s :.z rend)addprint)rargs)labelslevel offset_widthstartrr print_ps  z!dis..dis_..print_cs"tdddt|dS)N rr)r)r)rrrr print_2xsz"dis..dis_..print_2rz %#02x (%r) rz%#02x %#02x (%r-%r)rtc3s|]}|tjjVqdSr)to_bytesr!r byteorderr)sysrr r sz$dis..dis_..branch MAXREPEATrz prefix_skipz prefixrrcss|]}d|VqdS)z%#02xNrrrrr r sz(%r)z overlapin)9OPCODESr>r.r4r6r@rAr,r-r+LITERAL_IGNORENOT_LITERAL_IGNORELITERAL_UNI_IGNORENOT_LITERAL_UNI_IGNORELITERAL_LOC_IGNORENOT_LITERAL_LOC_IGNOREchrrFrATCODESrNCHCODESr/r2r*r1rorprqrrrslistrr!rrwrCrQrSrTrRrMrLr?r;r<rrUASSERT ASSERT_NOTrbinrrxr ValueError)rrrrr raargrdrcrjrr rmaxr prefix_lenrrrVdis_rrrr)rr ros                                 zdis..dis_)rsetrrrrrr dishsrc Cst|r|}t||}nd}t||}|t@r>tt||jj}dg|jj }| D]\}}|||<q\t |||jj B||jj d|t|S)Nr)r sre_parseparserSRE_FLAG_DEBUGrrr groupdictgroupsitemsr!compilerr)rirrWrV groupindex indexgrouprer rrr rs(    r)NNN)r)-__doc__r!r sre_constantsr-r+rr? MIN_REPEATr:rr>r.rrrrr4r/r _equivalencesr$rrr=r3r0rrrrintr|r~r9rrrrrrrrrrrrrr  sH  $ 3    ,;