AlkantarClanX12

Your IP : 3.149.237.231


Current Path : /opt/alt/python312/lib64/python3.12/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/lib2to3/pgen2/__pycache__/pgen.cpython-312.pyc

�

�Q�f6���ddlmZmZmZGd�dej�ZGd�de�ZGd�de�ZGd�d	e�Z	dd
�Z
y)
�)�grammar�token�tokenizec��eZdZy)�PgenGrammarN)�__name__�
__module__�__qualname__���9/opt/alt/python312/lib64/python3.12/lib2to3/pgen2/pgen.pyrrs��rrc�|�eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zdd�Zd�Zd�Zy)�ParserGeneratorNc�<�d}|�t|d��}|j}||_||_t	j
|j�|_|j�|j�\|_
|_|�|�i|_|j�y)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�F�!�<�<�L� ��
����!�1�1�&�/�/�B����
�
��&*�j�j�l�#��	�4�#��#��N���
����rc	��t�}t|jj��}|j	�|j|j�|jd|j�|D]8}dt|j�z}||j|<||j|<�:|D�]}|j|}g}|D]�}g}t|jj��D]7\}	}
|j|j||	�|j!|
�f��9|j"r"|jd|j!|�f�|j|���|j$j|�||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_grammarsz���M���T�Y�Y�^�^�%�&��
�
�
��
���T�%�%�&�
���Q��(�(�)��D��c�!�/�/�*�*�A�$%�A�O�O�D�!�!%�A�O�O�A����D��)�)�D�/�C��F�����#)�%�*�*�*:�*:�*<�#=�K�E�4��K�K�����E�!:�C�I�I�d�O� L�M�$>��=�=��K�K��C�I�I�e�$4� 5�6��
�
�d�#�
�
�H�H�O�O�F�#�-3�T�_�_�Q��5M�,N�A�F�F�1�?�?�4�(�)���/�/�$�"2�"2�3����rc�v�|j|}i}t|�D]}|j||�}d||<�|S�Nr)rr-r1)rr7r9�rawfirstrr=�ilabels       r
r5zParserGenerator.make_first4sD���:�:�d�#�����H�%�E��_�_�Q��.�F��E�&�M�&��rc��t|j�}|dj�r�||jvrX||jvr|j|S|jj|j|df�||j|<|St
t|d�}t|t�sJ|��|tjvsJ|��||jvr|j|S|jj|df�||j|<|S|ddvsJ|��t|�}|dj�rY||jvr|j|S|jjtj|f�||j|<|Stj |}||jvr|j|S|jj|df�||j|<|S)Nr#)�"�')r*�labels�isalphar+�symbol2labelr0�getattrr�
isinstance�int�tok_name�tokens�eval�keywords�NAMEr�opmap)rr7r=rC�itoken�values      r
r1zParserGenerator.make_label=s����Q�X�X�����8��������'��A�N�N�*��>�>�%�0�0��H�H�O�O�Q�_�_�U�%;�T�$B�C�,2�A�N�N�5�)�!�M�!���t�4��!�&�#�.�5��5�.�����/�6��6�/��Q�X�X�%��8�8�F�+�+��H�H�O�O�V�T�N�3�'-�A�H�H�V�$�!�M���8�z�)�0�5�0�)���K�E��Q�x���!��A�J�J�&��:�:�e�,�,��H�H�O�O�U�Z�Z��$7�8�(.�A�J�J�u�%�!�M�!���u�-���Q�X�X�%��8�8�F�+�+��H�H�O�O�V�T�N�3�'-�A�H�H�V�$�!�Mrc��t|jj��}|j�|D]"}||jvs�|j|��$y�N)r%rr&r'r�	calcfirst)rr8r9s   r
rzParserGenerator.addfirstsetsksB���T�Y�Y�^�^�%�&��
�
�
���D��4�:�:�%����t�$�rc
�8�|j|}d|j|<|d}i}i}|jj�D]�\}}||jvrd||jvr|j|}|�.t	d|z��|j|�|j|}|j
|�|||<�xd||<|di||<��i}	|j�D]/\}}
|
D]%}||	vrt	d|�d|�d|�d|	|����||	|<�'�1||j|<y)Nr#zrecursion for rule %rrzrule z is ambiguous; z is in the first sets of z as well as )rrr.r/�
ValueErrorrW�update)rr9r;r<�totalset�overlapcheckr=r>�fset�inverse�itsfirst�symbols            r
rWzParserGenerator.calcfirstss;���i�i��o����
�
�4���A������� �:�:�+�+�-�K�E�4���	�	�!��D�J�J�&��:�:�e�,�D��|�(�)@�4�)G�H�H��N�N�5�)��:�:�e�,�D�����%�&*��U�#�"#����',�a�j��U�#�.���+�1�1�3�O�E�8�"���W�$�$�&*�F�E�7�6�?�&L�M�M�#(����#� 4�$��
�
�4�rc��i}d}|jtjk7�r|jtjk(r.|j	�|jtjk(r�.|jtj�}|jtjd�|j�\}}|jtj�|j||�}t|�}|j|�t|�}|||<|�|}|jtjk7r��||fS)N�:)�typer�	ENDMARKER�NEWLINEr�expectrQ�OP�	parse_rhs�make_dfar*�simplify_dfa)	rrrr9�a�zr;�oldlen�newlens	         r
rzParserGenerator.parse�s��������i�i�5�?�?�*��)�)�u�}�}�,��
�
���)�)�u�}�}�,��;�;�u�z�z�*�D��K�K����#�&��>�>�#�D�A�q��K�K��
�
�&��-�-��1�%�C���X�F����c�"���X�F��D��J��"�"��#�i�i�5�?�?�*�$�[� � rc
����t|t�sJ�t|t�sJ��fd�}�fd��t||�|�g}|D]�}i}|jD]2}|jD]!\}}	|��	�|	|j|i���#�4t
|j��D]L\}}
|D]}|j|
k(s�nt|
|�}|j|�|j||��N��|S)Nc���i}�||�|SrVr)r<�base�
addclosures  �r
�closurez)ParserGenerator.make_dfa.<locals>.closure�s����D��u�d�#��Krc�~��t|t�sJ�||vryd||<|jD]\}}|��	�||��yrA)rK�NFAStater.)r<rqr=r>rrs    �r
rrz,ParserGenerator.make_dfa.<locals>.addclosure�sG����e�X�.�.�.���}���D��K�$�z�z���t��=��t�T�*� *r)
rKru�DFAState�nfasetr.�
setdefaultr-r/r0�addarc)
rr6�finishrsr4r<r.�nfastater=r>rw�strrs
            @r
rizParserGenerator.make_dfa�s����
�%��*�*�*��&�(�+�+�+�	�	+��7�5�>�6�2�3���E��D�!�L�L��#+�=�=�K�E�4��(�"�4������)C�D�$1�)�"(��
�
��!5�
��v� �B��y�y�F�*��!�"�&�&�1�B��M�M�"�%����R��'�"6�
��
rc�D�td|�|g}t|�D]�\}}td|||uxrdxsd�|jD]X\}}||vr|j|�}	nt	|�}	|j|�|�td|	z��Itd||	fz��Z��y)NzDump of NFA for�  State�(final)�z	    -> %d�    %s -> %d)�print�	enumerater.r2r*r0)
rr9r6rz�todor:r<r=r>�js
          r
�dump_nfazParserGenerator.dump_nfa�s���
���&��w��!�$��H�A�u��)�Q���� =�I� C��D�$�z�z���t��4�<��
�
�4�(�A��D�	�A��K�K��%��=��+��/�*��.�E�1�:�5�6� *�(rc	��td|�t|�D]n\}}td||jxrdxsd�t|jj��D]$\}}td||j
|�fz��&�py)NzDump of DFA forr~rr�r�)r�r�r3r-r.r/r2)rr9r;r:r<r=r>s       r
�dump_dfazParserGenerator.dump_dfa�ss��
���&�!�#��H�A�u��)�Q��
�
� ;�)� A�r�B�%�e�j�j�&6�&6�&8�9���t��n��s�y�y���'?�?�@� :�'rc���d}|r`d}t|�D]L\}}t|dzt|��D],}||}||k(s�||=|D]}|j||��d}�L�N|r�_yy)NTFr)r��ranger*�
unifystate)rr;�changesr:�state_ir��state_jr<s        r
rjzParserGenerator.simplify_dfa�s{������G�'��n�
��7��q��s�C��H�-�A�!�!�f�G��'�)���F�%(�E�!�,�,�W�g�>�&)�"&���.�-�rc��|j�\}}|jdk7r||fSt�}t�}|j|�|j|�|jdk(rU|j	�|j�\}}|j|�|j|�|jdk(r�U||fS)N�|)�	parse_altrTruryr)rrkrl�aa�zzs     r
rhzParserGenerator.parse_rhs�s����~�~����1��:�:����a�4�K���B���B��I�I�a�L�
�H�H�R�L��*�*��#��
�
���~�~�'���1��	�	�!�������	�*�*��#�
�r�6�Mrc�h�|j�\}}|jdvs,|jtjtj
fvrb|j�\}}|j
|�|}|jdvr�5|jtjtj
fvr�b||fS)N)�(�[)�
parse_itemrTrcrrQ�STRINGry)rrk�br7�ds     r
r�zParserGenerator.parse_alt
s������ ���1��z�z�Z�'��y�y�U�Z�Z����6�6��?�?�$�D�A�q�
�H�H�Q�K��A�	�z�z�Z�'��y�y�U�Z�Z����6�6��!�t�rc�z�|jdk(rX|j�|j�\}}|jtj
d�|j
|�||fS|j�\}}|j}|dvr||fS|j�|j
|�|dk(r||fS||fS)Nr��])�+�*r�)rTrrhrfrrgry�
parse_atom)rrkrlrTs    r
r�zParserGenerator.parse_items����:�:����M�M�O��>�>�#�D�A�q��K�K����#�&�
�H�H�Q�K��a�4�K��?�?�$�D�A�q��J�J�E��J�&��!�t���M�M�O�
�H�H�Q�K���|��!�t���!�t�rc���|jdk(rG|j�|j�\}}|jtj
d�||fS|jtjtjfvrDt�}t�}|j||j�|j�||fS|jd|j|j�y)Nr��)z+expected (...) or NAME or STRING, got %s/%s)rTrrhrfrrgrcrQr�rury�raise_error)rrkrls   r
r�zParserGenerator.parse_atom(s����:�:����M�M�O��>�>�#�D�A�q��K�K����#�&��a�4�K�
�Y�Y�5�:�:�u�|�|�4�
4��
�A��
�A�
�H�H�Q��
�
�#��M�M�O��a�4�K����J�!�Y�Y��
�
�
4rc���|j|k7s|�8|j|k7r)|jd|||j|j�|j}|j�|S)Nzexpected %s/%s, got %s/%s)rcrTr�r)rrcrTs   r
rfzParserGenerator.expect9sX���9�9����!2�t�z�z�U�7J����8�!�5�$�)�)�T�Z�Z�
A��
�
���
�
���rc�0�t|j�}|dtjtjfvr;t|j�}|dtjtjfvr�;|\|_|_|_|_|_	y)Nr#)
r>rr�COMMENT�NLrcrT�begin�end�line)r�tups  r
rzParserGenerator.gettokenAsp���4�>�>�"���!�f��)�)�8�;�;�7�7��t�~�~�&�C��!�f��)�)�8�;�;�7�7�AD�>��	�4�:�t�z�4�8�T�Yrc
���|r	||z}t	||j
|jd|jd|jf��#dj|gttt|��z�}Y�nxYw)N� r#r)�joinr%�map�str�SyntaxErrorrr�r�)r�msg�argss   r
r�zParserGenerator.raise_errorHsq���
=��D�j���#��
�
�t�x�x��{� $�����T�Y�Y� 8�9�	9��
=��h�h��u�t�C��T�N�';�;�<��s�A�.A7rV)rr	r
r!r?r5r1rrWrrir�r�rjrhr�r�r�rfrr�rrr
rr
s`��
��2�,"�\%�$�<!�0"�H7� A��*�"��(4�"�E�9rrc��eZdZd�Zdd�Zy)ruc��g|_yrV)r.)rs r
r!zNFAState.__init__Ss	����	rNc��|�t|t�sJ�t|t�sJ�|jj	||f�yrV)rKr�rur.r0�rr>r=s   r
ryzNFAState.addarcVs<���}�
�5�#� 6�6�6��$��)�)�)��	�	���%���'rrV)rr	r
r!ryrrr
ruruQs���(rruc�(�eZdZd�Zd�Zd�Zd�ZdZy)rvc���t|t�sJ�ttt|��t�sJ�t|t�sJ�||_||v|_i|_yrV)rK�dictr>�iterrurwr3r.)rrw�finals   r
r!zDFAState.__init__]sT���&�$�'�'�'��$�t�F�|�,�h�7�7�7��%��*�*�*�����������	rc��t|t�sJ�||jvsJ�t|t�sJ�||j|<yrV)rKr�r.rvr�s   r
ryzDFAState.addarcesB���%��%�%�%��D�I�I�%�%�%��$��)�)�)���	�	�%�rc�p�|jj�D]\}}||us�||j|<�yrV)r.r/)r�old�newr=r>s     r
r�zDFAState.unifystateks0���9�9�?�?�,�K�E�4��s�{�#&��	�	�%� �-rc�6�t|t�sJ�|j|jk7ryt|j�t|j�k7ry|jj�D]$\}}||jj
|�us�$yy)NFT)rKrvr3r*r.r/�get)r�otherr=r>s    r
�__eq__zDFAState.__eq__psx���%��*�*�*��<�<�5�=�=�(���t�y�y�>�S����_�,���9�9�?�?�,�K�E�4��5�:�:�>�>�%�0�0��-�rN)rr	r
r!ryr�r��__hash__rrr
rvrv[s��� �'�
��Hrrvc�8�t|�}|j�SrV)rr?)r�ps  r
�generate_grammarr��s����!�A��>�>��rN)zGrammar.txt)r�rrr�Grammarr�objectrrurvr�rrr
�<module>r�sJ��
'�&�	�'�/�/�	�E9�f�E9�N
(�v�(�#�v�#�Jr