File "HyperParser.cpython-34.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python34/lib64/python3.4/idlelib/__pycache__/HyperParser.cpython-34.pyc
File size: 7.26 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit


e fM2@sdZddlZddlmZddlmZeejejdZ	eejdZ
ddedDZd	dedDZ
Gd
ddZedkrddlZejd
ddndS)zProvide 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.
N)	iskeyword)PyParse_cCs"g|]}t|tkqS)chr_ASCII_ID_CHARS).0xrr8/opt/alt/python34/lib64/python3.4/idlelib/HyperParser.py
<listcomp>s	rcCs"g|]}t|tkqSr)r_ASCII_ID_FIRST_CHARS)rr	rrr
rs	c@seZdZddZddZddZddZd	d
ddZed
ddhZ	e
ddZdZddZ
dS)HyperParserc
s|_|j_}tj|j|j}dd}||j|}|jsx|jD]}t	||d}t
|d}	d|}
|j|j|	|
d|j
|j|	}|dk	s|dkrePqeqeW|j|pdn_|jd	|}|r(|d}	nd
}	d|}
|j|j|	|
d|jd|jdd_|
_|j_fdd
ttjD_j|dS)z;To initialize, analyze the surroundings of the given index.cSstt|S)N)intfloat)indexrrr

index2line#sz(HyperParser.__init__.<locals>.index2linez.0z%d.endz 
NrZconsolez1.0csBg|]8}|dko;j|dj|ddkqS)rr)
bracketing)ri)selfrr
rLs	z(HyperParser.__init__.<locals>.<listcomp>)editwintextrZParserZindentwidthZtabwidthrZcontext_use_ps1Znum_context_linesmaxreprZset_strgetZfind_good_parse_startZ_build_char_in_string_funcZset_loZ
tag_prevrangestrrawtextstopatindexZget_last_stmt_bracketingrrangelenisopener	set_index)
rrrrparserrZlnocontextZstartatZstartatindexr Zbodrr)rr
__init__s:		



	zHyperParser.__init__cCst|jt|jj||j}|dkrJtd|n||_d|_xP|jt|jdkr|j|jdd|jkr|jd7_q_W|jt|jdkr|j|jdd|jkr|j	|jdr|jd7_ndS)zgSet the index to which the functions relate.

        The index must be in the same statement.
        rz(Index %s precedes the analyzed statementrN)
r"rrrr 
ValueErrorindexinrawtextindexbracketrr#)rrr*rrr
r$Rs
		!!zHyperParser.set_indexcCs/|j|jo.|j|j|jddkS)z2Is the index given to the HyperParser in a string?r"')r,r-)r#r+rr)rrrr
is_in_stringgszHyperParser.is_in_stringcCs0|j|jp/|j|j|jddkS)z5Is the index given to the HyperParser in normal code?r#r,r-)r/r,r-)r#r+rr)rrrr

is_in_codeoszHyperParser.is_in_codez([{FcCs|j|jd}|j}x{|j|sc|j|j|d|ksc|j|d|kr|d8}|dkr}dSt||j|d}q W|jd}x:|t|jkr|j|d|kr|d7}qW|jjd|jt|j|j|df}|t|jksQ|j|dt|jkrg|r[dS|j}n;|jjd|jt|j|j|ddf}||fS)aReturn 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.
        rrNz%s-%dc)	rr+r#rminr"rrr )rZopenersZ	mustcloseZbracketinglevelZbeforeafterZbeforeindexZ
afterindexrrr
get_surrounding_bracketsus0	

+ 		)z$HyperParser.get_surrounding_bracketsTrueFalseNonecCst}|}xL||krZt||ddkrZ|t||drZ|d8}qW||krSt||ddkrSx<|d|krd||d|jr|d8}qW|d|krd||d|jr|d8}n|d|kr6d||d|jr6|d8}n|||jszdSn'||krztt||szdSn||krt|||r||||jkrdS||S)zGiven a string and pos, return the number of chars in the
        identifier which ends at pos, or 0 if there is no such one.

        This ignores non-identifier eywords are not identifiers.
        rrarr)_IS_ASCII_ID_CHARordisidentifier_IS_ASCII_ID_FIRST_CHARr_ID_KEYWORDS)clsrlimitposZis_ascii_id_charrrrr
_eat_identifiers.&1.
.
zHyperParser._eat_identifierz 	
\c
Csw|jstdn|j}|j}|j}||d}|j}|}d}x
x||kr||d|jkr|d8}q_|r||kr||ddkr|d8}d}q_||kr*|dkr*|||dddkr*|d8}||d}||dd}q_Pq_W|s9Pn|j|||}|rm||}|}d}q\||kra||d}	x2|dkr||dd|	kr|d8}qW||d|krPn||d}|d8}||d}|}||d	krqb||d
kr]x.|dkrS||ddkrS|d8}q&W|}nPq\Pq\W|||jS)zReturn a string with the Python expression which ends at the
        given index, which is empty if there is no real one.
        z>get_expression should only be calledif index is inside a code.rTr.r/rFz([z'"ZrRbBuU)r0r)rrr+r*_whitespace_charsrA)
rrrZ
brck_indexZ
brck_limitr@Zlast_identifier_posZ
postdot_phaseZretlevelrrr
get_expressionsb				#
 
	

	'
#	zHyperParser.get_expressionN)__name__
__module____qualname__r(r$r.r0r3	frozensetr=classmethodrArCrErrrr
rs7,:r__main__z"idlelib.idle_test.test_hyperparser	verbosityr)__doc__stringkeywordrZidlelibrrIZ
ascii_lettersZdigitsrr
r!r9r<rrFZunittestmainrrrr
<module>s