ok
Direktori : /lib64/python2.7/idlelib/ |
Current File : //lib64/python2.7/idlelib/HyperParser.pyc |
� {fc @ ss d Z d d l Z d d l Z d d l m Z d d d � � YZ e d k ro d d l Z e j d d d �n d S( 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( t PyParset HyperParserc B st e Z d � Z d � Z d � Z d � Z d e d � Z d Z e j e j d Z e j d Z d � Z d � Z RS( c C s� | | _ | j | _ } t j | j | j � } d � } | | j | � � } | j s x� | j D]� } t | | d � } t | � d } d | } | j | j | | � d � | j | j | � � } | d k s� | d k rb Pqb qb W| j | p� d � n_ | j d | � } | r%| d } n d } d | } | j | j | | � d � | j d � | j d | _ | | _ | j � | _ g t t | j � � D]8 } | d k o�| j | d | j | d d k ^ q�| _ | j | � d S( s; To initialize, analyze the surroundings of the given index.c S s t t | � � S( N( t intt float( t index( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyt index2line s i s .0s %d.ends i t consoles 1.0i����N( t editwint textR t Parsert indentwidtht tabwidthR t context_use_ps1t num_context_linest maxt reprt set_strt gett find_good_parse_startt _build_char_in_string_funct Nonet set_lot tag_prevranget strt rawtextt stopatindext get_last_stmt_bracketingt bracketingt ranget lent isopenert set_index( t selfR R R t parserR t lnot contextt startatt startatindexR t bodt rt i( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyt __init__ s: Tc C s t | j � t | j j | | j � � } | d k rJ t d | � � n | | _ d | _ xP | j t | j � d k r� | j | j d d | j k r� | j d 7_ q_ W| j t | j � d k r| j | j d d | j k r| j | j d r| j d 7_ n d S( sg Set the index to which the functions relate. The index must be in the same statement. i s( Index %s precedes the analyzed statementi N( R R R R R t ValueErrort indexinrawtextt indexbracketR R ( R R R+ ( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyR E s !!c C s/ | j | j o. | j | j | j d d k S( s2 Is the index given to the HyperParser in a string?i t "t '( R- R. ( R R, R R ( R ( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyt is_in_stringZ s c C s0 | j | j p/ | j | j | j d d k S( s5 Is the index given to the HyperParser in normal code?i t #R- R. ( R0 R- R. ( R R, R R ( R ( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyt is_in_codeb s s ([{c C s� | j | j d } | j } x{ | j | sc | j | j | d | k sc | j | d | k r� | d 8} | d k r} d St | | j | d � } q W| j d } x: | t | j � k r� | j | d | k r� | d 7} q� W| j j d | j t | j � | j | d f � } | t | j � k sQ| j | d t | j � k rg| r[d S| j } n; | j j d | j t | j � | j | d d f � } | | f S( 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. i i s %s-%dcN( R R, R R R t minR R R R ( R t openerst mustcloset bracketinglevelt beforet aftert beforeindext afterindex( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyt get_surrounding_bracketsh s0 + )s \t _c C s� | } x1 | | k r9 | | d | j k r9 | d 8} q W| | k rx | | | j k so t j | | | !� rx | } n | | S( Ni ( t _id_charst _id_first_charst keywordt iskeyword( R R t limitt posR( ( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyt _eat_identifier� s & c C st | j � s t d � � n | j } | j } | j } | | d } | j } | } t } x x� | | k r� | | d | j k r� | d 8} q_ | r� | | k r� | | d d k r� | d 8} t } q_ | | k r*| d k r*| | | d d d k r*| d 8} | | d } | | d d } q_ Pq_ W| s9Pn | j | | | � } | rm| | } | } t } q\ | | k ra| | d } x2 | d k r�| | d d | k r�| d 8} q�W| | d | k r�Pn | | d } | d 8} | | d } | } | | d k rqb| | d k r]x. | d k rS| | d d k rS| d 8} q&W| } n Pq\ 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.i i t .R0 i s ([s '"t rRbBuU( R1 R* R R R, R+ t Truet _whitespace_charsRB t False( R R R t brck_indext brck_limitRA t last_identifier_post postdot_phaset rett level( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyt get_expression� sb # ' # ( t __name__t __module__R) R R/ R1 RG R: RF t stringt ascii_letterst digitsR<