a
    ýÓEbÁ|  ã                   @   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 ddlmZmZmZmZmZmZ ddlmZ g d¢Zg d	¢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%d&„ d&eƒZ,G d'd(„ d(ee,d�Z-G d)d*„ d*ƒZ.G d+d,„ d,e-ƒZ/d-d.„ Z0G d/d0„ d0e,ƒZ1G d1d2„ d2e-e1d�Z2dS )3z´
    pygments.lexer
    ~~~~~~~~~~~~~~

    Base lexer classes.

    :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)Úapply_filtersÚFilter)Úget_filter_by_name)ÚErrorÚTextÚOtherÚ
_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))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   úZ/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/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|v 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                   @   sZ   e Zd ZdZdZg Zg Zg Zg Z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.

    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.
    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 )NÚstripnlTÚstripallFÚensurenlÚtabsizer   ÚencodingÚguessÚ
inencodingÚfiltersr   )Úoptionsr	   r/   r0   r1   r
   r2   Úgetr3   r6   r   Ú
add_filter)Úselfr7   Úfilter_r   r   r!   Ú__init__^   s    zLexer.__init__c                 C   s(   | j rd| jj| j f S d| jj S d S )Nz<pygments.lexers.%s with %r>z<pygments.lexers.%s>)r7   Ú	__class__r+   ©r:   r   r   r!   Ú__repr__j   s
    ÿzLexer.__repr__c                 K   s*   t |tƒst|fi |¤Ž}| j |¡ dS )z8
        Add a new stream filter to this lexer.
        N)Ú
isinstancer   r   r6   Úappend)r:   r;   r7   r   r   r!   r9   q   s    
zLexer.add_filterc                 C   s   dS )a~  
        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``.
        Nr   )Útextr   r   r!   r%   y   s    zLexer.analyse_textFc              
      s¾  t ˆtƒ�sˆ jdkr$tˆƒ\‰}nàˆ jdkrÜzddlm} W n. tyl } ztdƒ|‚W Y d}~n
d}~0 0 d}tD ].\}}ˆ |¡rvˆt	|ƒd…  
|d¡} q¦qv|du rÖ| ˆdd… ¡}	ˆ 
|	 d	¡pÐd
d¡}|‰n(ˆ 
ˆ j¡‰ˆ d¡�r"ˆt	dƒd… ‰nˆ d¡�r"ˆt	dƒd… ‰ˆ dd¡‰ˆ dd¡‰ˆ j�rLˆ ¡ ‰nˆ j�r^ˆ d¡‰ˆ jdk�rvˆ ˆ j¡‰ˆ j�r’ˆ d¡�s’ˆd7 ‰‡ ‡fdd„}
|
ƒ }|�sºt|ˆ jˆ ƒ}|S )a=  
        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.
        r4   Úchardetr   )rC   zkTo enable chardet encoding guessing, please install the chardet library from http://chardet.feedparser.org/NÚreplacei   r3   r   u   ï»¿z
Ú
úc                  3   s$   ˆ   ˆ¡D ]\} }}||fV  q
d S ©N)Úget_tokens_unprocessed)Ú_ÚtÚv©r:   rB   r   r!   Ústreamerº   s    z"Lexer.get_tokens.<locals>.streamer)r@   Ústrr3   r   Úpip._vendorrC   ÚImportErrorÚ_encoding_mapÚ
startswithÚlenÚdecodeÚdetectr8   rD   r0   Ústripr/   r2   Ú
expandtabsr1   Úendswithr   r6   )r:   rB   Z
unfilteredrI   rC   ÚeÚdecodedZbomr3   ÚencrM   Ústreamr   rL   r!   Ú
get_tokens‡   sR    	

þ
ÿ

zLexer.get_tokensc                 C   s   t ‚dS )zú
        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)ÚNotImplementedErrorrL   r   r   r!   rH   Â   s    zLexer.get_tokens_unprocessed)F)r+   r,   r-   r.   r(   ÚaliasesÚ	filenamesÚalias_filenamesÚ	mimetypesÚpriorityr<   r?   r9   r%   r]   rH   r   r   r   r!   r   0   s   
;r   )Ú	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   s<   |f i |¤Ž| _ |f i |¤Ž| _|| _tj| fi |¤Ž d S rG   )Ú
root_lexerÚlanguage_lexerÚneedler   r<   )r:   Z_root_lexerZ_language_lexerZ_needler7   r   r   r!   r<   ×   s    zDelegatingLexer.__init__c                 C   sŠ   d}g }g }| j  |¡D ]H\}}}|| ju rP|rF| t|ƒ|f¡ g }||7 }q| |||f¡ q|rx| t|ƒ|f¡ t|| j |¡ƒS )NÚ )rf   rH   rg   rA   rS   Údo_insertionsre   )r:   rB   ZbufferedÚ
insertionsZ
lng_bufferÚirJ   rK   r   r   r!   rH   Ý   s    


ÿz&DelegatingLexer.get_tokens_unprocessedN)r+   r,   r-   r.   r   r<   rH   r   r   r   r!   r   Í   s   	r   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-   r.   r   r   r   r!   r   ô   s   r   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!   r?   ÿ   s    z_inherit.__repr__N)r+   r,   r-   r.   r?   r   r   r   r!   rm   û   s   rm   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 rG   )Útupler'   )ÚclsÚargsr   r   r!   r'   
  s    zcombined.__new__c                 G   s   d S rG   r   )r:   rq   r   r   r!   r<     s    zcombined.__init__N)r+   r,   r-   r.   r'   r<   r   r   r   r!   rn     s   rn   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 rG   )Ú_textÚ_start)r:   ÚstartrB   r   r   r!   r<     s    z_PseudoMatch.__init__Nc                 C   s   | j S rG   )rt   ©r:   Úargr   r   r!   ru     s    z_PseudoMatch.startc                 C   s   | j t| jƒ S rG   )rt   rS   rs   rv   r   r   r!   Úend  s    z_PseudoMatch.endc                 C   s   |rt dƒ‚| jS )NzNo such group)Ú
IndexErrorrs   rv   r   r   r!   Úgroup!  s    z_PseudoMatch.groupc                 C   s   | j fS rG   )rs   r>   r   r   r!   Úgroups&  s    z_PseudoMatch.groupsc                 C   s   i S rG   r   r>   r   r   r!   Ú	groupdict)  s    z_PseudoMatch.groupdict)N)N)N)
r+   r,   r-   r.   r<   ru   rx   rz   r{   r|   r   r   r   r!   rr     s   


rr   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 u rqqt|ƒtu rR| |d ¡}|r¨| |d ¡||fV  q| |d ¡}|d ur|r|| |d ¡|_|| t| |d ¡|ƒ|ƒD ]}|r˜|V  q˜q|r¸| ¡ |_d S )Né   )Ú	enumerater&   r   rz   ru   Úposrr   rx   )ÚlexerÚmatchÚctxrk   ÚactionÚdataÚitem©rq   r   r!   Úcallback1  s$    ÿ
zbygroups.<locals>.callback)Nr   )rq   r‡   r   r†   r!   r   -  s    r   c                   @   s   e Zd ZdZdS )Ú_ThiszX
    Special singleton used for indicating the caller class.
    Used by ``using``.
    Nrl   r   r   r   r!   rˆ   G  s   rˆ   c                    sj   i ‰dˆv r:ˆ  d¡}t|ttfƒr.|ˆd< nd|fˆd< ˆ tu 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   sr   ˆr"ˆ  | j¡ | jf i ˆ¤Ž}n| }| ¡ }|j| ¡ fi ˆ ¤ŽD ]\}}}|| ||fV  qD|rn| ¡ |_d S rG   )Úupdater7   r=   ru   rH   rz   rx   r   ©r€   r�   r‚   ZlxÚsrk   rJ   rK   )Ú	gt_kwargsÚkwargsr   r!   r‡   f  s     zusing.<locals>.callbackc                 3   sf   ˆ  | j¡ ˆ f i ˆ¤Ž}| ¡ }|j| ¡ fi ˆ¤ŽD ]\}}}|| ||fV  q8|rb| ¡ |_d S rG   )rŒ   r7   ru   rH   rz   rx   r   r�   ©Ú_otherr�   r�   r   r!   r‡   u  s     )N)N)Úpopr@   Úlistro   r   )r’   r�   rŽ   r‡   r   r‘   r!   r   P  s    


r   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 rG   )r‰   )r:   r‰   r   r   r!   r<   Š  s    zdefault.__init__N)r+   r,   r-   r.   r<   r   r   r   r!   r   ‚  s   r   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
    rh   c                 C   s   || _ || _|| _d S rG   )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!   r8   š  s    z	words.getN)rh   rh   )r+   r,   r-   r.   r<   r8   r   r   r   r!   r   Ž  s   
r   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.)r@   r   r8   ÚreÚcompiler�   )rp   ÚregexÚrflagsr‰   r   r   r!   Ú_process_regex¤  s    
zRegexLexerMeta._process_regexc                 C   s&   t |ƒtu s"t|ƒs"J d|f ƒ‚|S )z5Preprocess the token component of a token definition.z2token type must be simple type or callable, not %r)r&   r   Úcallable)rp   Útokenr   r   r!   Ú_process_tokenª  s    ÿzRegexLexerMeta._process_tokenc                 C   s  t |tƒrd|dkrdS ||v r$|fS |dkr0|S |dd… dkrRt|dd… ƒ S dsbJ d| ƒ‚n®t |tƒrÊd	| j }|  jd
7  _g }|D ],}||ks¦J d| ƒ‚| |  |||¡¡ qŽ|||< |fS t |tƒ�r |D ] }||v sÚ|dv sÚJ d| ƒ‚qÚ|S d�sJ d| ƒ‚dS )z=Preprocess the state transition action of a token definition.ú#popéÿÿÿÿú#pushNé   z#pop:Fzunknown new state %rz_tmp_%dr}   zcircular state ref %r)r¡   r£   zunknown new state zunknown new state def %r)r@   rN   Úintrn   Ú_tmpnameÚextendÚ_process_statero   )rp   Ú	new_stateÚunprocessedÚ	processedZ	tmp_stateÚitokensZistater   r   r!   Ú_process_new_state°  s<    



ÿÿþz!RegexLexerMeta._process_new_statec                 C   s’  t |ƒtu sJ d| ƒ‚|d dks0J d| ƒ‚||v r@|| S g  }||< | j}|| D �]0}t|tƒr˜||ks~J d| ƒ‚| |  ||t|ƒ¡¡ qZt|tƒr¤qZt|tƒrØ|  	|j
||¡}| t d¡jd|f¡ qZt |ƒtu sðJ d| ƒ‚z|  |d ||¡}W n@ t�yF }	 z&td	|d || |	f ƒ|	‚W Y d}	~	n
d}	~	0 0 |  |d
 ¡}
t|ƒdk�rjd}n|  	|d ||¡}| ||
|f¡ qZ|S )z%Preprocess a single state definition.zwrong state name %rr   ú#zinvalid state name %rzcircular state reference %rrh   Nzwrong rule def %rz+uncompilable regex %r in state %r of %r: %sr}   é   )r&   rN   Úflagsr@   r   r§   r¨   rm   r   r­   r‰   rA   r™   rš   r�   ro   r�   Ú	ExceptionÚ
ValueErrorr    rS   )rp   rª   r«   r‰   Útokensrœ   Ztdefr©   ÚrexÚerrrŸ   r   r   r!   r¨   Ó  sH    
ÿ

ÿÿ
ÿ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¨   )rp   r(   Ú	tokendefsr«   r‰   r   r   r!   Úprocess_tokendefÿ  s
    zRegexLexerMeta.process_tokendefc           
   
   C   sÖ   i }i }| j D ]Â}|j di ¡}| ¡ D ]¦\}}| |¡}|du rz|||< z| t¡}W n tyn   Y q(Y n0 |||< q(| |d¡}|du r�q(||||d …< z| t¡}	W n tyÀ   Y q(0 ||	 ||< 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__r8   ÚitemsÚindexr   r²   r“   )
rp   r³   ÚinheritableÚcZtoksr‰   r»   ZcuritemsZinherit_ndxZnew_inh_ndxr   r   r!   Úget_tokendefs  s0    


zRegexLexerMeta.get_tokendefsc                 O   sR   d| j vr:i | _d| _t| dƒr(| jr(n|  d|  ¡ ¡| _tj	| g|¢R i |¤ŽS )z:Instantiate cls after preprocessing its token definitions.Ú_tokensr   Útoken_variantsrh   )
rº   r¶   r¦   ÚhasattrrÁ   r¸   r¿   rÀ   r&   Ú__call__)rp   rq   Úkwdsr   r   r!   rÃ   8  s    
zRegexLexerMeta.__call__)N)r+   r,   r-   r.   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urrt|ƒtu rb|||
 ¡ fV  n|| |
ƒE dH  |
 ¡ }|	du�rHt|	tƒrÚ|	D ]D}|dkr´t|ƒdkrÖ| 	¡  q’|dkrÌ| 
|d ¡ q’| 
|¡ q’nbt|	tƒ�rt|	ƒt|ƒk�r|dd…= n
||	d…= n,|	dk�r*| 
|d ¡ nd�s<J 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�y¸   Y �q¼Y q0 qdS )z}
        Split ``text`` into (tokentype, text) pairs.

        ``stack`` is the inital stack (default: ``['root']``)
        r   r¢   Nr¡   r}   r£   Fúwrong state def: %rrE   r‹   )rÀ   r”   r&   r   rz   rx   r@   ro   rS   r“   rA   r¥   Úabsr   r   ry   )r:   rB   rŠ   r   r·   Z
statestackÚstatetokensÚrexmatchrƒ   r©   Úmr‰   r   r   r!   rH   i  sR    




z!RegexLexer.get_tokens_unprocessedN)rÅ   )	r+   r,   r-   r.   r™   Ú	MULTILINEr°   r³   rH   r   r   r   r!   r   F  s   r   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‹   )rB   r   rS   rx   rŠ   )r:   rB   r   rŠ   rx   r   r   r!   r<   ¬  s    zLexerContext.__init__c                 C   s   d| j | j| jf S )NzLexerContext(%r, %r, %r))rB   r   rŠ   r>   r   r   r!   r?   ²  s    ÿzLexerContext.__repr__)NN)r+   r,   r-   r.   r<   r?   r   r   r   r!   r   §  s   
r   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 �]`\}}}|||j|jƒ}	|	r:|dur°t|ƒtu rŒ|j||	 ¡ fV  |	 ¡ |_n$|| |	|ƒE dH  |s°||jd  }|du�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Ênlt	|tƒ�rZt|ƒt|jƒk�rL|jdd…= n|j|d…= n0|dk�rx|j |jd ¡ nd�sŠJ d	| ƒ‚||jd  } q6q:zz|j|jk�r´W �q6||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�y2   Y �q6Y q60 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Æ   rE   )rÀ   r   rŠ   rB   r   rx   r&   r   rz   r@   ro   rS   r“   rA   r¥   rÇ   r‰   r   r   ry   )r:   rB   Úcontextr·   r‚   rÈ   rÉ   rƒ   r©   rÊ   r‰   r   r   r!   rH   ¼  s`    




z)ExtendedRegexLexer.get_tokens_unprocessed)NN)r+   r,   r-   r.   rH   r   r   r   r!   r   ·  s   r   c              	   c   s¨  t | ƒ} zt| ƒ\}}W n ty6   |E dH  Y dS 0 d}d}|D ]ð\}}}|du rZ|}d}	|�r|t|ƒ |k�r||	|| … }
|
r¢|||
fV  |t|
ƒ7 }|D ]"\}}}|||fV  |t|ƒ7 }q¦|| }	zt| ƒ\}}W q^ t�y    d}Y �qY q^0 q^|	t|ƒk rD||||	d… fV  |t|ƒ|	 7 }qD|�r¤|�pDd}|D ]$\}}}|||fV  |t|ƒ7 }�qJzt| ƒ\}}W n t�yž   d}Y �q¤Y n0 �q6d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ÚStopIterationrS   )rj   r³   r¼   r¬   ZrealposZinsleftrk   rJ   rK   ZoldiZtmpvalZit_indexZit_tokenZit_valueÚpr   r   r!   ri   ÿ  sN    

ri   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�   )rB   r   ÚendposÚinfoÚt0ÚresÚt1©rp   Úcompiledr´   r‰   r   r!   Ú
match_funcJ  s    z:ProfilingRegexLexerMeta._process_regex.<locals>.match_func)	r@   r   r   r•   r–   r™   rš   ÚsysÚmaxsize)rp   r›   rœ   r‰   rÜ   r   rÚ   r!   r�   B  s    

ÿz&ProfilingRegexLexerMeta._process_regexN)r+   r,   r-   r.   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è  )ÚreprrV   rD   )Ú.0rŽ   ÚrÚnrJ   r   r   r!   Ú	<genexpr>`  s   þÿz=ProfilingRegexLexer.get_tokens_unprocessed.<locals>.<genexpr>c                    s
   | ˆ j  S rG   )Ú_prof_sort_indexr   r>   r   r!   r"   c  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ç   e  r#   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Ò   rA   r   rH   r“   Úsortedr»   ÚsumÚprintr+   rS   )r:   rB   rŠ   Úrawdatar„   Z	sum_totalr*   r   r>   r!   rH   [  s(    þ
üÿz*ProfilingRegexLexer.get_tokens_unprocessedN)rÅ   )r+   r,   r-   r.   rÒ   rè   rH   r   r   r   r!   rß   U  s   rß   )3r.   r™   rÝ   rÔ   Zpip._vendor.pygments.filterr   r   Zpip._vendor.pygments.filtersr   Úpip._vendor.pygments.tokenr   r   r   r   Úpip._vendor.pygments.utilr	   r
   r   r   r   r   Zpip._vendor.pygments.regexoptr   Ú__all__rQ   ÚstaticmethodZ_default_analyser&   r$   r   r   rN   r   rm   r   ro   rn   rr   r   rˆ   r   r   r   r   r˜   r   r   r   ri   rÑ   rß   r   r   r   r!   Ú<module>   sD   
  '2 )aH@