a
    ;@b                     @   s2  d Z ddlZddlZddlmZmZmZmZmZm	Z	m
Z
mZmZmZ ddl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mZmZ ddlmZ g dZ e!dZ"G d	d
 d
eZ#e#Z$G dd deZ%G dd deZ&G dd deZ'e'Z(G dd deZ)G dd deZ*G dd deZ+G dd de#Z,dS )z
    pygments.lexers.python
    ~~~~~~~~~~~~~~~~~~~~~~

    Lexers for Python and related languages.

    :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)
Lexer
RegexLexerincludebygroupsusingdefaultwordscombineddo_insertionsthis)get_bool_optshebang_matches)TextCommentOperatorKeywordNameStringNumberPunctuationGenericOtherError)	unistring)PythonLexerPythonConsoleLexerPythonTracebackLexerPython2LexerPython2TracebackLexerCythonLexerDgLexer
NumPyLexerz.*?
c                #   @   s  e Zd ZdZdZg dZg dZg dZej	ej
B Zdejejf Zdd Zd	d
 Zdefdeeejejfdeeejejfdejfdejfdefdefededdeeedfdeeedfdeejedfdeejedfedgdeejejeddfd eejejedd!fd"eejejedd#fd$eejejedd%fd&eejejed'dfd(eejejed'd!fd)eejejed'd#fd*eejejed'd%fd+eejejd,fd-eejejd.fd/eejejd0fd1eejejd2fd3eejejed4d,fd5eejejed4d.fd6eejejed4d0fd7eejejed4d2fd8efed9d:efd;e fd<ej!fed=ed>ed?ed@edAgdBe dCfdDej"dEfdFej"dEfdGefedgdBe dCfdHe dEfdGefedge#dIdJdKefe#dLdJdKej$fge#dMdJdKefe#dLdJdKej$fgdNdO%e&j' dP eeedQfgdReee(e)efe*dEge#dSdTdJdUe+j,fdVe+j,j-fe#dWdTdJdUe+j.fge#dXdJdKe+j/j0fge#dYdJdKe+j1j0fgdZe2j3fd[e2j3fd\e2j4fd]e2j5fd^e2j6fd_e2j7fgd`e e+j8fd`efee+fged?ee+j/dEfe*dEgee+j9dEfgdaeeeefdbe+jfee+jfdceeeefe*dEgddeeejdEfdbe+jfdee+j,j-dEfee+jfe*dEgdfej:fdgej:fgeded4gdhej:fgeejeejeejeejdiejdEfdjej:fedkgdlejdEfdmej:fedngdiejdEfdjej:fedogdlejdEfdmej:fedpgdqejdEfedkdejfgdrejdEfedndejfgdqejdEfedodejfgdrejdEfedpdejfgds Z;dtdu Z<dvS )wr   z
    For `Python <http://www.python.org>`_ source code (version 3.x).

    .. versionadded:: 0.10

    .. versionchanged:: 2.5
       This is now the default ``PythonLexer``.  It is still available as the
       alias ``Python3Lexer``.
    Python)ZpythonpyZsagepython3Zpy3)z*.pyz*.pywz*.jyz*.sagez*.scZ
SConstructZ
SConscriptz*.bzlZBUCKZBUILDzBUILD.bazelZ	WORKSPACEz*.tac)ztext/x-pythonzapplication/x-pythonztext/x-python3zapplication/x-python3z	[%s][%s]*c                 C   s&   dt jfdt jfd| fd| fd| fgS )NzH%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsaux%]zg\{((\w+)((\.\w+)|(\[[^\]]+\]))*)?(\![sra])?(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?\}z[^\\\'"%{\n]+[\'"\\]z%|(\{{1,2})r   InterpolZttype r)   5lib/python3.9/site-packages/pygments/lexers/python.pyinnerstring_rulesD   s    zPythonLexer.innerstring_rulesc                 C   s"   dt jfdt jdfd| fd| fgS )Nz\}z\{expr-inside-fstringz[^\\\'"{}\n]+r%   r&   r(   r)   r)   r*   fstring_rulesX   s
    
zPythonLexer.fstring_rules\n&^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")&^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')\A#!.+$#.*$\\\n\\keywordssoft-keywords(def)((?:\s|\\\s)+)funcname(class)((?:\s|\\\s)+)	classname(from)((?:\s|\\\s)+)
fromimport(import)((?:\s|\\\s)+)importexprz(?i)(rf|fr)(""")rfstringescapetdqfz(?i)(rf|fr)(''')tsqfz(?i)(rf|fr)(")dqfz(?i)(rf|fr)(')sqfz([fF])(""")fstringescapez([fF])(''')z	([fF])(")z	([fF])(')z(?i)(rb|br|r)(""")tdqsz(?i)(rb|br|r)(''')tsqsz(?i)(rb|br|r)(")dqsz(?i)(rb|br|r)(')sqs([uUbB]?)(""")stringescape([uUbB]?)(''')([uUbB]?)(")([uUbB]?)(')[^\S\n]+numbersz!=|==|<<|>>|:=|[-~+/*%=<>&^|.][]{}:(),;[](in|is|and|or|not)\bexpr-keywordsbuiltins
magicfuncs	magicvarsnamez[{([]expr-inside-fstring-innerz(=\s*)?(\![sraf])?\}#popz(=\s*)?(\![sraf])?:\s+z[])}])z	async forawaitelseforiflambdayield
yield from\bsuffix)TrueFalseNone)assertasyncr[   breakcontinuedelelifr\   exceptfinallyr]   globalr^   r_   passraisenonlocalreturntrywhiler`   ra   aswithz6(^[ \t]*)(match|case)\b(?![ \t]*(?:[:,;=^&|@~)\]}]|(?:|z)\b))soft-keywords-innerz(\s+)([^\n_]*)(_\b))A
__import__absallanybinbool	bytearray
breakpointbyteschrclassmethodcompilecomplexdelattrdictdirdivmod	enumerateevalfilterfloatformat	frozensetgetattrglobalshasattrhashhexidinputint
isinstance
issubclassiterlenlistlocalsmapmax
memoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsumsupertupletypevarszip(?<!\.)prefixrd   z+(?<!\.)(self|Ellipsis|NotImplemented|cls)\b)DArithmeticErrorAssertionErrorAttributeErrorBaseExceptionBufferErrorBytesWarningDeprecationWarningEOFErrorEnvironmentError	ExceptionFloatingPointErrorFutureWarningGeneratorExitIOErrorImportErrorImportWarningIndentationError
IndexErrorKeyErrorKeyboardInterruptLookupErrorMemoryError	NameErrorNotImplementedErrorOSErrorOverflowErrorPendingDeprecationWarningReferenceErrorResourceWarningRuntimeErrorRuntimeWarningStopIterationSyntaxErrorSyntaxWarningSystemError
SystemExitTabError	TypeErrorUnboundLocalErrorUnicodeDecodeErrorUnicodeEncodeErrorUnicodeErrorUnicodeTranslateErrorUnicodeWarningUserWarning
ValueErrorVMSErrorWarningWindowsErrorZeroDivisionErrorBlockingIOErrorChildProcessErrorConnectionErrorBrokenPipeErrorConnectionAbortedErrorConnectionRefusedErrorConnectionResetErrorFileExistsErrorFileNotFoundErrorInterruptedErrorIsADirectoryErrorNotADirectoryErrorPermissionErrorProcessLookupErrorTimeoutErrorStopAsyncIterationModuleNotFoundErrorRecursionError)^__abs____add__
__aenter__	__aexit__	__aiter____and__	__anext__	__await____bool__	__bytes____call____complex____contains____del____delattr__
__delete____delitem____dir__
__divmod__	__enter____eq____exit__	__float____floordiv__
__format____ge____get____getattr____getattribute____getitem____gt____hash____iadd____iand____ifloordiv____ilshift____imatmul____imod____imul__	__index____init____instancecheck____int__
__invert____ior____ipow____irshift____isub____iter____itruediv____ixor____le____len____length_hint__
__lshift____lt__
__matmul____missing____mod____mul____ne____neg____new____next____or____pos____pow____prepare____radd____rand____rdivmod____repr____reversed____rfloordiv____rlshift____rmatmul____rmod____rmul____ror__	__round____rpow____rrshift__
__rshift____rsub____rtruediv____rxor____set____setattr____setitem____str____sub____subclasscheck____truediv____xor__)__annotations__	__bases__	__class____closure____code____defaults____dict____doc____file____func____globals____kwdefaults__
__module____mro____name____objclass____qualname____self__	__slots____weakref__zT(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)([eE][+-]?\d(?:_?\d)*)?z!\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?z0[oO](?:_?[0-7])+z0[bB](?:_?[01])+z0[xX](?:_?[a-fA-F0-9])+z\d(?:_?\d)*@(\s+)(as)(\s+)z\.(\s*)(,)(\s*)z(\s+)(import)\bNone\bz\{\{z\}\}Y\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})"\\\\|\\"|\\\nfstrings-double'\\\\|\\'|\\\nfstrings-singlestrings-doublestrings-single"""''') rootr?   r,   rX   rS   r5   r6   rz   rT   rU   rV   rP   rW   r8   r:   r>   r<   r@   rE   rK   r  r|  r  r  rC   rD   rH   rI   rA   rB   rF   rG   c                 C   s   t | dpd| d d v S )Npythonw?(3(\.\d)?)?import   r   textr)   r)   r*   analyse_text  s    
zPythonLexer.analyse_textN)=ro  rm  rq  rh  rW   aliases	filenames	mimetypesre	MULTILINEUNICODEflagsuniZ	xid_startZxid_continueZuni_namer+   r-   r   r   r   AffixDocr   HashbangSingler   r   	NamespaceDoubler	   r   r   Wordr'   r   ZConstantjoinkeywordkwlistr   r   r   r   BuiltinPseudor   FunctionMagicVariabler   FloatOctBinHexInteger	DecoratorClassEscapetokensr  r)   r)   r)   r*   r      s  
5	



)












    (r   c                    @   sb  e Zd ZdZdZddgZg ZddgZdd Zd	e	fd
e
e	ejejfde
e	ejejfde	fdejfdejfdefde	fde	fdejfdefedde
ee	dfde
ee	dfde
eje	dfde
eje	dfedededed d!e
ejejd"fd#e
ejejd$fd%e
ejejd&fd'e
ejejd(fd)e
ejejed*d"fd+e
ejejed*d$fd,e
ejejed*d&fd-e
ejejed*d(fed.ed/ged0d1d2efged3d4d1d5ejfd6ejjfed7d4d1d5ejfged8d1d2ejjfged9d1d2ej jfgd:e!j"fd;e!j"fd<e!j#fd=e!j$fd>e!j%fd?e!j&j'fd@e!j&fgdAej(fgdBej)fdCefgeddCejdDfe*dDgdCej+dDfgdEe	fdFejfdGefdHejfe*dDgdEe	fdIejdDfdJejjdDfdKejfe*dDgdLej,fgeejeejdMejdDfdNej,fedOgdPejdDfdQej,fedRgdSejdDfedOd	ejfgdTejdDfedRd	ejfgdUZ-dVdW Z.dXS )Yr   a   
    For `Python 2.x <http://www.python.org>`_ source code.

    .. versionchanged:: 2.5
       This class has been renamed from ``PythonLexer``.  ``PythonLexer`` now
       refers to the Python 3 variant.  File name patterns like ``*.py`` have
       been moved to Python 3 as well.
    z
Python 2.xZpython2Zpy2ztext/x-python2zapplication/x-python2c                 C   s   dt jfd| fd| fd| fgS )NG%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%][^\\\'"%\n]+r%   %r&   r(   r)   r)   r*   r+     s    zPython2Lexer.innerstring_rulesr.   r/   r0   rO   r1   r2   rQ   r3   r4   rR   z!=|==|<<|>>|[-~+/*%=<>&^|.]r5   r7   r8   r9   r:   r;   r<   r=   r>   rT   rU   rV   backtickz!([rR]|[uUbB][rR]|[rR][uUbB])(""")rF   z!([rR]|[uUbB][rR]|[rR][uUbB])(''')rG   z([rR]|[uUbB][rR]|[rR][uUbB])(")rH   z([rR]|[uUbB][rR]|[rR][uUbB])(')rI   rJ   rK   rL   rM   rN   rW   rP   )rh   rj   rk   rl   rm   r\   rn   execro   r]   rp   r^   r_   rq   r   rr   rt   ru   rv   r`   ra   rw   rx   rb   rc   )Nr{   r|   r}   r~   apply
basestringr   r   bufferr   r   callabler   r   cmpcoercer   r   r   r   r   r   r   r   execfileexitfiler   r   r   r   r   r   r   r   r   r   r   internr   r   r   r   r   r   longr   r   r   r   r   r   r   r   r   r   r   	raw_inputreducereloadr   r   r   r   r   r   r   r   r   r   r   r   r   unichrunicoder   xranger   r   r   z;(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|cls)\b)1r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   OverflowWarningr   r   r   r   StandardErrorr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )_r  r  r  r  Z__cmp__Z
__coerce__r  r  r  r  r  r  Z__delslice__Z__div__r  r  r  r  r  r  r  r  r  r  r   Z__getslice__r!  r"  Z__hex__r#  r$  Z__idiv__r%  r&  r(  r)  r*  r+  r,  r-  r.  Z__iop__r/  r0  r1  r2  r3  r4  r5  r6  r7  Z__long__r9  r:  r<  r=  r>  r?  r@  rA  Z__nonzero__Z__oct__Z__op__rC  rD  rE  rG  rH  Z__rcmp__Z__rdiv__rI  rJ  rK  rL  rM  rO  rP  Z__rop__rQ  rS  rT  rU  rV  rW  rX  rY  rZ  r[  Z__setslice__r\  r]  r^  r_  Z__unicode__r`  )rb  rc  rd  re  rf  rg  rh  ri  rj  rk  Z__metaclass__rm  rn  ro  rr  rs  rt  z'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?z\d+[eE][+-]?[0-9]+j?z	0[0-7]+j?z
0[bB][01]+0[xX][a-fA-F0-9]+\d+Lz\d+j?`.*?`z@[\w.]+[a-zA-Z_]\w*rY   z(?:[ \t]|\\\n)+as\b,[a-zA-Z_][\w.]*zimport\brx  [a-zA-Z_.][\w.]*ry  rz  r{  r  r}  r~  r  r  r  )r  r5   rT   rU   rV   rP   r  rW   r8   r:   r>   r<   rK   r  r  rH   rI   rF   rG   c                 C   s
   t | dS )Nzpythonw?2(\.\d)?r  r  r)   r)   r*   r  m  s    zPython2Lexer.analyse_textN)/ro  rm  rq  rh  rW   r  r  r  r+   r   r   r   r  r  r   r  r  r   r   r  r   r   r  r  r	   r   r   r  r  r   r  r  r  r   r  r  r  r  r  LongBacktickr  r   r  r  r  r  r)   r)   r)   r*   r     s,  	-	#









  >r   c                   @   s0   e Zd ZdZdZdgZdgZdd Zdd Zd	S )
r   a  
    For Python console output or doctests, such as:

    .. sourcecode:: pycon

        >>> a = 'foo'
        >>> print a
        foo
        >>> 1 / 0
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        ZeroDivisionError: integer division or modulo by zero

    Additional options:

    `python3`
        Use Python 3 lexer for code.  Default is ``True``.

        .. versionadded:: 1.0
        .. versionchanged:: 2.5
           Now defaults to ``True``.
    zPython console sessionZpyconztext/x-python-doctestc                 K   s$   t |dd| _tj| fi | d S )Nr$   T)r   r$   r   r+  )selfoptionsr)   r)   r*   r+    s    zPythonConsoleLexer.__init__c              	   c   s.  | j r(tf i | j}tf i | j}n tf i | j}tf i | j}d}g }d}d}d}t|D ]v}	|	 }
|
	ds|
	drd}|
t|dtj|
d d fgf ||
dd  7 }qf|
 dkr|s|
t|dtjdfgf ||
dd  7 }qf|r(t|||E d H  d}g }|
	dsBtd	|
rTd
}|
}|	 }qf|
dkrr|	 tj|
fV  qf|r||
7 }|
	ds|
 dksd}||D ]\}}}|| ||fV  qd}qf|	 tj|
fV  qf|rt|||E d H  |r*||D ]\}}}|| ||fV  qd S )N r   z>>> z...    z...   z"Traceback (most recent call last):z  File "[^"]+", line \d+\n$   zKeyboardInterrupt
 )r$   r   r  r   r   r   line_refinditergroup
startswithappendr   r   ZPromptrstripr
   get_tokens_unprocessedr  matchstartr   r  stripZOutput)r  r  ZpylexerZtblexerZcurcodeZ
insertionsZcurtbZtbindextbr  lineitvr)   r)   r*   r    sh    







z)PythonConsoleLexer.get_tokens_unprocessedN)	ro  rm  rq  rh  rW   r  r  r+  r  r)   r)   r)   r*   r   q  s   r   c                   @   s   e Zd ZdZdZddgZddgZddgZd	efd
e	j
dfde	j
fde	j
fde	j
dfdefgdeeejeeeeefdeeejeeefdeeeeedfdeeeefdee	jeeedfdee	jedfgdeeejedfedgdZdS )r   a   
    For Python 3.x tracebacks, with support for chained exceptions.

    .. versionadded:: 1.0

    .. versionchanged:: 2.5
       This is now the default ``PythonTracebackLexer``.  It is still available
       as the alias ``Python3TracebackLexer``.
    zPython TracebackZpytbZpy3tbz*.pytbz*.py3tbztext/x-python-tracebackztext/x-python3-tracebackr.   z'^Traceback \(most recent call last\):\nintbzH^During handling of the above exception, another exception occurred:\n\nzI^The above exception was the direct cause of the following exception:\n\n^(?=  File "[^"]+", line \d+)^.*\n0^(  File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)%^(  File )("[^"]+")(, line )(\d+)(\n)^(    )(.+)(\n)markers^([ \t]*)(\.\.\.)(\n)^([^:]+)(: )(.+)(\n)rY   z^([a-zA-Z_][\w.]*)(:?\n)z^( {4,})([~^]+)(\n))r  r  r  N)ro  rm  rq  rh  rW   r  r  r  r   r   	Tracebackr   r   r   r  r   r   r   r   r   r   Markerr   r  r)   r)   r)   r*   r     sT   



r   c                   @   s   e Zd ZdZdZdgZdgZdgZdee	e
jdfde
jdfd	efgd
ee	eje	ee	ee	fdee	eje	ee	fdee	eee	dfdee	ee	fdee
je	ee	dfdee
je	dfgdee	ejdfedgdZdS )r   z
    For Python tracebacks.

    .. versionadded:: 0.7

    .. versionchanged:: 2.5
       This class has been renamed from ``PythonTracebackLexer``.
       ``PythonTracebackLexer`` now refers to the Python 3 variant.
    zPython 2.x TracebackZpy2tbz*.py2tbztext/x-python2-tracebackz^(\^C)?(Traceback.*\n)r  r  r  r  r  r  markerr  r  rY   z^([a-zA-Z_]\w*)(:?\n)z( {4,})(\^))r  r  r  N)ro  rm  rq  rh  rW   r  r  r  r   r   r   r  r   r   r  r   r   r   r   r   r   r  r   r  r)   r)   r)   r*   r     sD   



r   c                !   @   sH  e Zd ZdZdZg dZg dZddgZdefde	ee
jfd	e	ee
jfd
efdefdefdefdefdejfde	eejefdefde	eejeeeeefedde	eedfde	eedfde	eefde	eedfde	eedfde	eedfeded d!e
d"fd#e
d$fd%e
d&fd'e
d(fd)e
ed*d"fd+e
ed*d$fd,e
ed*d&fd-e
ed*d(fed.ed/ged0d1d2efd3ejfged4d5d1d6ejfd7ejjfed8d5d1d6ejfgd9ejfd:ejfd;ejfd<ejjfd=ejfgd>e
j fgd?ej!fd@efgd@ej"dAfgdBej#fdCefdDe	ej"edAfdEe	ej"eefdFedAfdGefdHedAfdIedAfd@ejfdJefg
d@ej$dAfgdKe	eeefdLej%fdMe	eeefe&dAgdNe	eedAfdOej%fe&dAgdPe
j'fgdQe
j(fdRe
fdSe
fdTe
fgde
fgdUe
dAfdVe
j'fedWgdXe
dAfdYe
j'fedWgdZe
dAfedWed[gd\e
dAfedWed[gd]Z)d^S )_r   z]
    For Pyrex and `Cython <http://cython.org>`_ source code.

    .. versionadded:: 1.1
    ZCython)ZcythonZpyxZpyrex)z*.pyxz*.pxdz*.pxiztext/x-cythonzapplication/x-cythonr.   z^(\s*)("""(?:.|\n)*?""")z^(\s*)('''(?:.|\n)*?''')rO   r2   rQ   r3   r4   rR   z(<)([a-zA-Z0-9.?]+)(>)z!=|==|<<|>>|[-~+/*%=<>&^|.?]z(from)(\d+)(<=)(\s+)(<)(\d+)(:)r5   z(def|property)(\s+)r8   z(cp?def)(\s+)cdefz	(cdef)(:)z(class|struct)(\s+)r:   z(from)(\s+)r<   z(c?import)(\s+)r>   rT   r  z(?:[rR]|[uU][rR]|[rR][uU])"""rF   z(?:[rR]|[uU][rR]|[rR][uU])'''rG   z(?:[rR]|[uU][rR]|[rR][uU])"rH   z(?:[rR]|[uU][rR]|[rR][uU])'rI   z[uU]?"""rK   z[uU]?'''z[uU]?"z[uU]?'rW   rP   )rh   ri   r[   rj   Zbyrk   Zctypedefrl   rm   r\   rn   zexcept?r  ro   r]   ZfusedZgilrp   r^   r   r_   Znogilrq   r   rr   rt   ru   rv   r`   rw   rx   rb   rc   z(DEF|IF|ELIF|ELSE)\b)Qr{   r|   r}   r~   r  r  r   Zbintr   r  r   r   r  r   r   r  r  r   r   r   r   r   r   r   r   r  r  r  r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r   r  r   r   r   r   r   r   r   r   r   r   Z
Py_ssize_tr   r  r  r  r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  Zunsignedr   r  r   r   r   z<(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL)\b)0r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   NotImplementedr   r   r   r  r   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   z&(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?z0\d+r  r  z\d+r  z@\w+r  rY   z%(public|readonly|extern|api|inline)\bz(struct|enum|union|class)\bz([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)z([a-zA-Z_]\w*)(\s*)(,)zfrom\br  :z	(?=["\']).rv  r  rw  z(\s+)(c?import)\br  ry  zP%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]r  r%   r  rz  r{  stringsr}  r~  r  nlr  )r  r5   rT   rP   r  rW   r8   r  r:   r>   r<   rK   r  r  rH   rI   rF   rG   N)*ro  rm  rq  rh  rW   r  r  r  r   r   r   r  r   r   r   r  r   Typer   r  r   r   r	   r   ZPreprocr  r  r   r  r  r  r  r  r  r  Reservedr  r  r   r  r'   r  r)   r)   r)   r*   r   1  s  &
#


 r   c                   @   sz  e Zd ZdZdZdgZdgZdgZdefde	j
fdejfdejfd	ejfd
ejfdejfdejfdeedddfdeedddfdeedddfdeedddfdefdejfdefeddddejfeddddejfdejjfd ejfd!ejfd"ejfd#efd$ejfd%efd&efd'efgd(ejfgd)ej fd*efd+efd,efd-efgd.ed/fgd0ed/fgd1ed/fgd2ed/fgd3Z!d4S )5r    z
    Lexer for `dg <http://pyos.github.com/dg>`_,
    a functional and object-oriented programming language
    running on the CPython 3 VM.

    .. versionadded:: 1.6
    Zdgz*.dgz	text/x-dgrZ   z#.*?$z(?i)0b[01]+z(?i)0o[0-7]+z(?i)0x[0-9a-f]+z((?i)[+-]?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?j?z(?i)[+-]?[0-9]+e[+-]?\d+j?z(?i)[+-]?[0-9]+j?z(?i)(br|r?b?)'''rK   rG   stringz(?i)(br|r?b?)"""rF   z(?i)(br|r?b?)'rI   z(?i)(br|r?b?)"rH   z`\w+'*`z\b(and|in|is|or|where)\bz[!$%&*+\-./:<-@\\^|~;,]+)r   r   r   r   r   r   zdict'r   r   r   r   zlist'r   r   r   r   r   zset'r   r   r   r   r   ztuple'r   r   z
(?![\'\w])r   )=r{   r|   r}   r~   r   Zbindr   r  r   r   r   r   r   Zdrop	dropwhiler   r   Zexhaustr   Zflipzfoldl1?r   Zfstr   r   r   r   headr   r   initr   r   r   r   ZiterateZlastr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   zscanl1?Zsndr   r   tailtake	takewhiler   r   z>(?<!\.)(self|Ellipsis|NotImplemented|None|True|False)(?!['\w])z3(?<!\.)[A-Z]\w*(Error|Exception|Warning)'*(?!['\w])zT(?<!\.)(Exception|GeneratorExit|KeyboardInterrupt|StopIteration|SystemExit)(?!['\w])z_(?<![\w.])(except|finally|for|if|import|not|otherwise|raise|subclass|while|with|yield)(?!['\w])z[A-Z_]+'*(?!['\w])z[A-Z]\w+'*(?!['\w])z\w+'*z[()]r  ry  r  r  r%   r  r.   rz  rY   r}  r  r  )r  rK   r  rH   rI   rF   rG   N)"ro  rm  rq  rh  rW   r  r  r  r   r   r  r   r  r  r  r  r  r   r	   r   r  r   r   r  r  r   r   r  r  r   r   r  r'   r  r)   r)   r)   r*   r      s   	
9r    c                   @   s:   e Zd ZdZdZdgZg Zg Zh dZdd Z	dd Z
d	S )
r!   z[
    A Python lexer recognizing Numerical Python builtins.

    .. versionadded:: 0.10
    ZNumPyZnumpy>  Zbinary_reprZflatinfZaverageZ	remainderZbitwise_notZarray_equivZsignbitZalltrueZreal_if_closeZ
fromarraysZvstackZuniformZfastCopyAndTransposeZtriuZlexsortsplitZblackmanZcommon_typeZtostringZdiagonalZ
frombufferZsometrueZfabsinnerZmeanZs_ZvonmisesZmaximum_sctypeZmeshgridZconcatenatesortZwhoZseedr|   ZpolyaddZround_ZweibullZdstackZpolyintZmodfrootsZargminZ
reciprocalZissctypeZasmatrixZbyte_boundsZgreater_equaliterableZargsortZget_numarray_includeZasfortranarrayshapeZnanmintolistZargmaxZarray_splitZ
logical_orZ	isrealobjZ
left_shiftZmsortZmaximumZlstsqZdtypeZnewaxisdiffZarctan2ZplaceZpolyderZsqrtZlog2productZpolysubZdiagZldexpZogridZhypotZcan_castZcorrcoefZrecarrayZ	seterrobjZmatrixZ	newbufferZrandintadd	conjugatefillZi0Z
array_reprZmultiplyZhistogram2drepeatZbyteswapZloadtxtZright_shiftZpkgloadsourceZangler   ndimZarcsinZmintypecodeZrot90ZhistogramddZ
issubdtypeZapply_over_axesZswapaxesZ	correlateZsincZintersect1d_nuZisinfZlinspaceZfmodZ
fromstringr  Zget_printoptionsZpolyvalZsetxor1dZvanderZexpand_dimsZpoly1dZfrexpZptpZlessalenZasfarrayZinterpZputidentityZ	transposeZhanningZrandom_sampleZisrealZarctanZsolveZ
asanyarrayZbmatZ	broadcastZamaxZtracer   ZtofileZzerosZfftshiftlogZrollZdiagflatZissubclass_Z	index_expZ
cumproductZdispZgetfieldZseterrZstandard_normalZexpm1Zlogical_andZ
obj2sctypeZix_Z	histogramZrollaxisinvZitemsetZ
nan_to_numZmay_share_memoryZsetfieldZarrayinfoZpolymulZsinZlogical_xorZbitwise_andZravelZtanhsignZunique1dZtrilZargwhereZcolumn_stackZ	nanargmax
accumulateZgreaterZ
arrayrangeZarray_equalZexpZcumsumZgumbeltestZlog10Zunravel_indexwhereZproddumpZ	nanargminZ
seterrcallr~   uniqueZtrue_divideZrequireZc_Z
less_equalZpolyfitZ	tensordotZ	setdiff1dZget_includeZvsplitZdigitizeviewtypenameZsetmember1dZarccoshcopyZselectZminimumZconvolveZ	array_strZfftfreqZflipudemptyr}   ZisscalarrealdumpsZmatZhsplitZndenumerateZrandom_integersZputmaskZranfZalterdotZsvdZconjZ
atleast_2dZcoshZediff1dZhammingZsinhZmgridZ	deprecateZfloorZaminZpolyZifftZiscomplexobjZgradientZflatnonzerodotZ	base_reprsubtractZtriZcrossmodZ
restoredotZ
atleast_1dZarccosZ	isfortranZ	ones_liker  Zset_numeric_opsZintersect1dextractZmedianZint_asbufferZastypeZsquareZ	vectorizeindicesZhstackZclipZlog1pZarray2stringZbincountvarZchooseZget_numpy_includeZeyeZtileZget_array_wrapZsearchsortednanZunion1dr   Zsavetxtloadsr   Zsctype2charZequalZr_r   ZranknegativeimagZ
zeros_likeitemZfromiterZdivideZshuffleZ	row_stackZcumprodZ
frompyfuncZpowerZarctanhZbinomialZsampleZflattenZlogspaceZ
atleast_3dZfixZapply_along_axisZfromfileZfromfunctionZ
geterrcallZarcsinhZrintabsoluteZbetaZfloor_divideZreshapeZset_string_functionZkaiserZnewbyteorderZisneginfZissubsctyper  Z
bitwise_orinvertZouterZceilZpolydivZnanmaxZtanZarangeZfftZtypeDictZbitwise_xorZcovdeleteZtrapzZ	iscomplexZstdZ
empty_likeZkronZnonzeroZshow_configZaroundZcompare_chararraysZisfinitesizeZsqueezeZsort_complexunwrapZdsplitcompressZgeterrZfliplrZasscalarZnansumZ
getbufsizeZresizeZascontiguousarrayinsertZndindexZpermutationZsetflagsZ	piecewiseloadZonesZbartlettZisnanZ	geterrobj	getbufferZcosZ
trim_zerosZasarray_chkfiniteZ
setbufsizeZasarrayZallcloseZ	not_equalZvdotZfinfoZpinvr   ZpoissonZgenericZlogical_notZisposinfZset_printoptionsc                 c   sJ   t | |D ]8\}}}|tu r8|| jv r8|tj|fV  q|||fV  qd S )N)r   r  r   EXTRA_KEYWORDSr   r  )r  r  indextokenvaluer)   r)   r*   r    s
    
z!NumPyLexer.get_tokens_unprocessedc                 C   s.   | d d }t | dsd|v o,d|v p,d|v S )Nr  r  r  zimport numpyzfrom numpy importr  )r  ltextr)   r)   r*   r    s    
zNumPyLexer.analyse_textN)ro  rm  rq  rh  rW   r  r  r  r4  r  r  r)   r)   r)   r*   r!   G  s   Cr!   )-rh  r  r  Zpygments.lexerr   r   r   r   r   r   r   r	   r
   r   Zpygments.utilr   r   Zpygments.tokenr   r   r   r   r   r   r   r   r   r   r   Zpygmentsr   r  __all__r   r  r   ZPython3Lexerr   r   r   ZPython3TracebackLexerr   r   r    r!   r)   r)   r)   r*   <module>   s,   
04
  w ^X50 4c