ok
Direktori : /proc/thread-self/root/lib64/python2.7/idlelib/ |
Current File : //proc/thread-self/root/lib64/python2.7/idlelib/HyperParser.pyc |
� _цdc @ sE d Z d d l Z d d l Z d d l m Z d d d � � YZ d S( sk HyperParser =========== This module defines the HyperParser class, which provides advanced parsing abilities for the ParenMatch and other extensions. The HyperParser uses PyParser. PyParser is intended mostly to give information on the proper indentation of code. HyperParser gives some information on the structure of code, used by extensions to help the user. 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[ Initialize the HyperParser to 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 rF 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( si Set the index to which the functions relate. Note that it must be in the same statement. i s0 The index given is before 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 H s + !!c C s/ | j | j o. | j | j | j d d k S( s5 Is the index given to the HyperParser is in a string?i t "t '( R- R. ( R R, R R ( R ( ( s+ /usr/lib64/python2.7/idlelib/HyperParser.pyt is_in_string[ s c C s0 | j | j p/ | j | j | j d d k S( s: Is the index given to the HyperParser is in a 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� 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 sr | j � s t d � � n | j } | j } | j } | | d } | j } | } t } xx� | | 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_ | s8Pn | j | | | � } | rl| | } | } t } q\ | | k r`| | d } x2 | d k r�| | d d | k r�| d 8} q�W| | d | k r�Pn | | d } | d 8} | | d } | } | | d k rqa| | d k r\x. | d k rR| | d d k rR| d 8} q%W| } n Pq\ Pq\ | | | 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<