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__/pyparse.cpython-37.pyc

B

� f�M�@sdZddlZed�\ZZZZZe�dej	ej
B�jZe�dej	�j
Ze�dej	ejB�j
Ze�dej	�j
Ze�dej	�j
Ze�d	ej	�j
ZGd
d�de�Ze�ed�d
�Ze�dd�dD��e�dd�dD��e�dd�dD��Gdd�d�Zedk�rddlmZeddd�dS)a�Define partial Python code Parser used by editor and hyperparser.

Instances of ParseMap are used with str.translate.

The following bound search and match functions are defined:
_synchre - start of popular statement;
_junkre - whitespace or comment line;
_match_stringre: string, possibly without closer;
_itemre - line that may have bracket structure start;
_closere - line that must be followed by dedent.
_chew_ordinaryre - non-special characters.
�N�z�
    ^
    [ \t]*
    (?: while
    |   else
    |   def
    |   return
    |   assert
    |   break
    |   class
    |   continue
    |   elif
    |   try
    |   except
    |   raise
    |   import
    |   yield
    )
    \b
z'
    [ \t]*
    (?: \# \S .* )?
    \n
aK
    \""" [^"\\]* (?:
                     (?: \\. | "(?!"") )
                     [^"\\]*
                 )*
    (?: \""" )?

|   " [^"\\\n]* (?: \\. [^"\\\n]* )* "?

|   ''' [^'\\]* (?:
                   (?: \\. | '(?!'') )
                   [^'\\]*
                )*
    (?: ''' )?

|   ' [^'\\\n]* (?: \\. [^'\\\n]* )* '?
zM
    [ \t]*
    [^\s#\\]    # if we match, m.end()-1 is the interesting char
z_
    \s*
    (?: return
    |   break
    |   continue
    |   raise
    |   pass
    )
    \b
z
    [^[\](){}#'"\\]+
c@seZdZdZdd�ZdS)�ParseMapapDict subclass that maps anything not in dict to 'x'.

    This is designed to be used with str.translate in study1.
    Anything not specifically mapped otherwise becomes 'x'.
    Example: replace everything except whitespace with 'x'.

    >>> keepwhite = ParseMap((ord(c), ord(c)) for c in ' \t\n\r')
    >>> "a + b\tc\nd".translate(keepwhite)
    'x x x\tx\nx'
    cCsdS)N�x�)�self�keyrr�4/opt/alt/python37/lib64/python3.7/idlelib/pyparse.py�__missing__rszParseMap.__missing__N)�__name__�
__module__�__qualname__�__doc__r	rrrrrfs
r�rccs|]}t|�td�fVqdS)�(N)�ord)�.0�crrr�	<genexpr>xsrz({[ccs|]}t|�td�fVqdS)�)N)r)rrrrrrysz)}]ccs|]}t|�t|�fVqdS)N)r)rrrrrrzsz"'\
#c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�ParsercCs||_||_dS)N)�indentwidth�tabwidth)rrrrrr�__init__szParser.__init__cCs,t|�dks|ddkst�||_d|_dS)Nr����
)�len�AssertionError�code�study_level)r�srrr�set_code�szParser.set_codec	Cs�|jd}}t|�}xdtd�D]X}|�dd|�}|dkr:P|�dd|�d}t|||�}|rr||���sr|��}P|}qW|dkr�t|�}|r�||���s�|��}|S|d}x.t||�}|r�|��\}}||�s�|}q�Pq�W|S)a^
        Return index of a good place to begin parsing, as close to the
        end of the string as possible.  This will be the start of some
        popular stmt like "if" or "def".  Return None if none found:
        the caller should pass more prior context then, if possible, or
        if not (the entire program text up until the point of interest
        has already been tried) pass 0 to set_lo().

        This will be reliable iff given a reliable is_char_in_string()
        function, meaning that when it says "no", it's absolutely
        guaranteed that the char is not in a string.
        Nrz:
rr�)rr�range�rfind�_synchre�start�span)	rZis_char_in_stringr�pos�limitZtries�i�mrrrr�find_good_parse_start�s4
	
zParser.find_good_parse_startcCs:|dks|j|ddkst�|dkr6|j|d�|_dS)zx Throw away the start of the string.

        Intended to be called with the result of find_good_parse_start().
        rr!rN)rr)r�lorrr�set_lo�sz
Parser.set_loc
Cs|jdkrdSd|_|j}|�t�}|�dd�}|�dd�}|�dd�}|�dd�}|�dd�}t}d	}}d	g|_}|j}d	t|�}}�x||k�r�||}	|d}|	dkr�q�|	dkr�|d}|d	kr�||�q�|	d
kr�|d}q�|	dk�r|r�|d}q�|	dk�s|	d
k�r2|	}
||d|d�|
dk�r>|
d}
|}t|
�d}||}x�||k�r||}	|d}|	dk�r��qX||d||�|
k�r�||}P|	dk�r�|d}|d	k�rX|d	k�r�||�P�qX|	dk�rX||k�s�t	�||dk�r|d}|d}�qX�qXW|d|k�r,t
}q�t}q�|	dk�rV|�d|�}|d	ks�t	�q�|	dk�sdt	�||k�srt	�||dk�r�|d}|d|k�r�t
}|d}q�W|t
k�r�|tk�r�|d	k�r�t}||_|tk|d|kk�s�t	�|d|k�r�||�dS)z�Find the line numbers of non-continuation lines.

        As quickly as humanly possible <wink>, find the line numbers (0-
        based) of the non-continuation lines.
        Creates self.{goodlines, continuation}.
        r!NZxxxxxxxx�xZxxxxZxxz
xrrrr�"�'���\�#r)rr�	translate�trans�replace�C_NONE�	goodlines�appendrr�C_STRING_FIRST_LINE�C_STRING_NEXT_LINES�find�C_BACKSLASH�	C_BRACKET�continuation)
rrr@�levelZlnor9Z	push_goodr)�n�chZquoteZfirstlno�wrrr�_study1�s�










zParser._study1cCs|��|jS)N)rEr@)rrrr�get_continuation_typeOszParser.get_continuation_typecCs�|jdkrdS|��d|_|j|j}}t|�d}t|�}x`|r�|sLt�|}x4t||d||�D]}|�dd|d�d}qhWt||�r�|d}q@Pq@W|dkr�|dks�t�|}|||_	|_
d}g}|j}	|dfg}
�x�||k�r�t|||�}|�rX|�
�}|d}x&||k�r4||dk�r4|d}�qW||k�rH||}|}||k�rXP||}
|
dk�r�|	|�|
�|t|�f�|
}|d}q�|
d	k�r�|�r�|d
=|
}|d}|
�|t|�f�q�|
dk�s�|
dk�r|
�|t|�df�|
}t|||��
�}|
�|t|�f�q�|
d
k�rn|
�|t|�df�|�d||�d}|dk�sZt�|
�|t|�f�q�|
dk�s|t�|d}||k�s�t�||dk�r�|
||}|d}q�W||_|�r�|d
nd|_t|
�|_dS)am
        study1 was sufficient to determine the continuation status,
        but doing more requires looking at every character.  study2
        does this for the last interesting statement in the block.
        Creates:
            self.stmt_start, stmt_end
                slice indices of last interesting stmt
            self.stmt_bracketing
                the bracketing structure of the last interesting stmt; for
                example, for the statement "say(boo) or die",
                stmt_bracketing will be ((0, 0), (0, 1), (2, 0), (2, 1),
                (4, 0)). Strings and comments are treated as brackets, for
                the matter.
            self.lastch
                last interesting character before optional trailing comment
            self.lastopenbracketpos
                if continuation is C_BRACKET, index of last open bracket
        r1Nr!rr�z 	
z([{z)]}rr/r0r4r3)rrErr9rrr"r#�_junkre�
stmt_start�stmt_endr:�_chew_ordinaryre�end�_match_stringrer=�lastch�lastopenbracketpos�tuple�stmt_bracketing)rrr9r)�p�qZnothingrN�stackZ
push_stackZ
bracketingr*ZnewprCrrr�_study2Ss�








zParser._study2cCs�|��|jtkst�|j}|j}t|�}|�dd|�d}}|d}xj||kr�t||�}|rt|�	�d}d}PqJ|�
d|�d}}qJW|}}x||dkr�|d}q�W|j}t|||��|j
��|S)zpReturn number of spaces the next line should be indented.

        Line continuation must be C_BRACKET.
        rrr!z 	)rUr@r?rrOrrr#�_itemrerLr=r�
expandtabsr)r�jrrBZorigir)r*Zextrarrr�compute_bracket_indent�s&

zParser.compute_bracket_indentcCs|��|j}|d|dS)z�Return number of physical lines in last stmt.

        The statement doesn't have to be an interesting statement.  This is
        intended to be called when continuation is C_BACKSLASH.
        r���)rEr9)rr9rrr�get_num_lines_in_stmt�szParser.get_num_lines_in_stmtcCs�|��|jtkst�|j}|j}x||dkr:|d}q$W|}|�d|�d}d}}x�||k�r&||}|dkr�|d}|d}qZ|dkr�|r�|d}|d}qZ|dks�|dkr�t|||���}qZ|d	kr�PqZ|dk�r|d
k�r|dk�s||ddk�r||dd
k�rd}PqZ|d}qZW|�rN|d}t	�
d|||��d
k}|�sv|}x||dk�rt|d}�qZWt||j|��|j
��dS)z�Return number of spaces the next line should be indented.

        Line continuation must be C_BACKSLASH.  Also assume that the new
        line is the first one following the initial line of the stmt.
        z 	r!rrz([{z)]}r/r0r4�=z=<>!z\s*\\Nz 	
)rUr@r>rrrIr=rMrL�re�matchrrWr)rrr)�startpos�endpos�foundrArCrrr�compute_backslash_indent�sJ

zParser.compute_backslash_indentcCsN|��|j|j}}|}|j}x ||kr@||dkr@|d}q"W|||�S)z`Return the leading whitespace on the initial line of the last
        interesting stmt.
        z 	r!)rUrIrJr)rr)rBrXrrrr�get_base_indent_string0szParser.get_base_indent_stringcCs|��|jdkS)z<Return True if the last interesting statement opens a block.�:)rUrN)rrrr�is_block_opener<szParser.is_block_openercCs|��t|j|j�dk	S)z=Return True if the last interesting statement closes a block.N)rU�_closererrI)rrrr�is_block_closerAszParser.is_block_closercCs|��|jS)z�Return bracketing structure of the last interesting statement.

        The returned tuple is in the format defined in _study2().
        )rUrQ)rrrr�get_last_stmt_bracketingFszParser.get_last_stmt_bracketingN)r
rrrr r+r-rErFrUrYr[rbrcrergrhrrrrr}s8	{
9r�__main__)�mainzidlelib.idle_test.test_pyparser1)�	verbosity)r
r]r"r8r>r;r<r?�compile�VERBOSE�	MULTILINE�searchr$r^rH�DOTALLrMrVrfrK�dictr�fromkeysr6�updaterr
Zunittestrjrrrr�<module>s4	U


Hacked By AnonymousFox1.0, Coded By AnonymousFox