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.opt-1.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_firstcCst|j�}|d��rK||jvr,||jvr|j|S|j�|j|df�||j|<|Stt|d�}||jvr<|j|S|j�|df�||j|<|St	|�}|d��ro||j
vr_|j
|S|j�tj|f�||j
|<|Stj
|}||jvr~|j|S|j�|df�||j|<|S�Nr)r#�labels�isalphar$Zsymbol2labelr(�getattrr�tokens�eval�keywords�NAMErZopmap)rr/r5r9Zitoken�valuer	r	r
r)=s6














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'�
ValueErrorrD�update)rr1r3r4ZtotalsetZoverlapcheckr5r6�fsetZinverseZitsfirstZsymbolr	r	r
rDss8




�



�
�zParserGenerator.calcfirstc	Cs�i}d}|jtjkrV|jtjkr|��|jtjks|�tj�}|�tjd�|��\}}|�tj�|�	||�}t
|�}|�|�t
|�}|||<|durP|}|jtjks
||fS)N�:)�typer�	ENDMARKER�NEWLINEr�expectrA�OP�	parse_rhs�make_dfar#�simplify_dfa)	rrrr1�a�zr3ZoldlenZnewlenr	r	r
r�s&�
�zParserGenerator.parsec	s��fdd�}�fdd��t||�|�g}|D]F}i}|jD]}|jD]\}}	|dur3�|	|�|i��q"qt|���D] \}}
|D]	}|j|
krJnqAt|
|�}|�|�|�||�q;q|S)Ncsi}�||�|SrCr	)r4�base��
addclosurer	r
�closure�s
z)ParserGenerator.make_dfa.<locals>.closurecs:||vrdSd||<|jD]
\}}|dur�||�q
dSr8�r&)r4rSr5r6rTr	r
rU�s
��z,ParserGenerator.make_dfa.<locals>.addclosure)�DFAState�nfasetr&�
setdefaultr%r'r(�addarc)rr.�finishrVr,r4r&Znfastater5r6rY�str	rTr
rO�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 forr^r_r`ra)rbrcr+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)rc�ranger#�
unifystate)rr3Zchangesr2Zstate_irdZstate_jr4r	r	r
rP�s���zParserGenerator.simplify_dfacCs�|��\}}|jdkr||fSt�}t�}|�|�|�|�|jdkr=|��|��\}}|�|�|�|�|jdks$||fS)N�|)�	parse_altrB�NFAStater[r)rrQrRZaaZzzr	r	r
rN�s






�zParserGenerator.parse_rhscCsf|��\}}|jdvs|jtjtjfvr/|��\}}|�|�|}|jdvs|jtjtjfvs||fS)N)�(�[)�
parse_itemrBrIrrA�STRINGr[)rrQ�br/�dr	r	r
rj
s


�zParserGenerator.parse_altcCs�|jdkr|��|��\}}|�tjd�|�|�||fS|��\}}|j}|dvr0||fS|��|�|�|dkrA||fS||fS)Nrm�])�+�*rs)rBrrNrLrrMr[�
parse_atom)rrQrRrBr	r	r
rns


zParserGenerator.parse_itemcCs�|jdkr|��|��\}}|�tjd�||fS|jtjtjfvr8t	�}t	�}|�
||j�|��||fS|�d|j|j�dS)Nrl�)z+expected (...) or NAME or STRING, got %s/%s)rBrrNrLrrMrIrArorkr[�raise_error)rrQrRr	r	r
ru(s
�zParserGenerator.parse_atomcCsD|j|ks|dur|j|kr|�d|||j|j�|j}|��|S)Nzexpected %s/%s, got %s/%s)rIrBrwr)rrIrBr	r	r
rL9s�zParserGenerator.expectcCsXt|j�}|dtjtjfvrt|j�}|dtjtjfvs|\|_|_|_|_|_	dSr:)
r6rr�COMMENT�NLrIrBZbegin�end�line)r�tupr	r	r
rAs


�zParserGenerator.gettokenc
GsV|rz||}Wnd�|gttt|���}Yt||j|jd|jd|jf��)N� rr)�joinr�map�str�SyntaxErrorrrzr{)r�msg�argsr	r	r
rwHs�zParserGenerator.raise_errorrC)rrrrr7r-r)rrDrrOrerfrPrNrjrnrurLrrwr	r	r	r
r
s&
	.$

rc@seZdZdd�Zddd�ZdS)rkcCs
g|_dSrCrW)rr	r	r
rSs
zNFAState.__init__NcCs|j�||f�dSrC)r&r(�rr6r5r	r	r
r[VszNFAState.addarcrC)rrrrr[r	r	r	r
rkQsrkc@s0eZdZdd�Zdd�Zdd�Zdd�Zd	Zd	S)
rXcCs||_||v|_i|_dSrC)rYr+r&)rrY�finalr	r	r
r]s

zDFAState.__init__cCs||j|<dSrCrWr�r	r	r
r[eszDFAState.addarccCs*|j��D]
\}}||ur||j|<qdSrC)r&r')r�old�newr5r6r	r	r
rhks

��zDFAState.unifystatecCsV|j|jkrdSt|j�t|j�krdS|j��D]\}}||j�|�ur(dSqdS)NFT)r+r#r&r'�get)r�otherr5r6r	r	r
�__eq__ps�zDFAState.__eq__N)rrrrr[rhr��__hash__r	r	r	r
rX[srX�Grammar.txtcCst|�}|��SrC)rr7)r�pr	r	r
�generate_grammar�sr�N)r�)r`rrrZGrammarr�objectrrkrXr�r	r	r	r
�<module>sI
%

Hacked By AnonymousFox1.0, Coded By AnonymousFox