Hacked By AnonymousFox

Current Path : /opt/alt/python39/lib64/python3.9/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/lib2to3/pgen2/__pycache__/pgen.cpython-39.opt-1.pyc

a

R�f�5�@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	�7/opt/alt/python39/lib64/python3.9/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)(�ParserGeneratorNcCsld}|durt|�}|j}||_||_t�|j�|_|��|�	�\|_
|_|durZ|�i|_|�
�dS�N)�open�close�filename�streamr�generate_tokens�readline�	generator�gettoken�parse�dfas�startsymbol�first�addfirstsets)�selfrrZclose_streamr	r	r
�__init__szParserGenerator.__init__c	Cst�}t|j���}|��|�|j�|�d|j�|D]&}dt|j	�}||j	|<||j
|<q:|D]�}|j|}g}|D]`}g}t|j�
��D]$\}	}
|�|�||	�|�|
�f�q�|jr�|�d|�|�f�|�|�q||j�|�||�||�f|j|j	|<qf|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_firstcCs&t|j�}|d��r�||jvrZ||jvr4|j|S|j�|j|df�||j|<|Sn>tt|d�}||jvrz|j|S|j�|df�||j|<|Sn�t	|�}|d��r�||j
vr�|j
|S|j�tj|f�||j
|<|Sn>tj
|}||jv�r|j|S|j�|df�||j|<|SdS�Nr)r#�labels�isalphar$Zsymbol2labelr(�getattrr�tokens�eval�keywords�NAMErZopmap)rr/r5r9Zitoken�valuer	r	r
r)=s6













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

zParserGenerator.addfirstsetsc	Cs�|j|}d|j|<|d}i}i}|j��D]x\}}||jvr�||jvrj|j|}|dur~td|��n|�|�|j|}|�|�|||<q.d||<|di||<q.i}	|��D]:\}}
|
D],}||	vr�td||||	|f��||	|<q�q�||j|<dS)Nrzrecursion for rule %rrzArule %s is ambiguous; %s is in the first sets of %s as well as %s)rrr&r'�
ValueErrorrC�update)rr1r3r4ZtotalsetZoverlapcheckr5r6�fsetZinverseZitsfirstZsymbolr	r	r
rCss4








�zParserGenerator.calcfirstc	Cs�i}d}|jtjkr�|jtjkr*|��q|�tj�}|�tjd�|��\}}|�tj�|�	||�}t
|�}|�|�t
|�}|||<|dur|}q||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]�}i}|jD].}|jD]"\}}	|durD�|	|�|i��qDq:t|���D]@\}}
|D]}|j|
kr�q�q�t|
|�}|�|�|�||�qvq,|S)Ncsi}�||�|Srr	)r4�base��
addclosurer	r
�closure�s
z)ParserGenerator.make_dfa.<locals>.closurecs:||vrdSd||<|jD]\}}|dur�||�qdSr8�r&)r4rRr5r6rSr	r
rT�sz,ParserGenerator.make_dfa.<locals>.addclosure)�DFAState�nfasetr&�
setdefaultr%r'r(�addarc)rr.�finishrUr,r4r&Znfastater5r6rX�str	rSr
rN�s"



zParserGenerator.make_dfac
Cs�td|�|g}t|�D]|\}}td|||ur2dp4d�|jD]T\}}||vrZ|�|�}	nt|�}	|�|�|dur�td|	�q>td||	f�q>qdS)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]L\}}td||jr*dp,d�t|j���D]\}}td||�|�f�q>qdS)NzDump of DFA forr]r^r_r`)rarbr+r%r&r'r*)rr1r3r2r4r5r6r	r	r
�dump_dfa�s

zParserGenerator.dump_dfacCspd}|rld}t|�D]T\}}t|dt|��D]8}||}||kr.||=|D]}|�||�qLd}qq.qqdS)NTFr)rb�ranger#�
unifystate)rr3Zchangesr2Zstate_ircZstate_jr4r	r	r
rO�szParserGenerator.simplify_dfacCs~|��\}}|jdkr||fSt�}t�}|�|�|�|�|jdkrr|��|��\}}|�|�|�|�q>||fSdS)N�|)�	parse_altrB�NFAStaterZr)rrPrQZaaZzzr	r	r
rM�s




zParserGenerator.parse_rhscCsL|��\}}|jdvs(|jtjtjfvrD|��\}}|�|�|}q||fS)N)�(�[)�
parse_itemrBrHrrA�STRINGrZ)rrP�br/�dr	r	r
ri
s
�
zParserGenerator.parse_altcCs�|jdkr>|��|��\}}|�tjd�|�|�||fS|��\}}|j}|dvr`||fS|��|�|�|dkr�||fS||fSdS)Nrl�])�+�*rr)rBrrMrKrrLrZ�
parse_atom)rrPrQrBr	r	r
rms


zParserGenerator.parse_itemcCs�|jdkr4|��|��\}}|�tjd�||fS|jtjtjfvrpt	�}t	�}|�
||j�|��||fS|�d|j|j�dS)Nrk�)z+expected (...) or NAME or STRING, got %s/%s)rBrrMrKrrLrHrArnrjrZ�raise_error)rrPrQr	r	r
rt(s
�zParserGenerator.parse_atomcCsD|j|ks|dur2|j|kr2|�d|||j|j�|j}|��|S)Nzexpected %s/%s, got %s/%s)rHrBrvr)rrHrBr	r	r
rK9s�zParserGenerator.expectcCsFt|j�}|dtjtjfvr*t|j�}q
|\|_|_|_|_|_	dSr:)
r6rr�COMMENT�NLrHrBZbegin�end�line)r�tupr	r	r
rAs
zParserGenerator.gettokenc
Gs^|r8z||}Wn&d�|gttt|���}Yn0t||j|jd|jd|jf��dS)N� rr)�joinr�map�str�SyntaxErrorrryrz)r�msg�argsr	r	r
rvHs �zParserGenerator.raise_error)N)N)rrrrr7r-r)rrCrrNrdrerOrMrirmrtrKrrvr	r	r	r
r
s$
	.$

rc@seZdZdd�Zddd�ZdS)rjcCs
g|_dSrrV)rr	r	r
rSszNFAState.__init__NcCs|j�||f�dSr)r&r(�rr6r5r	r	r
rZVszNFAState.addarc)N)rrrrrZr	r	r	r
rjQsrjc@s0eZdZdd�Zdd�Zdd�Zdd�Zd	Zd	S)
rWcCs||_||v|_i|_dSr)rXr+r&)rrX�finalr	r	r
r]s
zDFAState.__init__cCs||j|<dSrrVr�r	r	r
rZeszDFAState.addarccCs*|j��D]\}}||ur
||j|<q
dSr)r&r')r�old�newr5r6r	r	r
rgkszDFAState.unifystatecCsV|j|jkrdSt|j�t|j�kr(dS|j��D]\}}||j�|�ur2dSq2dS)NFT)r+r#r&r'�get)r�otherr5r6r	r	r
�__eq__pszDFAState.__eq__N)rrrrrZrgr��__hash__r	r	r	r
rW[s
rW�Grammar.txtcCst|�}|��Sr)rr7)r�pr	r	r
�generate_grammar�sr�N)r�)r_rrrZGrammarr�objectrrjrWr�r	r	r	r
�<module>sI
%

Hacked By AnonymousFox1.0, Coded By AnonymousFox