U
    lufbB                     @   s   d Z ddlZddlmZ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lmZmZmZ ddlmZ ddlmZ ddlmZ d	d
dgZdee
jef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.csound
    ~~~~~~~~~~~~~~~~~~~~~~

    Lexers for Csound languages.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)
RegexLexerbygroupsdefaultincludeusingwords)
CommentErrorKeywordNameNumberOperatorPunctuationStringText
Whitespace)OPCODESDEPRECATED_OPCODESREMOVED_OPCODES)	HtmlLexer)PythonLexer)LuaLexerCsoundScoreLexerCsoundOrchestraLexerCsoundDocumentLexerz((?:(?:;|//).*)*)(\n)c                   @   s  e Zd ZdZdefdejfdejfdee	efgdej
fdej
dfd	ej
d
fdej
dfdej
dfgeddedfgeddedfgdefeddeej
edfdej
dfgeddej
fdefdedfgdefeddedfgdej
fdej
fdedfgeddej
dfgd eej
ed!fd"ej
fgd#ej
fdefded$fd%ed&fd'ej
d(fdedfgd)ej
fd*efed+gd)ej
fd*efed,gd-ej
fd'ej
d.fdej
dfgeded/gd0ejfd1eejejfd2ejfgdedfd3efed/d4efgg d5Zd6S )7CsoundLexerzhttps://csound.com/z[ \t]+z/[*](?:.|\n)*?[*]/(?:;|//).*$z(\\)(\n)z)#(?:e(?:nd(?:if)?|lse)\b|##)|@@?[ \t]*\d+z#includestrincludestr directivez#includeinclude directivez#[ \t]*definedefine directivez#(?:ifn?def|undef)\bmacro directive
whitespacez([^ \t]).*?\1#pop")r"   quoted string\nz([A-Z_a-z]\w*)(\())r"   macro parameter name list[A-Z_a-z]\w*)r"   before macro bodyz['#]z\)#)r"   
macro bodyz(?:\\(?!#)|[^#\\]|\n)+z\\#z(?<!\\)#z(\$[A-Z_a-z]\w*\.?)(\()macro parameter value listz\$[A-Z_a-z]\w*(?:\.|\b)z(?:[^\'#"{()]|\{(?!\{))+#macro parameter value quoted string\{\{#macro parameter value braced stringz\(#macro parameter value parentheticalz\\[#'()]z[#'()]r$   braced stringz(?:[^\\()]|\\\))+z#push
macro usesz2\d+[Ee][+-]?\d+|(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?z(0[Xx])([0-9A-Fa-f]+)\d+z[^"$]+z[$])r!   preprocessor directivesr   r   r   r&   r(   r*   r    r1   r+   r,   r.   r/   whitespace and macro usesnumbersr$   r0   N)__name__
__module____qualname__urlr   r   	MultilineSingler   r   Preprocr   r   r   r	   r   ZFloatr
   TypeZHexIntegertokens r@   r@   :/tmp/pip-unpacked-wheel-7eq1ciah/pygments/lexers/csound.pyr      s   



	


	

r   c                   @   s   e Zd ZdZdZddgZdgZdefededd	e	fd
e	j
fdee	ejfde	dfeddefdefdedfdejdfgeddejfdedfgeddejdfgeddejdfgdejdfedgdedfdefgdZdS ) r   zO
    For `Csound <https://csound.com>`_ scores.

    .. versionadded:: 2.1
    zCsound Scorezcsound-scorez
csound-scoz*.scor%   r4   r3   z[aBbCdefiqstvxy]zz([nNpP][pP])(\d+)z[mn]mark statementr5   z[!+\-*/^%&|<>#~.]z[()\[\]]r#   r$   z\{loop after left bracer'   r"   r2   )r"   loop after repeat count)r"   loopz\}root\}\}z[^}]|\}(?!\}))rG   rC   rD   rE   rF   r0   N)r6   r7   r8   __doc__namealiases	filenamesr   r   r
   Constantr   r   r>   r   r   r   r   r<   r   Labelr?   r@   r@   r@   rA   r      sD   



c                   @   s
  e Zd ZdZdZddgZddgZe Zdd Z	d	d
 Z
defdeeejeefededdejdfdejdfdejfedgdejjfeddefdefdedfdedfeddddefed dddejfd!ed"fd#eejed"fd$eejed%fd&eejed'fd(eejed)fd*ejd+fd,ejd-fd.ejd/fd0ejd1fd2ejjfd3e
fgedd4ejfd5efded6fgedd7e	d8fded6fgedd9ejfd:efded6fgded6fd;efed<ed=ed>d?efgd@ed6fdAefed=ed>dBefgdCejfgdDejfdEejfgedd:ed6fedgeddFejd6fed6geddedGfed6gdHejfdIejfedgeddedfdedJfded6fgd@ed6fdKe e!fgeddedfdedLfded6fgd@ed6fdKe e"fgeddedfdedMfded6fgd@ed6fdKe e#fgdNZ$dOS )Pr   zS
    For `Csound <https://csound.com>`_ orchestras.

    .. versionadded:: 2.1
    zCsound OrchestraZcsoundz
csound-orcz*.orcz*.udoc                 c   s,   | d}| j| | tj|fV  d S )Nr   )groupuser_defined_opcodesaddstartr   Function)lexermatchopcoder@   r@   rA   opcode_name_callback   s    
z)CsoundOrchestraLexer.opcode_name_callbackc                 c   s   t j}|d}|tks(|tks(|tkr<| tj|fV  nv|| j	krZ| tj
|fV  nXt}td|}|r|dt j|dfV  |dt|dfV  n| t|fV  |dr|dt|dfV  |d||dfV  d S )N   z^(g?[afikSw])(\w+)      )r
   r=   rO   r   r   r   rR   r   BuiltinrP   rS   researchr   )rT   rU   Ztype_annotation_tokenrJ   Z
name_matchr@   r@   rA   name_callback   s    


z"CsoundOrchestraLexer.name_callbackr%   z^([ \t]*)(\w+)(:)([ \t]+|$)r4   r3   z	\binstr\b"instrument numbers and identifiersz
\bopcode\bafter opcode keywordz\b(?:end(?:in|op))\bpartial statementsz-\b(?:0dbfs|A4|k(?:r|smps)|nchnls(?:_i)?|sr)\br5   u@   \+=|-=|\*=|/=|<<|>>|<=|>=|==|!=|&&|\|\||[~¬]|[=!+\-*/^%&|<>#?:]z	[(),\[\]]r#   r$   r-   r0   )ZdoelseZelseifendifZenduntilfiifZithenZkthenZodZthenZuntilwhilez\b)prefixsuffix)returnZrireturnz\b[ik]?goto\b
goto labelz"\b(r(?:einit|igoto)|tigoto)(\(|\b)z\b(c(?:g|in?|k|nk?)goto)(\(|\b))rj   goto argumentz\b(timout)(\(|\b))rj   rk   rk   z\b(loop_[gl][et])(\(|\b))rj   rk   rk   rk   z\bprintk?s\bprints opcodez"\b(?:readscore|scoreline(?:_i)?)\bCsound score opcodez\bpyl?run[it]?\bPython opcodez\blua_(?:exec|opdef)\b
Lua opcodez\bp\d+\bz$\b([A-Z_a-z]\w*)(?:(:)([A-Za-z]))?\bz\d+|[A-Z_a-z]\w*z[+,]r"   r'   )r"   opcode type signaturesz0|[afijkKoOpPStV\[\]]+,z
[^\\"$%)]+r1   escape sequencesformat specifiersz[\\$%)]rH   z(?:[^\\%)}]|\}(?!\}))+z[\\%)]z\\(?:[\\abnrt"]|[0-7]{1,3})z'%[#0\- +]*\d*(?:\.\d+)?[AE-GXac-giosux]z%%z\w+prints quoted stringz\\\\[aAbBnNrRtT]z%[!nNrRtT]|[~^]{1,2}Csound scorez([^}]+)|\}(?!\})PythonLua)rG   ra   r_   r`   rp   r$   r0   rr   rs   rk   rj   rl   rt   rm   ru   rn   rv   ro   rw   N)%r6   r7   r8   rI   rJ   rK   rL   setrP   rW   r^   r   r   r   rN   r   r   r
   ZDeclarationVariableZGlobalr   r   r   ZPseudor[   ZInstancerS   r=   ZEscapeZInterpolr   r   r   r   r   r?   r@   r@   r@   rA   r      s   


 




$		



 c                   @   s   e Zd ZdZdZddgZdgZdejfdej	fde
fd	ejd
fdejdfdejdfdejdfdejfgdejdfdeefgdejdfdeefgdejdfdeefgdefdejdfdejdfgdefdedfdedfdedfgd Zd!S )"r   zR
    For `Csound <https://csound.com>`_ documents.

    .. versionadded:: 2.1
    zCsound Documentzcsound-documentz
csound-csdz*.csdz/[*](.|\n)*?[*]/r   z[^/;<]+|/(?!/)z<\s*CsInstruments)	orchestratagz<\s*CsScore)scorer{   z<\s*[Hh][Tt][Mm][Ll])HTMLr{   z<\s*[\w:.-]+r{   z<\s*/\s*[\w:.-]+\s*>z<\s*/\s*CsInstruments\s*>r"   z%(.|\n)+?(?=<\s*/\s*CsInstruments\s*>)z<\s*/\s*CsScore\s*>z(.|\n)+?(?=<\s*/\s*CsScore\s*>)z<\s*/\s*[Hh][Tt][Mm][Ll]\s*>z((.|\n)+?(?=<\s*/\s*[Hh][Tt][Mm][Ll]\s*>)z\s+z[\w.:-]+\s*=attrz/?\s*>z".*?"z'.*?'z[^\s>]+)rG   rz   r|   r}   r{   r~   N)r6   r7   r8   rI   rJ   rK   rL   r   r:   r;   r   r   Tagr   r   r   r   r   	Attributer   r?   r@   r@   r@   rA   r     s@   











)%rI   r\   Zpygments.lexerr   r   r   r   r   r   Zpygments.tokenr   r	   r
   r   r   r   r   r   r   r   Z pygments.lexers._csound_builtinsr   r   r   Zpygments.lexers.htmlr   Zpygments.lexers.pythonr   Zpygments.lexers.scriptingr   __all__r;   newliner   r   r   r   r@   r@   r@   rA   <module>   s   
 0
nB S