Your IP : 3.147.54.100


Current Path : /opt/alt/python35/lib64/python3.5/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/lib2to3/pgen2/__pycache__/conv.cpython-35.opt-2.pyc



���]�%�@s?ddlZddlmZmZGdd�dej�ZdS)�N)�grammar�tokenc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�	ConvertercCs(|j|�|j|�|j�dS)N)�parse_graminit_h�parse_graminit_c�
finish_off)�selfZ
graminit_hZ
graminit_c�r	�)/opt/alt/python35/lib64/python3.5/conv.py�run/s

z
Converter.runc	Csyt|�}Wn=tk
rO}ztd||f�dSWYdd}~XnXi|_i|_d}x�|D]�}|d7}tjd|�}|r�|j�r�td|||j�f�qo|j�\}}t	|�}||j|<||j|<qoWdS)NzCan't open %s: %sFr�z^#define\s+(\w+)\s+(\d+)$z%s(%s): can't parse %sT)
�open�OSError�printZ
symbol2numberZ
number2symbol�re�match�strip�groups�int)	r�filename�f�err�lineno�line�mo�symbol�numberr	r	r
r5s&		


zConverter.parse_graminit_hc!Cs~yt|�}Wn=tk
rO}ztd||f�dSWYdd}~XnXd}|dt|�}}|dt|�}}|dt|�}}i}g}x|jd�r�x|jd�r�tjd|�}ttt	|j
���\}	}
}g}xqt|�D]c}
|dt|�}}tjd|�}ttt	|j
���\}}|j||f�qW|dt|�}}|||	|
f<|dt|�}}q�Wtjd|�}ttt	|j
���\}}g}x~t|�D]p}
|dt|�}}tjd	|�}ttt	|j
���\}}	}
||	|
f}|j|�qW|j|�|dt|�}}|dt|�}}q�W||_
i}tjd
|�}t	|jd��}x=t|�D]/}|dt|�}}tjd|�}|jd�}ttt	|jdd
dd���\}}}}||}|dt|�}}tjd|�}i}t|jd��}x]t|�D]O\}}t|�}x4td�D]&}|d|>@r�d||d|<q�Wq�W||f||<q�W|dt|�}}||_g}|dt|�}}tjd|�}t	|jd��}x�t|�D]�}|dt|�}}tjd|�}|j
�\}}t	|�}|dkr�d}nt|�}|j||f�q�W|dt|�}}||_|dt|�}}|dt|�}}tjd|�}t	|jd��}|dt|�}}|dt|�}}tjd|�}t	|jd��}|dt|�}}tjd|�}t	|jd��} | |_|dt|�}}y|dt|�}}Wntk
ryYnXdS)NzCan't open %s: %sFrrzstatic arc z)static arc arcs_(\d+)_(\d+)\[(\d+)\] = {$z\s+{(\d+), (\d+)},$z'static state states_(\d+)\[(\d+)\] = {$z\s+{(\d+), arcs_(\d+)_(\d+)},$zstatic dfa dfas\[(\d+)\] = {$z0\s+{(\d+), "(\w+)", (\d+), (\d+), states_(\d+),$����z\s+("(?:\\\d\d\d)*")},$�z!static label labels\[(\d+)\] = {$z\s+{(\d+), (0|"\w+")},$�0z
\s+(\d+),$z\s+{(\d+), labels},$z	\s+(\d+)$)r
rr�next�
startswithrr�list�maprr�range�append�states�group�eval�	enumerate�ord�dfas�labels�start�
StopIteration)!rrrrrrZallarcsr)r�n�m�kZarcs�_�i�j�s�t�stater.Zndfasrr�x�y�z�firstZ	rawbitset�cZbyter/Znlabelsr0r	r	r
rTs�		$!!$
			3
				
zConverter.parse_graminit_ccCs�i|_i|_xgt|j�D]V\}\}}|tjkr_|dk	r_||j|<q"|dkr"||j|<q"WdS)N)�keywords�tokensr,r/r�NAME)rZilabel�type�valuer	r	r
r�s		"zConverter.finish_offN)�__name__�
__module__�__qualname__rrrrr	r	r	r
r$s�r)rZpgen2rrZGrammarrr	r	r	r
�<module>s

?>