
    ;eFm                        	 d Z ddlZddlmZ dZi ad Z G d de          Z G d d	e          Z	 G d
 de          Z
d Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Zd ZdS )z#Guido van Rossum <guido@python.org>    N)StringIOic                     t           sGddlm} |j                                        D ]'\  }}t          |          t          k    r
|t           |<   (t                               | |           S )N   )python_symbols)_type_reprspygramr   __dict__itemstypeint
setdefault)type_numr   namevals       %/usr/lib/python3.11/lib2to3/pytree.py	type_reprr      sq     9****** (06688 	9 	9ID#CyyCDS!1!!(H555    c                       e Zd Z	 dZdZdZdZdZd Zd Z	dZ
d Zd Zd Zd	 Zd
 Zd Zd Zd Zed             Zed             Zd Zd Zd Zej        dk     rd ZdS dS )BaseN Fc                 8    	 t                               |           S Nobject__new__clsargskwdss      r   r   zBase.__new__1   s    E~~c"""r   c                 X    	 | j         |j         urt          S |                     |          S r   )	__class__NotImplemented_eqselfothers     r   __eq__zBase.__eq__6   s.    	
 >00!!xxr   c                     	 t           r   NotImplementedErrorr$   s     r   r#   zBase._eqB   s    	 "!r   c                     	 t           r   r)   r%   s    r   clonez
Base.cloneM       	
 "!r   c                     	 t           r   r)   r,   s    r   
post_orderzBase.post_orderU   r.   r   c                     	 t           r   r)   r,   s    r   	pre_orderzBase.pre_order]   r.   r   c                 >   	 t          |t                    s|g}g }d}| j        j        D ]5}|| u r||                    |           d} |                    |           6| j                                         || j        _        |D ]}| j        |_        d | _        d S NFT)
isinstancelistparentchildrenextendappendchanged)r%   new
l_childrenfoundchxs         r   replacezBase.replacee   s    = #t$$ 	%C
+& 	& 	&BTzz?%%c***!!"%%%%) 	# 	#A{AHHr   c                     	 | }t          |t                    s+|j        sd S |j        d         }t          |t                    +|j        S Nr   )r5   Leafr8   linenor%   nodes     r   
get_linenozBase.get_lineno|   sU    GT4(( 	$= =#D T4(( 	$ {r   c                 T    | j         r| j                                          d| _        d S NT)r7   r;   was_changedr,   s    r   r;   zBase.changed   s.    ; 	"K!!!r   c                     	 | j         rTt          | j         j                  D ]<\  }}|| u r1| j                                          | j         j        |= d | _         |c S ;d S d S r   )r7   	enumerater8   r;   )r%   irG   s      r   removezBase.remove   s    	 ; 	$T[%9::  44<<K''))),Q/"&DKHHH	  	 	 r   c                     	 | j         d S t          | j         j                  D ]3\  }}|| u r*	 | j         j        |dz            c S # t          $ r Y  d S w xY w4d S )Nr   )r7   rM   r8   
IndexErrorr%   rN   childs      r   next_siblingzBase.next_sibling   s    	 ;4 "$+"677 	  	 HAu}} ;/!4444!      444  	  	 s   A
AAc                     	 | j         d S t          | j         j                  D ])\  }}|| u r |dk    r d S | j         j        |dz
           c S *d S Nr   r   )r7   rM   r8   rR   s      r   prev_siblingzBase.prev_sibling   sz    	 ;4 "$+"677 	1 	1HAu}}6644{+AaC0000 	1 	1r   c              #   R   K   | j         D ]}|                                E d {V  d S r   )r8   leavesr%   rS   s     r   rY   zBase.leaves   sD      ] 	& 	&E||~~%%%%%%%%	& 	&r   c                 L    | j         dS d| j                                         z   S rV   )r7   depthr,   s    r   r\   z
Base.depth   s(    ;14;$$&&&&r   c                 (    	 | j         }|dS |j        S N )rT   prefix)r%   next_sibs     r   
get_suffixzBase.get_suffix   s$    	 $2r      r   c                 F    t          |                               d          S )Nascii)strencoder,   s    r   __str__zBase.__str__   s    t99##G,,,r   )__name__
__module____qualname__r   r7   r8   rK   was_checkedr   r'   __hash__r#   r-   r0   r2   rA   rH   r;   rO   propertyrT   rW   rY   r\   rb   sysversion_infori   r   r   r   r   r      s[        DFHKK# # #
   H	" 	" 	"" " "" " "" " "  .       
       X   1 1 X1& & &' ' '
   &  	- 	- 	- 	- 	- ! r   r   c                       e Zd Z	 	 	 	 ddZd Zd Zej        dk    reZd Z	d Z
d Zd	 Zed
             Zej        d             Zd Zd Zd ZdS )NodeNc                     	 || _         t          |          | _        | j        D ]	}| |_        
||| _        |r|d d          | _        d S d | _        d S r   )r   r6   r8   r7   r`   fixers_applied)r%   r   r8   contextr`   ru   r?   s          r   __init__zNode.__init__   sq    	 	X- 	 	BBII DK 	'"0"3D"&Dr   c                 \    	 | j         j        dt          | j                  d| j        dS N(, ))r!   rj   r   r   r8   r,   s    r   __repr__zNode.__repr__   s9    7#~666(3333#}}}. 	.r   c                 ^    	 d                     t          t          | j                            S r^   )joinmaprg   r8   r,   s    r   __unicode__zNode.__unicode__   s'    	
 wws3..///r   rc   c                 @    	 | j         | j        f|j         |j        fk    S r   )r   r8   r$   s     r   r#   zNode._eq   s"    -	4=)ej%.-IIIr   c                 Z    	 t          | j        d | j        D             | j                  S )Nc                 6    g | ]}|                                 S r   )r-   ).0r?   s     r   
<listcomp>zNode.clone.<locals>.<listcomp>  s     CCCr

CCCr   ru   )rs   r   r8   ru   r,   s    r   r-   z
Node.clone  s9    2DICCT]CCC#'#68 8 8 	8r   c              #   \   K   	 | j         D ]}|                                E d {V  | V  d S r   )r8   r0   rZ   s     r   r0   zNode.post_order  sN      8] 	* 	*E''))))))))))




r   c              #   \   K   	 | V  | j         D ]}|                                E d {V  d S r   )r8   r2   rZ   s     r   r2   zNode.pre_order  sR      7


] 	) 	)E((((((((((	) 	)r   c                 :    	 | j         sdS | j         d         j        S )Nr_   r   r8   r`   r,   s    r   r`   zNode.prefix  s(    	 } 	2}Q&&r   c                 <    | j         r|| j         d         _        d S d S rC   r   r%   r`   s     r   r`   zNode.prefix  s+    = 	-&,DM!###	- 	-r   c                 v    	 | |_         d | j        |         _         || j        |<   |                                  d S r   )r7   r8   r;   rR   s      r   	set_childzNode.set_child   s<    	 "&a ar   c                 t    	 | |_         | j                            ||           |                                  d S r   )r7   r8   insertr;   rR   s      r   insert_childzNode.insert_child*  s9    	 Q&&&r   c                 r    	 | |_         | j                            |           |                                  d S r   )r7   r8   r:   r;   rZ   s     r   append_childzNode.append_child3  s7    	 U###r   NNN)rj   rk   rl   rw   r}   r   rp   rq   ri   r#   r-   r0   r2   ro   r`   setterr   r   r   r   r   r   rs   rs      s       5  $' ' ' '2. . .0 0 0 &  J J J8 8 8
  ) ) ) ' ' X' ]- - ]-        r   rs   c                       e Zd Z	 dZdZdZddg fdZd Zd Ze	j
        dk    reZd Zd	 Zd
 Zd Zd Zed             Zej        d             ZdS )rD   r_   r   Nc                     	 ||\  | _         \  | _        | _        || _        || _        ||| _         |d d          | _        d S r   )_prefixrE   columnr   valueru   )r%   r   r   rv   r`   ru   s         r   rw   zLeaf.__init__F  sV    	 7>4DL44;	
!DL,QQQ/r   c                 B    	 | j         j        d| j        d| j        dS ry   )r!   rj   r   r   r,   s    r   r}   zLeaf.__repr__Y  s/    7#~666#yyy#zzz+ 	+r   c                 <    	 | j         t          | j                  z   S r   )r`   rg   r   r,   s    r   r   zLeaf.__unicode___  s    	
 {S__,,r   rc   c                 @    	 | j         | j        f|j         |j        fk    S r   )r   r   r$   s     r   r#   zLeaf._eqj  s"    -	4:&5:u{*CCCr   c                 n    	 t          | j        | j        | j        | j        | j        ff| j                  S )Nr   )rD   r   r   r`   rE   r   ru   r,   s    r   r-   z
Leaf.clonen  s=    2DItz[4;"<=#'#68 8 8 	8r   c              #      K   | V  d S r   r   r,   s    r   rY   zLeaf.leavest  s      




r   c              #      K   	 | V  d S r   r   r,   s    r   r0   zLeaf.post_orderw  s      8




r   c              #      K   	 | V  d S r   r   r,   s    r   r2   zLeaf.pre_order{  s      7




r   c                     	 | j         S r   )r   r,   s    r   r`   zLeaf.prefix  s    	 |r   c                 <    |                                   || _        d S r   )r;   r   r   s     r   r`   zLeaf.prefix  s    r   )rj   rk   rl   r   rE   r   rw   r}   r   rp   rq   ri   r#   r-   rY   r0   r2   ro   r`   r   r   r   r   rD   rD   =  s        1 GFF  "0 0 0 0&+ + +- - - &  D D D8 8 8         X ]  ]  r   rD   c                     	 |\  }}}}|s	|| j         v r-t          |          dk    r|d         S t          |||          S t          |||          S )Nr   r   )rv   )number2symbollenrs   rD   )grraw_noder   r   rv   r8   s         r   convertr     ss     &."D%( 242+++ x==AA;D(G4444D%1111r   c                   D    e Zd Z	 dZdZdZd Zd Zd ZddZ	ddZ
d ZdS )	BasePatternNc                 8    	 t                               |           S r   r   r   s      r   r   zBasePattern.__new__  s    L~~c"""r   c                     t          | j                  | j        | j        g}|r|d         |d= |r|d         | j        j        dd                    t          t          |                    dS )Nrz   r{   r|   )	r   r   contentr   r!   rj   r   r   repr)r%   r   s     r   r}   zBasePattern.__repr__  sw    $)$$dlDI> 	tBx'R  	tBx'>222DIIc$oo4N4N4N4NOOr   c                     	 | S r   r   r,   s    r   optimizezBasePattern.optimize  s    	
 r   c                     	 | j         |j         | j         k    rdS | j        5d }|i }|                     ||          sdS |r|                    |           || j        r
||| j        <   dS r4   )r   r   	_submatchupdater   )r%   rG   resultsrs       r   matchzBasePattern.match  s    		 9 TY$)%;%;5<#A">>$** u "q!!!49!%GDItr   c                 f    	 t          |          dk    rdS |                     |d         |          S )Nr   Fr   )r   r   )r%   nodesr   s      r   	match_seqzBasePattern.match_seq  s5    	
 u::??5zz%(G,,,r   c              #   `   K   	 i }|r$|                      |d         |          r
d|fV  d S d S d S rV   )r   )r%   r   r   s      r   generate_matcheszBasePattern.generate_matches  sX      	
  	TZZa!,, 	Q$JJJJJ	 	 	 	r   r   )rj   rk   rl   r   r   r   r   r}   r   r   r   r   r   r   r   r   r     s         DGD# # #
P P P     2- - - -    r   r   c                   &    e Zd ZddZddZddZdS )LeafPatternNc                 :    	 | | || _         || _        || _        d S r   )r   r   r   )r%   r   r   r   s       r   rw   zLeafPattern.__init__  s.    
	 				r   c                 j    	 t          |t                    sdS t                              | ||          S NF)r5   rD   r   r   r%   rG   r   s      r   r   zLeafPattern.match
  s4    8$%% 	5  tW555r   c                 $    	 | j         |j        k    S r   )r   r   r   s      r   r   zLeafPattern._submatch  s    	 |tz))r   r   r   )rj   rk   rl   rw   r   r   r   r   r   r   r     sP           (6 6 6 6* * * * * *r   r   c                   "    e Zd ZdZddZddZdS )NodePatternFNc                     	 | |@t          |          }t          |          D ]!\  }}t          |t                    rd| _        "|| _        || _        || _        d S rJ   )r6   rM   r5   WildcardPattern	wildcardsr   r   r   )r%   r   r   r   rN   items         r   rw   zNodePattern.__init__$  sn    	 7mmG$W-- * *4dO44 *%)DN				r   c                    	 | j         rTt          | j        |j                  D ]7\  }}|t	          |j                  k    r||                    |            dS 8dS t	          | j                  t	          |j                  k    rdS t          | j        |j                  D ]\  }}|                    ||          s dS dS NTF)r   r   r   r8   r   r   zipr   )r%   rG   r   cr   
subpatternrS   s          r   r   zNodePattern._submatchA  s    	 > 	(t}EE    1DM*****q)))44 + 5t|DM 2 2225!$T\4=!A!A 	 	J##E733 uutr   r   r   )rj   rk   rl   r   rw   r   r   r   r   r   r      sA        I   :     r   r   c                   N    e Zd Z	 ddedfdZd ZddZddZd Zd Z	d	 Z
d
 ZdS )r   Nr   c                     	 |'t          t          t           |                    }|D ]}|| _        || _        || _        || _        d S r   )tupler   r   minmaxr   )r%   r   r   r   r   alts         r   rw   zWildcardPattern.__init__k  sY    	. Cw//00G  + +			r   c                 >   	 d }| j         It          | j                   dk    r1t          | j         d                   dk    r| j         d         d         }| j        dk    rM| j        dk    rB| j         t	          | j                  S |$| j        |j        k    r|                                S | j        dk    rft          |t                    rQ|j        dk    rF| j        |j        k    r6t          |j         | j        |j        z  | j        |j        z  |j                  S | S )Nr   r   )r   )	r   r   r   r   r   r   r   r5   r   )r%   r   s     r   r   zWildcardPattern.optimize  s   9
L$""s4<?';';q'@'@a+J8q==TX]]|#"	2222%49
+G+G!**,,,HMMj_EEMNaDI$@$@":#5#'8JN#:#'8JN#:#-?4 4 4 r   c                 2    	 |                      |g|          S r   )r   r   s      r   r   zWildcardPattern.match  s    5~~tfg...r   c                     	 |                      |          D ]P\  }}|t          |          k    r8|3|                    |           | j        rt	          |          || j        <    dS QdS r   )r   r   r   r   r6   )r%   r   r   r   r   s        r   r   zWildcardPattern.match_seq  s|    B))%00 	 	DAqCJJ&NN1%%%y 9-1%[[	*tt  ur   c           	   #   0  K   	 | j         ^t          | j        dt          t          |          | j                  z             D ]#}i }| j        r|d |         || j        <   ||fV  $d S | j        dk    r|                     |          V  d S t          t          d          r$t          j	        }t                      t          _	        	 |                     |d          D ]$\  }}| j        r|d |         || j        <   ||fV  %nJ# t          $ r= |                     |          D ]$\  }}| j        r|d |         || j        <   ||fV  %Y nw xY wt          t          d          r|t          _	        d S d S # t          t          d          r|t          _	        w xY w)Nr   	bare_namegetrefcountr   )r   ranger   r   r   r   _bare_name_matcheshasattrrp   stderrr   _recursive_matchesRuntimeError_iterative_matches)r%   r   countr   save_stderrs        r   r   z WildcardPattern.generate_matches  s     
	 <txSUTX-F-F)FGG  9 1#(%=AdiLQh	 
 Y+%%))%0000000 sM** (!j%ZZ
- $ 7 7q A A # #HE1y 5',VeV}$)(NNNN#   # # # !% 7 7 > > # #HE1y 5',VeV}$)(NNNN# ## 3.. -!,CJJJ- -73.. -!,CJ,,,,s+   ;D E2 AE
E2 	E

E2 2#Fc              #   
  K   	 t          |          }d| j        k    rdi fV  g }| j        D ]5}t          ||          D ]"\  }}||fV  |                    ||f           #6|rg }|D ]\  }}	||k     r|| j        k    r}| j        D ]u}t          |||d                    D ]Z\  }
}|
dk    rOi }|                    |	           |                    |           ||
z   |fV  |                    ||
z   |f           [v|}|d S d S rC   )r   r   r   r   r:   r   r   )r%   r   nodelenr   r   r   r   new_resultsc0r0c1r1s               r   r   z"WildcardPattern._iterative_matches  s     6e**==R%KKK< 	' 	'C(e44 ' '1d


1v&&&&'
  	"K! 
A 
AB<<B$(NN#| A A&6sE"##J&G&G A AFB!Avv$& ! !&(2gqj 0 0 0 + 2 2BGQ< @ @ @A "G  	" 	" 	" 	" 	"r   c                     	 d}i }d}t          |          }|sE||k     r?d}| j        D ]-}|d                             ||         |          r	|dz  }d} n.|s||k     ?|d |         || j        <   ||fS )Nr   FTr   )r   r   r   r   )r%   r   r   r   doner   leafs          r   r   z"WildcardPattern._bare_name_matches  s    6%jj 	53;;D  7==uq11 QJE DE  	53;; VeV}$)axr   c              #   @  K   	 || j         k    rdi fV  || j        k     r|| j        D ]v}t          ||          D ]a\  }}|                     ||d          |dz             D ]:\  }}i }|                    |           |                    |           ||z   |fV  ;bud S d S rV   )r   r   r   r   r   r   )	r%   r   r   r   r   r   r   r   r   s	            r   r   z"WildcardPattern._recursive_matches
  s      6DHR%KKK48| ) ).sE:: ) )FB"&"9"9%*eAg"N"N ) )B 2gqj((((	)) ) )r   r   )rj   rk   rl   HUGErw   r   r   r   r   r   r   r   r   r   r   r   r   ]  s        
  $4 ! ! ! !F  &/ / / /	 	 	 	+- +- +-Z" " ":   ) ) ) ) )r   r   c                   (    e Zd ZddZd Zd Zd ZdS )NegatedPatternNc                     	 | || _         d S r   )r   )r%   r   s     r   rw   zNegatedPattern.__init__  s    	 r   c                     dS r   r   rF   s     r   r   zNegatedPattern.match(  s    ur   c                 (    t          |          dk    S rC   )r   )r%   r   s     r   r   zNegatedPattern.match_seq,  s    5zzQr   c              #      K   | j         t          |          dk    rdi fV  d S d S | j                             |          D ]\  }} d S di fV  d S rC   )r   r   r   )r%   r   r   r   s       r   r   zNegatedPattern.generate_matches0  sr      <5zzQe  55e<<  1R%KKKKKr   r   )rj   rk   rl   rw   r   r   r   r   r   r   r   r     sU               	 	 	 	 	r   r   c              #   2  K   	 | sdi fV  d S | d         | dd          }}|                     |          D ]a\  }}|s||fV  t          |||d                    D ]:\  }}i }|                    |           |                    |           ||z   |fV  ;bd S rV   )r   r   )	patternsr   prestr   r   r   r   r   s	            r   r   r   <  s        %e1+x|4((// 	% 	%FB %"f.tU233Z@@ % %FBAHHRLLLHHRLLLr'1*$$$$	%		% 	%r   )
__author__rp   ior   r   r   r   r   r   rs   rD   r   r   r   r   r   r   r   r   r   r   <module>r      s   3
 



      6 6 6n- n- n- n- n-6 n- n- n-`k k k k k4 k k k\L L L L L4 L L L\2 2 2&S S S S S& S S Sl)* )* )* )* )*+ )* )* )*X: : : : :+ : : :zy) y) y) y) y)k y) y) y)x         [      F% % % % %r   