U
    ;»{jŠ  ã                   @   sê  d 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mZ ddl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dgZe d¡ZdddddgZedd„ ƒZG dd„ deƒZG dd„ ded �Z G d!d„ de ƒZ!G d"d„ de"ƒZ#G d#d$„ d$ƒZ$e$ƒ Z%G d%d&„ d&e&ƒZ'G d'd(„ d(ƒZ(d)d„ Z)G d*d+„ d+ƒZ*e*ƒ Z+d,d„ Z,G d-d„ dƒZ-G d.d„ deƒZ.G d/d0„ d0eƒZ/G d1d	„ d	e e/d �Z0G d2d„ dƒZ1G d3d
„ d
e0ƒZ2d4d5„ Z3G d6d7„ d7e/ƒZ4G d8d9„ d9e0e4d �Z5dS ):z´
    pygments.lexer
    ~~~~~~~~~~~~~~

    Base lexer classes.

    :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)Úapply_filtersÚFilter)Úget_filter_by_name)ÚErrorÚTextÚOtherÚ
WhitespaceÚ
_TokenType)Úget_bool_optÚget_int_optÚget_list_optÚmake_analysatorÚFutureÚguess_decode)Ú	regex_optÚLexerÚ
RegexLexerÚExtendedRegexLexerÚDelegatingLexerÚLexerContextÚincludeÚinheritÚbygroupsÚusingÚthisÚdefaultÚwordsÚline_rez.*?
)s   ï»¿úutf-8)s   ÿþ  zutf-32)s     þÿzutf-32be)s   ÿþzutf-16)s   þÿzutf-16bec                 C   s   dS )Nç        © ©Úxr    r    ú;/tmp/pip-install-zsn1f9xv/pip/pip/_vendor/pygments/lexer.pyÚ<lambda>"   ó    r$   c                   @   s   e Zd ZdZdd„ ZdS )Ú	LexerMetaz‚
    This metaclass automagically converts ``analyse_text`` methods into
    static methods which always return float values.
    c                 C   s(   d|krt |d ƒ|d< t | |||¡S )NÚanalyse_text)r   ÚtypeÚ__new__)ZmcsÚnameÚbasesÚdr    r    r#   r)   +   s    zLexerMeta.__new__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)   r    r    r    r#   r&   %   s   r&   c                   @   sn   e Zd ZdZdZg Zg Zg Zg ZdZ	dZ
dZdZdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Zddd„Zdd„ ZdS )r   a"  
    Lexer for a specific language.

    See also :doc:`lexerdevelopment`, a high-level guide to writing
    lexers.

    Lexer classes have attributes used for choosing the most appropriate
    lexer based on various criteria.

    .. autoattribute:: name
       :no-value:
    .. autoattribute:: aliases
       :no-value:
    .. autoattribute:: filenames
       :no-value:
    .. autoattribute:: alias_filenames
    .. autoattribute:: mimetypes
       :no-value:
    .. autoattribute:: priority

    Lexers included in Pygments should have two additional attributes:

    .. autoattribute:: url
       :no-value:
    .. autoattribute:: version_added
       :no-value:

    Lexers included in Pygments may have additional attributes:

    .. autoattribute:: _example
       :no-value:

    You can pass options to the constructor. The basic options recognized
    by all lexers and processed by the base `Lexer` class are:

    ``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.
    Nr   c                 K   s„   || _ t|ddƒ| _t|ddƒ| _t|ddƒ| _t|ddƒ| _| dd	¡| _| d
¡pZ| j| _g | _	t
|ddƒD ]}|  |¡ qpdS )a‘  
        This constructor takes arbitrary options as keyword arguments.
        Every subclass must first process its own options and then call
        the `Lexer` constructor, since it processes the basic
        options like `stripnl`.

        An example looks like this:

        .. sourcecode:: python

           def __init__(self, **options):
               self.compress = options.get('compress', '')
               Lexer.__init__(self, **options)

        As these options must all be specifiable as strings (due to the
        command line usage), there are various utility functions
        available to help with that, see `Utilities`_.
        ÚstripnlTÚstripallFÚensurenlÚtabsizer   ÚencodingÚguessZ
inencodingÚfiltersr    N)Úoptionsr
   r1   r2   r3   r   r4   Úgetr5   r7   r   Ú
add_filter)Úselfr8   Úfilter_r    r    r#   Ú__init__‘   s    zLexer.__init__c                 C   s2   | j rd| jj› d| j ›d�S d| jj› d�S d S )Nz<pygments.lexers.z with ú>)r8   Ú	__class__r-   ©r;   r    r    r#   Ú__repr__¯   s    zLexer.__repr__c                 K   s&   t |tƒst|f|Ž}| j |¡ dS )z8
        Add a new stream filter to this lexer.
        N)Ú
isinstancer   r   r7   Úappend)r;   r<   r8   r    r    r#   r:   µ   s    
zLexer.add_filterc                 C   s   dS )aÁ  
        A static method which is called for lexer guessing.

        It should analyse the text and return a float in the range
        from ``0.0`` to ``1.0``.  If it returns ``0.0``, the lexer
        will not be selected as the most probable one, if it returns
        ``1.0``, it will be selected immediately.  This is used by
        `guess_lexer`.

        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``.
        Nr    )Útextr    r    r#   r'   ½   s    zLexer.analyse_textc              
   C   sŒ  t |tƒsü| jdkr"t|ƒ\}}nØ| jdkrÔztdƒ‚W n, tk
rd } ztdƒ|‚W 5 d}~X Y nX d}tD ].\}}| |¡rn|t|ƒd…  |d¡} qžqn|dkrÎt	 
|dd… ¡}| | d¡pÈd	d¡}|}n&| | j¡}| d
¡rú|td
ƒd… }n| d
¡�r|td
ƒd… }| dd¡}| dd¡}| j�rB| ¡ }n| j�rT| d¡}| jdk�rl| | j¡}| j�rˆ| d¡�sˆ|d7 }|S )zVApply preprocessing such as decoding the input, removing BOM and normalizing newlines.r6   Úchardetzchardet is not vendored by pipzkTo enable chardet encoding guessing, please install the chardet library from http://chardet.feedparser.org/NÚreplacei   r5   r   u   ï»¿z
Ú
úr   )rB   Ústrr5   r   ÚImportErrorÚ_encoding_mapÚ
startswithÚlenÚdecoderE   Údetectr9   rF   r2   Ústripr1   r4   Ú
expandtabsr3   Úendswith)r;   rD   Ú_ÚeÚdecodedÚbomr5   Úencr    r    r#   Ú_preprocess_lexer_inputÎ   sJ    


þ
ÿ


zLexer._preprocess_lexer_inputFc                    s4   ˆ   ˆ¡‰‡ ‡fdd„}|ƒ }|s0t|ˆ jˆ ƒ}|S )ae  
        This method is the basic interface of a lexer. It is called by
        the `highlight()` function. It must process the text and return an
        iterable of ``(tokentype, value)`` pairs from `text`.

        Normally, you don't need to override this method. The default
        implementation processes the options recognized by all lexers
        (`stripnl`, `stripall` and so on), and then yields all tokens
        from `get_tokens_unprocessed()`, with the ``index`` dropped.

        If `unfiltered` is set to `True`, the filtering mechanism is
        bypassed even if filters are defined.
        c                  3   s$   ˆ   ˆ¡D ]\} }}||fV  q
d S ©N)Úget_tokens_unprocessed)rS   ÚtÚv©r;   rD   r    r#   Ústreamer  s    z"Lexer.get_tokens.<locals>.streamer)rX   r   r7   )r;   rD   Z
unfilteredr^   Ústreamr    r]   r#   Ú
get_tokensÿ   s    
zLexer.get_tokensc                 C   s   t ‚dS )aS  
        This method should process the text and return an iterable of
        ``(index, tokentype, value)`` tuples where ``index`` is the starting
        position of the token within the input text.

        It must be overridden by subclasses. It is recommended to
        implement it as a generator to maximize effectiveness.
        N)ÚNotImplementedErrorr]   r    r    r#   rZ     s    	zLexer.get_tokens_unprocessed)F)r-   r.   r/   r0   r*   ÚaliasesÚ	filenamesZalias_filenamesÚ	mimetypesÚpriorityÚurlZversion_addedZ_exampler=   rA   r:   r'   rX   r`   rZ   r    r    r    r#   r   1   s"   ;1
)Ú	metaclassc                   @   s$   e Zd ZdZefdd„Zdd„ ZdS )r   a   
    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   s0   |f |Ž| _ |f |Ž| _|| _tj| f|Ž d S rY   )Ú
root_lexerÚlanguage_lexerÚneedler   r=   )r;   Z_root_lexerZ_language_lexerZ_needler8   r    r    r#   r=   -  s    zDelegatingLexer.__init__c                 C   sŠ   d}g }g }| j  |¡D ]H\}}}|| jkrP|rF| t|ƒ|f¡ g }||7 }q| |||f¡ q|rx| t|ƒ|f¡ t|| j |¡ƒS )NÚ )ri   rZ   rj   rC   rM   Údo_insertionsrh   )r;   rD   ZbufferedÚ
insertionsZ
lng_bufferÚir[   r\   r    r    r#   rZ   3  s    


ÿz&DelegatingLexer.get_tokens_unprocessedN)r-   r.   r/   r0   r   r=   rZ   r    r    r    r#   r   #  s   	c                   @   s   e Zd ZdZdS )r   zI
    Indicates that a state should include rules from another state.
    N©r-   r.   r/   r0   r    r    r    r#   r   J  s   c                   @   s   e Zd ZdZdd„ ZdS )Ú_inheritzC
    Indicates the a state should inherit from its superclass.
    c                 C   s   dS )Nr   r    r@   r    r    r#   rA   U  s    z_inherit.__repr__N)r-   r.   r/   r0   rA   r    r    r    r#   rp   Q  s   rp   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )Úcombinedz:
    Indicates a state combined from multiple states.
    c                 G   s   t  | |¡S rY   )Útupler)   )ÚclsÚargsr    r    r#   r)   `  s    zcombined.__new__c                 G   s   d S rY   r    )r;   rt   r    r    r#   r=   c  s    zcombined.__init__N)r-   r.   r/   r0   r)   r=   r    r    r    r#   rq   [  s   rq   c                   @   sF   e Zd ZdZdd„ Zddd„Zddd„Zdd	d
„Zdd„ Zdd„ Z	dS )Ú_PseudoMatchz:
    A pseudo match object constructed from a string.
    c                 C   s   || _ || _d S rY   )Ú_textÚ_start)r;   ÚstartrD   r    r    r#   r=   m  s    z_PseudoMatch.__init__Nc                 C   s   | j S rY   )rw   ©r;   Úargr    r    r#   rx   q  s    z_PseudoMatch.startc                 C   s   | j t| jƒ S rY   )rw   rM   rv   ry   r    r    r#   Úendt  s    z_PseudoMatch.endc                 C   s   |rt dƒ‚| jS )NzNo such group)Ú
IndexErrorrv   ry   r    r    r#   Úgroupw  s    z_PseudoMatch.groupc                 C   s   | j fS rY   )rv   r@   r    r    r#   Úgroups|  s    z_PseudoMatch.groupsc                 C   s   i S rY   r    r@   r    r    r#   Ú	groupdict  s    z_PseudoMatch.groupdict)N)N)N)
r-   r.   r/   r0   r=   rx   r{   r}   r~   r   r    r    r    r#   ru   h  s   


ru   c                     s   d‡ fdd„	}|S )zL
    Callback that yields multiple actions for each group in the match.
    Nc                 3   s¼   t ˆ ƒD ] \}}|d krqqt|ƒtkrR| |d ¡}|r¨| |d ¡||fV  q| |d ¡}|d k	r|r|| |d ¡|_|| t| |d ¡|ƒ|ƒD ]}|r˜|V  q˜q|r¸| ¡ |_d S )Né   )Ú	enumerater(   r	   r}   rx   Úposru   r{   )ÚlexerÚmatchÚctxrn   ÚactionÚdataÚitem©rt   r    r#   Úcallback‡  s&     ÿ
zbygroups.<locals>.callback)Nr    )rt   rŠ   r    r‰   r#   r   ƒ  s    c                   @   s   e Zd ZdZdS )Ú_ThiszX
    Special singleton used for indicating the caller class.
    Used by ``using``.
    Nro   r    r    r    r#   r‹   �  s   r‹   c                    sj   i ‰dˆkr:ˆ  d¡}t|ttfƒr.|ˆd< nd|fˆd< ˆ tkrTd‡‡fdd„	}nd	‡ ‡‡fdd„	}|S )
aÂ  
    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`.
    ÚstateÚstackÚrootNc                 3   sj   ˆrˆ  | j¡ | jf ˆŽ}n| }| ¡ }|j| ¡ fˆ ŽD ]\}}}|| ||fV  q<|rf| ¡ |_d S rY   )Úupdater8   r?   rx   rZ   r}   r{   r‚   ©rƒ   r„   r…   ZlxÚsrn   r[   r\   )Ú	gt_kwargsÚkwargsr    r#   rŠ   ¼  s    zusing.<locals>.callbackc                 3   s^   ˆ  | j¡ ˆ f ˆŽ}| ¡ }|j| ¡ fˆŽD ]\}}}|| ||fV  q0|rZ| ¡ |_d S rY   )r�   r8   rx   rZ   r}   r{   r‚   r�   ©Ú_otherr’   r“   r    r#   rŠ   Ë  s    
)N)N)ÚpoprB   Úlistrr   r   )r•   r“   r‘   rŠ   r    r”   r#   r   ¦  s    


c                   @   s   e Zd ZdZdd„ ZdS )r   zÑ
    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 rY   )rŒ   )r;   rŒ   r    r    r#   r=   à  s    zdefault.__init__N)r-   r.   r/   r0   r=   r    r    r    r#   r   Ø  s   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )	r   z•
    Indicates a list of literal words that is transformed into an optimized
    regex that matches any of the words.

    .. versionadded:: 2.0
    rk   c                 C   s   || _ || _|| _d S rY   )r   ÚprefixÚsuffix)r;   r   r˜   r™   r    r    r#   r=   ë  s    zwords.__init__c                 C   s   t | j| j| jd�S )N©r˜   r™   )r   r   r˜   r™   r@   r    r    r#   r9   ð  s    z	words.getN)rk   rk   )r-   r.   r/   r0   r=   r9   r    r    r    r#   r   ä  s   
c                   @   sJ   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zddd„Zdd„ Z	dd„ Z
d
S )ÚRegexLexerMetazw
    Metaclass for RegexLexer, creates the self._tokens attribute from
    self.tokens on the first instantiation.
    c                 C   s    t |tƒr| ¡ }t ||¡jS )zBPreprocess the regular expression component of a token definition.)rB   r   r9   ÚreÚcompiler„   )rs   ÚregexÚrflagsrŒ   r    r    r#   Ú_process_regexú  s    
zRegexLexerMeta._process_regexc                 C   s&   t |ƒtks"t|ƒs"td|›�ƒ‚|S )z5Preprocess the token component of a token definition.z0token type must be simple type or callable, not )r(   r	   ÚcallableÚAssertionError)rs   Útokenr    r    r#   Ú_process_token   s    ÿzRegexLexerMeta._process_tokenc                 C   s  t |tƒrf|dkrdS ||kr$|fS |dkr0|S |dd… dkrRt|dd… ƒ S dsdtd|›�ƒ‚n²t |tƒrÎd	| j }|  jd
7  _g }|D ].}||ksªtd|›�ƒ‚| |  |||¡¡ q�|||< |fS t |tƒ�r|D ] }||ksÞ|dksÞtd| ƒ‚qÞ|S d�std|›�ƒ‚dS )z=Preprocess the state transition action of a token definition.ú#popéÿÿÿÿú#pushNé   z#pop:Fzunknown new state z_tmp_%dr€   zcircular state ref )r¥   r§   zunknown new state def )	rB   rI   Úintr¢   rq   Ú_tmpnameÚextendÚ_process_staterr   )rs   Ú	new_stateÚunprocessedÚ	processedZ	tmp_stateÚitokensZistater    r    r#   Ú_process_new_state  s>    



 ÿÿþz!RegexLexerMeta._process_new_statec                 C   s¢  t |tƒstd|›�ƒ‚|d dks2td|›�ƒ‚||krB|| S g  }||< | j}|| D �]>}t |tƒrœ||ks‚td|›�ƒ‚| |  ||t|ƒ¡¡ q\t |tƒr¨q\t |tƒrÜ|  	|j
||¡}| t d¡jd|f¡ q\t|ƒtksötd|›�ƒ‚z|  |d ||¡}W nJ tk
�rV }	 z*td	|d ›d
|›d| ›d|	› �ƒ|	‚W 5 d}	~	X Y nX |  |d ¡}
t|ƒdk�rzd}n|  	|d ||¡}| ||
|f¡ q\|S )z%Preprocess a single state definition.zwrong state name r   ú#zinvalid state name zcircular state reference rk   Nzwrong rule def zuncompilable regex z
 in state z of z: r€   é   )rB   rI   r¢   Úflagsr   r«   r¬   rp   r   r±   rŒ   rC   rœ   r�   r„   r(   rr   r    Ú	ExceptionÚ
ValueErrorr¤   rM   )rs   r®   r¯   rŒ   ÚtokensrŸ   Ztdefr­   ÚrexÚerrr£   r    r    r#   r¬   )  sB    
ÿ

8
 ÿzRegexLexerMeta._process_stateNc                 C   s<   i  }| j |< |p| j| }t|ƒD ]}|  |||¡ q$|S )z-Preprocess a dictionary of token definitions.)Ú_all_tokensr·   r—   r¬   )rs   r*   Ú	tokendefsr¯   rŒ   r    r    r#   Úprocess_tokendefT  s
    zRegexLexerMeta.process_tokendefc           
   
   C   sÚ   i }i }| j D ]Æ}|j di ¡}| ¡ D ]ª\}}| |¡}|dkr||||< z| t¡}W n tk
rp   Y q(Y nX |||< q(| |d¡}|dkr’q(||||d …< z| t¡}	W n tk
rÄ   Y q(X ||	 ||< q(q|S )a  
        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·   Nr€   )Ú__mro__Ú__dict__r9   ÚitemsÚindexr   r¶   r–   )
rs   r·   ÚinheritableÚcÚtoksrŒ   r¿   ZcuritemsZinherit_ndxZnew_inh_ndxr    r    r#   Úget_tokendefs\  s0    


zRegexLexerMeta.get_tokendefsc                 O   sL   d| j kr:i | _d| _t| dƒr(| jr(n|  d|  ¡ ¡| _tj	| f|ž|ŽS )z:Instantiate cls after preprocessing its token definitions.Ú_tokensr   Útoken_variantsrk   )
r¾   rº   rª   ÚhasattrrÆ   r¼   rÄ   rÅ   r(   Ú__call__)rs   rt   Úkwdsr    r    r#   rÈ   �  s    
zRegexLexerMeta.__call__)N)r-   r.   r/   r0   r    r¤   r±   r¬   r¼   rÄ   rÈ   r    r    r    r#   r›   ô  s   #+
1r›   c                   @   s$   e Zd ZdZejZi Zddd„ZdS )r   z±
    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  }|D �]*\}}}	|||ƒ}
|
r"|dk	rrt|ƒtkrb|||
 ¡ fV  n|| |
ƒE dH  |
 ¡ }|	dk	�rJt|	tƒrÚ|	D ]D}|dkr´t|ƒdkrÖ| 	¡  q’|dkrÌ| 
|d ¡ q’| 
|¡ q’ndt|	tƒ�rt|	ƒt|ƒk�r|dd…= n
||	d…= n.|	dk�r*| 
|d ¡ nd�s>td|	›�ƒ‚||d  } qq"zP|| d	k�r†d
g}|d
 }|td	fV  |d7 }W q|t|| fV  |d7 }W q tk
�r¼   Y �qÀY qX qdS )z~
        Split ``text`` into (tokentype, text) pairs.

        ``stack`` is the initial stack (default: ``['root']``)
        r   r¦   Nr¥   r€   r§   Fúwrong state def: rG   rŽ   )rÅ   r—   r(   r	   r}   r{   rB   rr   rM   r–   rC   r©   Úabsr¢   r   r   r|   )r;   rD   r�   r‚   r»   Z
statestackÚstatetokensÚrexmatchr†   r­   ÚmrŒ   r    r    r#   rZ   ¾  sR    




z!RegexLexer.get_tokens_unprocessedN)rÊ   )	r-   r.   r/   r0   rœ   Ú	MULTILINEr´   r·   rZ   r    r    r    r#   r   ›  s   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )r   z9
    A helper object that holds lexer position data.
    Nc                 C   s*   || _ || _|pt|ƒ| _|p"dg| _d S )NrŽ   )rD   r‚   rM   r{   r�   )r;   rD   r‚   r�   r{   r    r    r#   r=     s    zLexerContext.__init__c                 C   s   d| j ›d| j›d| j›d�S )NzLexerContext(z, ú))rD   r‚   r�   r@   r    r    r#   rA     s    zLexerContext.__repr__)NN)r-   r.   r/   r0   r=   rA   r    r    r    r#   r   ü  s   
c                   @   s   e Zd ZdZddd„ZdS )r   zE
    A RegexLexer that uses a context object to store its state.
    Nc                 c   s>  | j }|st|dƒ}|d }n|}||jd  }|j}|D �]b\}}}|||j|jƒ}	|	r:|dk	r°t|ƒtkrŒ|j||	 ¡ fV  |	 ¡ |_n$|| |	|ƒE dH  |s°||jd  }|dk	�ršt	|t
ƒ�r|D ]P}
|
dkrðt|jƒdkrî|j ¡  qÊ|
dk�r|j |jd ¡ qÊ|j |
¡ qÊnnt	|tƒ�rZt|ƒt|jƒk�rL|jdd…= n|j|d…= n2|dk�rx|j |jd ¡ nd�sŒtd	|›�ƒ‚||jd  } q6q:zz|j|jk�r¶W �q:||j d
k�rödg|_|d }|jtd
fV  | jd7  _W q6|jt||j fV  | jd7  _W q6 tk
�r6   Y �q:Y q6X q6dS )z
        Split ``text`` into (tokentype, text) pairs.
        If ``context`` is given, use this lexer context instead.
        r   rŽ   r¦   Nr¥   r€   r§   FrË   rG   )rÅ   r   r�   rD   r‚   r{   r(   r	   r}   rB   rr   rM   r–   rC   r©   rÌ   r¢   r   r   r|   )r;   rD   Úcontextr»   r…   rÍ   rÎ   r†   r­   rÏ   rŒ   r    r    r#   rZ     s`    




z)ExtendedRegexLexer.get_tokens_unprocessed)NN)r-   r.   r/   r0   rZ   r    r    r    r#   r     s   c              	   c   s®  t | ƒ} zt| ƒ\}}W n  tk
r8   |E dH  Y dS X d}d}|D ]ò\}}}|dkr\|}d}	|�r|t|ƒ |k�r||	|| … }
|
r¤|||
fV  |t|
ƒ7 }|D ]"\}}}|||fV  |t|ƒ7 }q¨|| }	zt| ƒ\}}W q` tk
�r   d}Y �qY q`X q`|	t|ƒk rF||||	d… fV  |t|ƒ|	 7 }qF|�rª|�pHd}|D ]$\}}}|||fV  |t|ƒ7 }�qNzt| ƒ\}}W n  tk
�r¤   d}Y �qªY nX �q:dS )ag  
    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.
    NTr   F)ÚiterÚnextÚStopIterationrM   )rm   r·   rÀ   r°   ÚrealposZinsleftrn   r[   r\   ZoldiZtmpvalZit_indexZit_tokenZit_valueÚpr    r    r#   rl   S  sN    

rl   c                   @   s   e Zd ZdZdd„ ZdS )ÚProfilingRegexLexerMetaz>Metaclass for ProfilingRegexLexer, collects regex timing info.c                    sL   t |tƒr t|j|j|jd�‰n|‰t ˆ|¡‰tjf‡ ‡‡‡fdd„	}|S )Nrš   c                    s`   ˆ j d  ˆˆfddg¡}t ¡ }ˆ | ||¡}t ¡ }|d  d7  < |d  || 7  < |S )Nr¦   r   r   r€   )Ú
_prof_dataÚ
setdefaultÚtimer„   )rD   r‚   ÚendposÚinfoÚt0ÚresÚt1©rs   Zcompiledr¸   rŒ   r    r#   Ú
match_funcž  s    z:ProfilingRegexLexerMeta._process_regex.<locals>.match_func)	rB   r   r   r˜   r™   rœ   r�   ÚsysÚmaxsize)rs   rž   rŸ   rŒ   râ   r    rá   r#   r    –  s    

ÿz&ProfilingRegexLexerMeta._process_regexN)r-   r.   r/   r0   r    r    r    r    r#   rØ   “  s   rØ   c                   @   s"   e Zd ZdZg ZdZddd„ZdS )ÚProfilingRegexLexerzFDrop-in replacement for RegexLexer that does profiling of its regexes.é   rÊ   c                 #   sÂ   ˆ j j i ¡ t ˆ ||¡E d H  ˆ j j ¡ }tdd„ | ¡ D ƒ‡ fdd„dd�}tdd„ |D ƒƒ}t	ƒ  t	dˆ j j
t|ƒ|f ƒ t	d	ƒ t	d
d ƒ t	dƒ |D ]}t	d| ƒ q¤t	d	ƒ d S )Nc                 s   sN   | ]F\\}}\}}|t |ƒ d ¡ dd¡dd… |d| d| | fV  qdS )zu'z\\ú\NéA   iè  )ÚreprrP   rF   )Ú.0r‘   ÚrÚnr[   r    r    r#   Ú	<genexpr>´  s   þ  
ÿz=ProfilingRegexLexer.get_tokens_unprocessed.<locals>.<genexpr>c                    s
   | ˆ j  S rY   )Ú_prof_sort_indexr!   r@   r    r#   r$   ·  r%   z<ProfilingRegexLexer.get_tokens_unprocessed.<locals>.<lambda>T)ÚkeyÚreversec                 s   s   | ]}|d  V  qdS )é   Nr    )rê   r"   r    r    r#   rí   ¹  s     z2Profiling result for %s lexing %d chars in %.3f mszn==============================================================================================================z$%-20s %-64s ncalls  tottime  percall)rŒ   rž   zn--------------------------------------------------------------------------------------------------------------z%-20s %-65s %5d %8.4f %8.4f)r?   rÙ   rC   r   rZ   r–   Úsortedr¿   ÚsumÚprintr-   rM   )r;   rD   r�   Úrawdatar‡   Z	sum_totalr,   r    r@   r#   rZ   ¯  s(    þ
üÿz*ProfilingRegexLexer.get_tokens_unprocessedN)rÊ   )r-   r.   r/   r0   rÙ   rî   rZ   r    r    r    r#   rå   ©  s   rå   )6r0   rœ   rã   rÛ   Zpip._vendor.pygments.filterr   r   Zpip._vendor.pygments.filtersr   Zpip._vendor.pygments.tokenr   r   r   r   r	   Zpip._vendor.pygments.utilr
   r   r   r   r   r   Zpip._vendor.pygments.regexoptr   Ú__all__r�   r   rK   ÚstaticmethodZ_default_analyser(   r&   r   r   rI   r   rp   r   rr   rq   ru   r   r‹   r   r   r   r   r›   r   r   r   rl   rØ   rå   r    r    r    r#   Ú<module>   sd   
        þ
ü s'2 (aH@