
e[Tc           @  s  d  Z  d d l m Z d d l 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.   Z0 d d@ d/     YZ1 d e f d0     YZ2 d1 e" f d2     YZ3 e e3  d
 e$ f d3     Y Z4 d e# f d4     YZ5 d e4 f d5     YZ6 d6   Z7 d7 e3 f d8     YZ8 e e8  d9 e4 f d:     Y Z9 d S(A   s   
    pygments.lexer
    ~~~~~~~~~~~~~~

    Base lexer classes.

    :copyright: Copyright 2006-2014 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-32t     s   utf-32bes   s   utf-16s   s   utf-16bec         C  s   d S(   Ng        (    (   t   x(    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt   <lambda>%   s    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   clst   namet   basest   d(    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR$   .   s    (   t   __name__t
   __module__t   __doc__R$   (    (    (    s2   /usr/lib/python2.7/dist-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_(    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt   __init__c   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   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt   __repr__o   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   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR8   v   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(    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR"   ~   s    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   chardetiNsk   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   it   tt   v(   R9   R@   (    s2   /usr/lib/python2.7/dist-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
   unfilteredt   _RA   t   decodedt   bomR0   t   encRG   t   stream(    (   R9   R@   s2   /usr/lib/python2.7/dist-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@   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRC      s    N(   R)   R*   R+   RI   R&   t   aliasest	   filenamest   alias_filenamest	   mimetypest   priorityR;   R=   R8   R"   R6   RX   RC   (    (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   4   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   (    (    s2   /usr/lib/python2.7/dist-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(   Nt    (   R`   RC   Ra   R?   RL   t   do_insertionsR_   (   R9   R@   t   bufferedt
   insertionst
   lng_bufferRD   RE   RF   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRC      s    "	(   R)   R*   R+   R   R;   RC   (    (    (    s2   /usr/lib/python2.7/dist-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+   (    (    (    s2   /usr/lib/python2.7/dist-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   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR=     s    (   R)   R*   R+   R=   (    (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRj      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$   (   R%   t   args(    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR$     s    c         G  s   d  S(   N(    (   R9   Rm   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR;     s    (   R)   R*   R+   R$   R;   (    (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRk   
  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@   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR;     s    	c         C  s   |  j  S(   N(   Rp   (   R9   t   arg(    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRq      s    c         C  s   |  j  t |  j  S(   N(   Rp   RL   Ro   (   R9   Rr   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt   end#  s    c         C  s   | r t  d   n  |  j S(   Ns   No such group(   t
   IndexErrorRo   (   R9   Rr   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt   group&  s    c         C  s
   |  j  f S(   N(   Ro   (   R9   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt   groups+  s    c         C  s   i  S(   N(    (   R9   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt	   groupdict.  s    N(
   R)   R*   R+   R;   RI   Rq   Rs   Ru   Rv   Rw   (    (    (    s2   /usr/lib/python2.7/dist-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   ctxRD   t   actiont   datat   item(   Rm   (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt   callback6  s"    !N(   RI   (   Rm   R   (    (   Rm   s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   2  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+   (    (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   L  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   sRD   RE   RF   (   t	   gt_kwargst   kwargs(    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   j  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   RD   RE   RF   (   t   _otherR   R   (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   y  s    (N(   t   popR>   t   listRl   R   RI   (   R   R   R   R   (    (   R   R   R   s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   T  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   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR;     s    (   R)   R*   R+   R;   (    (    (    s2   /usr/lib/python2.7/dist-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
    Re   c         C  s   | |  _  | |  _ | |  _ d  S(   N(   R   t   prefixt   suffix(   R9   R   R   R   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR;     s    		c         C  s   t  |  j d |  j d |  j S(   NR   R   (   R   R   R   R   (   R9   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR7     s    (   R)   R*   R+   R;   R7   (    (    (    s2   /usr/lib/python2.7/dist-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{   (   R%   t   regext   rflagsR   (    (    s2   /usr/lib/python2.7/dist-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(   R%   t   token(    (    s2   /usr/lib/python2.7/dist-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   #popis   #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   Rk   t   _tmpnamet   extendt   _process_stateRl   (   R%   t	   new_statet   unprocessedt	   processedt	   tmp_statet   itokenst   istate(    (    s2   /usr/lib/python2.7/dist-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 %rRe   s   wrong rule def %rs+   uncompilable regex %r in state %r of %r: %si   i   N(   R#   R   R   t   flagsR>   R   R   R   Rj   R   R   R   R?   R   R   R{   RI   Rl   R   t	   Exceptiont
   ValueErrorR   RL   (   R%   R   R   R   t   tokensR   t   tdefR   t   rext   errR   (    (    s2   /usr/lib/python2.7/dist-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   (   R%   R&   t	   tokendefsR   R   (    (    s2   /usr/lib/python2.7/dist-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   (
   R%   R   t   inheritablet   ct   toksR   t   itemst   curitemst   inherit_ndxt   new_inh_ndx(    (    s2   /usr/lib/python2.7/dist-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_variantsRe   (
   R   R   R   t   hasattrR   R   R   R   R#   t   __call__(   R%   Rm   t   kwds(    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   <  s    		N(   R)   R*   R+   R   R   R   R   RI   R   R   R   (    (    (    s2   /usr/lib/python2.7/dist-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  s  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  r/x |	 D]L } | d k r | j	   q | d k r| j
 | d  q | j
 |  q WnO t |	 t  rH| |	 3n6 |	 d k rh| 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
 rPq, Xq, d
 S(   s}   
        Split ``text`` into (tokentype, text) pairs.

        ``stack`` is the inital stack (default: ``['root']``)
        i    is   #pops   #pushs   wrong state def: %rs   
R   u   
i   N(   R   R   RI   R#   R   Ru   Rs   R>   Rl   R   R?   R   R6   R   R   R   Rt   (   R9   R@   R   Ry   R   t
   statestackt   statetokenst   rexmatchR}   R   t   mR   R   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRC   i  sP    	
	

(   s   root(   R)   R*   R+   R   t	   MULTILINER   R   RC   (    (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   J  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   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR;     s    		c         C  s   d |  j  |  j |  j f S(   Ns   LexerContext(%r, %r, %r)(   R@   Ry   R   (   R9   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR=     s    N(   R)   R*   R+   RI   R;   R=   (    (    (    s2   /usr/lib/python2.7/dist-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 } xWxQ| 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	 rt
 | t  rx | D]X } | d k rL| j j   q*| d k rr| j j | j d  q*| j j |  q*WnX t
 | t  r| j | 3n< | d k r| j j | j d  n t st d |   | | j d } n  PqU qU Wy | j | j k rPn  | | j d k re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 d
 S(   s   
        Split ``text`` into (tokentype, text) pairs.
        If ``context`` is given, use this lexer context instead.
        i    R   is   #pops   #pushs   wrong state def: %rs   
u   
i   N(   R   R   R   R@   Ry   Rs   RI   R#   R   Ru   R>   Rl   R   R?   R   R6   R   R   R   Rt   (   R9   R@   t   contextR   R|   R   R   R}   R   R   R   R   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRC     s^    			
N(   R)   R*   R+   RI   RC   (    (    (    s2   /usr/lib/python2.7/dist-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   (   Rh   R   R   R   R   t   realpost   insleftRD   RE   RF   t   oldit   tmpvalt   it_indext   it_tokent   it_valuet   p(    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRf     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(   Nii    g        i   (   t
   _prof_datat
   setdefaultt   timeR{   (   R@   Ry   t   endpost   infot   t0t   rest   t1(   R%   t   compiledR   R   (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt
   match_func?  s    %(	   R>   R   R   R   R   R   R   t   syst   maxsize(   R%   R   R   R   R   (    (   R%   R   R   R   s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   7  s    (   R)   R*   R+   R   (    (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   4  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   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pys	   <genexpr>W  s   t   keyc           s   |    j  S(   N(   t   _prof_sort_index(   R   (   R9   (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR    Z  s    t   reversec         s  s   |  ] } | d  Vq d S(   i   N(    (   R   R   (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pys	   <genexpr>\  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(   s   states   regex(   R<   R   R?   R   RC   R   t   sortedR   R5   t   sumt   printR)   RL   (   R9   R@   R   t   tokt   rawdataR~   t	   sum_totalR(   (    (   R9   s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyRC   Q  s$    			(   s   root(   R)   R*   R+   R   R   RC   (    (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyR   J  s   (   s   ﻿s   utf-8(   s     s   utf-32(   s     s   utf-32be(   s   s   utf-16(   s   s   utf-16be(    (:   R+   t
   __future__R    R   R   R   t	   itertoolst   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   Rj   R   Rl   Rk   Rn   R   R   R   R   R   R   R   R   R   R   Rf   R   R   (    (    (    s2   /usr/lib/python2.7/dist-packages/pygments/lexer.pyt   <module>
   sV   "@	'				2UE	?