Your IP : 18.117.91.116


Current Path : /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/idlelib/__pycache__/HyperParser.cpython-35.opt-2.pyc



���]M2�@s�ddlZddlmZddlmZeejejd�Zeejd�Z	dd�e
d�D�Zdd�e
d�D�ZGd	d
�d
�Z
edkr�ddlZejdd
d�dS)�N)�	iskeyword)�PyParse�_cCs"g|]}t|�tk�qS�)�chr�_ASCII_ID_CHARS)�.0�xrr�0/opt/alt/python35/lib64/python3.5/HyperParser.py�
<listcomp>s	r�cCs"g|]}t|�tk�qSr)r�_ASCII_ID_FIRST_CHARS)rr	rrr
rs	c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
dd�Zed
ddh�Z	e
dd��ZdZdd�Z
dS)�HyperParserc
s�|�_|j�_}tj|j|j�}dd�}||j|��}|jsx�|jD]�}t	||d�}t
|�d}	d|}
|j|j|	|
�d�|j
|j|	��}|dk	s�|dkrePqeW|j|p�d�n_|jd|�}|r%|d}	nd	}	d|}
|j|j|	|
�d�|jd�|jdd
��_|
�_|j��_�fdd�tt�j��D��_�j|�dS)NcSstt|��S)N)�int�float)�indexrrr
�
index2line#sz(HyperParser.__init__.<locals>.index2line�z.0z%d.endz 
rZconsolez1.0�csBg|]8}|dko;�j|d�j|ddk�qS)rr)�
bracketing)r�i)�selfrr
rLs	z(HyperParser.__init__.<locals>.<listcomp>���)�editwin�textrZParserZindentwidthZtabwidthrZcontext_use_ps1Znum_context_lines�max�reprZset_str�getZfind_good_parse_startZ_build_char_in_string_funcZset_loZ
tag_prevrange�str�rawtext�stopatindexZget_last_stmt_bracketingr�range�len�isopener�	set_index)
rrrr�parserr�lno�contextZstartatZstartatindexr Zbod�rr)rr
�__init__s:		



	zHyperParser.__init__cCst|j�t|jj||j��}|dkrGtd|��||_d|_xP|jt|j�dkr�|j|jdd|jkr�|jd7_q\W|jt|j�dkr
|j|jdd|jkr
|j	|jdr
|jd7_dS)Nrz(Index %s precedes the analyzed statementr)
r"rrrr �
ValueError�indexinrawtext�indexbracketrr#)rrr+rrr
r$Rs
		!!zHyperParser.set_indexcCs/|j|jo.|j|j|jddkS)Nr�"�')r-r.)r#r,rr)rrrr
�is_in_stringgszHyperParser.is_in_stringcCs0|j|jp/|j|j|jddkS)Nr�#r-r.)r0r-r.)r#r,rr)rrrr
�
is_in_codeoszHyperParser.is_in_codez([{FcCs�|j|jd}|j}x{|j|sc|j|j|d|ksc|j|d|kr�|d8}|dkr}dSt||j|d�}q W|jd}x:|t|j�kr�|j|d|kr�|d7}q�W|jjd|jt|j�|j|df�}|t|j�ksQ|j|dt|j�krg|r[dS|j}n;|jjd|jt|j�|j|ddf�}||fS)Nrrz%s-%dc)	rr,r#r�minr"rrr )rZopenersZ	mustcloseZbracketinglevelZbefore�afterZbeforeindexZ
afterindexrrr
�get_surrounding_bracketsus0	

+ 		)z$HyperParser.get_surrounding_brackets�True�False�NonecCs�t}|}xL||krZt||d�dkrZ|t||d�rZ|d8}qW||krMt||d�dkrMx<|d|kr�d||d|�j�r�|d8}q�W|d|kr�d||d|�j�r�|d8}|d|kr0d||d|�j�r0|d8}|||�j�sqdSn$||krqtt||�sqdS||kr�t|||��r�|||�|jkr�dS||S)Nrr��arr)�_IS_ASCII_ID_CHAR�ord�isidentifier�_IS_ASCII_ID_FIRST_CHARr�_ID_KEYWORDS)�clsr�limit�posZis_ascii_id_charrrrr
�_eat_identifier�s.&1.
.
zHyperParser._eat_identifierz 	
\c
Csk|j�std��|j}|j}|j}||d}|j}|}d}xx�||kr�||d|jkr�|d8}q\|r�||kr�||ddkr�|d8}d}q\||kr'|dkr'|||dddkr'|d8}||d}||dd}q\Pq\W|s3P|j|||�}|rg||}|}d}qY||krU||d}	x2|dkr�||dd|	kr�|d8}q�W||d|kr�P||d}|d8}||d}|}||d	kr
qV||d
krQx.|dkrJ||ddkrJ|d8}qW|}PqYPqYW|||j�S)Nz>get_expression should only be calledif index is inside a code.rTr�.r0rFz([z'"ZrRbBuU)r1r*rrr,r+�_whitespace_charsrB)
rrrZ
brck_indexZ
brck_limitrAZlast_identifier_posZ
postdot_phase�ret�levelrrr
�get_expression�sb				#
 
	

	'
#zHyperParser.get_expressionN)�__name__�
__module__�__qualname__r)r$r/r1r4�	frozensetr>�classmethodrBrDrGrrrr
rs7,:r�__main__z"idlelib.idle_test.test_hyperparser�	verbosityr)�string�keywordrZidlelibrrK�
ascii_letters�digitsrr
r!r:r=rrHZunittest�mainrrrr
�<module>s�

?>