B
    G
\@                 @   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 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-2017 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)	HtmlLexer)PythonLexer)LuaLexerCsoundScoreLexerCsoundOrchestraLexerCsoundDocumentLexerz((?:(?:;|//).*)*)(\n)c               @   s  e 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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d,ejfd-eejejfd.ejfgg d/Zd0S )1CsoundLexerz[ \t]+z/[*](?:.|\n)*?[*]/z(?:;|//).*$z(\\)(\n)z)#(?:e(?:nd(?:if)?|lse)\b|##)|@@?[ \t]*\d+z#includezinclude directivez#[ \t]*definezdefine directivez#(?:ifn?def|undef)\bzmacro directive
whitespacez([^ \t]).*?\1z#popz\nz([A-Z_a-z]\w*)(\())z#popzmacro parameter name listz[A-Z_a-z]\w*)z#popzbefore macro bodyz['#]z\)#)z#popz
macro bodyz(?:\\(?!#)|[^#\\]|\n)+z\\#z(?<!\\)#z(\$[A-Z_a-z]\w*\.?)(\()zmacro parameter value listz\$[A-Z_a-z]\w*(?:\.|\b)z(?:[^\'#"{()]|\{(?!\{))+"z#macro parameter value quoted stringz\{\{z#macro parameter value braced stringz\(z#macro parameter value parentheticalz\\[#'()]z[#'()]zquoted stringzbraced stringz(?:[^\\()]|\\\))+z#pushz
macro usesz2\d+[Ee][+-]?\d+|(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?z(0[Xx])([0-9A-Fa-f]+)z\d+)r   zpreprocessor directiveszinclude directivezdefine directivezmacro parameter name listzbefore macro bodyz
macro bodyzmacro directivez
macro useszmacro parameter value listz#macro parameter value quoted stringz#macro parameter value braced stringz#macro parameter value parentheticalzwhitespace and macro usesnumberszbraced stringN)__name__
__module____qualname__r   r   	MultilineSingler   r   Preprocr   r   r   r	   r   ZFloatr
   TypeZHexIntegertokens r(   r(   5lib/python3.7/site-packages/pygments/lexers/csound.pyr      sf   










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dedfdefedde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   zU
    For `Csound <https://csound.github.io>`_ scores.

    .. versionadded:: 2.1
    zCsound Scorezcsound-scorez
csound-scoz*.scoz\nzwhitespace and macro useszpreprocessor directivesz[abCdefiqstvxy]zz([nNpP][pP])(\d+)z[mn]zmark statementr   z[!+\-*/^%&|<>#~.]z[()\[\]]r   zquoted stringz\{zloop after left bracez[A-Z_a-z]\w*z#popz[^"$]+z
macro usesz[$]z\d+)z#popzloop after repeat count)z#poploopz\}rootz\}\}z[^}]|\}(?!\}))r,   zmark statementzquoted stringzloop after left bracezloop after repeat countr+   zbraced stringN)r   r    r!   __doc__namealiases	filenamesr   r   r
   ZConstantr   r   r&   r   r   r   r   r$   r   Labelr'   r(   r(   r(   r)   r   {   s>   

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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dJfded6fgd@ed6fdKe e!fgeddedLfded6fgd@ed6fdKe e"fgeddedMfded6fgd@ed6fdKe e#fgdNZ$dOS )Pr   zY
    For `Csound <https://csound.github.io>`_ 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matchZopcoder(   r(   r)   opcode_name_callback   s    
z)CsoundOrchestraLexer.opcode_name_callbackc             c   s  | d}|tks|tkrj| tj|fV  | drh|dt| dfV  |dtj| dfV  n|| j	kr| tj
|fV  ntd|}|r|dtj| dfV  |dt| dfV  nL| t|fV  | dr|dt| dfV  |dt| dfV  d S )N         z^(g?[afikSw])(\w+))r2   r   r   r5   r   Builtinr   r
   r%   r3   r6   research)r7   r8   r.   Z	nameMatchr(   r(   r)   name_callback   s     


z"CsoundOrchestraLexer.name_callbackz\nz^([ \t]*)(\w+)(:)(?:[ \t]+|$)zwhitespace and macro useszpreprocessor directivesz	\binstr\bz"instrument numbers and identifiersz
\bopcode\bzafter opcode keywordz\b(?:end(?:in|op))\bzpartial statementsz-\b(?:0dbfs|A4|k(?:r|smps)|nchnls(?:_i)?|sr)\br   u@   \+=|-=|\*=|/=|<<|>>|<=|>=|==|!=|&&|\|\||[~¬]|[=!+\-*/^%&|<>#?:]z	[(),\[\]]r   zquoted stringz\{\{zbraced string)ZdoelseZelseifZendifZenduntilZfiifZithenZkthenZodZthenZuntilwhilez\b)prefixsuffix)returnZrireturnz\b[ik]?goto\bz
goto labelz"\b(r(?:einit|igoto)|tigoto)(\(|\b)z\b(c(?:g|in?|k|nk?)goto)(\(|\b))z
goto labelzgoto argumentz\b(timout)(\(|\b))z
goto labelzgoto argumentzgoto argumentz\b(loop_[gl][et])(\(|\b))z
goto labelzgoto argumentzgoto argumentzgoto argumentz\bprintk?s\bzprints opcodez"\b(?:readscore|scoreline(?:_i)?)\bzCsound score opcodez\bpyl?run[it]?\bzPython opcodez\blua_(?:exec|opdef)\bz
Lua opcodez\bp\d+\bz$\b([A-Z_a-z]\w*)(?:(:)([A-Za-z]))?\bz\d+|[A-Z_a-z]\w*z[+,]z#popz[A-Z_a-z]\w*)z#popzopcode type signaturesz0|[afijkKoOpPStV\[\]]+,z
[^\\"$%)]+z
macro useszescape sequenceszformat specifiersz[\\$%)]z\}\}z(?:[^\\%)}]|\}(?!\}))+z[\\%)]z\\(?:[\\abnrt"]|[0-7]{1,3})z)%[#0\- +]*\d*(?:\.\d+)?[diuoxXfFeEgGaAcs]z%%z\w+zprints quoted stringz\\\\[aAbBnNrRtT]z%[!nNrRtT]|[~^]{1,2}zCsound scorez([^}]+)|\}(?!\})PythonLua)r,   zpartial statementsz"instrument numbers and identifierszafter opcode keywordzopcode type signatureszquoted stringzbraced stringzescape sequenceszformat specifierszgoto argumentz
goto labelzprints opcodezprints quoted stringzCsound score opcodezCsound scorezPython opcoderH   z
Lua opcoderI   N)%r   r    r!   r-   r.   r/   r0   setr3   r9   r@   r   r   r   r1   r   r   r
   ZDeclarationZVariableZGlobalr   r   r   ZPseudor=   ZInstancer6   r%   ZEscapeZInterpolr   r   r   r   r   r'   r(   r(   r(   r)   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   zX
    For `Csound <https://csound.github.io>`_ documents.

    .. versionadded:: 2.1
    zCsound Documentzcsound-documentz
csound-csdz*.csdz/[*](.|\n)*?[*]/z(?:;|//).*$z[^/;<]+|/(?!/)z<\s*CsInstruments)	orchestratagz<\s*CsScore)scorerL   z<\s*[Hh][Tt][Mm][Ll])HTMLrL   z<\s*[\w:.-]+rL   z<\s*/\s*[\w:.-]+\s*>z<\s*/\s*CsInstruments\s*>z#popz%(.|\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>]+)r,   rK   rM   rN   rL   rO   N)r   r    r!   r-   r.   r/   r0   r   r"   r#   r   r   ZTagr   r   r   r   Z	Attributer   r'   r(   r(   r(   r)   r     s2   








)$r-   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   Zpygments.lexers.htmlr   Zpygments.lexers.pythonr   Zpygments.lexers.scriptingr   __all__r#   newliner   r   r   r   r(   r(   r(   r)   <module>
   s    0
`I M