AlkantarClanX12
Current Path : /proc/self/root/opt/alt/python311/lib64/python3.11/lib2to3/__pycache__/ |
Current File : //proc/self/root/opt/alt/python311/lib64/python3.11/lib2to3/__pycache__/patcomp.cpython-311.pyc |
� c��f� � �� � d Z dZddlZddlmZmZmZmZmZm Z ddl mZ ddl mZ G d� d e � � Zd � Z G d� de� � Zej ej ej dd �Zd� Zd� Zd� 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 � � e Zd ZdS )�PatternSyntaxErrorN)�__name__� __module__�__qualname__� � �6/opt/alt/python311/lib64/python3.11/lib2to3/patcomp.pyr r s � � � � � ��Dr r c # �� K � t j t j t j h}t j t j | � � j � � }|D ]}|\ }}}}}||vr|V � �dS )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_texts r �tokenize_wrapperr% ss � � � ��M�5�<���6�D� � %�b�k�%�&8�&8�&A� B� B�F�� � � �-6�*��e�U�C���t����O�O�O��� r c �2 � e Zd Zdd�Zd d�Zd� Zdd�Zd� ZdS ) �PatternCompilerNc �L � |�#t j | _ t j | _ n7t j |� � | _ t j | j � � | _ t j | _ t j | _ t j | j t �� � | _ 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_files r �__init__zPatternCompiler.__init__( su � � ��!�1�D�L��.�D�I�I�!�.�|�<�<�D�L���t�|�4�4�D�I��.����+����m�D�L�/�J�J�J����r Fc � � t |� � } | j � ||�� � }n4# t j $ r"}t t |� � � � d�d}~ww xY w|r| � |� � |fS | � |� � S )z=Compiles a pattern string to a nested pytree.*Pattern object.)�debugN)r% r �parse_tokensr � ParseErrorr �str�compile_node)r5 r r9 � with_treer �root�es r �compile_patternzPatternCompiler.compile_pattern7 s� � �!�%�(�(�� 7��;�+�+�F�%�+�@�@�D�D���� 7� 7� 7�$�S��V�V�,�,�$�6����� 7����� +��$�$�T�*�*�D�0�0��$�$�T�*�*�*s �. �A�A�Ac � � � |j � j j k r |j d }|j � j j k rl� fd�|j ddd� D � � }t |� � dk r|d S t j d� |D � � dd�� � }|� � � S |j � j j k rZ� fd�|j D � � }t |� � dk r|d S t j |gdd�� � }|� � � S |j � j j k rJ� � |j dd� � � }t j |� � }|� � � S |j � j j k sJ �d}|j }t |� � d k r2|d j t j k r|d j }|dd� }d}t |� � dk r-|d j � j j k r|d }|dd � }� � ||� � }|��:|j � j j k sJ �|j } | d } | j t j k rd}t j }n�| j t j k rd}t j }n�| j t j k r|| d j t j k sJ �t | � � dv sJ �� � | d � � x}}t | � � dk r� � | d � � }nJ �|dk s|dk r-|� � � }t j |gg||�� � }|�||_ |� � � S ) zXCompiles a node, recursively. This is one big switch on the node type. r c �: �� g | ]}�� |� � ��S r �r= ��.0�chr5 s �r � <listcomp>z0PatternCompiler.compile_node.<locals>.<listcomp>O s'