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.opt-1.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||_d|_dS)Nr)�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:
r�
�)r�len�range�rfind�_synchre�start�span)	rZis_char_in_stringr�pos�limitZtries�i�mrrrr�find_good_parse_start�s4
	
zParser.find_good_parse_startcCs|dkr|j|d�|_dS)zx Throw away the start of the string.

        Intended to be called with the result of find_good_parse_start().
        rN)r)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�rn||}	|d}|	dkr�q�|	dkr�|d}|d	kr�||�q�|	d
kr�|d}q�|	dk�r|r�|d}q�|	dk�s|	d
k�r$|	}
||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||dk�r�|d}|d}�qX�qXW|d|k�rt	}q�t
}q�|	dk�r<|�d|�}q�||dk�rd|d}|d|k�rdt}|d}q�W|t	k�r�|t
k�r�|d	k�r�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}.
        rNZxxxxxxxx�xZxxxxZxxz
xrrrr�"�'���\�#���)rr�	translate�trans�replace�C_NONE�	goodlines�appendr�C_STRING_FIRST_LINE�C_STRING_NEXT_LINES�find�C_BACKSLASH�	C_BRACKET�continuation)
rrr?�levelZlnor8Z	push_goodr'�n�chZquoteZfirstlno�wrrr�_study1�s�










zParser._study1cCs|��|jS)N)rDr?)rrrr�get_continuation_typeOszParser.get_continuation_typecCs�|jdkrdS|��d|_|j|j}}t|�d}t|�}xX|r�|}x4t||d||�D]}|�dd|d�d}q`Wt||�r�|d}q@Pq@W|dkr�|}|||_|_	d}g}|j
}	|dfg}
�x�||k�rxt|||�}|�rD|��}|d}x&||k�r ||dk�r |d}�q�W||k�r4||}|}||k�rDP||}
|
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�rL|
�
|t|�df�|�d||�d}|
�
|t|�f�q�|d}||dk�rn|
||}|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
        r/Nrrr�z 	
z([{z)]}r3r-r.r2)rrDrr8rr r!�_junkre�
stmt_start�stmt_endr9�_chew_ordinaryre�end�_match_stringrer<�lastch�lastopenbracketpos�tuple�stmt_bracketing)rrr8r'�p�qZnothingrM�stackZ
push_stackZ
bracketingr(ZnewprBrrr�_study2Ss�








zParser._study2cCs�|��|j}|j}t|�}|�dd|�d}}|d}xj||kr|t||�}|rf|��d}d}Pq<|�d|�d}}q<W|}}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.
        rrrz 	)rTrNrrr!�_itemrerKr<r�
expandtabsr)r�jrrAZorigir'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.
        r3���)rDr8)rr8rrr�get_num_lines_in_stmt�szParser.get_num_lines_in_stmtcCs�|��|j}|j}x||dkr,|d}qW|}|�d|�d}d}}x�||k�r||}|dkrx|d}|d}qL|dkr�|r�|d}|d}qL|dks�|dkr�t|||���}qL|d	kr�PqL|dk�r|d
k�r|dks�||ddk�r||dd
k�rd}PqL|d}qLW|�r>|d}t�d|||��d
k}|�sf|}x||dk�rd|d}�qJWt||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 	rrrz([{z)]}r-r.r2�=z=<>!z\s*\\Nz 	
)rTrrHr<rLrK�re�matchrrVr)rrr'�startpos�endpos�foundr@rBrrr�compute_backslash_indent�sH

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)rTrHrIr)rr'rArWrrrr�get_base_indent_string0szParser.get_base_indent_stringcCs|��|jdkS)z<Return True if the last interesting statement opens a block.�:)rTrM)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)rT�_closererrH)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().
        )rTrP)rrrr�get_last_stmt_bracketingFszParser.get_last_stmt_bracketingN)r
rrrrr)r+rDrErTrXrZrarbrdrfrgrrrrr}s8	{
9r�__main__)�mainzidlelib.idle_test.test_pyparser/)�	verbosity)r
r\r r7r=r:r;r>�compile�VERBOSE�	MULTILINE�searchr"r]rG�DOTALLrLrUrerJ�dictr�fromkeysr5�updaterr
Zunittestrirrrr�<module>s4	U


Hacked By AnonymousFox1.0, Coded By AnonymousFox