U
    luf&                     @   s   d Z ddl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mZmZmZmZ ddddd	g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G dd	 d	eZdS )z
    pygments.lexers.algebra
    ~~~~~~~~~~~~~~~~~~~~~~~

    Lexers for computer algebra systems.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)Lexer
RegexLexerbygroupsdo_insertionswords)
TextCommentOperatorKeywordNameStringNumberPunctuationGeneric
WhitespaceGAPLexerGAPConsoleLexerMathematicaLexer
MuPADLexerBCLexerc                   @   s   e Zd ZdZdZdZdgZddddgZd	d
ej	fde
fdefdefdejfdejfdefdejfdejfdefdefdefgiZdd ZdS )r   z9
    For GAP source code.

    .. versionadded:: 2.0
    ZGAPzhttps://www.gap-system.orgZgapz*.gz*.gdz*.giz*.gaprootz#.*$"(?:[^"\\]|\\.)*"\(|\)|\[|\]|\{|\}aV  (?x)\b(?:
                if|then|elif|else|fi|
                for|while|do|od|
                repeat|until|
                break|continue|
                function|local|return|end|
                rec|
                quit|QUIT|
                IsBound|Unbind|
                TryNextMethod|
                Info|Assert
              )\bzD(?x)\b(?:
                true|false|fail|infinity
              )\bzx(?x)\b(?:
                (Declare|Install)([A-Z][A-Za-z]+)|
                   BindGlobal|BIND_GLOBAL
              )\bz\.|,|:=|;|=|\+|-|\*|/|\^|>|<z=(?x)\b(?:
                and|or|not|mod|in
              )\bzC(?x)
              (?:\w+|`[^`]*`)
              (?:::\w+|`[^`]*`)*[0-9]+(?:\.[0-9]*)?(?:e[0-9]+)?\.[0-9]+(?:e[0-9]+)?.c                 C   s6   d}t d| r|d7 }t d| r,|d7 }t|dS )N        zl(InstallTrueMethod|Declare(Attribute|Category|Filter|Operation|GlobalFunction|Synonym|SynonymAttr|Property))gffffff?zm(DeclareRepresentation|Install(GlobalFunction|Method|ImmediateMethod|OtherMethod)|New(Family|Type)|Objectify)g      ?)researchmin)textZscore r!   ;/tmp/pip-unpacked-wheel-7eq1ciah/pygments/lexers/algebra.pyanalyse_textH   s    zGAPLexer.analyse_textN)__name__
__module____qualname____doc__nameurlaliases	filenamesr   Singler   r   r
   r   ConstantBuiltinr	   WordVariabler   r   tokensr#   r!   r!   r!   r"   r      s>   (c                   @   s2   e Zd ZdZdZddgZdgZdd Zdd	 Zd
S )r   z`
    For GAP console sessions. Modeled after JuliaConsoleLexer.

    .. versionadded:: 2.14
    zGAP sessionzgap-consolezgap-replz*.tstc           	   	   c   sL  t f | j}d}d}g }d}d}|jddD ]}|dsD|dr|t|dtj|d d fgf ||dd  7 }d}d}n|s|d	r|t|dtj|d d
 fgf ||d
d  7 }nX|rt||	|E d H  d}g }|ds|r|tj
|fV  d}n|tj|fV  d}|t|7 }q,|rHt||	|E d H  d S )Nr    FT)keependszgap> zbrk>    z>    zError, )r   options
splitlines
startswithappendlenr   ZPromptr   get_tokens_unprocessedErrorZOutput)	selfr    ZgaplexerstartZcurcodeZ
insertionsoutputerrorliner!   r!   r"   r;   f   sB    $$ 
 z&GAPConsoleLexer.get_tokens_unprocessedc                 C   s   t d| rdS dS d S )Nz^gap> g?r   )r   r   )r    r!   r!   r"   r#      s    zGAPConsoleLexer.analyse_textN)	r$   r%   r&   r'   r(   r*   r+   r;   r#   r!   r!   r!   r"   r   \   s   $c                   @   s   e Zd ZdZdZdZdddgZddd	d
gZddddgZdZ	dZ
dd Zddefdejfdejfdejfdefdejfdejfdejfee	efee
efdefdejfgiZdS )r   zG
    Lexer for Mathematica source code.

    .. versionadded:: 2.0
    ZMathematicaz#http://www.wolfram.com/mathematica/ZmathematicaZmmanbz*.nbz*.cdfz*.nbpz*.mazapplication/mathematicaz#application/vnd.wolfram.mathematicaz+application/vnd.wolfram.mathematica.packagezapplication/vnd.wolfram.cdf) z;;=z=.z!===z:=z->z:>z/.+-*/^z&&z||!z<>|z/;?@z//z/@z@@z@@@z~~z===&<>z<=z>=),;()[]{}c                 C   s   dd dd | D  S )Nz(%s)rJ   c                 s   s   | ]}t |V  qd S )N)r   escape).0entryr!   r!   r"   	<genexpr>   s     z1MathematicaLexer._multi_escape.<locals>.<genexpr>)join)entriesr!   r!   r"   _multi_escape   s    zMathematicaLexer._multi_escaper   z(?s)\(\*.*?\*\)z([a-zA-Z]+[A-Za-z0-9]*`)z([A-Za-z0-9]*_+[A-Za-z0-9]*)z#\d*z([a-zA-Z]+[a-zA-Z0-9]*)z
-?\d+\.\d*z
-?\d*\.\d+z-?\d+z".*?"\s+N)r$   r%   r&   r'   r(   r)   r*   r+   	mimetypes	operatorspunctuationr^   r   r   	Namespacer0   r   ZFloatZIntegerr   r	   r   r   r   r   r1   r!   r!   r!   r"   r      s8   


c                   @   s   e Zd ZdZdZdZdgZdgZdej	fdej
dfd	efd
efdefdejfdejfdejjfdefdejfdefdeejeefdejfdefdefdefdefgdej
fdej
dfdej
dfdej
fgdZdS )r   zv
    A MuPAD lexer.
    Contributed by Christopher Creutzig <christopher@creutzig.de>.

    .. versionadded:: 0.8
    ZMuPADzhttp://www.mupad.comZmupadz*.muz//.*?$/\*commentr   r   a  (?x)\b(?:
                next|break|end|
                axiom|end_axiom|category|end_category|domain|end_domain|inherits|
                if|%if|then|elif|else|end_if|
                case|of|do|otherwise|end_case|
                while|end_while|
                repeat|until|end_repeat|
                for|from|to|downto|step|end_for|
                proc|local|option|save|begin|end_proc|
                delete|frame
              )\baU  (?x)\b(?:
                DOM_ARRAY|DOM_BOOL|DOM_COMPLEX|DOM_DOMAIN|DOM_EXEC|DOM_EXPR|
                DOM_FAIL|DOM_FLOAT|DOM_FRAME|DOM_FUNC_ENV|DOM_HFARRAY|DOM_IDENT|
                DOM_INT|DOM_INTERVAL|DOM_LIST|DOM_NIL|DOM_NULL|DOM_POLY|DOM_PROC|
                DOM_PROC_ENV|DOM_RAT|DOM_SET|DOM_STRING|DOM_TABLE|DOM_VAR
              )\bz(?x)\b(?:
                PI|EULER|E|CATALAN|
                NIL|FAIL|undefined|infinity|
                TRUE|FALSE|UNKNOWN
              )\bz\b(?:dom|procname)\bz-\.|,|:|;|=|\+|-|\*|/|\^|@|>|<|\$|\||!|\'|%|~=z(?x)\b(?:
                and|or|not|xor|
                assuming|
                div|mod|
                union|minus|intersect|in|subset
              )\bz \b(?:I|RDN_INF|RD_NINF|RD_NAN)\bzi(?x)
              ((?:[a-zA-Z_#][\w#]*|`[^`]*`)
              (?:::[a-zA-Z_#][\w#]*|`[^`]*`)*)(\s*)([(])z](?x)
              (?:[a-zA-Z_#][\w#]*|`[^`]*`)
              (?:::[a-zA-Z_#][\w#]*|`[^`]*`)*r   r   r_   r   z[^/*]+z#push\*/#pop[*/]r   re   N)r$   r%   r&   r'   r(   r)   r*   r+   r   r,   	Multiliner   r   r
   r   ZClassr-   r.   ZPseudor	   r/   r   r   ZFunctionr   r0   r   r1   r!   r!   r!   r"   r      sR   


4

c                	   @   s   e Zd ZdZdZdZdgZdgZdej	dfde
fd	efed
ddefdefdefdefdefgdej	fdej	dfdej	fgdZdS )r   z0
    A BC lexer.

    .. versionadded:: 2.1
    ZBCz https://www.gnu.org/software/bc/Zbcz*.bcrd   re   r   z[{}();,])ifelsewhileforbreakcontinueZhaltreturnZdefineautoprintreadlengthZscalesqrtZlimitsquitZwarrantyz\b)suffixz!\+\+|--|\|\||&&|([-<>+*%\^/!=])=?z[0-9]+(\.[0-9]*)?z\.[0-9]+r   z[^*/]+rf   rg   rh   ri   N)r$   r%   r&   r'   r(   r)   r*   r+   r   rj   r   r   r   r
   r	   r   r   r1   r!   r!   r!   r"   r     s2   

)r'   r   Zpygments.lexerr   r   r   r   r   Zpygments.tokenr   r   r	   r
   r   r   r   r   r   r   __all__r   r   r   r   r   r!   r!   r!   r"   <module>   s   
0G90I