ó
xił\c           @  sŅ  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l m Z m Z d d l	 m
 Z
 d d l m Z m Z m Z m Z d d l m Z m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z d	 d
 d d d d d d d d d d g Z d; d< d= d> d? g Z e d    Z d  e  f d!     YZ! e e!  d	 e" f d"     Y Z# d e# f d#     YZ$ d e% f d$     YZ& d% e" f d&     YZ' e'   Z( d' e) f d(     YZ* d) e" f d*     YZ+ d+   Z, d, e" f d-     YZ- e-   Z. d.   Z/ d d@ d/     YZ0 d e f d0     YZ1 d1 e! f d2     YZ2 e e2  d
 e# f d3     Y Z3 d e" f d4     YZ4 d e3 f d5     YZ5 d6   Z6 d7 e2 f d8     YZ7 e e7  d9 e3 f d:     Y Z8 d S(A   s“   
    pygments.lexer
    ~~~~~~~~~~~~~~

    Base lexer classes.

    :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
i’’’’(   t   print_functionN(   t   apply_filterst   Filter(   t   get_filter_by_name(   t   Errort   Textt   Othert
   _TokenType(	   t   get_bool_optt   get_int_optt   get_list_optt   make_analysatort	   text_typet   add_metaclasst	   iteritemst   Futuret   guess_decode(   t	   regex_optt   Lexert
   RegexLexert   ExtendedRegexLexert   DelegatingLexert   LexerContextt   includet   inheritt   bygroupst   usingt   thist   defaultt   wordss   ļ»æs   utf-8s   ’ž  s   utf-32s     ž’s   utf-32bes   ’žs   utf-16s   ž’s   utf-16bec         C  s   d S(   Ng        (    (   t   x(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   <lambda>$   t    t	   LexerMetac           B  s   e  Z d  Z d   Z RS(   s   
    This metaclass automagically converts ``analyse_text`` methods into
    static methods which always return float values.
    c         C  s9   d | k r# t  | d  | d <n  t j |  | | |  S(   Nt   analyse_text(   R   t   typet   __new__(   t   mcst   namet   basest   d(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR$   -   s    (   t   __name__t
   __module__t   __doc__R$   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR!   '   s   c           B  sk   e  Z d  Z d Z g  Z g  Z g  Z g  Z d Z	 d   Z
 d   Z d   Z d   Z e d  Z d   Z RS(	   sČ  
    Lexer for a specific language.

    Basic options recognized:
    ``stripnl``
        Strip leading and trailing newlines from the input (default: True).
    ``stripall``
        Strip all leading and trailing whitespace from the input
        (default: False).
    ``ensurenl``
        Make sure that the input ends with a newline (default: True).  This
        is required for some lexers that consume input linewise.

        .. versionadded:: 1.3

    ``tabsize``
        If given and greater than 0, expand tabs in the input (default: 0).
    ``encoding``
        If given, must be an encoding name. This encoding will be used to
        convert the input string to Unicode, if it is not already a Unicode
        string (default: ``'guess'``, which uses a simple UTF-8 / Locale /
        Latin1 detection.  Can also be ``'chardet'`` to use the chardet
        library, if it is installed.
    ``inencoding``
        Overrides the ``encoding`` if given.
    i    c         K  sÄ   | |  _  t | d t  |  _ t | d t  |  _ t | d t  |  _ t | d d  |  _ | j	 d d  |  _
 | j	 d  p |  j
 |  _
 g  |  _ x' t | d	 d
  D] } |  j |  q© Wd  S(   Nt   stripnlt   stripallt   ensurenlt   tabsizei    t   encodingt   guesst
   inencodingt   filters(    (   t   optionsR   t   TrueR,   t   FalseR-   R.   R	   R/   t   getR0   R3   R
   t
   add_filter(   t   selfR4   t   filter_(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   __init__b   s    		c         C  s2   |  j  r  d |  j j |  j  f Sd |  j j Sd  S(   Ns   <pygments.lexers.%s with %r>s   <pygments.lexers.%s>(   R4   t	   __class__R)   (   R9   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   __repr__n   s    	c         K  s5   t  | t  s! t | |  } n  |  j j |  d S(   s8   
        Add a new stream filter to this lexer.
        N(   t
   isinstanceR   R   R3   t   append(   R9   R:   R4   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR8   u   s    c         C  s   d S(   s~  
        Has to return a float between ``0`` and ``1`` that indicates
        if a lexer wants to highlight this text. Used by ``guess_lexer``.
        If this method returns ``0`` it won't highlight it in any case, if
        it returns ``1`` highlighting with this lexer is guaranteed.

        The `LexerMeta` metaclass automatically wraps this function so
        that it works like a static method (no ``self`` or ``cls``
        parameter) and the return value is automatically converted to
        `float`. If the return value is an object that is boolean `False`
        it's the same as if the return values was ``0.0``.
        N(    (   t   text(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR"   }   R    c           sA  t   t  sA  j d k r3 t   \  } qc  j d k r
y d d l } Wn t k
 rq t d   n Xd } xC t D]; \ } }  j |  r  t	 |  j
 | d  } Pq q W| d k r| j  d   }  j
 | j d  põ d	 d  } n  |  qc j
   j    j d
  rc t	 d
   qcn"  j d
  rc t	 d
   n   j d d    j d d     j r j    n   j rŗ j d   n    j d k rŽ j   j   n    j r j d  r d 7 n     f d   }	 |	   }
 | s=t |
   j    }
 n  |
 S(   s=  
        Return an iterable of (tokentype, value) pairs generated from
        `text`. If `unfiltered` is set to `True`, the filtering mechanism
        is bypassed even if filters are defined.

        Also preprocess the text, i.e. expand tabs and strip it if
        wanted and applies registered filters.
        R1   t   chardeti’’’’Nsk   To enable chardet encoding guessing, please install the chardet library from http://chardet.feedparser.org/t   replacei   R0   s   utf-8u   ļ»æs   
s   
s   i    c          3  s2   x+   j    D] \ }  } } | | f Vq Wd  S(   N(   t   get_tokens_unprocessed(   t   _t   tt   v(   R9   R@   (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   streamer¾   s    (   R>   R   R0   R   RA   t   ImportErrort   Nonet   _encoding_mapt
   startswitht   lent   decodet   detectR7   RB   R-   t   stripR,   R/   t
   expandtabsR.   t   endswithR   R3   (   R9   R@   t
   unfilteredRD   RA   t   decodedt   bomR0   t   encRG   t   stream(    (   R9   R@   s-   lib/python2.7/site-packages/pygments/lexer.pyt
   get_tokens   sL    					c         C  s
   t   d S(   sś   
        Return an iterable of (index, tokentype, value) pairs where "index"
        is the starting position of the token within the input text.

        In subclasses, implement this method as a generator to
        maximize effectiveness.
        N(   t   NotImplementedError(   R9   R@   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRC   Ę   s    N(   R)   R*   R+   RI   R&   t   aliasest	   filenamest   alias_filenamest	   mimetypest   priorityR;   R=   R8   R"   R6   RW   RC   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   3   s   				;c           B  s#   e  Z d  Z e d  Z d   Z RS(   s   
    This lexer takes two lexer as arguments. A root lexer and
    a language lexer. First everything is scanned using the language
    lexer, afterwards all ``Other`` tokens are lexed using the root
    lexer.

    The lexers from the ``template`` lexer package use this base lexer.
    c         K  s;   | |   |  _  | |   |  _ | |  _ t j |  |  d  S(   N(   t
   root_lexert   language_lexert   needleR   R;   (   R9   t   _root_lexert   _language_lexert   _needleR4   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR;   Ū   s    	c         C  sĶ   d } g  } g  } x} |  j  j |  D]i \ } } } | |  j k rx | rk | j t |  | f  g  } n  | | 7} q% | j | | | f  q% W| r“ | j t |  | f  n  t | |  j j |   S(   NR    (   R_   RC   R`   R?   RL   t   do_insertionsR^   (   R9   R@   t   bufferedt
   insertionst
   lng_buffert   iRE   RF   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRC   į   s    "	(   R)   R*   R+   R   R;   RC   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   Ń   s   c           B  s   e  Z d  Z RS(   sI   
    Indicates that a state should include rules from another state.
    (   R)   R*   R+   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   ų   s   t   _inheritc           B  s   e  Z d  Z d   Z RS(   sC   
    Indicates the a state should inherit from its superclass.
    c         C  s   d S(   NR   (    (   R9   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR=     s    (   R)   R*   R+   R=   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRi   ’   s   t   combinedc           B  s    e  Z d  Z d   Z d   Z RS(   s:   
    Indicates a state combined from multiple states.
    c         G  s   t  j |  |  S(   N(   t   tupleR$   (   t   clst   args(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR$     s    c         G  s   d  S(   N(    (   R9   Rm   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR;     s    (   R)   R*   R+   R$   R;   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRj   	  s   	t   _PseudoMatchc           B  sM   e  Z d  Z d   Z d d  Z d d  Z d d  Z d   Z d   Z	 RS(   s:   
    A pseudo match object constructed from a string.
    c         C  s   | |  _  | |  _ d  S(   N(   t   _textt   _start(   R9   t   startR@   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR;     s    	c         C  s   |  j  S(   N(   Rp   (   R9   t   arg(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRq     s    c         C  s   |  j  t |  j  S(   N(   Rp   RL   Ro   (   R9   Rr   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   end"  s    c         C  s   | r t  d   n  |  j S(   Ns   No such group(   t
   IndexErrorRo   (   R9   Rr   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   group%  s    c         C  s
   |  j  f S(   N(   Ro   (   R9   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   groups*  s    c         C  s   i  S(   N(    (   R9   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt	   groupdict-  s    N(
   R)   R*   R+   R;   RI   Rq   Rs   Ru   Rv   Rw   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRn     s   		c            s   d   f d  } | S(   sL   
    Callback that yields multiple actions for each group in the match.
    c         3  s  xś t     D]ģ \ } } | d  k r+ q q t |  t k rw | j | d  } | rł | j | d  | | f Vqł q | j | d  } | d  k	 r | rµ | j | d  | _ n  xA | |  t | j | d  |  |  D] } | rŽ | VqŽ qŽ Wq q W| r| j   | _ n  d  S(   Ni   (	   t	   enumerateRI   R#   R   Ru   Rq   t   posRn   Rs   (   t   lexert   matcht   ctxRh   t   actiont   datat   item(   Rm   (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   callback5  s"    !	&N(   RI   (   Rm   R   (    (   Rm   s-   lib/python2.7/site-packages/pygments/lexer.pyR   1  s    t   _Thisc           B  s   e  Z d  Z RS(   sX   
    Special singleton used for indicating the caller class.
    Used by ``using``.
    (   R)   R*   R+   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   K  s   c           s   i   d  k rV  j  d  } t | t t f  rC |  d <qV d | f  d <n    t k rz d   f d  } n d     f d  } | S(   sĀ  
    Callback that processes the match with a different lexer.

    The keyword arguments are forwarded to the lexer, except `state` which
    is handled separately.

    `state` specifies the state that the new lexer will start in, and can
    be an enumerable such as ('root', 'inline', 'string') or a simple
    string which is assumed to be on top of the root state.

    Note: For that to work, `_other` must not be an `ExtendedRegexLexer`.
    t   statet   stackt   rootc         3  s    r(  j  |  j  |  j    } n |  } | j   } x; | j | j      D]! \ } } } | | | | f VqS W| r | j   | _ n  d  S(   N(   t   updateR4   R<   Rq   RC   Ru   Rs   Ry   (   Rz   R{   R|   t   lxt   sRh   RE   RF   (   t	   gt_kwargst   kwargs(    s-   lib/python2.7/site-packages/pygments/lexer.pyR   i  s    (c         3  s    j  |  j       } | j   } x; | j | j     D]! \ } } } | | | | f VqA W| r~ | j   | _ n  d  S(   N(   R   R4   Rq   RC   Ru   Rs   Ry   (   Rz   R{   R|   R   R   Rh   RE   RF   (   t   _otherR   R   (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   x  s    (N(   t   popR>   t   listRk   R   RI   (   R   R   R   R   (    (   R   R   R   s-   lib/python2.7/site-packages/pygments/lexer.pyR   S  s    
c           B  s   e  Z d  Z d   Z RS(   sŃ   
    Indicates a state or state action (e.g. #pop) to apply.
    For example default('#pop') is equivalent to ('', Token, '#pop')
    Note that state tuples may be used as well.

    .. versionadded:: 2.0
    c         C  s   | |  _  d  S(   N(   R   (   R9   R   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR;     s    (   R)   R*   R+   R;   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR     s   c           B  s&   e  Z d  Z d d d  Z d   Z RS(   s   
    Indicates a list of literal words that is transformed into an optimized
    regex that matches any of the words.

    .. versionadded:: 2.0
    R    c         C  s   | |  _  | |  _ | |  _ d  S(   N(   R   t   prefixt   suffix(   R9   R   R   R   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR;     s    		c         C  s   t  |  j d |  j d |  j S(   NR   R   (   R   R   R   R   (   R9   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR7     s    (   R)   R*   R+   R;   R7   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR     s   t   RegexLexerMetac           B  sP   e  Z d  Z d   Z d   Z d   Z d   Z d d  Z d   Z	 d   Z
 RS(	   sw   
    Metaclass for RegexLexer, creates the self._tokens attribute from
    self.tokens on the first instantiation.
    c         C  s1   t  | t  r | j   } n  t j | |  j S(   sB   Preprocess the regular expression component of a token definition.(   R>   R   R7   t   ret   compileR{   (   Rl   t   regext   rflagsR   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   _process_regex§  s    c         C  s5   t  |  t k s1 t |  s1 t d | f   | S(   s5   Preprocess the token component of a token definition.s2   token type must be simple type or callable, not %r(   R#   R   t   callablet   AssertionError(   Rl   t   token(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   _process_token­  s    !c         C  sk  t  | t  rz | d k r d S| | k r2 | f S| d k rB | S| d  d k ra t | d  St sgt d |   nķ t  | t  rd |  j } |  j d 7_ g  } xF | D]> } | | k sŌ t d	 |   | j |  j | | |   q² W| | | <| f St  | t	  rQx6 | D]. } | | k s| d k st d
 |   qW| St sgt d |   d S(   s=   Preprocess the state transition action of a token definition.s   #popi’’’’s   #pushi   s   #pop:s   unknown new state %rs   _tmp_%di   s   circular state ref %rs   unknown new state s   unknown new state def %rN(   s   #pops   #push(
   R>   t   strt   intR6   R   Rj   t   _tmpnamet   extendt   _process_stateRk   (   Rl   t	   new_statet   unprocessedt	   processedt	   tmp_statet   itokenst   istate(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   _process_new_state³  s6    
c         C  s  t  |  t k s" t d |   | d d k sB t d |   | | k rV | | Sg  } | | <|  j } x| | D]} t | t  rŃ | | k s© t d |   | j |  j | | t |    qx n  t | t  rę qx n  t | t	  r5|  j
 | j | |  } | j t j d  j d | f  qx n  t  |  t k sWt d |   y |  j | d | |  } Wn3 t k
 r©}	 t d | d | |  |	 f   n X|  j | d	  }
 t |  d
 k rŲd } n |  j
 | d
 | |  } | j | |
 | f  qx W| S(   s%   Preprocess a single state definition.s   wrong state name %ri    t   #s   invalid state name %rs   circular state reference %rR    s   wrong rule def %rs+   uncompilable regex %r in state %r of %r: %si   i   N(   R#   R   R   t   flagsR>   R   R   R   Ri   R   R¤   R   R?   R   R   R{   RI   Rk   R   t	   Exceptiont
   ValueErrorR   RL   (   Rl   R   R    R   t   tokensR   t   tdefR   t   rext   errR   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   Ö  s>    " 	""	c         C  sR   i  } |  j  | <| p! |  j | } x' t |  D] } |  j | | |  q1 W| S(   s-   Preprocess a dictionary of token definitions.(   t   _all_tokensR©   R   R   (   Rl   R&   t	   tokendefsR    R   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   process_tokendef  s
    c   
      C  s  i  } i  } x|  j  D]} | j j d i   } xć t |  D]Õ \ } } | j |  } | d k r© | | | <y | j t  } Wn t k
 r q> n X| | | <q> n  | j | d  } | d k rĶ q> n  | | | | d +y | j t  }	 Wn t k
 rq> X| |	 | | <q> Wq W| S(   s  
        Merge tokens from superclasses in MRO order, returning a single tokendef
        dictionary.

        Any state that is not defined by a subclass will be inherited
        automatically.  States that *are* defined by subclasses will, by
        default, override that state in the superclass.  If a subclass wishes to
        inherit definitions from a superclass, it can use the special value
        "inherit", which will cause the superclass' state definition to be
        included at that point in the state.
        R©   i   N(	   t   __mro__t   __dict__R7   R   RI   t   indexR   RØ   R   (
   Rl   R©   t   inheritablet   ct   toksR   t   itemst   curitemst   inherit_ndxt   new_inh_ndx(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   get_tokendefs
  s0    

c         O  sm   d |  j  k rZ i  |  _ d |  _ t |  d  r< |  j r< qZ |  j d |  j    |  _ n  t j	 |  | |  S(   s:   Instantiate cls after preprocessing its token definitions.t   _tokensi    t   token_variantsR    (
   R±   R­   R   t   hasattrR¼   RÆ   Rŗ   R»   R#   t   __call__(   Rl   Rm   t   kwds(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR¾   ;  s    		N(   R)   R*   R+   R   R   R¤   R   RI   RÆ   Rŗ   R¾   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   ”  s   			#	,	1c           B  s)   e  Z d  Z e j Z i  Z d d  Z RS(   s±   
    Base for simple stateful regular expression-based lexers.
    Simplifies the lexing process so that you need only
    provide a list of states and regular expressions.
    R   c         c  sL  d } |  j  } t |  } | | d } xx| D]\ } } }	 | | |  }
 |
 r3 | d
 k	 r® t |  t k r | | |
 j   f Vq® x | |  |
  D] } | Vq Wn  |
 j   } |	 d
 k	 rĘt |	 t  rDxŻ |	 D]a } | d k rt	 |  d k r=| j
   q=qÜ | d k r0| j | d  qÜ | j |  qÜ Wnq t |	 t  rt |	  t	 |  k ru| d 3qµ| |	 3n6 |	 d k r| j | d  n t sµt d |	   | | d } n  Pq3 q3 Wya | | d k rd g } | d } | t d	 f V| d 7} w, n  | t | | f V| d 7} Wq, t k
 rCPq, Xq, Wd
 S(   s}   
        Split ``text`` into (tokentype, text) pairs.

        ``stack`` is the inital stack (default: ``['root']``)
        i    i’’’’s   #popi   s   #pushs   wrong state def: %rs   
R   u   
N(   R»   R   RI   R#   R   Ru   Rs   R>   Rk   RL   R   R?   R   t   absR6   R   R   R   Rt   (   R9   R@   R   Ry   R®   t
   statestackt   statetokenst   rexmatchR}   R   t   mR   R   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRC   h  sV    	

	

(   R   (   R)   R*   R+   R   t	   MULTILINER¦   R©   RC   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   I  s   	c           B  s&   e  Z d  Z d d d  Z d   Z RS(   s9   
    A helper object that holds lexer position data.
    c         C  s=   | |  _  | |  _ | p! t |  |  _ | p3 d g |  _ d  S(   NR   (   R@   Ry   RL   Rs   R   (   R9   R@   Ry   R   Rs   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR;   ¬  s    		c         C  s   d |  j  |  j |  j f S(   Ns   LexerContext(%r, %r, %r)(   R@   Ry   R   (   R9   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR=   ²  s    N(   R)   R*   R+   RI   R;   R=   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   §  s   c           B  s   e  Z d  Z d d d  Z RS(   sE   
    A RegexLexer that uses a context object to store its state.
    c         c  sź  |  j  } | s+ t | d  } | d } n  | } | | j d } | j } xx| D]ä\ } } } | | | j | j  }	 |	 rU | d
 k	 rt |  t k rÉ | j | |	 j	   f V|	 j   | _ qx | |  |	 |  D] }
 |
 VqÜ W| s| | j d } qn  | d
 k	 r5t
 | t  r”xū | D]p } | d k rdt | j  d k r| j j   qq*| d k r| j j | j d  q*| j j |  q*Wn t
 | t  råt |  t | j  k rŲ| j d 3q!| j | 3n< | d k r| j j | j d  n t s!t d |   | | j d } n  PqU qU Wy | j | j k rVPn  | | j d k r„d g | _ | d } | j t d	 f V| j d 7_ wN n  | j t | | j f V| j d 7_ WqN t k
 rįPqN XqN Wd
 S(   s   
        Split ``text`` into (tokentype, text) pairs.
        If ``context`` is given, use this lexer context instead.
        i    R   i’’’’s   #popi   s   #pushs   wrong state def: %rs   
u   
N(   R»   R   R   R@   Ry   Rs   RI   R#   R   Ru   R>   Rk   RL   R   R?   R   RĄ   R   R6   R   R   R   Rt   (   R9   R@   t   contextR®   R|   RĀ   RĆ   R}   R   RÄ   R   R   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRC   ¼  sd    			
N(   R)   R*   R+   RI   RC   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   ·  s   c         c  s’  t  |   }  y t |   \ } } Wn( t k
 rL x | D] } | Vq9 Wd SXd } t } x| D]\ } } }	 | d k r | } n  d }
 xĀ | rN| t |	  | k rN|	 |
 | | !} | | | f V| t |  7} x5 | D]- \ } } } | | | f V| t |  7} qß W| | }
 y t |   \ } } Wq t k
 rJt } Pq Xq W| | |	 |
 f V| t |	  |
 7} q` Wx | rś| pd } x5 | D]- \ } } }	 | | |	 f V| t |	  7} qWy t |   \ } } Wq|t k
 röt } Pq|Xq|Wd S(   sg  
    Helper for lexers which must combine the results of several
    sublexers.

    ``insertions`` is a list of ``(index, itokens)`` pairs.
    Each ``itokens`` iterable should be inserted at position
    ``index`` into the token stream given by the ``tokens``
    argument.

    The result is a combined token stream.

    TODO: clean up the code here.
    Ni    (   t   itert   nextt   StopIterationRI   R5   RL   R6   (   Rf   R©   R²   R¢   R   t   realpost   insleftRh   RE   RF   t   oldit   tmpvalt   it_indext   it_tokent   it_valuet   p(    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRd      sL    		
		t   ProfilingRegexLexerMetac           B  s   e  Z d  Z d   Z RS(   s>   Metaclass for ProfilingRegexLexer, collects regex timing info.c           sm   t  | t  r3 t | j d | j d | j  n |  t j  |   t j      f d  } | S(   NR   R   c           sz     j  d j   f d d g  } t j   }  j |  | |  } t j   } | d c d 7<| d c | | 7<| S(   Ni’’’’i    g        i   (   t
   _prof_datat
   setdefaultt   timeR{   (   R@   Ry   t   endpost   infot   t0t   rest   t1(   Rl   t   compiledR«   R   (    s-   lib/python2.7/site-packages/pygments/lexer.pyt
   match_funcJ  s    %(	   R>   R   R   R   R   R   R   t   syst   maxsize(   Rl   R   R   R   RÜ   (    (   Rl   RŪ   R«   R   s-   lib/python2.7/site-packages/pygments/lexer.pyR   B  s    (   R)   R*   R+   R   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRŅ   ?  s   t   ProfilingRegexLexerc           B  s&   e  Z d  Z g  Z d Z d d  Z RS(   sF   Drop-in replacement for RegexLexer that does profiling of its regexes.i   R   c         #  s    j  j j i   x" t j   | |  D] } | Vq) W  j  j j   } t d   | j   D d   f d   d t } t	 d   | D  } t
   t
 d   j  j t |  | f  t
 d d  t
 d	 d  t
 d d  x | D] } t
 d |  qģ Wt
 d d  d  S(   Nc         s  sa   |  ]W \ \ } } \ } } | t  |  j d   j d d  d  | d | d | | f Vq d S(   s   u's   \\s   \iA   ič  N(   t   reprRO   RB   (   t   .0R   t   rt   nRE   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pys	   <genexpr>b  s   t   keyc           s   |    j  S(   N(   t   _prof_sort_index(   R   (   R9   (    s-   lib/python2.7/site-packages/pygments/lexer.pyR   e  R    t   reversec         s  s   |  ] } | d  Vq d S(   i   N(    (   Rį   R   (    (    s-   lib/python2.7/site-packages/pygments/lexer.pys	   <genexpr>g  s    s2   Profiling result for %s lexing %d chars in %.3f mst   =in   s$   %-20s %-64s ncalls  tottime  percallR   R   t   -s   %-20s %-65s %5d %8.4f %8.4f(   R   R   (   R<   RÓ   R?   R   RC   R   t   sortedR¶   R5   t   sumt   printR)   RL   (   R9   R@   R   t   tokt   rawdataR~   t	   sum_totalR(   (    (   R9   s-   lib/python2.7/site-packages/pygments/lexer.pyRC   \  s$    			(   R   (   R)   R*   R+   RÓ   Rå   RC   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyRß   U  s   (   s   ļ»æs   utf-8(   s   ’ž  s   utf-32(   s     ž’s   utf-32be(   s   ’žs   utf-16(   s   ž’s   utf-16be(    (9   R+   t
   __future__R    R   RŻ   RÕ   t   pygments.filterR   R   t   pygments.filtersR   t   pygments.tokenR   R   R   R   t   pygments.utilR   R	   R
   R   R   R   R   R   R   t   pygments.regexoptR   t   __all__RJ   t   staticmethodt   _default_analyseR#   R!   t   objectR   R   R   R   Ri   R   Rk   Rj   Rn   R   R   R   R   R   R   R   R   R   R   Rd   RŅ   Rß   (    (    (    s-   lib/python2.7/site-packages/pygments/lexer.pyt   <module>
   sT   "@	'				2Ø]I	?