AlkantarClanX12

Your IP : 18.224.31.90


Current Path : /proc/self/root/opt/alt/python39/lib64/python3.9/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python39/lib64/python3.9/lib2to3/pgen2/__pycache__/pgen.cpython-39.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_firstcCsbt|j�}|d��r�||jvrZ||jvr4|j|S|j�|j|df�||j|<|Snbtt|d�}t|t	�sxJ|��|tj
vs�J|��||jvr�|j|S|j�|df�||j|<|Sn�|ddvs�J|��t|�}|d���r ||j
v�r�|j
|S|j�tj|f�||j
|<|Sn>tj|}||jv�r@|j|S|j�|df�||j|<|SdS)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|�|�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'�
ValueErrorrG�update)rr1r3r4ZtotalsetZoverlapcheckr5r6�fsetZinverseZitsfirstZsymbolr	r	r
rGss4








�zParserGenerator.calcfirstc	Cs�i}d}|jtjkr�|jtjkr*|��q|�tj�}|�tjd�|��\}}|�tj�|�	||�}t
|�}|�|�t
|�}|||<|dur|}q||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]�}i}|jD].}|jD]"\}}	|dur`�|	|�|i��q`qVt|���D]@\}}
|D]}|j|
kr�q�q�t|
|�}|�|�|�	||�q�qH|S)Ncsi}�||�|Srr	)r4�base��
addclosurer	r
�closure�s
z)ParserGenerator.make_dfa.<locals>.closurecsHt|t�sJ�||vrdSd||<|jD]\}}|dur(�||�q(dSr8)r?�NFAStater&)r4rVr5r6rWr	r
rX�sz,ParserGenerator.make_dfa.<locals>.addclosure)
r?rZ�DFAState�nfasetr&�
setdefaultr%r'r(�addarc)rr.�finishrYr,r4r&Znfastater5r6r\�str	rWr
rR�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 forrarbrcrd)rerfr+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)rf�ranger#�
unifystate)rr3Zchangesr2Zstate_irgZstate_jr4r	r	r
rS�szParserGenerator.simplify_dfacCs~|��\}}|jdkr||fSt�}t�}|�|�|�|�|jdkrr|��|��\}}|�|�|�|�q>||fSdS)N�|)�	parse_altrFrZr^r)rrTrUZaaZzzr	r	r
rQ�s




zParserGenerator.parse_rhscCsL|��\}}|jdvs(|jtjtjfvrD|��\}}|�|�|}q||fS)N)�(�[)�
parse_itemrFrLrrE�STRINGr^)rrT�br/�dr	r	r
rm
s
�
zParserGenerator.parse_altcCs�|jdkr>|��|��\}}|�tjd�|�|�||fS|��\}}|j}|dvr`||fS|��|�|�|dkr�||fS||fSdS)Nro�])�+�*ru)rFrrQrOrrPr^�
parse_atom)rrTrUrFr	r	r
rps


zParserGenerator.parse_itemcCs�|jdkr4|��|��\}}|�tjd�||fS|jtjtjfvrpt	�}t	�}|�
||j�|��||fS|�d|j|j�dS)Nrn�)z+expected (...) or NAME or STRING, got %s/%s)rFrrQrOrrPrLrErqrZr^�raise_error)rrTrUr	r	r
rw(s
�zParserGenerator.parse_atomcCsD|j|ks|dur2|j|kr2|�d|||j|j�|j}|��|S)Nzexpected %s/%s, got %s/%s)rLrFryr)rrLrFr	r	r
rO9s�zParserGenerator.expectcCsFt|j�}|dtjtjfvr*t|j�}q
|\|_|_|_|_|_	dS)Nr)
r6rr�COMMENT�NLrLrFZbegin�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�SyntaxErrorrr|r})r�msg�argsr	r	r
ryHs �zParserGenerator.raise_error)N)N)rrrrr7r-r)rrGrrRrhrirSrQrmrprwrOrryr	r	r	r
r
s$
	.$

rc@seZdZdd�Zddd�ZdS)rZcCs
g|_dSr)r&)rr	r	r
rSszNFAState.__init__NcCs8|dust|t�sJ�t|t�s$J�|j�||f�dSr)r?r�rZr&r(�rr6r5r	r	r
r^VszNFAState.addarc)N)rrrrr^r	r	r	r
rZQsrZc@s0eZdZdd�Zdd�Zdd�Zdd�Zd	Zd	S)
r[cCsLt|t�sJ�ttt|��t�s$J�t|t�s2J�||_||v|_i|_dSr)r?�dictr6�iterrZr\r+r&)rr\�finalr	r	r
r]s
zDFAState.__init__cCs8t|t�sJ�||jvsJ�t|t�s*J�||j|<dSr)r?r�r&r[r�r	r	r
r^eszDFAState.addarccCs*|j��D]\}}||ur
||j|<q
dSr)r&r')r�old�newr5r6r	r	r
rkkszDFAState.unifystatecCsdt|t�sJ�|j|jkrdSt|j�t|j�kr6dS|j��D]\}}||j�|�ur@dSq@dS)NFT)r?r[r+r#r&r'�get)r�otherr5r6r	r	r
�__eq__pszDFAState.__eq__N)rrrrr^rkr��__hash__r	r	r	r
r[[s
r[�Grammar.txtcCst|�}|��Sr)rr7)r�pr	r	r
�generate_grammar�sr�N)r�)rcrrrZGrammarr�objectrrZr[r�r	r	r	r
�<module>sI
%