AlkantarClanX12

Your IP : 3.147.205.19


Current Path : /proc/self/root/opt/alt/python311/lib64/python3.11/lib2to3/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python311/lib64/python3.11/lib2to3/__pycache__/patcomp.cpython-311.pyc

�

c��f�����dZdZddlZddlmZmZmZmZmZm	Z	ddl
mZddl
mZGd�d	e
��Zd
�ZGd�de��Zejejejdd
�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��eZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__���6/opt/alt/python311/lib64/python3.11/lib2to3/patcomp.pyr
r
s�������Drr
c#��K�tjtjtjh}t	jt
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���rc�2�eZdZdd�Zd	d�Zd�Zdd�Zd�ZdS)
�PatternCompilerNc�L�|�#tj|_tj|_n7tj|��|_tj|j��|_tj|_	tj
|_tj|jt���|_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����rFc� �t|��}	|j�||���}n4#tj$r"}tt
|����d�d}~wwxYw|r|�|��|fS|�|��S)z=Compiles a pattern string to a nested pytree.*Pattern object.)�debugN)r%r�parse_tokensr�
ParseErrorr
�str�compile_node)r5rr9�	with_treer�root�es       r�compile_patternzPatternCompiler.compile_pattern7s���!�%�(�(��	7��;�+�+�F�%�+�@�@�D�D����	7�	7�	7�$�S��V�V�,�,�$�6�����	7�����	+��$�$�T�*�*�D�0�0��$�$�T�*�*�*s�.�A�A�Ac���|j�jjkr
|jd}|j�jjkrl�fd�|jddd�D��}t|��dkr|dSt
jd�|D��dd���}|���S|j�jj	krZ�fd�|jD��}t|��dkr|dSt
j|gdd���}|���S|j�jj
krJ��|jdd���}t
j|��}|���S|j�jj
ksJ�d}|j}t|��d	kr2|djtjkr|dj}|dd�}d}t|��dkr-|d
j�jjkr|d
}|dd
�}��||��}|��:|j�jjksJ�|j}	|	d}
|
jtjkrd}tj}n�|
jtjkrd}tj}n�|
jtjkr||	d
jtjksJ�t|	��dvsJ���|	d��x}}t|	��dkr��|	d	��}nJ�|dks|dkr-|���}t
j|gg||���}|�||_|���S)
zXCompiles a node, recursively.

        This is one big switch on the node type.
        rc�:��g|]}��|����Sr�r=��.0�chr5s  �r�
<listcomp>z0PatternCompiler.compile_node.<locals>.<listcomp>Os'���G�G�G�b�D�%�%�b�)�)�G�G�GrN�rc��g|]}|g��Srr)rF�as  rrHz0PatternCompiler.compile_node.<locals>.<listcomp>Rs��':�':�':����':�':�':r��min�maxc�:��g|]}��|����SrrDrEs  �rrHz0PatternCompiler.compile_node.<locals>.<listcomp>Vs'���C�C�C�r�T�&�&�r�*�*�C�C�Cr����)rP�rR)r r,�Matcher�children�Alternatives�lenr
�WildcardPattern�optimize�Alternative�NegatedUnit�
compile_basic�NegatedPattern�Unitr�EQUALr!�Repeater�STAR�HUGE�PLUS�LBRACE�RBRACE�get_int�name)
r5�node�alts�p�units�patternrf�nodes�repeatrT�childrMrNs
`            rr=zPatternCompiler.compile_nodeCs]����9��	�)�)�)��=��#�D��9��	�.�.�.�G�G�G�G�D�M�#�#�A�#�4F�G�G�G�D��4�y�y�A�~�~��A�w���&�':�':�T�':�':�':��q�I�I�I�A��:�:�<�<���9��	�-�-�-�C�C�C�C�T�]�C�C�C�E��5�z�z�Q����Q�x���&��w�A�1�=�=�=�A��:�:�<�<���9��	�-�-�-��(�(���q�r�r�):�;�;�G��%�g�.�.�A��:�:�<�<���y�D�I�N�*�*�*�*����
���u�:�:��?�?�u�Q�x�}���;�;���8�>�D��!�"�"�I�E����u�:�:��?�?�u�R�y�~���1C�C�C��2�Y�F��#�2�#�J�E��$�$�U�F�3�3�����;�$�)�"4�4�4�4�4���H��Q�K�E��z�U�Z�'�'����k�����u�z�)�)����k�����u�|�+�+���|�(�E�L�8�8�8�8��H�
�
��/�/�/�/� �L�L��!��5�5�5��c��x�=�=�A�%�%��,�,�x��{�3�3�C���u��a�x�x�3�!�8�8�!�*�*�,�,�� �0�7�)��#�3�O�O�O�����G�L����!�!�!rc��t|��dksJ�|d}|jtjkrHt	tj|j����}tj	t|��|��S|jtjkr�|j}|���rS|tvrtd|z���|dd�rtd���tj	t|��S|dkrd}n?|�d��s*t!|j|d��}|�td|z���|dd�r(|�|djd��g}nd}tj||��S|jdkr|�|d��S|jd	kr8|�J�|�|d��}tj|ggdd�
��SJ|���)NrrzInvalid token: %rzCan't have details for token�any�_zInvalid symbol: %r�(�[rL)rVr r�STRINGr<r�
evalStringr!r
�LeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr
�
startswith�getattrr2r=rT�NodePatternrW)r5rlrmrgr!r �content�
subpatterns        rr[zPatternCompiler.compile_basic�s����5�z�z�Q������Q�x���9���$�$���+�D�J�7�7�8�8�E��%�&6�u�&=�&=�u�E�E�E�
�Y�%�*�
$�
$��J�E��}�}���
9��	�)�)�,�-@�5�-H�I�I�I�����9�M�,�-K�L�L�L��)�)�E�*:�;�;�;��E�>�>��D�D��)�)�#�.�.�O�"�4�;��t�<�<�D��|�0�1E��1M�N�N�N�����9�#�#�0�0��q��1B�1�1E�F�F�G�G�G�"�G��)�$��8�8�8�
�Z�3�
�
��$�$�U�1�X�.�.�.�
�Z�3�
�
��>�>�>��*�*�5��8�4�4�J��)�J�<�.�a�Q�G�G�G�G��d���urc�X�|jtjksJ�t|j��S�N)r r�NUMBER�intr!)r5rgs  rrezPatternCompiler.get_int�s%���y�E�L�(�(�(�(��4�:���rr�)FF)rrrr7rAr=r[rerrrr'r'&sw������
K�
K�
K�
K�
+�
+�
+�
+�E"�E"�E"�N!�!�!�!�F����rr')rxrtr��TOKENc��|d���rtjS|tjvrtj|SdS)Nr)�isalpharrxr	�opmap)r!s rrwrw�sA���Q�x�������z��	�'�-�	�	��}�U�#�#��trc��|\}}}}|s	||jvrtj|||���Stj|||���S)z9Converts raw node information to a Node or Leaf instance.)�context)�
number2symbolr
�Node�Leaf)r	�
raw_node_infor r!r�rTs      rr4r4�sS��%2�"�D�%��(��9�4�7�0�0�0��{�4��7�;�;�;�;��{�4���8�8�8�8rc�D�t���|��Sr�)r'rA)rks rrArA�s�����,�,�W�5�5�5r)�__doc__�
__author__r�pgen2rrrrrr	�r
r�	Exceptionr
r%�objectr'rxrtr�rzrwr4rArrr�<module>r�s=����3�
�
�	�	�	�E�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�������������	�	�	�	�	��	�	�	����I�I�I�I�I�f�I�I�I�Z�Z��|��|��
�
�	����9�9�9�6�6�6�6�6r