File: //proc/25637/root/usr/lib/python3.8/lib2to3/__pycache__/btm_utils.cpython-38.pyc
U
���מ7� @ s| d Z ddlmZ ddlmZmZ ddlmZmZ eZ eZ
ejZeZ
dZdZdZG dd � d e�Zddd�Zd
d� Zdd� Zd
S )z0Utility functions used by the btm_matcher module� )�pytree)�grammar�token)�pattern_symbols�python_symbols���������c @ s: e Zd ZdZd
dd�Zdd� Zdd� Zd d
� Zdd� ZdS )�MinNodez�This class serves as an intermediate representation of the
pattern tree during the conversion to sets of leaf-to-root
subpatternsNc C s. || _ || _g | _d| _d | _g | _g | _d S )NF)�type�name�children�leaf�parent�alternatives�group)�selfr r � r �</tmp/_install_python3/usr/lib/python3.8/lib2to3/btm_utils.py�__init__ s zMinNode.__init__c C s t | j�d t | j� S )N� )�strr r )r r r r �__repr__ s zMinNode.__repr__c C s� | }g }|r�|j tkr^|j�|� t|j�t|j�krRt|j�g}g |_|j}qn|j}d}q�|j tkr�|j �|� t|j �t|j�kr�t
|j �}g |_ |j}qn|j}d}q�|j tjkr�|j
r�|�|j
� n|�|j � |j}q|S )z�Internal method. Returns a characteristic path of the
pattern tree. This method must be run for all leaves until the
linear subpatterns are merged into a singleN)r �TYPE_ALTERNATIVESr �append�lenr
�tupler �
TYPE_GROUPr �get_characteristic_subpattern�token_labels�NAMEr )r �node�subpr r r �leaf_to_root! s8
zMinNode.leaf_to_rootc C s&