AlkantarClanX12

Your IP : 18.118.137.113


Current Path : /proc/self/root/lib64/python3.8/lib2to3/__pycache__/
Upload File :
Current File : //proc/self/root/lib64/python3.8/lib2to3/__pycache__/btm_matcher.cpython-38.opt-2.pyc

U

e5d��@shdZddlZddlZddlmZddlmZddlmZGdd�de	�Z
Gd	d
�d
e	�Ziadd�Z
dS)
z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@seZdZe��Zdd�ZdS)�BMNodecCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content��self�r�+/usr/lib64/python3.8/lib2to3/btm_matcher.py�__init__szBMNode.__init__N)�__name__�
__module__�__qualname__�	itertoolsrrrrrrrsrc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
BottomMatchercCs0t�|_t�|_|jg|_g|_t�d�|_dS)NZRefactoringTool)	�set�matchr�rootZnodesr	�loggingZ	getLoggerZloggerrrrrrs

zBottomMatcher.__init__cCsH|j�|�t|j�}|��}|j||jd�}|D]}|j�|�q2dS)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�r`g}|dD]6}|j||d�}|D]}|�|�|dd�|��q:q$|S|d|jkr�t�}||j|d<n|j|d}|dd�r�|j|dd�|d�}n|g}|SdS)Nrrr)�
isinstance�tupler�extendrr)r�patternrr!�alternativeZ	end_nodes�endZ	next_noderrrr1s"zBottomMatcher.addc	Cs�|j}tt�}|D]�}|}|rd|_|jD]$}t|tj�r*|jdkr*d|_qPq*|j	dkrb|j}n|j	}||j
kr�|j
|}|jD]}||�|�q�nH|j}|j
dk	r�|j
jr�q||j
kr�|j
|}|jD]}||�|�q�|j
}qq|S)NT�;Fr)rr�listZwas_checkedZchildrenr#rZLeaf�value�typerr	r�parent)	rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ
node_tokenr rrr�runSs8





�



zBottomMatcher.runcs*td��fdd���|j�td�dS)Nz
digraph g{csZ|j��D]J}|j|}td|j|jt|�t|j�f�|dkrLt|j��|�q
dS)Nz%d -> %d [label=%s] //%sr)r�keys�printr�	type_repr�strr	r
)ZnodeZsubnode_keyZsubnode��
print_noderrr4�s
�
z*BottomMatcher.print_ac.<locals>.print_node�})r0rrrr3r�print_ac�s
zBottomMatcher.print_acN)rrrrr"rr.r6rrrrrs
"8rcCsDts8ddlm}|j��D]\}}t|�tkr|t|<qt�||�S)Nr)�python_symbols)�_type_reprsZpygramr7�__dict__�itemsr,�int�
setdefault)Ztype_numr7�name�valrrrr1�s
r1)�
__author__rr�collectionsrrrZ	btm_utilsr�objectrrr8r1rrrr�<module>s