Your IP : 18.191.116.61


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



��Yf�O�@sddlZddlZddlmZed�\ZZZZZ	ej
dejejB�j
Zej
dej�jZej
dejejB�jZej
dej�jZej
dej�jZej
d	ej�jZGd
d�de�ZGdd
�d
�ZdS)�N)�Mapping�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@sUeZdZdZdd�Zdd�Zdd�Zdd	�Zd
dd�Zd
S)
�StringTranslatePseudoMappingaTUtility class to be used with str.translate()

    This Mapping class wraps a given dict. When a value for a key is
    requested via __getitem__() or get(), the key is looked up in the
    given dict. If found there, the value from the dict is returned.
    Otherwise, the default value given upon initialization is returned.

    This allows using str.translate() to make some replacements, and to
    replace all characters for which no replacement was specified with
    a given character instead of leaving them as-is.

    For example, to replace everything except whitespace with 'x':

    >>> whitespace_chars = ' \t\n\r'
    >>> preserve_dict = {ord(c): ord(c) for c in whitespace_chars}
    >>> mapping = StringTranslatePseudoMapping(preserve_dict, ord('x'))
    >>> text = "a + b\tc\nd"
    >>> text.translate(mapping)
    'x x x\tx\nx'
    cCs4||_||_|j|dd�}||_dS)NcSs
|||�S)N�)�key�_getZ_defaultrr�4/opt/alt/python35/lib64/python3.5/idlelib/PyParse.pyrysz3StringTranslatePseudoMapping.__init__.<locals>._get)�
_non_defaultsZ_default_value�getr)�selfZnon_defaults�
default_valuerrrr�__init__us		z%StringTranslatePseudoMapping.__init__cCs
|j|�S)N)r)r�itemrrr�__getitem__}sz(StringTranslatePseudoMapping.__getitem__cCs
t|j�S)N)�lenr	)rrrr�__len__�sz$StringTranslatePseudoMapping.__len__cCs
t|j�S)N)�iterr	)rrrr�__iter__�sz%StringTranslatePseudoMapping.__iter__NcCs
|j|�S)N)r)rr�defaultrrrr
�sz StringTranslatePseudoMapping.get)	�__name__�
__module__�__qualname__�__doc__r
rrrr
rrrrr`src@sBeZdZdd�Zdd�Zdedd�Zdd	�ZiZej	d
d�dD��ej	d
d�dD��ej	dd�dD��e
eded��Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdZd%d&�ZdZd'd(�ZdS))�ParsercCs||_||_dS)N)�indentwidth�tabwidth)rrrrrrr
�s	zParser.__init__cCs||_d|_dS)Nr)�str�study_level)r�srrr�set_str�s	zParser.set_strNc
CsI|jd}}|sdSt|�}x�td�D]}|jdd|�}|dkr[P|jdd|�d}||||�}|r�||j��r�|j�}P|}q3W|dkr�||�}|r�||j��r�|j�}|S|d}xA|||�}|r@|j�\}	}||	�sA|	}qPqW|S)Nrz:
r�
�)rr�range�rfind�start�span)
rZis_char_in_string�_synchrer�pos�limitZtries�i�mrrrr�find_good_parse_start�s8
	
	zParser.find_good_parse_startcCs&|dkr"|j|d�|_dS)Nr)r)r�lorrr�set_lo�sz
Parser.set_loccs'|]}t|�td�fVqdS)�(N)�ord)�.0�crrr�	<genexpr>�szParser.<genexpr>z({[ccs'|]}t|�td�fVqdS)�)N)r/)r0r1rrrr2�sz)}]ccs'|]}t|�t|�fVqdS)N)r/)r0r1rrrr2�sz"'\
#r�xc
Csp|jdkrdSd|_|j}|j|j�}|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}t}d}}dg|_}|j}dt|�}}xO||kr||}	|d}|	dkr�q�|	dkr.|d}|dkr�||�q�|	d	krG|d}q�|	d
krf|r�|d}q�|	dks~|	dkr�|	}
||d|d
�|
dkr�|
d}
|}t|
�d}||}x�||kr�||}	|d}|	dkrq�||d||�|
kr+||}P|	dkrg|d}|dkr�|dkrc||�Pq�|	dkr�||dkr�|d}|d}q�q�W|d|kr�t	}q�t
}q�|	dkr�|jd|�}q�||dkr|d}|d|krt}|d}q�W|t	krI|t
krI|dkrIt
}||_|d|krl||�dS)Nr!Zxxxxxxxxr4ZxxxxZxxz
xr rr.r3�"�'���\�#���)rr�	translate�_tran�replace�C_NONE�	goodlines�appendr�C_STRING_FIRST_LINE�C_STRING_NEXT_LINES�find�C_BACKSLASH�	C_BRACKET�continuation)
rrrG�levelZlnor@Z	push_goodr)�n�chZquoteZfirstlno�wrrr�_study1�s�		
	





"








	
	zParser._study1cCs|j�|jS)N)rLrG)rrrr�get_continuation_typegs
zParser.get_continuation_typecCsg|jdkrdS|j�d|_|j|j}}t|�d}t|�}xp|r�|}x@t||d||�D]#}|jdd|d�d}q�Wt||�r�|d}qXPqXW|dkr�|}|||_|_	d}g}|j
}	|dfg}
x$||kr7t|||�}|r�|j�}|d}x*||krz||dkrz|d}qQW||kr�||}|}||kr�P||}
|
dkr�|	|�|
j
|t|�f�|
}|d}q|
dkr5|r	|d=|
}|d}|
j
|t|�f�q|
d	ksM|
d
kr�|
j
|t|�df�|
}t
|||�j�}|
j
|t|�f�q|
dkr|
j
|t|�df�|jd||�d}|
j
|t|�f�q|d}||dkr*|
||}|d}qW||_|rT|d
|_t|
�|_dS)Nr7r!r r�z 	
z([{z)]}r5r6r:r;r;)rrLrr@rr"r#�_junkre�
stmt_start�stmt_endrA�_chew_ordinaryre�end�_match_stringrerD�lastch�lastopenbracketpos�tuple�stmt_bracketing)rrr@r)�p�qZnothingrU�stackZ
push_stackZ
bracketingr*ZnewprJrrr�_study2|s�
		"!
	






	
zParser._study2cCs|j�|j}|j}t|�}|jdd|�d}}|d}x�||kr�t||�}|r�|j�d}d}PqR|jd|�d}}qRW|}}x||dkr�|d}q�W|j}t|||�j	|j
��|S)Nr rr!z 	)r\rVrrr#�_itemrerSrDr�
expandtabsr)r�jrrIZorigir)r*Zextrarrr�compute_bracket_indent�s$
		

	zParser.compute_bracket_indentcCs#|j�|j}|d|dS)Nr!r7r;���)rLr@)rr@rrr�get_num_lines_in_stmts
	zParser.get_num_lines_in_stmtcCs�|j�|j}|j}x||dkr<|d}qW|}|jd|�d}d}}x	||krn||}|dkr�|d}|d}qf|dkr�|r�|d}|d}qf|dks�|dkr�t|||�j�}qf|d	krPqf|dkra|d
kra|dksC||ddkra||dd
krad}Pqf|d}qfW|r�|d}tjd|||��dk}|s�|}x||d
kr�|d}q�Wt||j|�j	|j
��dS)Nz 	r!r rz([{z)]}r5r6r:�=z=<>!z\s*\\z 	
)r\rrPrDrTrS�re�matchrr^r)rrr)�startpos�endpos�foundrHrJrrr�compute_backslash_indentsH
		





 
"zParser.compute_backslash_indentcCsg|j�|j|j}}|}|j}x*||krX||dkrX|d}q/W|||�S)Nz 	r!)r\rPrQr)rr)rIr_rrrr�get_base_indent_stringFs
	zParser.get_base_indent_stringcCs|j�|jdkS)N�:)r\rU)rrrr�is_block_openerQs
zParser.is_block_openercCs#|j�t|j|j�dk	S)N)r\�_closererrP)rrrr�is_block_closerWs
zParser.is_block_closercCs|j�|jS)N)r\rV)rrrr�get_last_open_bracket_pos^s
z Parser.get_last_open_bracket_poscCs|j�|jS)N)r\rX)rrrr�get_last_stmt_bracketinggs
zParser.get_last_stmt_bracketing)rrrr
rr&r+r-r=�updaterr/rLrMr\r`rbrirjrlrnrVrorXrprrrrr�s.3	�m	5r)rd�sys�collectionsrr"r?rErBrCrF�compile�VERBOSE�	MULTILINE�searchr&rerO�DOTALLrTr]rmrRrrrrrr�<module>s"	*

?>