AlkantarClanX12

Your IP : 18.222.20.250


Current Path : /opt/alt/python311/lib64/python3.11/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/lib2to3/pgen2/__pycache__/driver.cpython-311.pyc

�

c��fQ����dZdZddgZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZm
Z
Gd�de��Zd	�Z		dd
�Zd�Zd�Zd�Zedkr$ejee������dSdS)zZParser driver.

This provides a high-level interface to parse a file into a syntax tree.

z#Guido van Rossum <guido@python.org>�Driver�load_grammar�N�)�grammar�parse�token�tokenize�pgenc�>�eZdZd	d�Zd
d�Zd
d�Zd
d�Zdd�Zd
d�ZdS)rNc�Z�||_|�tj��}||_||_dS)N)r�logging�	getLogger�logger�convert)�selfrrrs    �;/opt/alt/python311/lib64/python3.11/lib2to3/pgen2/driver.py�__init__zDriver.__init__s.������>��&�(�(�F���������Fc�X�tj|j|j��}|���d}d}dx}x}x}x}	}
d}|D�]D}|\}}}}	}
|||fkrE||f|ksJ||f|f���|\}
}||
kr|d|
|z
zz
}|
}d}||kr||
||�z
}|}|t
jt
jfvr'||z
}|	\}}|�d��r|dz
}d}��|tj
krtj|}|r-|j�
dtj|||��|�||||f��r|r|j�
d��n>d}|	\}}|�d��r|dz
}d}��Ftjd||||f���|jS)	z4Parse a series of tokens and return the syntax tree.rrN��
z%s %r (prefix=%r)zStop.zincomplete input)r�Parserrr�setupr	�COMMENT�NL�endswithr�OP�opmapr�debug�tok_name�addtoken�
ParseError�rootnode)r�tokensr�p�lineno�column�type�value�start�end�	line_text�prefix�	quintuple�s_lineno�s_columns               r�parse_tokenszDriver.parse_tokens&s9��
�L���t�|�4�4��	���	�	�	�����15�5��5�u�5�u�5�s�Y����$	A�$	A�I�1:�.�D�%���Y����(�(�(���'�5�0�0�0�F�F�3C�U�2K�0�0�0�%*�"��(��H�$�$��d�h��&7�8�8�F�%�F��F��H�$�$��i��x��8�8�F�%�F���(�(�+�6�6�6��%���!$�����>�>�$�'�'���a�K�F��F���u�x����}�U�+���
G���!�!�"5�"'�.��"6��v�G�G�G��z�z�$�����7�7�
��/��K�%�%�g�.�.�.����F� �N�F�F��~�~�d�#�#�
��!�������"�#5�#'�����A�A�
A��z�rc�`�tj|j��}|�||��S�z*Parse a stream and return the syntax tree.)r	�generate_tokens�readliner1)r�streamrr$s    r�parse_stream_rawzDriver.parse_stream_rawVs*���)�&�/�:�:��� � ���/�/�/rc�.�|�||��Sr3)r7)rr6rs   r�parse_streamzDriver.parse_stream[s���$�$�V�U�3�3�3rc��tj|d|���5}|�||��cddd��S#1swxYwYdS)z(Parse a file and return the syntax tree.�r)�encodingN)�io�openr9)r�filenamer<rr6s     r�
parse_filezDriver.parse_file_s���
�W�X�s�X�
6�
6�
6�	4�&��$�$�V�U�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s
�;�?�?c��tjtj|��j��}|�||��S)z*Parse a string and return the syntax tree.)r	r4r=�StringIOr5r1)r�textrr$s    r�parse_stringzDriver.parse_stringds5���)�"�+�d�*;�*;�*D�E�E��� � ���/�/�/r)NN)F)NF)	�__name__�
__module__�__qualname__rr1r7r9r@rD�rrrrs�����������.�.�.�.�`0�0�0�0�
4�4�4�4�4�4�4�4�
0�0�0�0�0�0rc���tj�|��\}}|dkrd}||zd�t	t
tj����zdzS)Nz.txtr�.z.pickle)�os�path�splitext�join�map�str�sys�version_info)�gt�head�tails   r�_generate_pickle_namerVjsV����!�!�"�%�%�J�D�$��v�~�~����$�;����#�c�3�+;�"<�"<�=�=�=�	�I�Ir�Grammar.txtTFc���|�tj��}|�t|��n|}|st||��s�|�d|��tj|��}|rZ|�d|��	|�|��nV#t$r }|�d|��Yd}~n1d}~wwxYwn(tj
��}|�|��|S)z'Load the grammar (maybe from a pickle).Nz!Generating grammar tables from %szWriting grammar tables to %szWriting failed: %s)r
rrV�_newer�infor
�generate_grammar�dump�OSErrorr�Grammar�load)rS�gp�save�forcer�g�es       rrrqs���~��"�$�$��&(�j�	�r�	"�	"�	"�b�B���F�2�r�N�N�����7��<�<�<��!�"�%�%���	5��K�K�6��;�;�;�
5����r�
�
�
�
���
5�
5�
5����0�!�4�4�4�4�4�4�4�4�����
5����		5�
�O����	���r�
�
�
��Hs�>B�
B>�B9�9B>c��tj�|��sdStj�|��sdStj�|��tj�|��kS)z0Inquire whether file a was written since file b.FT)rKrL�exists�getmtime)�a�bs  rrYrY�sc��
�7�>�>�!�����u�
�7�>�>�!�����t�
�7���A���"�'�"2�"2�1�"5�"5�5�5rc�4�tj�|��rt|��St	tj�|����}t
j||��}tj	��}|�
|��|S)a�Normally, loads a pickled grammar by doing
        pkgutil.get_data(package, pickled_grammar)
    where *pickled_grammar* is computed from *grammar_source* by adding the
    Python version and using a ``.pickle`` extension.

    However, if *grammar_source* is an extant file, load_grammar(grammar_source)
    is called instead. This facilitates using a packaged grammar file when needed
    but preserves load_grammar's automatic regeneration behavior when possible.

    )rKrL�isfilerrV�basename�pkgutil�get_datarr^�loads)�package�grammar_source�pickled_name�datarcs     r�load_packaged_grammarrt�sx��
�w�~�~�n�%�%�,��N�+�+�+�(���)9�)9�.�)I�)I�J�J�L���G�\�2�2�D�����A��G�G�D�M�M�M��Hrc��|stjdd�}tjtjtjd���|D]}t
|dd����dS)z�Main program, when run as a script: produce grammar pickle files.

    Calls load_grammar for each argument, a path to a grammar text file.
    rNz%(message)s)�levelr6�formatT)rarb)rQ�argvr
�basicConfig�INFO�stdoutr)�argsrSs  r�mainr}�sl��
���x����|����g�l�3�:�,�.�.�.�.��0�0���R�d�$�/�/�/�/�/��4r�__main__)rWNTFN)�__doc__�
__author__�__all__r=rKr
rmrQrrrrr	r
�objectrrVrrYrtr}rE�exit�intrHrr�<module>r�sF����3�
��^�
$��
�	�	�	�	�	�	�	���������
�
�
�
�4�3�3�3�3�3�3�3�3�3�3�3�3�3�J0�J0�J0�J0�J0�V�J0�J0�J0�ZJ�J�J�'+�04�
�
�
�
�*6�6�6�
�
�
�(����z����C�H�S�S�T�T�V�V��_�_�������r