File: //opt/alt/python37/lib64/python3.7/lib2to3/__pycache__/btm_utils.cpython-37.opt-1.pyc
B
��� (�� @ 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 �6/opt/alt/python37/lib64/python3.7/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 }x�|r�|j tkr`|j�|� t|j�t|j�krTt|j�g}g |_|j}q
n|j}d}P |j tkr�|j �|� t|j �t|j�kr�t
|j �}g |_ |j}q
n|j}d}P |j tjkr�|j
r�|�|j
� n|�|j � |j}q
W |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&