ok

Mini Shell

Direktori : /opt/alt/python311/lib64/python3.11/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/lib2to3/pgen2/__pycache__/pgen.cpython-311.opt-1.pyc

�

�f6���ddlmZmZmZGd�dej��ZGd�de��ZGd�de��ZGd�d	e��Z	d
d�Z
dS)�)�grammar�token�tokenizec��eZdZdS)�PgenGrammarN)�__name__�
__module__�__qualname__���9/opt/alt/python311/lib64/python3.11/lib2to3/pgen2/pgen.pyrrs�������Drrc�~�eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zdd�Zd�Zd�ZdS)�ParserGeneratorNc�N�d}|�t|d���}|j}||_||_t	j|j��|_|���|�	��\|_
|_|�
|��i|_|�
��dS)Nzutf-8)�encoding)�open�close�filename�streamr�generate_tokens�readline�	generator�gettoken�parse�dfas�startsymbol�first�addfirstsets)�selfrr�close_streams    r
�__init__zParserGenerator.__init__s������>��(�W�5�5�5�F�!�<�L� ��
����!�1�&�/�B�B����
�
����&*�j�j�l�l�#��	�4�#��#��L�N�N�N���
��������rc	��t��}t|j�����}|���|�|j��|�d|j��|D]-}dt|j	��z}||j	|<||j
|<�.|D�]}|j|}g}|D]�}g}t|j�
����D]C\}	}
|�|�||	��|�|
��f���D|jr*|�d|�|��f��|�|����|j�|��||�||��f|j|j	|<��|j	|j|_|S)N��)r�listr�keys�sort�remover�insert�len�
symbol2number�
number2symbol�sorted�arcs�items�append�
make_label�index�isfinal�states�
make_first�start)r�c�names�name�i�dfar4�stater.�label�nexts           r
�make_grammarzParserGenerator.make_grammars����M�M���T�Y�^�^�%�%�&�&��
�
�
����
���T�%�&�&�&�
���Q��(�)�)�)��	&�	&�D��c�!�/�*�*�*�A�$%�A�O�D�!�!%�A�O�A����	O�	O�D��)�D�/�C��F��
$�
$����#)�%�*�*:�*:�*<�*<�#=�#=�N�N�K�E�4��K�K�����E�!:�!:�C�I�I�d�O�O� L�M�M�M�M��=�7��K�K��C�I�I�e�$4�$4� 5�6�6�6��
�
�d�#�#�#�#�
�H�O�O�F�#�#�#�-3�T�_�_�Q��5M�5M�,N�A�F�1�?�4�(�)�)��/�$�"2�3����rc�~�|j|}i}t|��D]}|�||��}d||<�|S�Nr)rr-r1)rr7r9�rawfirstrr=�ilabels       r
r5zParserGenerator.make_first4sM���:�d�#�����H�%�%�	�	�E��_�_�Q��.�.�F��E�&�M�M��rc�,�t|j��}|d���r�||jvrI||jvr
|j|S|j�|j|df��||j|<|St
t|d��}||jvr
|j|S|j�|df��||j|<|St|��}|d���rH||j
vr
|j
|S|j�tj|f��||j
|<|Stj
|}||jvr
|j|S|j�|df��||j|<|S�Nr#)r*�labels�isalphar+�symbol2labelr0�getattrr�tokens�eval�keywords�NAMEr�opmap)rr7r=rC�itoken�values      r
r1zParserGenerator.make_label=s����Q�X������8�����)	"����'�'��A�N�*�*��>�%�0�0��H�O�O�Q�_�U�%;�T�$B�C�C�C�,2�A�N�5�)�!�M�!���t�4�4���Q�X�%�%��8�F�+�+��H�O�O�V�T�N�3�3�3�'-�A�H�V�$�!�M���K�K�E��Q�x���!�!�
"��A�J�&�&��:�e�,�,��H�O�O�U�Z��$7�8�8�8�(.�A�J�u�%�!�M�!��u�-���Q�X�%�%��8�F�+�+��H�O�O�V�T�N�3�3�3�'-�A�H�V�$�!�Mrc��t|j�����}|���|D] }||jvr|�|���!dS�N)r%rr&r'r�	calcfirst)rr8r9s   r
rzParserGenerator.addfirstsetsksa���T�Y�^�^�%�%�&�&��
�
�
�����	%�	%�D��4�:�%�%����t�$�$�$��	%�	%rc
�.�|j|}d|j|<|d}i}i}|j���D]�\}}||jvrh||jvr"|j|}|�t	d|z���n"|�|��|j|}|�|��|||<�vd||<|di||<��i}	|���D]4\}}
|
D],}||	vr!t	d|�d|�d|�d|	|�����||	|<�-�5||j|<dS)Nr#zrecursion for rule %rrzrule z is ambiguous; z is in the first sets of z as well as )rrr.r/�
ValueErrorrS�update)rr9r;r<�totalset�overlapcheckr=r>�fset�inverse�itsfirst�symbols            r
rSzParserGenerator.calcfirstss����i��o����
�4���A������� �:�+�+�-�-�
	1�
	1�K�E�4���	�!�!��D�J�&�&��:�e�,�D��|�(�)@�4�)G�H�H�H�$��N�N�5�)�)�)��:�e�,�D�����%�%�%�&*��U�#�#�"#����',�a�j��U�#�#���+�1�1�3�3�	(�	(�O�E�8�"�
(�
(���W�$�$�$�*�&*�d�d�F�F�F�E�E�E�7�6�?�?�&L�M�M�M�#(�����
(�$��
�4���rc�t�i}d}|jtjk�r|jtjkr)|���|jtjk�)|�tj��}|�tjd��|���\}}|�tj��|�	||��}t|��}|�|��t|��}|||<|�|}|jtjk��||fS)N�:)�typer�	ENDMARKER�NEWLINEr�expectrM�OP�	parse_rhs�make_dfar*�simplify_dfa)	rrrr9�a�zr;�oldlen�newlens	         r
rzParserGenerator.parse�s	�������i�5�?�*�*��)�u�}�,�,��
�
�����)�u�}�,�,��;�;�u�z�*�*�D��K�K���#�&�&�&��>�>�#�#�D�A�q��K�K��
�&�&�&��-�-��1�%�%�C���X�X�F����c�"�"�"���X�X�F��D��J��"�"��#�i�5�?�*�*�$�[� � rc
����fd�}�fd��t||��|��g}|D]�}i}|jD]1}|jD]'\}}	|� �|	|�|i�����(�2t	|�����D]R\}}
|D]}|j|
krn&�t|
|��}|�|��|�||���S��|S)Nc�$��i}�||��|SrRr)r<�base�
addclosures  �r
�closurez)ParserGenerator.make_dfa.<locals>.closure�s����D��J�u�d�#�#�#��Krc�T��||vrdSd||<|jD]\}}|��||���dSrA�r.)r<rmr=r>rns    �r
rnz,ParserGenerator.make_dfa.<locals>.addclosure�sQ�����}�}����D��K�$�z�
+�
+���t��=��J�t�T�*�*�*��
+�
+r)�DFAState�nfasetr.�
setdefaultr-r/r0�addarc)
rr6�finishror4r<r.�nfastater=r>rs�strns
            @r
rezParserGenerator.make_dfa�sM���	�	�	�	�	�	+�	+�	+�	+�	+��7�7�5�>�>�6�2�2�3���
	(�
	(�E��D�!�L�
E�
E��#+�=�E�E�K�E�4��(�"�
�4������)C�)C�D�D�D��E�"(��
�
���!5�!5�
(�
(�
��v� �&�&�B��y�F�*�*���+�"�&�&�1�1�B��M�M�"�%�%�%����R��'�'�'�'�
(��
rc�l�td|��|g}t|��D]�\}}td|||urdpd��|jD]l\}}||vr|�|��}	n$t	|��}	|�|��|�td|	z���Xtd||	fz���m��dS)NzDump of NFA for�  State�(final)�z	    -> %d�    %s -> %d)�print�	enumerater.r2r*r0)
rr9r6rv�todor:r<r=r>�js
          r
�dump_nfazParserGenerator.dump_nfa�s���
���&�&�&��w��!�$���	7�	7�H�A�u��)�Q���� =�I� C��D�D�D�$�z�	
7�	
7���t��4�<�<��
�
�4�(�(�A�A��D�	�	�A��K�K��%�%�%��=��+��/�*�*�*�*��.�E�1�:�5�6�6�6�6�	
7�	7�	7rc	�*�td|��t|��D]r\}}td||jrdpd��t|j�����D],\}}td||�|��fz���-�sdS)NzDump of DFA forrzr{r|r})r~rr3r-r.r/r2)rr9r;r:r<r=r>s       r
�dump_dfazParserGenerator.dump_dfa�s���
���&�&�&�!�#���	A�	A�H�A�u��)�Q��
� ;�)� A�r�B�B�B�%�e�j�&6�&6�&8�&8�9�9�
A�
A���t��n��s�y�y����'?�?�@�@�@�@�
A�	A�	Arc���d}|rnd}t|��D]X\}}t|dzt|����D]2}||}||kr"||=|D]}|�||���d}n�3�Y|�ldSdS)NTFr)r�ranger*�
unifystate)rr;�changesr:�state_ir��state_jr<s        r
rfzParserGenerator.simplify_dfa�s������	��G�'��n�n�	
�	
�
��7��q��s�C��H�H�-�-���A�!�!�f�G��'�)�)���F�%(�?�?�E�!�,�,�W�g�>�>�>�>�"&����
*���	�	�	�	�	rc��|���\}}|jdkr||fSt��}t��}|�|��|�|��|jdkr`|���|���\}}|�|��|�|��|jdk�`||fS)N�|)�	parse_altrP�NFAStaterur)rrgrh�aa�zzs     r
rdzParserGenerator.parse_rhs�s����~�~�����1��:�����a�4�K����B����B��I�I�a�L�L�L�
�H�H�R�L�L�L��*��#�#��
�
�����~�~�'�'���1��	�	�!�����������	�*��#�#�
�r�6�Mrc�4�|���\}}|jdvs|jtjtjfvrV|���\}}|�|��|}|jdv�7|jtjtjfv�V||fS)N)�(�[)�
parse_itemrPr_rrM�STRINGru)rrg�br7�ds     r
r�zParserGenerator.parse_alt
s������ � ���1��z�Z�'�'��y�U�Z���6�6�6��?�?�$�$�D�A�q�
�H�H�Q�K�K�K��A�	�z�Z�'�'��y�U�Z���6�6�6��!�t�rc��|jdkrd|���|���\}}|�tjd��|�|��||fS|���\}}|j}|dvr||fS|���|�|��|dkr||fS||fS)Nr��])�+�*r�)rPrrdrbrrcru�
parse_atom)rrgrhrPs    r
r�zParserGenerator.parse_items����:�����M�M�O�O�O��>�>�#�#�D�A�q��K�K���#�&�&�&�
�H�H�Q�K�K�K��a�4�K��?�?�$�$�D�A�q��J�E��J�&�&��!�t���M�M�O�O�O�
�H�H�Q�K�K�K���|�|��!�t���!�t�rc���|jdkrO|���|���\}}|�tjd��||fS|jtjtjfvrOt��}t��}|�
||j��|���||fS|�d|j|j��dS)Nr��)z+expected (...) or NAME or STRING, got %s/%s)rPrrdrbrrcr_rMr�r�ru�raise_error)rrgrhs   r
r�zParserGenerator.parse_atom(s����:�����M�M�O�O�O��>�>�#�#�D�A�q��K�K���#�&�&�&��a�4�K�
�Y�5�:�u�|�4�
4�
4��
�
�A��
�
�A�
�H�H�Q��
�#�#�#��M�M�O�O�O��a�4�K����J�!�Y��
�
4�
4�
4�
4�
4rc��|j|ks
|�.|j|kr#|�d|||j|j��|j}|���|S)Nzexpected %s/%s, got %s/%s)r_rPr�r)rr_rPs   r
rbzParserGenerator.expect9sd���9�����!2�t�z�U�7J�7J����8�!�5�$�)�T�Z�
A�
A�
A��
���
�
�����rc��t|j��}|dtjtjfvr4t|j��}|dtjtjfv�4|\|_|_|_|_|_	dSrE)
r>rr�COMMENT�NLr_rP�begin�end�line)r�tups  r
rzParserGenerator.gettokenAsr���4�>�"�"���!�f��)�8�;�7�7�7��t�~�&�&�C��!�f��)�8�;�7�7�7�AD�>��	�4�:�t�z�4�8�T�Y�Y�Yrc
��|rG	||z}n@#d�|gttt|����z��}YnxYwt	||j|jd|jd|jf���)N� r#r)�joinr%�map�str�SyntaxErrorrr�r�)r�msg�argss   r
r�zParserGenerator.raise_errorHs����	=�
=��D�j����
=��h�h��u�t�C��T�N�N�';�';�;�<�<��������#��
�t�x��{� $����T�Y� 8�9�9�	9s	�
�;ArR)rr	r
r!r?r5r1rrSrrer�r�rfrdr�r�r�rbrr�rrr
rr
s4������
�
�
�
����2���,"�,"�,"�\%�%�%�$�$�$�<!�!�!�0"�"�"�H7�7�7� A�A�A����*���"������(4�4�4�"����E�E�E�9�9�9�9�9rrc��eZdZd�Zdd�ZdS)r�c��g|_dSrRrq)rs r
r!zNFAState.__init__Ss
����	�	�	rNc�>�|j�||f��dSrR)r.r0�rr>r=s   r
ruzNFAState.addarcVs$��	
�	���%���'�'�'�'�'rrR)rr	r
r!rurrr
r�r�Qs7���������(�(�(�(�(�(rr�c�*�eZdZd�Zd�Zd�Zd�ZdZdS)rrc�4�||_||v|_i|_dSrR)rsr3r.)rrs�finals   r
r!zDFAState.__init__]s!������������	�	�	rc��||j|<dSrRrqr�s   r
ruzDFAState.addarces�� ��	�%���rc�`�|j���D]\}}||ur
||j|<�dSrR)r.r/)r�old�newr=r>s     r
r�zDFAState.unifystateksA���9�?�?�,�,�	'�	'�K�E�4��s�{�{�#&��	�%� ��	'�	'rc��|j|jkrdSt|j��t|j��krdS|j���D]$\}}||j�|��urdS�%dS)NFT)r3r*r.r/�get)r�otherr=r>s    r
�__eq__zDFAState.__eq__ps����<�5�=�(�(��5��t�y�>�>�S���_�_�,�,��5��9�?�?�,�,�	�	�K�E�4��5�:�>�>�%�0�0�0�0��u�u�1��trN)rr	r
r!rur�r��__hash__rrr
rrrr[sQ��������� � � �'�'�'�
����H�H�Hrrr�Grammar.txtc�H�t|��}|���SrR)rr?)r�ps  r
�generate_grammarr��s����!�!�A��>�>���rN)r�)r|rrr�Grammarr�objectrr�rrr�rrr
�<module>r�s���
'�&�&�&�&�&�&�&�&�&�	�	�	�	�	�'�/�	�	�	�E9�E9�E9�E9�E9�f�E9�E9�E9�N
(�(�(�(�(�v�(�(�(�#�#�#�#�#�v�#�#�#�J�����r

Zerion Mini Shell 1.0