HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/lib2to3/__pycache__/btm_matcher.cpython-310.opt-2.pyc
o

�i��@sj	dZddlZddlZddlmZddlmZddlmZGdd�de	�Z
Gd	d
�d
e	�Ziadd�Z
dS)
z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@seZdZ	e��Zdd�ZdS)�BMNodecCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content��self�r�0/usr/local/lib/python3.10/lib2to3/btm_matcher.py�__init__s
zBMNode.__init__N)�__name__�
__module__�__qualname__�	itertoolsrrrrrrrsrc@s6eZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
BottomMatchercCs0t�|_t�|_|jg|_g|_t�d�|_dS)NZRefactoringTool)	�set�matchr�rootZnodesr	�logging�	getLogger�loggerrrrrrs

zBottomMatcher.__init__cCsJ	|j�|�t|j�}|��}|j||jd�}|D]}|j�|�qdS)N��start)r	�appendrZpattern_treeZget_linear_subpattern�addr)r�fixerZtreeZlinear�match_nodesZ
match_noderrr�	add_fixer%s
�zBottomMatcher.add_fixerc	Cs�	|s|gSt|dt�r1g}|dD]}|j||d�}|D]}|�|�|dd�|��qq|S|d|jvrCt�}||j|d<n|j|d}|dd�r]|j|dd�|d�}|S|g}|S)Nrrr)�
isinstance�tupler!�extendrr)r�patternrr#ZalternativeZ	end_nodes�endZ	next_noderrrr!1s(��zBottomMatcher.addc	Cs�	|j}tt�}|D]l}|}|rvd|_|jD]}t|tj�r(|jdkr(d|_nq|j	dkr2|j}n|j	}||j
vrM|j
|}|jD]	}||�|�qBn$|j}|j
durZ|j
jrZn||j
vrq|j
|}|jD]	}||�|�qg|j
}|sq
|S)NT�;Fr)rr�listZwas_checked�childrenr%rZLeaf�value�typerr	r �parent)	rZleavesZcurrent_ac_node�resultsZleafZcurrent_ast_node�childZ
node_tokenr"rrr�runSsB
�



�
�


��"zBottomMatcher.runcs,	td��fdd���|j�td�dS)Nz
digraph g{csZ|j��D]%}|j|}td|j|jt|�t|j�f�|dkr&t|j��|�qdS)Nz%d -> %d [label=%s] //%sr)r�keys�printr�	type_repr�strr	r
)ZnodeZsubnode_keyZsubnode��
print_noderrr8�s
�

�z*BottomMatcher.print_ac.<locals>.print_node�})r4rrrr7r�print_ac�s

zBottomMatcher.print_acN)rrrrr$r!r2r:rrrrrs"8rcCsDtsddlm}|j��D]\}}t|�tkr|t|<q
t�||�S)Nr)�python_symbols)�_type_reprsZpygramr;�__dict__�itemsr.�int�
setdefault)Ztype_numr;�name�valrrrr5�s�r5)�
__author__rr�collectionsrrrZ	btm_utilsr�objectrrr<r5rrrr�<module>s