ok

Mini Shell

Direktori : /opt/alt/python27/lib64/python2.7/idlelib/
Upload File :
Current File : //opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pyc

�
�[
bc@ssdZddlZddlZddlmZdd
d��YZedkroddlZejddd	�ndS(s�Provide advanced parsing abilities for ParenMatch and other extensions.

HyperParser uses PyParser.  PyParser mostly gives information on the
proper indentation of code.  HyperParser gives additional information on
the structure of code.
i����N(tPyParsetHyperParsercBsteZd�Zd�Zd�Zd�Zded�ZdZe	j
e	jdZe	j
dZ
d�Zd	�ZRS(
cCs�||_|j|_}tj|j|j�}d�}||j|��}|jsx�|jD]�}t	||d�}t
|�d}	d|}
|j|j|	|
�d�|j
|j|	��}|d
k	s�|dkrbPqbqbW|j|p�d�n_|jd|�}|r%|d}	nd}	d|}
|j|j|	|
�d�|jd�|jd	 |_|
|_|j�|_gtt|j��D]8}
|
dko�|j|
d|j|
ddk^q�|_|j|�d
S(s;To initialize, analyze the surroundings of the given index.cSstt|��S(N(tinttfloat(tindex((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pyt
index2linesis.0s%d.ends 
itconsoles1.0i����N(teditwinttextRtParsertindentwidthttabwidthRtcontext_use_ps1tnum_context_linestmaxtreprtset_strtgettfind_good_parse_startt_build_char_in_string_functNonetset_lot
tag_prevrangetstrtrawtexttstopatindextget_last_stmt_bracketingt
bracketingtrangetlentisopenert	set_index(tselfRRRtparserRtlnotcontexttstartattstartatindexRtbodtrti((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pyt__init__s:			



	TcCst|j�t|jj||j��}|dkrJtd|��n||_d|_xP|jt|j�dkr�|j|jdd|jkr�|jd7_q_W|jt|j�dkr|j|jdd|jkr|j	|jdr|jd7_ndS(sgSet the index to which the functions relate.

        The index must be in the same statement.
        is(Index %s precedes the analyzed statementiN(
RRRRRt
ValueErrortindexinrawtexttindexbracketRR(R RR+((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pyREs
		!!cCs/|j|jo.|j|j|jddkS(s2Is the index given to the HyperParser in a string?it"t'(R-R.(RR,RR(R ((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pytis_in_stringZscCs0|j|jp/|j|j|jddkS(s5Is the index given to the HyperParser in normal code?it#R-R.(R0R-R.(RR,RR(R ((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pyt
is_in_codebss([{cCs�|j|jd}|j}x{|j|sc|j|j|d|ksc|j|d|kr�|d8}|dkr}dSt||j|d�}q W|jd}x:|t|j�kr�|j|d|kr�|d7}q�W|jjd|j	t|j�|j|df�}|t|j�ksQ|j|dt|j�krg|r[dS|j	}n;|jjd|j	t|j�|j|ddf�}||fS(s�Return bracket indexes or None.

        If the index given to the HyperParser is surrounded by a
        bracket defined in openers (or at least has one before it),
        return the indices of the opening bracket and the closing
        bracket (or the end of line, whichever comes first).

        If it is not surrounded by brackets, or the end of line comes
        before the closing bracket and mustclose is True, returns None.
        iis%s-%dcN(
RR,RRRtminRRRR(R topenerst	mustclosetbracketingleveltbeforetaftertbeforeindext
afterindex((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pytget_surrounding_bracketshs0	

+ 		)s 	
\t_cCs�|}x1||kr9||d|jkr9|d8}q	W||krx|||jksotj|||!�rx|}n||S(Ni(t	_id_charst_id_first_charstkeywordt	iskeyword(R RtlimittposR(((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pyt_eat_identifier�s&	c
Cst|j�std��n|j}|j}|j}||d}|j}|}t}x
x�||kr�||d|jkr�|d8}q_|r�||kr�||ddkr�|d8}t}q_||kr*|dkr*|||dddkr*|d8}||d}||dd}q_Pq_W|s9Pn|j|||�}|rm||}|}t	}q\||kra||d}	x2|dkr�||dd|	kr�|d8}q�W||d|kr�Pn||d}|d8}||d}|}||dkrqb||dkr]x.|dkrS||dd	krS|d8}q&W|}nPq\Pq\W|||j!S(
s�Return a string with the Python expression which ends at the
        given index, which is empty if there is no real one.
        s?get_expression should only be called if index is inside a code.iit.R0is([s'"trRbBuU(
R1R*RRR,R+tTruet_whitespace_charsRBtFalse(
R RRt
brck_indext
brck_limitRAtlast_identifier_post
postdot_phasetrettlevel((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pytget_expression�sb				#
 
	

	'
#	(t__name__t
__module__R)RR/R1RGR:RFtstringt
ascii_letterstdigitsR<R=RBRN(((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pyRs	7			+
		t__main__s"idlelib.idle_test.test_hyperparsert	verbosityi((	t__doc__RQR>tidlelibRRROtunittesttmain(((s8/opt/alt/python27/lib64/python2.7/idlelib/HyperParser.pyt<module>s�

Zerion Mini Shell 1.0