• File: hyperparser.cpython-37.opt-1.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/hyperparser.cpython-37.opt-1.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 6.59 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

NjS2@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).0xrr8/opt/alt/python37/lib64/python3.7/idlelib/hyperparser.py
<listcomp>srcCsg|]}t|tkqSr)r_ASCII_ID_FIRST_CHARS)rr	rrr
rsc@s\eZdZddZddZddZddZdddZed
ddhZ	e
ddZdZddZ
dS)HyperParserc
sJ|_|j_}t|j|j}dd}|||}|jsxh|jD]^}t	||d}t
|d}	d|}
|||	|
d|
||	}|dk	s|dkrFPqFW||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)ri)selfrr
rKsz(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)
rrrrparserrZlnocontextZstartatZstartatindexrZbodrr)rr
__init__s:



zHyperParser.__init__cCst|jt|j||j}|dkr2td|||_d|_x@|jt|jdkr~|j|jdd|jkr~|jd7_q@W|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!rrrr
ValueErrorindexinrawtextindexbracketrr")rrr)rrr
r#QszHyperParser.set_indexcCs&|j|jo$|j|j|jddkS)z2Is the index given to the HyperParser in a string?r)"')r"r*rr)rrrr
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,)r"r*rr)rrrr

is_in_codenszHyperParser.is_in_code([{FcCsL|j|jd}|j}x`|j|rL|j|j|d|ksL|j|d|krv|d8}|dkr`dSt||j|d}qW|jd}x,|t|jkr|j|d|kr|d7}qW|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"rminr!rrr)rZopenersZ	mustcloseZbracketinglevelZbeforeZafterZbeforeindexZ
afterindexrrr
get_surrounding_bracketsts0
""z$HyperParser.get_surrounding_bracketsTrueFalseNonecCsdt}|}x<||krDt||ddkrD|t||drD|d8}q
W||krt||ddkrx0|d|krd||d|r|d8}qhW|d|krd||d|r|d8}|d|krd||d|r|d8}|||s(dSn ||kr(tt||s(dS||kr\t|||r\||||jkr\dS||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_identifiers.
 &$$

zHyperParser._eat_identifierz 	
\c
Cs|std|j}|j}|j}||d}|j}|}d}xx||krf||d|jkrf|d8}qB|s||kr||ddkr|d8}d}qB||kr|dkr|||dddkr|d8}||d}||dd}qBPqBW|sP||||}|r||}|}d}q@||kr||d}	x.|dkrT||dd|	krT|d8}q(W||d|krjP||d}|d8}||d}|}||d	krn@||d
krx*|dkr||ddkr|d8}qW|}Pq@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 called if index is inside a code.rTr.r.r8Fz([z'"ZrRbBuU)r/r(rrr*r)_whitespace_charsrB)
rrrZ
brck_indexZ
brck_limitrAZlast_identifier_posZ
postdot_phaseZretlevelrrr
get_expressionsb

"zHyperParser.get_expressionN)r0F)__name__
__module____qualname__r'r#r-r/r2	frozensetr=classmethodrBrDrFrrrr
rs7
,:r__main__)mainz"idlelib.idle_test.test_hyperparserr8)	verbosity)__doc__keywordrstringZidlelibrrJZ
ascii_lettersZdigitsrr
r r9r<rrGZunittestrMrrrr
<module>s