%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/idlelib/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/idlelib/__pycache__/hyperparser.cpython-38.pyc

U

qaS2@sdZddlmZddlZddlmZeejejdZ	eejdZ
ddedDZd	dedDZ
Gd
ddZedkrdd
lmZeddddS)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.
)	iskeywordN)pyparse_cCsg|]}t|tkqS)chr_ASCII_ID_CHARS.0xrr//usr/local/lib/python3.8/idlelib/hyperparser.py
<listcomp>srcCsg|]}t|tkqSr)r_ASCII_ID_FIRST_CHARSrrrrrsc@s\eZdZddZddZddZddZdddZed
ddhZ	e
ddZdZddZ
dS)HyperParserc
sH|_|j_}t|j|j}dd}|||}|js|jD]`}t	||d}t
|d}	d|}
|||	|
d|
||	}|dk	s|dkrDqqD||pdnF|d	|}|r|d}	nd
}	d|}
|||	|
d|d|jdd_|
_|_fdd
ttjD_|dS)z;To initialize, analyze the surroundings of the given index.cSstt|S)N)intfloat)indexrrr
index2line"sz(HyperParser.__init__.<locals>.index2linez.0z%d.endz 
NrZconsolez1.0cs4g|],}|dko.j|dj|ddkqS)rr)
bracketing)r	iselfrrrKsz(HyperParser.__init__.<locals>.<listcomp>)editwintextrZParserZindentwidthZtabwidthrZprompt_last_lineZnum_context_linesmaxreprZset_codegetZfind_good_parse_startZ_build_char_in_string_funcZset_loZ
tag_prevrangecoderawtextstopatindexZget_last_stmt_bracketingrrangelenisopener	set_index)
rrrrparserrlnocontextZstartatZstartatindexr!Zbodrrrr__init__s>




zHyperParser.__init__cCst|jt|j||j}|dkr2td|||_d|_|jt|jdkr||j|jdd|jkr||jd7_q>|jt|jdkr|j|jdd|jkr|j	|jds|jd7_dS)zgSet the index to which the functions relate.

        The index must be in the same statement.
        rz(Index %s precedes the analyzed statementrN)
r#r rrr!
ValueErrorindexinrawtextindexbracketrr$)rrr,rrrr%Qs&zHyperParser.set_indexcCs&|j|jo$|j|j|jddkS)z2Is the index given to the HyperParser in a string?r)"'r$r-r rrrrris_in_stringfs
zHyperParser.is_in_stringcCs(|j|jp&|j|j|jddkS)z5Is the index given to the HyperParser in normal code?r)#r.r/r0rrrr
is_in_codens
zHyperParser.is_in_code([{FcCsB|j|jd}|j}|j|rJ|j|j|d|ksJ|j|d|krt|d8}|dkr^dSt||j|d}q|jd}|t|jkr|j|d|kr|d7}q~|jd|jt|j|j|df}|t|jks|j|dt|jkr|rdS|j}n.|jd|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$r minr#rrr!)rZopenersZ	mustcloseZbracketinglevelbeforeZafterZbeforeindexZ
afterindexrrrget_surrounding_bracketsts>


z$HyperParser.get_surrounding_bracketsTrueFalseNonecCsVt}|}||krBt||ddkrB|t||drB|d8}q||krt||ddkr|d|krd||d|r|d8}q^|d|krd||d|r|d8}|d|krd||d|r|d8}|||sdSn ||krtt||sdS||krNt|||rN||||jkrNdS||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
ar)_IS_ASCII_ID_CHARordisidentifier_IS_ASCII_ID_FIRST_CHARr_ID_KEYWORDS)clsstrlimitposZis_ascii_id_charrrrr_eat_identifiers6
$
$$

zHyperParser._eat_identifierz 	
\c
Cs|std|j}|j}|j}||d}|j}|}d}||kr`||d|jkr`|d8}q<|s||kr||ddkr|d8}d}q<||kr|dkr|||dddkr|d8}||d}||dd}q<qq<|sq||||}|r
||}|}d}q<||kr||d}	|dkrL||dd|	krL|d8}q ||d|krbq||d}|d8}||d}|}||d	krn>||d
kr|dkr||ddkr|d8}q|}qq<qq<|||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 called if index is inside a code.rTr.r2r=Fz([z'"ZrRbBuU)r3r+r rr-r,_whitespace_charsrG)
rr rZ
brck_indexZ
brck_limitrFZlast_identifier_posZ
postdot_phaseretlevelrrrget_expressionsf

 zHyperParser.get_expressionN)r4F)__name__
__module____qualname__r*r%r1r3r7	frozensetrBclassmethodrGrIrLrrrrrs7
,
9r__main__)mainz"idlelib.idle_test.test_hyperparserr=)	verbosity)__doc__keywordrstringZidlelibrrP
ascii_lettersdigitsrrr"r>rArrMZunittestrSrrrr<module>s

Zerion Mini Shell 1.0