Spade
Mini Shell
| Directory:~$ /lib64/python3.6/lib2to3/__pycache__/ |
| [Home] [System Details] [Kill Me] |
3
\��@shdZddlZddlZddlmZddlmZddlmZGdd�de �Z
Gd d
�d
e �Ziadd�Z
dS)
z+George Boutsioukis
<gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@seZdZej�Zdd�ZdS)�BMNodecCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content)�self�r�+/usr/lib64/python3.6/lib2to3/btm_matcher.py�__init__szBMNode.__init__N)�__name__�
__module__�__qualname__� itertoolsrrrrrrrsrc@s4eZdZdd�Zdd�Zdd�Zdd�Zd d
�ZdS)�
BottomMatchercCs0t�|_t�|_|jg|_g|_tjd�|_dS)NZRefactoringTool) �set�matchr�rootZnodesr �loggingZ getLoggerZlogger)rrrrrs
zBottomMatcher.__init__cCsL|jj|�t|j�}|j�}|j||jd�}x|D]}|jj|�q4WdS)N)�start)r �appendrZpattern_treeZget_linear_subpattern�addr)r�fixerZtreeZlinear�match_nodesZ
match_noderrr� add_fixer%s
zBottomMatcher.add_fixercCs�|s
|gSt|dt�rhg}xF|dD]:}|j||d�}x&|D]}|j|j|dd�|��q>Wq&W|S|d|jkr�t�}||j|d<n|j|d}|dd�r�|j|dd�|d�}n|g}|SdS)Nr)rr)�
isinstance�tupler�extendrr)r�patternrrZalternativeZ end_nodes�endZ next_noderrrr1s"
"zBottomMatcher.addc Cs0|j}tt�}�x|D�]}|}�x|�r&d|_x,|jD]"}t|tj�r8|jdkr8d|_Pq8W|j dkrp|j}n|j }||j
kr�|j
|}x�|jD]"}||kr�g||<||j|�q�Wnd|j}|j
dk r�|j
jr�P||j
k�r|j
|}x2|jD](}||j�k�rg||<||j|�q�W|j
}q$WqW|S)NT�;Fr)rr�listZwas_checkedZchildrenr!rZLeaf�value�typerr r�parent�keys) rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ
node_tokenrrrr�runSs>
zBottomMatcher.runcs*td��fdd���|j�td�dS)Nz
digraph
g{cs^xX|jj�D]J}|j|}td|j|jt|�t|j�f�|dkrNt|j��|�qWdS)Nz%d
-> %d [label=%s]
//%sr)rr+�printr� type_repr�strr r
)ZnodeZsubnode_keyZsubnode)�
print_noderrr0�s
z*BottomMatcher.print_ac.<locals>.print_node�})r-r)rr)r0r�print_ac�s
zBottomMatcher.print_acN)rrrrr rr,r2rrrrrs
"=rcCsHts<ddlm}x*|jj�D]\}}t|�tkr|t|<qWtj||�S)Nr)�python_symbols)�_type_reprsZpygramr3�__dict__�itemsr)�int�
setdefault)Ztype_numr3�name�valrrrr.�sr.)�
__author__rr�collectionsrrrZ btm_utilsr�objectrrr4r.rrrr�<module>s