Your IP : 18.227.134.165


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.pyc

�
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>t|�dks(|ddks(t�||_d|_dS)Nr��
���)r�AssertionError�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:
rrr)r r�range�rfind�start�span)
rZis_char_in_string�_synchrer �pos�limitZtries�i�mr"rrr�find_good_parse_start�s8
	
zParser.find_good_parse_startcCsR|dks)|j|ddks)t�|dkrN|j|d�|_ndS)Nrrr)r 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)r1)r2r3rrrr4�sz)}]ccs'|]}t|�t|�fVqdS)N)r1)r2r3rrrr4�sz"'\
#r�xc
Cs|jdkrdSd|_|j}|j|j�}|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}t}d}}dg|_}|j}dt|�}}x�||kr�||}	|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�||ks�t	�||dkr�|d}n|d}q�q�q�W|d|kr�t
}q�t}q�n|	dkr5|jd|�}|dks�t	�q�n|	dksGt	�||ksYt	�||dkr�|d}|d|kr�t
}q�n|d}q�W|t
kr�|tkr�|dkr�t}n||_|tk|d|kks�t	�|d|kr||�ndS)NrZxxxxxxxxr6ZxxxxZxxz
xrrr0r5�"�'���\�#rr)r!r �	translate�_tran�replace�C_NONE�	goodlines�appendrr�C_STRING_FIRST_LINE�C_STRING_NEXT_LINES�find�C_BACKSLASH�	C_BRACKET�continuation)
rr rH�levelZlnorAZ	push_goodr+�n�chZquoteZfirstlno�wrrr�_study1�s�		
	





"









	
		"zParser._study1cCs|j�|jS)N)rMrH)rrrr�get_continuation_typegs
zParser.get_continuation_typecCs�|jdkrdS|j�d|_|j|j}}t|�d}t|�}x||r�|sjt�|}x@t||d||�D]#}|jdd|d�d}q�Wt||�r�|d}qXPqXW|dkr�|dks�t�|}n|||_	|_
d}g}|j}	|dfg}
xu||kr�t|||�}|r�|j
�}|d}x*||kr�||dkr�|d}qrW||kr�||}n|}||kr�Pq�n||}
|
dkr|	|�|
j|t|�f�|
}|d}q5n|
dkrh|r9|d
=n|
}|d}|
j|t|�f�q5n|
d	ks�|
d
kr�|
j|t|�df�|
}t|||�j
�}|
j|t|�f�q5n|
dkrM|
j|t|�df�|jd||�d}|dks.t�|
j|t|�f�q5n|
dks_t�|d}||ks{t�||dkr�|
||}n|d}q5W||_|r�|d|_nt|
�|_dS)Nr9rrr�z 	
z([{z)]}r7r8r<r;rr)r!rMr rArrr$r%�_junkre�
stmt_start�stmt_endrB�_chew_ordinaryre�end�_match_stringrerE�lastch�lastopenbracketpos�tuple�stmt_bracketing)rr rAr+�p�qZnothingrV�stackZ
push_stackZ
bracketingr,ZnewprKrrr�_study2|s�
		"!
		







	zParser._study2cCs|j�|jtkst�|j}|j}t|�}|jdd|�d}}|d}x�||kr�t||�}|r�|j	�d}d}Pqg|j
d|�d}}qgW|}}x||dkr�|d}q�W|j}t|||�j|j
��|S)Nrrrz 	)r]rHrGrrWr rr%�_itemrerTrEr�
expandtabsr)r�jr rJZorigir+r,Zextrarrr�compute_bracket_indent�s&
		

	zParser.compute_bracket_indentcCs#|j�|j}|d|dS)Nrr9r���)rMrA)rrArrr�get_num_lines_in_stmts
	zParser.get_num_lines_in_stmtcCs|j�|jtkst�|j}|j}x||dkrQ|d}q4W|}|jd|�d}d}}x||kr�||}|dkr�|d}|d}q{|dkr�|r�|d}n|d}q{|dks�|dkrt|||�j�}q{|d	kr#Pq{|dkry|d
kry|dks[||ddkry||dd
kryd}Pq{|d}q{W|r�|d}t	j
d|||��dk}n|s�|}x!||d
kr�|d}q�Wnt||j|�j|j
��dS)Nz 	rrrz([{z)]}r7r8r<�=z=<>!z\s*\\z 	
)r]rHrFrr rQrErUrT�re�matchrr_r)rr r+�startpos�endpos�foundrIrKrrr�compute_backslash_indentsJ
		





 
%zParser.compute_backslash_indentcCsg|j�|j|j}}|}|j}x*||krX||dkrX|d}q/W|||�S)Nz 	r)r]rQrRr )rr+rJr`r rrr�get_base_indent_stringFs
	zParser.get_base_indent_stringcCs|j�|jdkS)N�:)r]rV)rrrr�is_block_openerQs
zParser.is_block_openercCs#|j�t|j|j�dk	S)N)r]�_closerer rQ)rrrr�is_block_closerWs
zParser.is_block_closercCs|j�|jS)N)r]rW)rrrr�get_last_open_bracket_pos^s
z Parser.get_last_open_bracket_poscCs|j�|jS)N)r]rY)rrrr�get_last_stmt_bracketinggs
zParser.get_last_stmt_bracketing)rrrr
r#r(r-r/r>�updaterr1rMrNr]rarcrjrkrmrorWrprYrqrrrrr�s.3	�m	5r)re�sys�collectionsrr$r@rFrCrDrG�compile�VERBOSE�	MULTILINE�searchr(rfrP�DOTALLrUr^rnrSrrrrrr�<module>s"	*

?>