Your IP : 3.145.37.211


Current Path : /opt/alt/python310/lib64/python3.10/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/lib2to3/__pycache__/btm_utils.cpython-310.opt-2.pyc

o

6��f�&�@sz	ddlmZddlmZmZddlmZmZeZeZ	ej
ZeZdZ
dZdZGdd�de�Zdd
d�Zdd
�Zdd�Zd	S)�)�pytree)�grammar�token)�pattern_symbols�python_symbols���������c@s8eZdZ	ddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�MinNodeNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)�type�name�children�leaf�parent�alternatives�group)�selfrr�r�8/opt/alt/python310/lib64/python3.10/lib2to3/btm_utils.py�__init__s
zMinNode.__init__cCst|j�dt|j�S)N� )�strrr)rrrr�__repr__szMinNode.__repr__cCs�	|}g}|ru|jtkr1|j�|�t|j�t|j�kr)t|j�g}g|_|j}q|j}d}	|S|jtkrZ|j	�|�t|j	�t|j�krRt
|j	�}g|_	|j}q|j}d}	|S|jtjkrj|j
rj|�|j
�n|�|j�|j}|s|S�N)r�TYPE_ALTERNATIVESr�append�lenr
�tupler�
TYPE_GROUPr�get_characteristic_subpattern�token_labels�NAMEr)r�node�subprrr�leaf_to_root!s@

�
	��"zMinNode.leaf_to_rootcCs(	|��D]}|��}|r|SqdSr)�leavesr$)r�lr#rrr�get_linear_subpatternKs��zMinNode.get_linear_subpatternccs2�	|jD]	}|��EdHq|js|VdSdSr)r
r%)r�childrrrr%`s�

�zMinNode.leaves)NN)�__name__�
__module__�__qualname__rrr$r'r%rrrrr
s
	*r
Nc
Cs�	d}|jtjkr|jd}|jtjkrJt|j�dkr%t|jd|�}�n�ttd�}|jD]}|j�	|�dr8q-t||�}|durG|j�
|�q-�nw|jtjkr�t|j�dkrvttd�}|jD]}t||�}|rn|j�
|�q_|jstd}�nKt|jd|�}�nA|jtj
k�r�t|jdtj�r�|jdjdkr�t|jd|�St|jdtj�r�|jdjdks�t|j�dkr�t|jdd�r�|jdjdkr�dSd}d}d}d	}d}	d	}
|jD].}|jtjkr�d	}|}n|jtjkr�d}|}	n|jtjkr�|}t|d��r|jd
k�rd}
q�|
�r"|jd}t|d��r!|jdk�r!|jd}n|jd}|jtjk�rU|jdk�r:ttd�}nItt|j��rKttt|j�d�}n8ttt|j�d�}n.|jtjk�rw|j�d
�}|tv�rott|d�}nttj|d�}n|jtjk�r�t||�}|�r�|	jdjdk�r�d}n|	jdjdk�r�nt�|�r�|du�r�|jdd�D]}t||�}|du�r�|j�
|��q�|�r�||_|S)N��)rr�(�[�valueTF�=��any�')rr�*�+r)r�symsZMatcherr
ZAlternativesr�reduce_treer
r�indexrZAlternativerZUnit�
isinstancerZLeafr0�hasattrZDetailsZRepeaterr r!�TYPE_ANY�getattr�pysyms�STRING�strip�tokens�NotImplementedErrorr)
r"rZnew_noder(ZreducedrZdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr8gs�



��


���
�

�




�r8cs�	t|t�s|St|�dkr|dSg}g}gd��g}d�|D]2}tt|dd���rRtt|�fdd���r<|�|�q tt|�fdd���rM|�|�q |�|�q |rX|}n	|r]|}n|ra|}t|td	�S)
Nrr,)�in�for�if�not�Nonez[]().,:cSst|�tuSr)rr��xrrr�<lambda>�sz/get_characteristic_subpattern.<locals>.<lambda>c�t|t�o|�vSr�r:rrH)�common_charsrrrJ�crKrrLrH)�common_namesrrrJrN)�key)r:�listrr3�rec_testr�max)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars�
subpatternr)rMrOrr�s:

�
�
�rccs<�	|D]}t|ttf�rt||�EdHq||�VqdSr)r:rQrrR)ZsequenceZ	test_funcrIrrrrRs��rRr)�rZpgen2rrZpygramrrr7r>ZopmaprAr r<rr�objectr
r8rrRrrrr�<module>s 
W%

?>