a �DOgK�� @s�dZddlTdZdZed�Zed�Zed�Zed�Zed �Z ee e h�Z ee eeeeeh�Zeed �feed �feed �feed �feed�feed�feed�feed�fd�Zeefeefeefeeefgfeeefgfeeefgfeeefgfeeefgfeeefgfee fd� Z!e"e#e$e%e&e'e(e)d�Z*e'e#Be)BZ+e,e(BZ-Gdd�de.�Z/Gdd�d�Z0Gdd�d�Z1Gdd�d�Z2dd�Z3dd �Z4d!d"�Z5d#d$�Z6d3d&d'�Z7d(d)�Z8d*d+�Z9d4d-d.�Z:d/d0�Z;d1d2�Z������)r;r:rG� MAXREPEATr0�min�max�CALL� SUBPATTERN� _REPEATCODES� _UNITCODES�GROUPREFr9rrJ�SUCCESS) r#�lo�hirOrPr�j�l�hrrrr0�sZ                  zSubPattern.getwidth)N)r) rrrr$rIrUrVrZr\r_r`r(r0rrrrr8ns  (r8c@sbeZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Ze d d��Z dd�Z dd�Z ddd�Z dS)� TokenizercCs@t|t�|_||_|js"t|d�}||_d|_d|_|��dS)N�latin1r)rKrE�istext�string�decoded_stringrY�next�_Tokenizer__next)r#rtrrrr$�s  zTokenizer.__init__cCs�|j}z|j|}Wnty.d|_YdS0|dkr�|d7}z||j|7}Wn,ty~td|jt|j�d�d�Yn0|d|_||_dS)Nr r>zbad escape (end of pattern))rYru� IndexErrorrvr*rtr&)r#rY�charrrr�__next�s$  �� zTokenizer.__nextcCs||jkr|��dSdS)NTF�rvrw)r#ryrrr�match�s zTokenizer.matchcCs|j}|��|Sr%r{)r#�thisrrrr+�sz Tokenizer.getcCs8d}t|�D]&}|j}||vr"q4||7}|��q |S�Nr<)�rangervrw)r#�n�charset�result�_�crrr�getwhiles  zTokenizer.getwhilecCsld}|j}|��|dur@|s,|�d|��|�d|t|���||kr^|sh|�d|d��qh||7}q|S)Nr<zmissing zmissing %s, unterminated namer>)rvrwr*r&)r#� terminatorr,r�r�rrr�getuntil s � zTokenizer.getuntilcCs|jt|jpd�Sr~�rYr&rvr"rrr�possz Tokenizer.poscCs|jt|jpd�Sr~r�r"rrr�tellszTokenizer.tellcCs||_|��dSr%)rYrwrXrrr�seek!szTokenizer.seekrcCst||j|��|�Sr%)r*rtr�)r#�msg�offsetrrrr*%szTokenizer.errorN)r)rrrr$rwr|r+r�r�r7r�r�r�r*rrrrrq�s   rqc Cs�t�|�}|r|St�|�}|r0|dtur0|S�zL|dd�}|dkr�||�dt�7}t|�dkrx|�d|t|���tt |dd�d�fWS|dkr�|j r�||�dt�7}t|�d kr�|�d|t|���tt |dd�d�fWS|d k�rN|j �rN||�d t�7}t|�d k�r*|�d|t|���t |dd�d�}t |�t|fWS|d k�r�|j �r�ddl }|� d��s~|�d��|�dd�}zt|�|��}Wn4ttf�y�|�d|t|�td���Yn0t|fWS|tv�r0||�dt�7}t |dd�d �}|dk�r&|�d|t|���t|fWS|tv�r>t�t|�dk�r||tv�rj|�d|t|���tt|d�fWSWnt�y�Yn0|�d|t|���dS)Nrr>rbr��incomplete escape %s�r��U�� �N�{� missing {�}�character name�undefined character name %r�\N{}���.octal escape value %s outside of range 0-0o377� bad escape %s)�ESCAPESr+� CATEGORIESrFr�� HEXDIGITSr&r*�LITERAL�intrs�chr� unicodedatar|r��ord�lookup�KeyError� TypeError� OCTDIGITS�DIGITS� ValueError� ASCIILETTERS)r5�escaper^r�r��charnamerrr� _class_escape(sp          �    ��   r�c Csft�|�}|r|St�|�}|r$|S�z|dd�}|dkr�||�dt�7}t|�dkrl|�d|t|���tt|dd�d�fWS|dkr�|j r�||�dt�7}t|�dkr�|�d|t|���tt|dd�d�fWS|d k�rB|j �rB||�d t�7}t|�d k�r|�d|t|���t|dd�d�}t |�t|fWS|d k�r�|j �r�d dl }|� d��sr|�d��|� dd�}zt|�|��}Wn4ttf�y�|�d|t|�td���Yn0t|fWS|dk�r||�dt�7}tt|dd�d �fWS|tv�r�|jtv�r�||��7}|dtv�r�|dtv�r�|jtv�r�||��7}t|dd�d �}|dk�r�|�d|t|���t|fWSt|dd��}||jk�r�|�|��s�|�dt|���|�||�t|fWS|�d|t|�d��t|�dk�r6|tv�r$|�d|t|���tt|d�fWSWnt�yLYn0|�d|t|���dS)Nr>rbrr�r�r�rr�r�r�r�r�rr�r�r�r�r�r��0r�r�r4�invalid group reference %dr�)r�r+r�r�r�r&r*r�r�rsr�r�r|r�r�r�r�r�r�r�rvr'r3r6rjr�r�)r5r�r9r^r�r�r��grouprrr�_escapeds�          �      �  ��   �   r�cCstt�|��Sr%)rC�dict�fromkeys)�itemsrrr�_uniq�sr�cCsVg}|j}|j}|��}|t||||d| o2| ��|d�sqDqt|�dkrX|dSt|�}d} |D].} | stq�| dur�| d} qh| d| krhq�qh|D] } | d=q�|�| �q`q�q`g} |D]h} t| �dkr��q@| d\} } | tur�| �| | f�q�| tu�r"| ddtu�r"| � | �q��q@q�|�tt | �f�|S|�t d|ff�|S)Nr>�|r) r(r|r��_parser&r8r�rF�NEGATE�extendr�rG)r5r9�verbose�nestedr�� itemsappend� sourcematch�start� subpattern�prefix�item�setrOrPrrr� _parse_sub�sN �       r�Fc/ Cs� t|�}|j}|j}|j}t} t} |j} | dur4� qR| dvr@� qR|�|rx| tvrTq"| dkrx|�} | dusv| dkr\q"q\q"| ddkr�t|| |�} || �q"| t vr�|t | | �f�q"| dk�r�|� �d} g}|j}|jdk�rddl }|j d|� �t|d d �|d �}|�} | du�r0|�d |� �| ��| d k�rF|�rF�qbn�| ddk�r`t|| �}n~|�r�| dv�r�|j| k�r�ddl }|j d| dk�r�dn| dk�r�dn| dk�r�dnd|� �dft|d d �t | | �f}|d��r<|�}|du�r |�d |� �| ��|d k�rL|dtu�r0|dd}||�|t | d�f��qb|ddk�rft||�}n>|dk�r�ddl }|j d|� �dt|d d �t | |�f}|dt k�s�|dt k�r�d| |f}|�|t| �dt|���|d}|d}||k�r*d| |f}|�|t| �dt|���|t||ff�n"|dtu�rV|dd}||��q t|�}| |�dk�r�|ddt u�r�|�r�|t|ddf�n ||d�n"|�r�|�dtdf�|t|f�q"| tv�r.|� �} | dk�rd\}}�nB| dk�rdt}}�n*| dk�r0dt}}�n| dk�r4|jdk�rX|t | | �f�q"dt}}d }}|jtv�r�||�7}�qj|d!��r�|jtv�r�||�7}�q�n|}|d��s�|t | | �f�|�| �q"|�r�t|�}|tk�r�td"��|�rBt|�}|tk�rtd"��||k�rB|�d#|� �| ��ntd$|f��|�rV|d%d�}nd}|�rr|ddtu�r�|�d&|� �| t| ���|ddtv�r�|�d'|� �| t| ���|ddt u�r�|dd\}}}}|du�r�|�s�|�s�|}|d��rt!|||ff|d%<nt"|||ff|d%<q"| d(k�rF|t#df�q"| d)k� r|� �d} d*}d}!d}d}|d�� rB|�}|du�r�|�d+��|d,k�r�|d-��r�|�$d.d/�}!|!�%��s�d0|!}|�|t|!�d��n�|d1��r�|�$d2d/�}!|!�%��sd0|!}|�|t|!�d��|j&�|!�}"|"du�rFd3|!}|�|t|!�d��|�'|"��sf|�d4t|!�d��|�(|"|�|t)|"f�q"n2|�}|du�r�|�d+��|�d5|t|�d���n�|d6k�r�d}�nx|dk�r |jdu�r�|�d7|� �| ��|�d2k�r�q"�q�q"�n6|d8v�r�d}#|d-k�r||�}|du�r>|�d+��|d9v�r`|�d:|t|�d��d%}#|j*}$|$du�r||j+|_*t,||||d�}|#dk�r�|$du�r�d|_*|d2��s�|�d;|� �| ��|d1k�r�|t-|#|ff�q"|t.|#|ff�q"�nJ|d)k� r�|�$d2d/�}%|%�%�� rL|j&�|%�}&|&du� rd3|%}|�|t|%�d��n�zt|%�}&|&dk� rdt/�Wn2t/� y�d0|%}|�|t|%�d�d�Yn0|&� s�|�d�� rTt2||||d�}(|jd>k� rX|�d?��nd}(|�d2�� sx|�d;|� �| ��|t3|&|'|(ff�q"n�|t4v� s�|dk� r*t5|||�})|)du� r|� r�|� rddl }|j d@|j6ddA�t|j6�dAk� r�dBnd | ft7|d d �|j8t9@r"|s"t:�q"|)\}}d}n|�dC|t|�d��|du� r�z|�;|!�}Wn>t� y�}*z$|�|*jf�q"| dDk� rB|tt?f�q"tdE|f��q"t@t|��ddd%�D]N},||,\}-}.|-t u� rh|.\}}}}|du� rh|� sh|� sh|||,|,d�<� qh|S)FNz|)�#rrr �[r>z"Possible nested set at position %dr�)� stacklevel�^zunterminated character set�]z-&~|zPossible set %s at position %d�-� difference�&� intersection�~zsymmetric difference�unionz&Possible set difference at position %drbzbad character range %s-%s�?)rr>r�+r�r�r<�,z"the repetition number is too largez"min repeat greater than max repeatzunsupported quantifier %rraznothing to repeatzmultiple repeat�.�(Tzunexpected end of pattern�P�<�>� group name�bad character in group name %r�=�)�unknown group name %rr4zunknown extension ?P�:zmissing ), unterminated commentz=!z missing flagz8bad inline flags: cannot turn off flags 'a', 'u' and 'L'z missing :r�z-bad inline flags: cannot turn off global flagz(bad inline flags: flag turned on and off) r+r�rsr*� TYPE_FLAGS�isalphar&r� GLOBAL_FLAGS)r5r9ryr�rr�flagr�rrrr�dsn                   r�cCsjt|t�r>|t@rtd��|t@s,|tO}qf|t@rftd��n(|t@rNtd��|t@rf|t@rftd��|S)Nz)cannot use LOCALE flag with a str patternz(ASCII and UNICODE flags are incompatiblez,cannot use UNICODE flag with a bytes patternz'ASCII and LOCALE flags are incompatible)rKrE�SRE_FLAG_LOCALEr��SRE_FLAG_ASCII�SRE_FLAG_UNICODE)�srcrrrr� fix_flags�s   rNcCs�t|�}|durt�}||_||_zt|||t@d�}Wn@tyxt�}|tB|_||_|�d�t||dd�}Yn0t||j j�|j _|j dur�|j dks�J�|� d��|j j D],}||j j kr�d|}t |||j j |��q�|t@r�|��|S)NrTr�zunbalanced parenthesisr�)rqrrrEr�r�rr�rr9rvr*r!r'�SRE_FLAG_DEBUGrI)rErr9r5r1�gr�rrr�parse�s0       rc s�t|���j}g�g�g��j}�����fdd�}�j}|�}|durL�q�|ddk�r�|d}|dk�rFd}��d�s���d ����d d �}|��r�z ||} Wnty�t d |��Yn0njzt |�} | dkr�t �Wn.t �y ��d |t |�d�d�Yn0| t k�r0��d| t |�d��|| t |�d��q�|dk�r��jtv�r|||�7}�jtv�r|||�7}|tt |dd�d�d@���q�|tv�rVd} �jtv�r0||�7}|tv�r0|dtv�r0�jtv�r0||�7}d} t |dd�d�}|dk�r$��d|t |���|t|��| �s�|t |dd��t |�d�nPztt|d�}Wn2t�y�|tv�r���d|t |���Yn0||�q:||�q:��rȈ�d����t|t��s�dd��D����fS)NcsX|�jkr��d||���r8��d�����dd�=��t��|f���d�dS)Nr�r<)r'r*r(�joinr&)rYr��r'�literal�literalsrr9rr�addgroup�s  z parse_template..addgrouprr r>rr<r�z missing '�z"parse_template..)rqr+r(� groupindexr|r*r�r�r�rxr�r�r&r)rvr�r�r�r�r�rrKrE) r5r9�sget�lappendrrr}r�r,rY�isoctalrrr�parse_template�s�        ��   �     "   �  ��      r#cCst|j}|jdd�}|\}}|dd�}z"|D]\}}||�p@|||<q.Wntyhtd|��Yn0|�|�S)Nrr�)r�rtrxr*r)�templater|r�emptyr'rrYr�rrr�expand_template*s   r&)F)rN)=�__doc__� sre_constantsr�r�� frozensetr�r�r�r�r�r�r�rhr�r�rFr�r��CATEGORYrir�r�r�ZAT_BEGINNING_STRINGZ AT_BOUNDARYZAT_NON_BOUNDARYZCATEGORY_DIGITZCATEGORY_NOT_DIGITZCATEGORY_SPACEZCATEGORY_NOT_SPACEZ CATEGORY_WORDZCATEGORY_NOT_WORDZ AT_END_STRINGr��SRE_FLAG_IGNORECASEr�SRE_FLAG_MULTILINE�SRE_FLAG_DOTALLr�r�SRE_FLAG_TEMPLATErr�r rr � Exceptionrrr8rqr�r�r�r�r�r�rrr#r&rrrr� sr         �       �� $rH<M: x< %U