����JFIF���������
1#@!#!123s
D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
python37
/
lib64
/
python3.7
/
idlelib
/
__pycache__
/
Filename :
hyperparser.cpython-37.pyc
back
Copy
B ����� fS2������������������@���s����d�Z�ddlmZ�ddlZddlmZ�eejej�d��Z eejd��Z dd��ed�D��Zd d��ed�D��Z G�d d��d�Zedkr�dd lmZ�eddd��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�_c�������������C���s���g�|�]}t�|�tk�qS���)�chr�_ASCII_ID_CHARS)�.0�xr���r����8/opt/alt/python37/lib64/python3.7/idlelib/hyperparser.py� <listcomp>���s����r�������c�������������C���s���g�|�]}t�|�tk�qS�r���)r����_ASCII_ID_FIRST_CHARS)r���r ���r���r���r ���r������s����c���������������@���s\���e�Zd�Zdd��Zdd��Zdd��Zdd��Zddd�Zed ddh�Z e dd���ZdZdd��Z dS�)�HyperParserc������� ���������sJ��|��_�|j���_}t�|j|j�}dd��}||�|��}|js�xh|jD�]^}t ||�d�}t |�d�} d|�} |�|�| | �d���|� |�| ��}|dk s�|dkrFP�qFW�|�|p�d��nF|�d |�}|r�|d�} nd } d|�} |�|�| | �d���|�d��|jdd����_| ��_|�����_��fdd �tt��j��D����_���|��dS�)z;To initialize, analyze the surroundings of the given index.c�������������S���s���t�t|���S�)N)�int�float)�indexr���r���r ���� index2line"���s����z(HyperParser.__init__.<locals>.index2line����z.0z%d.endz Nr���Zconsolez1.0���c����������������s4���g�|�],}|d�ko.��j�|�d���j�|d��d�k�qS�)r���r���)� bracketing)r����i)�selfr���r ���r���K���s���z(HyperParser.__init__.<locals>.<listcomp>)�editwin�textr���ZParserZindentwidthZtabwidthr���Zprompt_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) r���r���r���r����parserr���Zlno�contextZstartatZstartatindexr���Zbod�rr���)r���r ����__init__���s:���� zHyperParser.__init__c�������������C���s����t�|�j�t�|�j�||�j���}|dk�r2td|���||�_d|�_x@|�jt�|�j�d�k�r~|�j|�jd��d�|�jk�r~|��jd7��_q@W�|�jt�|�j�d�k�r�|�j|�jd��d�|�jkr�|�j |�jd��s�|��jd7��_dS�)zgSet the index to which the functions relate. The index must be in the same statement. r���z(Index %s precedes the analyzed statementr���N) r!���r���r���r���r���� ValueError�indexinrawtext�indexbracketr���r"���)r���r���r)���r���r���r ���r#���Q���s����zHyperParser.set_indexc�������������C���s&���|�j�|�j�o$|�j|�j|�j�d��dkS�)z2Is the index given to the HyperParser in a string?r���)�"�')r"���r*���r���r���)r���r���r���r ����is_in_stringf���s����zHyperParser.is_in_stringc�������������C���s(���|�j�|�j��p&|�j|�j|�j�d��dkS�)z5Is the index given to the HyperParser in normal code?r���)�#r+���r,���)r"���r*���r���r���)r���r���r���r ���� is_in_coden���s����zHyperParser.is_in_code�([{Fc�������������C���sL��|�j�|�j�d�}|�j}x`|�j|�rL|�j|�j�|�d��|ksL|�j�|�d�|krv|d8�}|dk�r`dS�t||�j�|�d��}qW�|�jd�}x,|t|�j��k�r�|�j�|�d�|kr�|d7�}q�W�|�j�d|�jt|�j�|�j�|�d��f��}|t|�j��k�s|�j�|�d�t|�j�k�r|�rdS�|�j}n.|�j�d|�jt|�j�|�j�|�d�d��f��}||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. r���r���Nz%s-%dc) r���r*���r"���r����minr!���r���r���r���)r���ZopenersZ mustcloseZbracketinglevelZbeforeZafterZbeforeindexZ afterindexr���r���r ����get_surrounding_bracketst���s0���� ""z$HyperParser.get_surrounding_brackets�True�False�Nonec�������������C���sd��t�}|}x<||krDt||d���dk�rD|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(dS�n ||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. r���r��������a����r���)�_IS_ASCII_ID_CHAR�ord�isidentifier�_IS_ASCII_ID_FIRST_CHARr����_ID_KEYWORDS)�cls�str�limit�posZis_ascii_id_charr���r���r���r ����_eat_identifier����s.���� &$$ zHyperParser._eat_identifierz \c������� ������C���s���|�����std��|�j}|�j}|�j}||�d�}|�j}|}d}�x�x�||krf||d��|�jkrf|d8�}qB|s�||kr�||d��dkr�|d8�}d}qB||kr�|dkr�|||d��d��dkr�|d8�}||�d�}||d��d�}qBP�qBW�|s�P�|��|||�}|�r||�}|}d}q@||k�r�||�d�} x.|dk�rT||d��d�| k�rT|d8�}�q(W�||�d�|k�rjP�||�d�}|d8�}||�d�}|}||�d k�r�n@||�d k�r�x*|dk�r�||d��dk�r�|d8�}�q�W�|}P�q@P�q@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.r���Tr����.r.���r8���Fz([z'"ZrRbBuU)r/���r(���r���r���r*���r)����_whitespace_charsrB���) r���r���r���Z brck_indexZ brck_limitrA���Zlast_identifier_posZ postdot_phaseZret�levelr���r���r ����get_expression����sb���� "zHyperParser.get_expressionN)r0���F)�__name__� __module__�__qualname__r'���r#���r-���r/���r2���� frozensetr=����classmethodrB���rD���rF���r���r���r���r ���r������s���7 ,:r����__main__)�mainz"idlelib.idle_test.test_hyperparserr8���)� verbosity)�__doc__�keywordr����stringZidlelibr���rJ���Z ascii_lettersZdigitsr���r ���r ���r9���r<���r���rG���ZunittestrM���r���r���r���r ����<module>���s�����