Your IP : 3.139.86.74


Current Path : /opt/alt/python34/lib64/python3.4/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/idlelib/__pycache__/PyParse.cpython-34.pyo

�
e f�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/python34/lib64/python3.4/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
CsU|jd}}|sdSt|�}x�td�D]�}|jdd|�}|dkr^Pn|jdd|�d}||||�}|r�||j��r�|j�}Pn|}q3W|dkr||�}|r�||j��r�|j�}n|S|d}xD|||�}|rL|j�\}	}||	�sM|	}qMq
Pq
W|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�|_ndS)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
Cs�|jdkrdSd|_|j}|j|j�}|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}t}d}}dg|_}|j}dt|�}}x�||krT||}	|d}|	dkrq�n|	dkr7|d}|dkr�||�q�q�n|	d	krS|d}q�n|	d
krx|r�|d}q�q�n|	dks�|	dkr�|	}
||d|d
�|
dkr�|
d}
n|}t|
�d}||}x�||kr�||}	|d}|	dkrq�n||d||�|
krF||}Pn|	dkr�|d}|dkr�|dkr�||�nPq�q�n|	dkr�||dkr�|d}n|d}q�q�q�W|d|kr�t	}q�t
}q�n|	dkr|jd|�}q�n||dkrG|d}|d|krGt}qGn|d}q�W|t	kr�|t
kr�|dkr�t
}n||_|d|kr�||�ndS)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_typecCs�|jdkrdS|j�d|_|j|j}}t|�d}t|�}xp|r�|}x@t||d||�D]#}|jdd|d�d}q�Wt||�r�|d}qXPqXW|dkr�|}n|||_|_	d}g}|j
}	|dfg}
x?||krUt|||�}|r�|j�}|d}x*||kr}||dkr}|d}qTW||kr�||}n|}||kr�Pq�n||}
|
dkr�|	|�|
j
|t|�f�|
}|d}qn|
dkrJ|r|d=n|
}|d}|
j
|t|�f�qn|
d	ksb|
d
kr�|
j
|t|�df�|
}t
|||�j�}|
j
|t|�f�qn|
dkr|
j
|t|�df�|jd||�d}|
j
|t|�f�qn|d}||dkrH|
||}n|d}qW||_|ru|d
|_nt|
�|_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||krq||}|dkr�|d}|d}qf|dkr�|r�|d}n|d}qf|dks�|dkr�t|||�j�}qf|d	krPqf|dkrd|d
krd|dksF||ddkrd||dd
krdd}Pqf|d}qfW|r�|d}tjd|||��dk}n|s�|}x!||d
kr�|d}q�Wnt||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"	*

?>