Your IP : 3.142.174.8


Current Path : /opt/alt/python311/lib64/python3.11/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/lib2to3/__pycache__/btm_matcher.cpython-311.opt-2.pyc

�

c��f����	dZddlZddlZddlmZddlmZddlmZGd�de	��Z
Gd	�d
e	��Ziad�Z
dS)z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec�4�eZdZ	ej��Zd�ZdS)�BMNodec�l�i|_g|_ttj��|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content��selfs �:/opt/alt/python311/lib64/python3.11/lib2to3/btm_matcher.py�__init__zBMNode.__init__s-�� "�������v�|�$�$��������N)�__name__�
__module__�__qualname__�	itertoolsrr�rrrrs5������I��I�O���E�����rrc�.�eZdZ	d�Zd�Zd�Zd�Zd�ZdS)�
BottomMatcherc��t��|_t��|_|jg|_g|_t
jd��|_dS)N�RefactoringTool)	�set�matchr�root�nodesr�logging�	getLogger�loggerrs rrzBottomMatcher.__init__sA���U�U��
��H�H��	��i�[��
�����'�(9�:�:����rc��	|j�|��t|j��}|���}|�||j���}|D]}|j�|���dS)N��start)r�appendr�pattern_tree�get_linear_subpattern�addr!)r�fixer�tree�linear�match_nodes�
match_nodes      r�	add_fixerzBottomMatcher.add_fixer%s���	�	
����5�!�!�!��5�-�.�.���+�+�-�-���h�h�v�T�Y�h�7�7��%�	,�	,�J���$�$�U�+�+�+�+�	,�	,rc	���	|s|gSt|dt��r\g}|dD]O}|�||���}|D]3}|�|�|dd�|�����4�P|S|d|jvrt��}||j|d<n|j|d}|dd�r |�|dd�|���}n|g}|S)Nrr'r)�
isinstance�tupler,�extendrr)r�patternr(r0�alternative�	end_nodes�end�	next_nodes        rr,zBottomMatcher.add1s'��?��	��7�N��g�a�j�%�(�(�	��K�&�q�z�
C�
C��!�H�H�[��H�>�>�	�$�C�C�C��&�&�t�x�x������S�'A�'A�B�B�B�B�C����q�z��!7�7�7�"�H�H�	�5>��&�w�q�z�2�2�"�2�7�1�:�>�	��q�r�r�{�
(� �H�H�W�Q�R�R�[�	�H�B�B�	�	�&�K�	��rc�8�	|j}tt��}|D]�}|}|r�d|_|jD]0}t|tj��r|jdkr	d|_n�1|j	dkr|j}n|j	}||j
vr3|j
|}|jD]}||�|���nV|j}|j
�
|j
jrnD||j
vr2|j
|}|jD]}||�|���|j
}|��|S)NT�;Fr)r!r�list�was_checked�childrenr4r�Leaf�value�typerrr)�parent)	r�leaves�current_ac_node�results�leaf�current_ast_node�child�
node_tokenr-s	         r�runzBottomMatcher.runSs���	��)���d�#�#���#	;�#	;�D�#��"�!
;�/3� �,�-�6���E�!�%���5�5��%�+��:L�:L�7<�(�4����#�(�A�-�-�!1�!7�J�J�!1�!6�J���!A�A�A�&5�&F�z�&R�O�!0�!7�@�@�����-�-�.>�?�?�?�?�@�'+�i�O�(�/�;�,�3�?�<��"�_�%E�E�E�*9�*J�:�*V��%4�%;�D�D�E�#�E�N�1�1�2B�C�C�C�C�#3�#:� �C#�!
;��D�rc�p��	td���fd���|j��td��dS)Nz
digraph g{c
�"��|j���D]s}|j|}td|j|jt	|��t|j��fz��|dkrt|j���|���tdS)Nz%d -> %d [label=%s] //%sr)r�keys�printr�	type_repr�strrr)�node�subnode_key�subnode�
print_nodes   �rrVz*BottomMatcher.print_ac.<locals>.print_node�s����#�4�9�9�;�;�
$�
$���/��<���0��w��
�I�k�,B�,B�C���DW�DW�X�Y�Z�Z�Z��!�#�#��'�/�*�*�*��
�7�#�#�#�#�

$�
$r�})rPr!)rrVs @r�print_aczBottomMatcher.print_ac�sP���F�
�l����	$�	$�	$�	$�	$�	�
�4�9����
�c�
�
�
�
�
rN)rrrrr2r,rLrXrrrrrsf������+�;�;�;�
,�
,�
,� � � �D6�6�6�p����rrc���tsGddlm}|j���D]'\}}t|��tkr
|t|<�(t�||��S)Nr)�python_symbols)�_type_reprs�pygramrZ�__dict__�itemsrC�int�
setdefault)�type_numrZ�name�vals    rrQrQ�sq���9�*�*�*�*�*�*�(�0�6�6�8�8�	9�	9�I�D�#��C�y�y�C���D��S�!1���!�!�(�H�5�5�5r)�
__author__r#r�collectionsrr
r�	btm_utilsr�objectrrr[rQrrr�<module>rhs���G�;�
���������#�#�#�#�#�#�������"�"�"�"�"�"������V����}�}�}�}�}�F�}�}�}�@��6�6�6�6�6r

?>