Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/idlelib/__pycache__/hyperparser.cpython-37.pyc

B

� fS2�@s�dZddlmZddlZddlmZeejejd�Z	eejd�Z
dd�ed�D�Zd	d�ed�D�Z
Gd
d�d�Zedkr�dd
lmZeddd�dS)z�Provide advanced parsing abilities for ParenMatch and other extensions.

HyperParser uses PyParser.  PyParser mostly gives information on the
proper indentation of code.  HyperParser gives additional information on
the structure of code.
�)�	iskeywordN)�pyparse�_cCsg|]}t|�tk�qS�)�chr�_ASCII_ID_CHARS)�.0�xrr�8/opt/alt/python37/lib64/python3.7/idlelib/hyperparser.py�
<listcomp>sr�cCsg|]}t|�tk�qSr)r�_ASCII_ID_FIRST_CHARS)rr	rrr
rsc@s\eZdZdd�Zdd�Zdd�Zdd�Zddd�Zed
ddh�Z	e
dd��ZdZdd�Z
dS)�HyperParserc
sJ|�_|j�_}t�|j|j�}dd�}||�|��}|js�xh|jD]^}t	||d�}t
|�d}	d|}
|�|�|	|
�d�|�
|�|	��}|dk	s�|dkrFPqFW|�|p�d�nF|�d	|�}|r�|d}	nd
}	d|}
|�|�|	|
�d�|�d�|jdd��_|
�_|���_�fdd
�tt�j��D��_��|�dS)z;To initialize, analyze the surroundings of the given index.cSstt|��S)N)�int�float)�indexrrr
�
index2line"sz(HyperParser.__init__.<locals>.index2line�z.0z%d.endz 
NrZconsolez1.0���cs4g|],}|dko.�j|d�j|ddk�qS)rr)�
bracketing)r�i)�selfrr
rKsz(HyperParser.__init__.<locals>.<listcomp>)�editwin�textrZParserZindentwidthZtabwidthrZprompt_last_lineZnum_context_lines�max�reprZset_code�getZfind_good_parse_startZ_build_char_in_string_funcZset_loZ
tag_prevrange�code�rawtext�stopatindexZget_last_stmt_bracketingr�range�len�isopener�	set_index)
rrrr�parserrZlno�contextZstartatZstartatindexrZbod�rr)rr
�__init__s:



zHyperParser.__init__cCs�t|j�t|j�||j��}|dkr2td|��||_d|_x@|jt|j�dkr~|j|jdd|jkr~|jd7_q@W|jt|j�dkr�|j|jdd|jkr�|j	|jds�|jd7_dS)zgSet the index to which the functions relate.

        The index must be in the same statement.
        rz(Index %s precedes the analyzed statementrN)
r!rrrr�
ValueError�indexinrawtext�indexbracketrr")rrr)rrr
r#QszHyperParser.set_indexcCs&|j|jo$|j|j|jddkS)z2Is the index given to the HyperParser in a string?r)�"�')r"r*rr)rrrr
�is_in_stringfszHyperParser.is_in_stringcCs(|j|jp&|j|j|jddkS)z5Is the index given to the HyperParser in normal code?r)�#r+r,)r"r*rr)rrrr
�
is_in_codenszHyperParser.is_in_code�([{FcCsL|j|jd}|j}x`|j|rL|j|j|d|ksL|j|d|krv|d8}|dkr`dSt||j|d�}qW|jd}x,|t|j�kr�|j|d|kr�|d7}q�W|j�d|jt|j�|j|df�}|t|j�k�s|j|dt|j�k�r|�rdS|j}n.|j�d|jt|j�|j|ddf�}||fS)a�Return bracket indexes or None.

        If the index given to the HyperParser is surrounded by a
        bracket defined in openers (or at least has one before it),
        return the indices of the opening bracket and the closing
        bracket (or the end of line, whichever comes first).

        If it is not surrounded by brackets, or the end of line comes
        before the closing bracket and mustclose is True, returns None.
        rrNz%s-%dc)	rr*r"r�minr!rrr)rZopenersZ	mustcloseZbracketinglevelZbeforeZafterZbeforeindexZ
afterindexrrr
�get_surrounding_bracketsts0
""z$HyperParser.get_surrounding_brackets�True�False�NonecCsdt}|}x<||krDt||d�dkrD|t||d�rD|d8}q
W||k�rt||d�dk�rx0|d|kr�d||d|���r�|d8}qhW|d|kr�d||d|���r�|d8}|d|kr�d||d|���r�|d8}|||����s(dSn ||k�r(tt||��s(dS||k�r\t|||���r\|||�|jk�r\dS||S)z�Given a string and pos, return the number of chars in the
        identifier which ends at pos, or 0 if there is no such one.

        This ignores non-identifier eywords are not identifiers.
        rr��a�r)�_IS_ASCII_ID_CHAR�ord�isidentifier�_IS_ASCII_ID_FIRST_CHARr�_ID_KEYWORDS)�cls�str�limit�posZis_ascii_id_charrrrr
�_eat_identifier�s.
 &$$

zHyperParser._eat_identifierz 	
\c
Cs�|��std��|j}|j}|j}||d}|j}|}d}�x�x�||krf||d|jkrf|d8}qB|s�||kr�||ddkr�|d8}d}qB||kr�|dkr�|||dddkr�|d8}||d}||dd}qBPqBW|s�P|�|||�}|�r||}|}d}q@||k�r�||d}	x.|dk�rT||dd|	k�rT|d8}�q(W||d|k�rjP||d}|d8}||d}|}||d	k�r�n@||d
k�r�x*|dk�r�||ddk�r�|d8}�q�W|}Pq@Pq@W|||j�S)z�Return a string with the Python expression which ends at the
        given index, which is empty if there is no real one.
        z?get_expression should only be called if index is inside a code.rTr�.r.r8Fz([z'"ZrRbBuU)r/r(rrr*r)�_whitespace_charsrB)
rrrZ
brck_indexZ
brck_limitrAZlast_identifier_posZ
postdot_phaseZret�levelrrr
�get_expression�sb

"zHyperParser.get_expressionN)r0F)�__name__�
__module__�__qualname__r'r#r-r/r2�	frozensetr=�classmethodrBrDrFrrrr
rs7
,:r�__main__)�mainz"idlelib.idle_test.test_hyperparserr8)�	verbosity)�__doc__�keywordr�stringZidlelibrrJZ
ascii_lettersZdigitsrr
r r9r<rrGZunittestrMrrrr
�<module>s

Hacked By AnonymousFox1.0, Coded By AnonymousFox