0x1949 Team - FAZEMRX - MANAGER
Edit File: patcomp.cpython-310.pyc
o ��bc� � @ s� d Z dZddlZddlmZmZmZmZmZm Z ddl mZ ddl mZ G dd � d e �Zd d� ZG dd � d e�Zejejejdd�Zdd� Zdd� Zdd� ZdS )z�Pattern compiler. The grammar is taken from PatternGrammar.txt. The compiler compiles a pattern to a pytree.*Pattern instance. z#Guido van Rossum <guido@python.org>� N� )�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramc @ s e Zd ZdS )�PatternSyntaxErrorN)�__name__� __module__�__qualname__� r r �&/usr/lib/python3.10/lib2to3/patcomp.pyr s r c c sN � t jt jt jh}t�t�| �j�}|D ]}|\}}}}}||vr$|V qdS )z6Tokenizes a string suppressing significant whitespace.N) r �NEWLINE�INDENT�DEDENTr �generate_tokens�io�StringIO�readline) �input�skip�tokens� quintuple�type�value�start�end� line_textr r r �tokenize_wrapper s ���r! c @ s: e Zd Zd dd�Zddd�Zdd� Zd d d �Zdd� ZdS )�PatternCompilerNc C sZ |du r t j| _t j| _n t�|�| _t �| j�| _t j| _ t j | _tj| jt d�| _dS )z^Initializer. Takes an optional alternative filename for the pattern grammar. N)�convert)r �pattern_grammarr �pattern_symbols�symsr �load_grammar�Symbols�python_grammar� pygrammar�python_symbols�pysyms�Driver�pattern_convert)�self�grammar_filer r r �__init__( s zPatternCompiler.__init__Fc C sb t |�}z | jj||d�}W n tjy" } ztt|��d�d}~ww |r,| �|�|fS | �|�S )z=Compiles a pattern string to a nested pytree.*Pattern object.)�debugN)r! r �parse_tokensr � ParseErrorr �str�compile_node)r/ r r2 � with_treer �root�er r r �compile_pattern7 s �� zPatternCompiler.compile_patternc s� |j � jjkr|jd }|j � jjkr=� fdd�|jddd� D �}t|�dkr,|d S tjdd� |D �ddd�}|�� S |j � jj kre� fd d�|jD �}t|�dkrX|d S tj|gddd�}|�� S |j � jj kr� �|jdd� �}t�|�}|�� S |j � jj ks�J �d}|j}t|�d kr�|d j tjkr�|d j}|dd� }d}t|�dkr�|d j � jjkr�|d }|dd� }� �||�}|du�rA|j � jjks�J �|j} | d } | j tjkr�d}tj}nA| j tjkr�d}tj}n5| j tjk�r'| d j tjk�sJ �t| �dv �sJ �� �| d � }}t| �d k�r&� �| d �}nJ �|dk�s3|dk�rA|�� }tj|gg||d�}|du�rI||_|�� S )zXCompiles a node, recursively. This is one big switch on the node type. r c � g | ]}� � |��qS r �r6 ��.0�ch�r/ r r � <listcomp>O � z0PatternCompiler.compile_node.<locals>.<listcomp>N� r c S s g | ]}|g�qS r r )r>