Hacked By AnonymousFox

Current Path : /opt/alt/python310/lib64/python3.10/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/lib2to3/pgen2/__pycache__/pgen.cpython-310.pyc

o

6��f6�@sdddlmZmZmZGdd�dej�ZGdd�de�ZGdd�de�ZGdd	�d	e�Z	ddd�Z
d
S)�)�grammar�token�tokenizec@seZdZdS)�PgenGrammarN)�__name__�
__module__�__qualname__�r	r	�9/opt/alt/python310/lib64/python3.10/lib2to3/pgen2/pgen.pyrsrc@s�eZdZd&dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd&d d!�Zd"d#�Zd$d%�ZdS)'�ParserGeneratorNcCspd}|durt|dd�}|j}||_||_t�|j�|_|��|�	�\|_
|_|dur/|�i|_|�
�dS)Nzutf-8)�encoding)�open�close�filename�streamr�generate_tokens�readline�	generator�gettoken�parse�dfas�startsymbol�first�addfirstsets)�selfrrZclose_streamr	r	r
�__init__szParserGenerator.__init__c	Cst�}t|j���}|��|�|j�|�d|j�|D]}dt|j	�}||j	|<||j
|<q|D]P}|j|}g}|D]0}g}t|j�
��D]\}	}
|�|�||	�|�|
�f�qI|jri|�d|�|�f�|�|�q>|j�|�||�||�f|j|j	|<q3|j	|j|_|S)N��)r�listr�keys�sort�remover�insert�len�
symbol2numberZ
number2symbol�sorted�arcs�items�append�
make_label�index�isfinal�states�
make_first�start)r�c�names�name�i�dfar,�stater&�label�nextr	r	r
�make_grammars.

zParserGenerator.make_grammarcCs4|j|}i}t|�D]}|�||�}d||<q|S�Nr)rr%r))rr/r1Zrawfirstrr5�ilabelr	r	r
r-4s

zParserGenerator.make_firstcCsRt|j�}|d��r]||jvr,||jvr|j|S|j�|j|df�||j|<|Stt|d�}t|t	�s;J|��|tj
vsDJ|��||jvrN|j|S|j�|df�||j|<|S|ddvsgJ|��t|�}|d��r�||j
vr{|j
|S|j�tj|f�||j
|<|Stj|}||jvr�|j|S|j�|df�||j|<|S)Nr)�"�')r#�labels�isalphar$Zsymbol2labelr(�getattrr�
isinstance�int�tok_name�tokens�eval�keywords�NAMErZopmap)rr/r5r9Zitoken�valuer	r	r
r)=s<














zParserGenerator.make_labelcCs8t|j���}|��|D]}||jvr|�|�q
dS�N)rrrr r�	calcfirst)rr0r1r	r	r
rks

��zParserGenerator.addfirstsetsc	Cs�|j|}d|j|<|d}i}i}|j��D]<\}}||jvrI||jvr5|j|}|dur4td|��n
|�|�|j|}|�|�|||<qd||<|di||<qi}	|��D]\}}
|
D]}||	vrrtd||||	|f��||	|<q`qZ||j|<dS)Nrzrecursion for rule %rrzArule %s is ambiguous; %s is in the first sets of %s as well as %s)rrr&r'�
ValueErrorrH�update)rr1r3r4ZtotalsetZoverlapcheckr5r6�fsetZinverseZitsfirstZsymbolr	r	r
rHss8




�



�
�zParserGenerator.calcfirstc	Cs�i}d}|jtjkrV|jtjkr|��|jtjks|�tj�}|�tjd�|��\}}|�tj�|�	||�}t
|�}|�|�t
|�}|||<|durP|}|jtjks
||fS)N�:)�typer�	ENDMARKER�NEWLINEr�expectrE�OP�	parse_rhs�make_dfar#�simplify_dfa)	rrrr1�a�zr3ZoldlenZnewlenr	r	r
r�s&�
�zParserGenerator.parsec	s�t|t�sJ�t|t�sJ��fdd�}�fdd��t||�|�g}|D]F}i}|jD]}|jD]\}}	|durA�|	|�|i��q0q+t|���D] \}}
|D]	}|j|
krXnqOt|
|�}|�|�|�	||�qIq$|S)Ncsi}�||�|SrGr	)r4�base��
addclosurer	r
�closure�s
z)ParserGenerator.make_dfa.<locals>.closurecsHt|t�sJ�||vr
dSd||<|jD]
\}}|dur!�||�qdSr8)r?�NFAStater&)r4rWr5r6rXr	r
rY�s
��z,ParserGenerator.make_dfa.<locals>.addclosure)
r?r[�DFAState�nfasetr&�
setdefaultr%r'r(�addarc)rr.�finishrZr,r4r&Znfastater5r6r]�str	rXr
rS�s.
��
�

�zParserGenerator.make_dfac
Cs�td|�|g}t|�D]>\}}td|||urdpd�|jD]*\}}||vr-|�|�}	n	t|�}	|�|�|durAtd|	�qtd||	f�qqdS)NzDump of NFA for�  State�(final)�z	    -> %d�    %s -> %d)�print�	enumerater&r*r#r()
rr1r.r`Ztodor2r4r5r6�jr	r	r
�dump_nfa�s

��zParserGenerator.dump_nfacCsdtd|�t|�D]&\}}td||jrdpd�t|j���D]\}}td||�|�f�qq	dS)NzDump of DFA forrbrcrdre)rfrgr+r%r&r'r*)rr1r3r2r4r5r6r	r	r
�dump_dfa�s
��zParserGenerator.dump_dfacCsvd}|r9d}t|�D]*\}}t|dt|��D]}||}||kr3||=|D]}|�||�q&d}nqq
|sdSdS)NTFr)rg�ranger#�
unifystate)rr3Zchangesr2Zstate_irhZstate_jr4r	r	r
rT�s���zParserGenerator.simplify_dfacCs�|��\}}|jdkr||fSt�}t�}|�|�|�|�|jdkr=|��|��\}}|�|�|�|�|jdks$||fS)N�|)�	parse_altrFr[r_r)rrUrVZaaZzzr	r	r
rR�s






�zParserGenerator.parse_rhscCsf|��\}}|jdvs|jtjtjfvr/|��\}}|�|�|}|jdvs|jtjtjfvs||fS)N)�(�[)�
parse_itemrFrMrrE�STRINGr_)rrU�br/�dr	r	r
rn
s


�zParserGenerator.parse_altcCs�|jdkr|��|��\}}|�tjd�|�|�||fS|��\}}|j}|dvr0||fS|��|�|�|dkrA||fS||fS)Nrp�])�+�*rv)rFrrRrPrrQr_�
parse_atom)rrUrVrFr	r	r
rqs


zParserGenerator.parse_itemcCs�|jdkr|��|��\}}|�tjd�||fS|jtjtjfvr8t	�}t	�}|�
||j�|��||fS|�d|j|j�dS)Nro�)z+expected (...) or NAME or STRING, got %s/%s)rFrrRrPrrQrMrErrr[r_�raise_error)rrUrVr	r	r
rx(s
�zParserGenerator.parse_atomcCsD|j|ks|dur|j|kr|�d|||j|j�|j}|��|S)Nzexpected %s/%s, got %s/%s)rMrFrzr)rrMrFr	r	r
rP9s�zParserGenerator.expectcCsXt|j�}|dtjtjfvrt|j�}|dtjtjfvs|\|_|_|_|_|_	dS)Nr)
r6rr�COMMENT�NLrMrFZbegin�end�line)r�tupr	r	r
rAs


�zParserGenerator.gettokenc
GsV|rz||}Wnd�|gttt|���}Yt||j|jd|jd|jf��)N� rr)�joinr�map�str�SyntaxErrorrr}r~)r�msg�argsr	r	r
rzHs�zParserGenerator.raise_errorrG)rrrrr7r-r)rrHrrSrirjrTrRrnrqrxrPrrzr	r	r	r
r
s&
	.$

rc@seZdZdd�Zddd�ZdS)r[cCs
g|_dSrG)r&)rr	r	r
rSs
zNFAState.__init__NcCs8|dust|t�sJ�t|t�sJ�|j�||f�dSrG)r?r�r[r&r(�rr6r5r	r	r
r_VszNFAState.addarcrG)rrrrr_r	r	r	r
r[Qsr[c@s0eZdZdd�Zdd�Zdd�Zdd�Zd	Zd	S)
r\cCsLt|t�sJ�ttt|��t�sJ�t|t�sJ�||_||v|_i|_dSrG)r?�dictr6�iterr[r]r+r&)rr]�finalr	r	r
r]s

zDFAState.__init__cCs8t|t�sJ�||jvsJ�t|t�sJ�||j|<dSrG)r?r�r&r\r�r	r	r
r_eszDFAState.addarccCs*|j��D]
\}}||ur||j|<qdSrG)r&r')r�old�newr5r6r	r	r
rlks

��zDFAState.unifystatecCsdt|t�sJ�|j|jkrdSt|j�t|j�krdS|j��D]\}}||j�|�ur/dSq dS)NFT)r?r\r+r#r&r'�get)r�otherr5r6r	r	r
�__eq__ps�zDFAState.__eq__N)rrrrr_rlr��__hash__r	r	r	r
r\[sr\�Grammar.txtcCst|�}|��SrG)rr7)r�pr	r	r
�generate_grammar�sr�N)r�)rdrrrZGrammarr�objectrr[r\r�r	r	r	r
�<module>sI
%

Hacked By AnonymousFox1.0, Coded By AnonymousFox