summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Whetsell <nathan.whetsell@gmail.com>2015-09-05 16:18:59 -0400
committerNathan Whetsell <nathan.whetsell@gmail.com>2015-09-05 16:18:59 -0400
commita0d6562e88f017378469f654a92510cc2e1e4f7d (patch)
tree135fdae15693bb684525d3eb30602fdee4254c0d
parent1a3034b179ccbdd1411f6cb4718a628e89f723d3 (diff)
downloadpygments-a0d6562e88f017378469f654a92510cc2e1e4f7d.tar.gz
Added Csound lexer
-rw-r--r--pygments/lexers/_csound_builtins.py1338
-rw-r--r--pygments/lexers/_mapping.py2
-rw-r--r--pygments/lexers/csound.py326
-rw-r--r--tests/examplefiles/test.orc255
4 files changed, 1921 insertions, 0 deletions
diff --git a/pygments/lexers/_csound_builtins.py b/pygments/lexers/_csound_builtins.py
new file mode 100644
index 00000000..ddf87a64
--- /dev/null
+++ b/pygments/lexers/_csound_builtins.py
@@ -0,0 +1,1338 @@
+# -*- coding: utf-8 -*-
+
+# Opcodes in Csound 6.05 from
+# csound --list-opcodes
+# except
+# cggoto <http://www.csounds.com/manual/html/cggoto.html>
+# cigoto <http://www.csounds.com/manual/html/cigoto.html>
+# cingoto (undocumented)
+# ckgoto <http://www.csounds.com/manual/html/ckgoto.html>
+# cngoto <http://www.csounds.com/manual/html/cngoto.html>
+# endin <http://www.csounds.com/manual/html/endin.html
+# endop <http://www.csounds.com/manual/html/endop.html
+# goto <http://www.csounds.com/manual/html/goto.html>
+# igoto <http://www.csounds.com/manual/html/igoto.html>
+# kgoto <http://www.csounds.com/manual/html/kgoto.html>
+# loop_ge <http://www.csounds.com/manual/html/loop_ge.html>
+# loop_gt <http://www.csounds.com/manual/html/loop_gt.html>
+# loop_le <http://www.csounds.com/manual/html/loop_le.html>
+# loop_lt <http://www.csounds.com/manual/html/loop_lt.html>
+# opcode <http://www.csounds.com/manual/html/opcode.html>
+# return <http://www.csounds.com/manual/html/return.html>
+# rigoto <http://www.csounds.com/manual/html/rigoto.html>
+# tigoto <http://www.csounds.com/manual/html/tigoto.html>
+# timout <http://www.csounds.com/manual/html/timout.html>
+# which are treated as keywords; the scoreline opcodes
+# scoreline <http://www.csounds.com/manual/html/scoreline.html>
+# scoreline_i <http://www.csounds.com/manual/html/scoreline_i.html>
+# which allow Csound Score highlighting; the pyrun opcodes
+# <http://www.csounds.com/manual/html/pyrun.html>
+# pylrun
+# pylruni
+# pylrunt
+# pyrun
+# pyruni
+# pyrunt
+# which allow Python highlighting; and the Lua opcodes
+# lua_exec <http://www.csounds.com/manual/html/lua_exec.html>
+# lua_opdef <http://www.csounds.com/manual/html/lua_opdef.html>
+# which allow Lua highlighting.
+OPCODES = set((
+ 'ATSadd',
+ 'ATSaddnz',
+ 'ATSbufread',
+ 'ATScross',
+ 'ATSinfo',
+ 'ATSinterpread',
+ 'ATSpartialtap',
+ 'ATSread',
+ 'ATSreadnz',
+ 'ATSsinnoi',
+ 'FLbox',
+ 'FLbutBank',
+ 'FLbutton',
+ 'FLcloseButton',
+ 'FLcolor',
+ 'FLcolor2',
+ 'FLcount',
+ 'FLexecButton',
+ 'FLgetsnap',
+ 'FLgroup',
+ 'FLgroupEnd',
+ 'FLgroup_end',
+ 'FLhide',
+ 'FLhvsBox',
+ 'FLhvsBoxSetValue',
+ 'FLjoy',
+ 'FLkeyIn',
+ 'FLknob',
+ 'FLlabel',
+ 'FLloadsnap',
+ 'FLmouse',
+ 'FLpack',
+ 'FLpackEnd',
+ 'FLpack_end',
+ 'FLpanel',
+ 'FLpanelEnd',
+ 'FLpanel_end',
+ 'FLprintk',
+ 'FLprintk2',
+ 'FLroller',
+ 'FLrun',
+ 'FLsavesnap',
+ 'FLscroll',
+ 'FLscrollEnd',
+ 'FLscroll_end',
+ 'FLsetAlign',
+ 'FLsetBox',
+ 'FLsetColor',
+ 'FLsetColor2',
+ 'FLsetFont',
+ 'FLsetPosition',
+ 'FLsetSize',
+ 'FLsetSnapGroup',
+ 'FLsetText',
+ 'FLsetTextColor',
+ 'FLsetTextSize',
+ 'FLsetTextType',
+ 'FLsetVal',
+ 'FLsetVal_i',
+ 'FLsetVali',
+ 'FLsetsnap',
+ 'FLshow',
+ 'FLslidBnk',
+ 'FLslidBnk2',
+ 'FLslidBnk2Set',
+ 'FLslidBnk2Setk',
+ 'FLslidBnkGetHandle',
+ 'FLslidBnkSet',
+ 'FLslidBnkSetk',
+ 'FLslider',
+ 'FLtabs',
+ 'FLtabsEnd',
+ 'FLtabs_end',
+ 'FLtext',
+ 'FLupdate',
+ 'FLvalue',
+ 'FLvkeybd',
+ 'FLvslidBnk',
+ 'FLvslidBnk2',
+ 'FLxyin',
+ 'MixerClear',
+ 'MixerGetLevel',
+ 'MixerReceive',
+ 'MixerSend',
+ 'MixerSetLevel',
+ 'MixerSetLevel_i',
+ 'OSCinit',
+ 'OSClisten',
+ 'OSCsend',
+ 'a',
+ 'abs',
+ 'active',
+ 'adsr',
+ 'adsyn',
+ 'adsynt',
+ 'adsynt2',
+ 'aftouch',
+ 'alpass',
+ 'alwayson',
+ 'ampdb',
+ 'ampdbfs',
+ 'ampmidi',
+ 'ampmidid',
+ 'areson',
+ 'aresonk',
+ 'array',
+ 'atone',
+ 'atonek',
+ 'atonex',
+ 'babo',
+ 'balance',
+ 'bamboo',
+ 'barmodel',
+ 'bbcutm',
+ 'bbcuts',
+ 'betarand',
+ 'bexprnd',
+ 'bformdec',
+ 'bformdec1',
+ 'bformenc',
+ 'bformenc1',
+ 'binit',
+ 'biquad',
+ 'biquada',
+ 'birnd',
+ 'bqrez',
+ 'buchla',
+ 'butbp',
+ 'butbr',
+ 'buthp',
+ 'butlp',
+ 'butterbp',
+ 'butterbr',
+ 'butterhp',
+ 'butterlp',
+ 'button',
+ 'buzz',
+ 'c2r',
+ 'cabasa',
+ 'cauchy',
+ 'cauchyi',
+ 'ceil',
+ 'cell',
+ 'cent',
+ 'centroid',
+ 'ceps',
+ #'cggoto',
+ 'chanctrl',
+ 'changed',
+ 'chani',
+ 'chano',
+ 'chebyshevpoly',
+ 'checkbox',
+ 'chn_S',
+ 'chn_a',
+ 'chn_k',
+ 'chnclear',
+ 'chnexport',
+ 'chnget',
+ 'chnmix',
+ 'chnparams',
+ 'chnset',
+ 'chuap',
+ #'cigoto',
+ #'cingoto',
+ #'ckgoto',
+ 'clear',
+ 'clfilt',
+ 'clip',
+ 'clockoff',
+ 'clockon',
+ 'cmplxprod',
+ #'cngoto',
+ 'comb',
+ 'combinv',
+ 'compilecsd',
+ 'compileorc',
+ 'compilestr',
+ 'compress',
+ 'connect',
+ 'control',
+ 'convle',
+ 'convolve',
+ 'copy2ftab',
+ 'copy2ttab',
+ 'copya2ftab',
+ 'copyf2array',
+ 'cos',
+ 'cosh',
+ 'cosinv',
+ 'cosseg',
+ 'cossegb',
+ 'cossegr',
+ 'cps2pch',
+ 'cpsmidi',
+ 'cpsmidib',
+ 'cpsmidinn',
+ 'cpsoct',
+ 'cpspch',
+ 'cpstmid',
+ 'cpstun',
+ 'cpstuni',
+ 'cpsxpch',
+ 'cpuprc',
+ 'cross2',
+ 'crossfm',
+ 'crossfmi',
+ 'crossfmpm',
+ 'crossfmpmi',
+ 'crosspm',
+ 'crosspmi',
+ 'crunch',
+ 'ctlchn',
+ 'ctrl14',
+ 'ctrl21',
+ 'ctrl7',
+ 'ctrlinit',
+ 'cuserrnd',
+ 'dam',
+ 'date',
+ 'dates',
+ 'db',
+ 'dbamp',
+ 'dbfsamp',
+ 'dcblock',
+ 'dcblock2',
+ 'dconv',
+ 'delay',
+ 'delay1',
+ 'delayk',
+ 'delayr',
+ 'delayw',
+ 'deltap',
+ 'deltap3',
+ 'deltapi',
+ 'deltapn',
+ 'deltapx',
+ 'deltapxw',
+ 'denorm',
+ 'diff',
+ 'diskgrain',
+ 'diskin',
+ 'diskin2',
+ 'dispfft',
+ 'display',
+ 'distort',
+ 'distort1',
+ 'divz',
+ 'doppler',
+ 'downsamp',
+ 'dripwater',
+ 'dumpk',
+ 'dumpk2',
+ 'dumpk3',
+ 'dumpk4',
+ 'duserrnd',
+ 'dust',
+ 'dust2',
+ #'endin',
+ #'endop',
+ 'envlpx',
+ 'envlpxr',
+ 'ephasor',
+ 'eqfil',
+ 'evalstr',
+ 'event',
+ 'event_i',
+ 'exciter',
+ 'exitnow',
+ 'exp',
+ 'expcurve',
+ 'expon',
+ 'exprand',
+ 'exprandi',
+ 'expseg',
+ 'expsega',
+ 'expsegb',
+ 'expsegba',
+ 'expsegr',
+ 'fareylen',
+ 'fareyleni',
+ 'faustaudio',
+ 'faustcompile',
+ 'faustctl',
+ 'faustgen',
+ 'fft',
+ 'fftinv',
+ 'ficlose',
+ 'filebit',
+ 'filelen',
+ 'filenchnls',
+ 'filepeak',
+ 'filesr',
+ 'filevalid',
+ 'fillarray',
+ 'filter2',
+ 'fin',
+ 'fini',
+ 'fink',
+ 'fiopen',
+ 'flanger',
+ 'flashtxt',
+ 'flooper',
+ 'flooper2',
+ 'floor',
+ 'fluidAllOut',
+ 'fluidCCi',
+ 'fluidCCk',
+ 'fluidControl',
+ 'fluidEngine',
+ 'fluidLoad',
+ 'fluidNote',
+ 'fluidOut',
+ 'fluidProgramSelect',
+ 'fluidSetInterpMethod',
+ 'fmb3',
+ 'fmbell',
+ 'fmmetal',
+ 'fmpercfl',
+ 'fmrhode',
+ 'fmvoice',
+ 'fmwurlie',
+ 'fof',
+ 'fof2',
+ 'fofilter',
+ 'fog',
+ 'fold',
+ 'follow',
+ 'follow2',
+ 'foscil',
+ 'foscili',
+ 'fout',
+ 'fouti',
+ 'foutir',
+ 'foutk',
+ 'fprintks',
+ 'fprints',
+ 'frac',
+ 'fractalnoise',
+ 'freeverb',
+ 'ftchnls',
+ 'ftconv',
+ 'ftcps',
+ 'ftfree',
+ 'ftgen',
+ 'ftgenonce',
+ 'ftgentmp',
+ 'ftlen',
+ 'ftload',
+ 'ftloadk',
+ 'ftlptim',
+ 'ftmorf',
+ 'ftresize',
+ 'ftresizei',
+ 'ftsave',
+ 'ftsavek',
+ 'ftsr',
+ 'gain',
+ 'gainslider',
+ 'gauss',
+ 'gaussi',
+ 'gausstrig',
+ 'gbuzz',
+ 'genarray',
+ 'genarray_i',
+ 'gendy',
+ 'gendyc',
+ 'gendyx',
+ 'getcfg',
+ 'getcol',
+ 'getrow',
+ 'gogobel',
+ #'goto',
+ 'grain',
+ 'grain2',
+ 'grain3',
+ 'granule',
+ 'guiro',
+ 'harmon',
+ 'harmon2',
+ 'harmon3',
+ 'harmon4',
+ 'hdf5read',
+ 'hdf5write',
+ 'hilbert',
+ 'hrtfearly',
+ 'hrtfer',
+ 'hrtfmove',
+ 'hrtfmove2',
+ 'hrtfreverb',
+ 'hrtfstat',
+ 'hsboscil',
+ 'hvs1',
+ 'hvs2',
+ 'hvs3',
+ 'i',
+ 'iceps',
+ #'igoto',
+ 'ihold',
+ 'imagecreate',
+ 'imagefree',
+ 'imagegetpixel',
+ 'imageload',
+ 'imagesave',
+ 'imagesetpixel',
+ 'imagesize',
+ 'in',
+ 'in32',
+ 'inch',
+ 'inh',
+ 'init',
+ 'initc14',
+ 'initc21',
+ 'initc7',
+ 'inleta',
+ 'inletf',
+ 'inletk',
+ 'inletkid',
+ 'inletv',
+ 'ino',
+ 'inq',
+ 'inrg',
+ 'ins',
+ 'insglobal',
+ 'insremot',
+ 'instr',
+ 'int',
+ 'integ',
+ 'interp',
+ 'invalue',
+ 'inx',
+ 'inz',
+ 'jitter',
+ 'jitter2',
+ 'jspline',
+ 'k',
+ #'kgoto',
+ 'ktableseg',
+ 'lenarray',
+ 'lentab',
+ 'lfo',
+ 'limit',
+ 'line',
+ 'linen',
+ 'linenr',
+ 'lineto',
+ 'linrand',
+ 'linseg',
+ 'linsegb',
+ 'linsegr',
+ 'locsend',
+ 'locsig',
+ 'log',
+ 'log10',
+ 'log2',
+ 'logbtwo',
+ 'logcurve',
+ #'loop_ge',
+ #'loop_gt',
+ #'loop_le',
+ #'loop_lt',
+ 'loopseg',
+ 'loopsegp',
+ 'looptseg',
+ 'loopxseg',
+ 'lorenz',
+ 'loscil',
+ 'loscil3',
+ 'loscilx',
+ 'lowpass2',
+ 'lowres',
+ 'lowresx',
+ 'lpf18',
+ 'lpform',
+ 'lpfreson',
+ 'lphasor',
+ 'lpinterp',
+ 'lposcil',
+ 'lposcil3',
+ 'lposcila',
+ 'lposcilsa',
+ 'lposcilsa2',
+ 'lpread',
+ 'lpreson',
+ 'lpshold',
+ 'lpsholdp',
+ 'lpslot',
+ #'lua_exec',
+ 'lua_ikopcall',
+ #'lua_opdef',
+ 'mac',
+ 'maca',
+ 'madsr',
+ 'mags',
+ 'mandel',
+ 'mandol',
+ 'maparray',
+ 'maparray_i',
+ 'marimba',
+ 'massign',
+ 'max',
+ 'max_k',
+ 'maxabs',
+ 'maxabsaccum',
+ 'maxaccum',
+ 'maxalloc',
+ 'maxarray',
+ 'maxtab',
+ 'mclock',
+ 'mdelay',
+ 'median',
+ 'mediank',
+ 'metro',
+ 'midglobal',
+ 'midic14',
+ 'midic21',
+ 'midic7',
+ 'midichannelaftertouch',
+ 'midichn',
+ 'midicontrolchange',
+ 'midictrl',
+ 'mididefault',
+ 'midifilestatus',
+ 'midiin',
+ 'midinoteoff',
+ 'midinoteoncps',
+ 'midinoteonkey',
+ 'midinoteonoct',
+ 'midinoteonpch',
+ 'midion',
+ 'midion2',
+ 'midiout',
+ 'midipgm',
+ 'midipitchbend',
+ 'midipolyaftertouch',
+ 'midiprogramchange',
+ 'miditempo',
+ 'midremot',
+ 'min',
+ 'minabs',
+ 'minabsaccum',
+ 'minaccum',
+ 'minarray',
+ 'mincer',
+ 'mintab',
+ 'mirror',
+ 'mode',
+ 'modmatrix',
+ 'monitor',
+ 'moog',
+ 'moogladder',
+ 'moogvcf',
+ 'moogvcf2',
+ 'moscil',
+ 'mp3bitrate',
+ 'mp3in',
+ 'mp3len',
+ 'mp3nchnls',
+ 'mp3sr',
+ 'mpulse',
+ 'mrtmsg',
+ 'multitap',
+ 'mute',
+ 'mxadsr',
+ 'nestedap',
+ 'nlalp',
+ 'nlfilt',
+ 'nlfilt2',
+ 'noise',
+ 'noteoff',
+ 'noteon',
+ 'noteondur',
+ 'noteondur2',
+ 'notnum',
+ 'nreverb',
+ 'nrpn',
+ 'nsamp',
+ 'nstance',
+ 'nstrnum',
+ 'ntrpol',
+ 'octave',
+ 'octcps',
+ 'octmidi',
+ 'octmidib',
+ 'octmidinn',
+ 'octpch',
+ #'opcode',
+ 'oscbnk',
+ 'oscil',
+ 'oscil1',
+ 'oscil1i',
+ 'oscil3',
+ 'oscili',
+ 'oscilikt',
+ 'osciliktp',
+ 'oscilikts',
+ 'osciln',
+ 'oscils',
+ 'oscilx',
+ 'out',
+ 'out32',
+ 'outc',
+ 'outch',
+ 'outh',
+ 'outiat',
+ 'outic',
+ 'outic14',
+ 'outipat',
+ 'outipb',
+ 'outipc',
+ 'outkat',
+ 'outkc',
+ 'outkc14',
+ 'outkpat',
+ 'outkpb',
+ 'outkpc',
+ 'outleta',
+ 'outletf',
+ 'outletk',
+ 'outletkid',
+ 'outletv',
+ 'outo',
+ 'outq',
+ 'outq1',
+ 'outq2',
+ 'outq3',
+ 'outq4',
+ 'outrg',
+ 'outs',
+ 'outs1',
+ 'outs2',
+ 'outvalue',
+ 'outx',
+ 'outz',
+ 'p',
+ 'pan',
+ 'pan2',
+ 'pareq',
+ 'partials',
+ 'partikkel',
+ 'partikkelget',
+ 'partikkelset',
+ 'partikkelsync',
+ 'passign',
+ 'pcauchy',
+ 'pchbend',
+ 'pchmidi',
+ 'pchmidib',
+ 'pchmidinn',
+ 'pchoct',
+ 'pconvolve',
+ 'pcount',
+ 'pdclip',
+ 'pdhalf',
+ 'pdhalfy',
+ 'peak',
+ 'pgmassign',
+ 'pgmchn',
+ 'phaser1',
+ 'phaser2',
+ 'phasor',
+ 'phasorbnk',
+ 'phs',
+ 'pindex',
+ 'pinker',
+ 'pinkish',
+ 'pitch',
+ 'pitchac',
+ 'pitchamdf',
+ 'planet',
+ 'platerev',
+ 'plltrack',
+ 'pluck',
+ 'poisson',
+ 'pol2rect',
+ 'polyaft',
+ 'polynomial',
+ 'pop',
+ 'pop_f',
+ 'port',
+ 'portk',
+ 'poscil',
+ 'poscil3',
+ 'pow',
+ 'powershape',
+ 'powoftwo',
+ 'prealloc',
+ 'prepiano',
+ 'print',
+ 'print_type',
+ 'printf',
+ 'printf_i',
+ 'printk',
+ 'printk2',
+ 'printks',
+ 'printks2',
+ 'prints',
+ 'product',
+ 'pset',
+ 'ptable',
+ 'ptable3',
+ 'ptablei',
+ 'ptableiw',
+ 'ptablew',
+ 'ptrack',
+ 'push',
+ 'push_f',
+ 'puts',
+ 'pvadd',
+ 'pvbufread',
+ 'pvcross',
+ 'pvinterp',
+ 'pvoc',
+ 'pvread',
+ 'pvs2array',
+ 'pvs2tab',
+ 'pvsadsyn',
+ 'pvsanal',
+ 'pvsarp',
+ 'pvsbandp',
+ 'pvsbandr',
+ 'pvsbin',
+ 'pvsblur',
+ 'pvsbuffer',
+ 'pvsbufread',
+ 'pvsbufread2',
+ 'pvscale',
+ 'pvscent',
+ 'pvsceps',
+ 'pvscross',
+ 'pvsdemix',
+ 'pvsdiskin',
+ 'pvsdisp',
+ 'pvsenvftw',
+ 'pvsfilter',
+ 'pvsfread',
+ 'pvsfreeze',
+ 'pvsfromarray',
+ 'pvsftr',
+ 'pvsftw',
+ 'pvsfwrite',
+ 'pvsgain',
+ 'pvsgendy',
+ 'pvshift',
+ 'pvsifd',
+ 'pvsin',
+ 'pvsinfo',
+ 'pvsinit',
+ 'pvslock',
+ 'pvsmaska',
+ 'pvsmix',
+ 'pvsmooth',
+ 'pvsmorph',
+ 'pvsosc',
+ 'pvsout',
+ 'pvspitch',
+ 'pvstanal',
+ 'pvstencil',
+ 'pvsvoc',
+ 'pvswarp',
+ 'pvsynth',
+ 'pwd',
+ 'pyassign',
+ 'pyassigni',
+ 'pyassignt',
+ 'pycall',
+ 'pycall1',
+ 'pycall1i',
+ 'pycall1t',
+ 'pycall2',
+ 'pycall2i',
+ 'pycall2t',
+ 'pycall3',
+ 'pycall3i',
+ 'pycall3t',
+ 'pycall4',
+ 'pycall4i',
+ 'pycall4t',
+ 'pycall5',
+ 'pycall5i',
+ 'pycall5t',
+ 'pycall6',
+ 'pycall6i',
+ 'pycall6t',
+ 'pycall7',
+ 'pycall7i',
+ 'pycall7t',
+ 'pycall8',
+ 'pycall8i',
+ 'pycall8t',
+ 'pycalli',
+ 'pycalln',
+ 'pycallni',
+ 'pycallt',
+ 'pyeval',
+ 'pyevali',
+ 'pyevalt',
+ 'pyexec',
+ 'pyexeci',
+ 'pyexect',
+ 'pyinit',
+ 'pylassign',
+ 'pylassigni',
+ 'pylassignt',
+ 'pylcall',
+ 'pylcall1',
+ 'pylcall1i',
+ 'pylcall1t',
+ 'pylcall2',
+ 'pylcall2i',
+ 'pylcall2t',
+ 'pylcall3',
+ 'pylcall3i',
+ 'pylcall3t',
+ 'pylcall4',
+ 'pylcall4i',
+ 'pylcall4t',
+ 'pylcall5',
+ 'pylcall5i',
+ 'pylcall5t',
+ 'pylcall6',
+ 'pylcall6i',
+ 'pylcall6t',
+ 'pylcall7',
+ 'pylcall7i',
+ 'pylcall7t',
+ 'pylcall8',
+ 'pylcall8i',
+ 'pylcall8t',
+ 'pylcalli',
+ 'pylcalln',
+ 'pylcallni',
+ 'pylcallt',
+ 'pyleval',
+ 'pylevali',
+ 'pylevalt',
+ 'pylexec',
+ 'pylexeci',
+ 'pylexect',
+ #'pylrun',
+ #'pylruni',
+ #'pylrunt',
+ #'pyrun',
+ #'pyruni',
+ #'pyrunt',
+ 'qinf',
+ 'qnan',
+ 'r2c',
+ 'rand',
+ 'randh',
+ 'randi',
+ 'random',
+ 'randomh',
+ 'randomi',
+ 'rbjeq',
+ 'readclock',
+ 'readf',
+ 'readfi',
+ 'readk',
+ 'readk2',
+ 'readk3',
+ 'readk4',
+ 'readks',
+ 'readscore',
+ 'readscratch',
+ 'rect2pol',
+ 'reinit',
+ 'release',
+ 'remoteport',
+ 'remove',
+ 'repluck',
+ 'reson',
+ 'resonk',
+ 'resonr',
+ 'resonx',
+ 'resonxk',
+ 'resony',
+ 'resonz',
+ 'resyn',
+ #'return',
+ 'reverb',
+ 'reverb2',
+ 'reverbsc',
+ 'rewindscore',
+ 'rezzy',
+ 'rfft',
+ 'rifft',
+ #'rigoto',
+ 'rireturn',
+ 'rms',
+ 'rnd',
+ 'rnd31',
+ 'round',
+ 'rspline',
+ 'rtclock',
+ 's16b14',
+ 's32b14',
+ 'samphold',
+ 'sandpaper',
+ 'scale',
+ 'scalearray',
+ 'scalet',
+ 'scanhammer',
+ 'scans',
+ 'scantable',
+ 'scanu',
+ 'schedkwhen',
+ 'schedkwhennamed',
+ 'schedule',
+ 'schedwhen',
+ #'scoreline',
+ #'scoreline_i',
+ 'seed',
+ 'sekere',
+ 'semitone',
+ 'sense',
+ 'sensekey',
+ 'seqtime',
+ 'seqtime2',
+ 'serialBegin',
+ 'serialEnd',
+ 'serialFlush',
+ 'serialPrint',
+ 'serialRead',
+ 'serialWrite',
+ 'serialWrite_i',
+ 'setcol',
+ 'setctrl',
+ 'setksmps',
+ 'setrow',
+ 'setscorepos',
+ 'sfilist',
+ 'sfinstr',
+ 'sfinstr3',
+ 'sfinstr3m',
+ 'sfinstrm',
+ 'sfload',
+ 'sflooper',
+ 'sfpassign',
+ 'sfplay',
+ 'sfplay3',
+ 'sfplay3m',
+ 'sfplaym',
+ 'sfplist',
+ 'sfpreset',
+ 'shaker',
+ 'shiftin',
+ 'shiftout',
+ 'signalflowgraph',
+ 'signum',
+ 'sin',
+ 'sinh',
+ 'sininv',
+ 'sinsyn',
+ 'sleighbells',
+ 'slicearray',
+ 'slider16',
+ 'slider16f',
+ 'slider16table',
+ 'slider16tablef',
+ 'slider32',
+ 'slider32f',
+ 'slider32table',
+ 'slider32tablef',
+ 'slider64',
+ 'slider64f',
+ 'slider64table',
+ 'slider64tablef',
+ 'slider8',
+ 'slider8f',
+ 'slider8table',
+ 'slider8tablef',
+ 'sliderKawai',
+ 'sndload',
+ 'sndloop',
+ 'sndwarp',
+ 'sndwarpst',
+ 'sockrecv',
+ 'sockrecvs',
+ 'socksend',
+ 'socksends',
+ 'soundin',
+ 'soundout',
+ 'soundouts',
+ 'space',
+ 'spat3d',
+ 'spat3di',
+ 'spat3dt',
+ 'spdist',
+ 'specaddm',
+ 'specdiff',
+ 'specdisp',
+ 'specfilt',
+ 'spechist',
+ 'specptrk',
+ 'specscal',
+ 'specsum',
+ 'spectrum',
+ 'splitrig',
+ 'sprintf',
+ 'sprintfk',
+ 'spsend',
+ 'sqrt',
+ 'stack',
+ 'statevar',
+ 'stix',
+ 'strcat',
+ 'strcatk',
+ 'strchar',
+ 'strchark',
+ 'strcmp',
+ 'strcmpk',
+ 'strcpy',
+ 'strcpyk',
+ 'strecv',
+ 'streson',
+ 'strfromurl',
+ 'strget',
+ 'strindex',
+ 'strindexk',
+ 'strlen',
+ 'strlenk',
+ 'strlower',
+ 'strlowerk',
+ 'strrindex',
+ 'strrindexk',
+ 'strset',
+ 'strsub',
+ 'strsubk',
+ 'strtod',
+ 'strtodk',
+ 'strtol',
+ 'strtolk',
+ 'strupper',
+ 'strupperk',
+ 'stsend',
+ 'subinstr',
+ 'subinstrinit',
+ 'sum',
+ 'sumarray',
+ 'sumtab',
+ 'svfilter',
+ 'syncgrain',
+ 'syncloop',
+ 'syncphasor',
+ 'system',
+ 'system_i',
+ 'tab',
+ 'tab2pvs',
+ 'tab_i',
+ 'tabgen',
+ 'table',
+ 'table3',
+ 'table3kt',
+ 'tablecopy',
+ 'tablefilter',
+ 'tablefilteri',
+ 'tablegpw',
+ 'tablei',
+ 'tableicopy',
+ 'tableigpw',
+ 'tableikt',
+ 'tableimix',
+ 'tableiw',
+ 'tablekt',
+ 'tablemix',
+ 'tableng',
+ 'tablera',
+ 'tableseg',
+ 'tableshuffle',
+ 'tableshufflei',
+ 'tablew',
+ 'tablewa',
+ 'tablewkt',
+ 'tablexkt',
+ 'tablexseg',
+ 'tabmap',
+ 'tabmap_i',
+ 'tabmorph',
+ 'tabmorpha',
+ 'tabmorphak',
+ 'tabmorphi',
+ 'tabplay',
+ 'tabrec',
+ 'tabslice',
+ 'tabsum',
+ 'tabw',
+ 'tabw_i',
+ 'tambourine',
+ 'tan',
+ 'tanh',
+ 'taninv',
+ 'taninv2',
+ 'tb0',
+ 'tb0_init',
+ 'tb1',
+ 'tb10',
+ 'tb10_init',
+ 'tb11',
+ 'tb11_init',
+ 'tb12',
+ 'tb12_init',
+ 'tb13',
+ 'tb13_init',
+ 'tb14',
+ 'tb14_init',
+ 'tb15',
+ 'tb15_init',
+ 'tb1_init',
+ 'tb2',
+ 'tb2_init',
+ 'tb3',
+ 'tb3_init',
+ 'tb4',
+ 'tb4_init',
+ 'tb5',
+ 'tb5_init',
+ 'tb6',
+ 'tb6_init',
+ 'tb7',
+ 'tb7_init',
+ 'tb8',
+ 'tb8_init',
+ 'tb9',
+ 'tb9_init',
+ 'tbvcf',
+ 'tempest',
+ 'tempo',
+ 'temposcal',
+ 'tempoval',
+ #'tigoto',
+ 'timedseq',
+ 'timeinstk',
+ 'timeinsts',
+ 'timek',
+ 'times',
+ #'timout',
+ 'tival',
+ 'tlineto',
+ 'tone',
+ 'tonek',
+ 'tonex',
+ 'tradsyn',
+ 'trandom',
+ 'transeg',
+ 'transegb',
+ 'transegr',
+ 'trcross',
+ 'trfilter',
+ 'trhighest',
+ 'trigger',
+ 'trigseq',
+ 'trirand',
+ 'trlowest',
+ 'trmix',
+ 'trscale',
+ 'trshift',
+ 'trsplit',
+ 'turnoff',
+ 'turnoff2',
+ 'turnon',
+ 'unirand',
+ 'unwrap',
+ 'upsamp',
+ 'urd',
+ 'vactrol',
+ 'vadd',
+ 'vadd_i',
+ 'vaddv',
+ 'vaddv_i',
+ 'vaget',
+ 'valpass',
+ 'vaset',
+ 'vbap',
+ 'vbap16',
+ 'vbap4',
+ 'vbap4move',
+ 'vbap8',
+ 'vbap8move',
+ 'vbapg',
+ 'vbapgmove',
+ 'vbaplsinit',
+ 'vbapmove',
+ 'vbapz',
+ 'vbapzmove',
+ 'vcella',
+ 'vco',
+ 'vco2',
+ 'vco2ft',
+ 'vco2ift',
+ 'vco2init',
+ 'vcomb',
+ 'vcopy',
+ 'vcopy_i',
+ 'vdel_k',
+ 'vdelay',
+ 'vdelay3',
+ 'vdelayk',
+ 'vdelayx',
+ 'vdelayxq',
+ 'vdelayxs',
+ 'vdelayxw',
+ 'vdelayxwq',
+ 'vdelayxws',
+ 'vdivv',
+ 'vdivv_i',
+ 'vecdelay',
+ 'veloc',
+ 'vexp',
+ 'vexp_i',
+ 'vexpseg',
+ 'vexpv',
+ 'vexpv_i',
+ 'vibes',
+ 'vibr',
+ 'vibrato',
+ 'vincr',
+ 'vlimit',
+ 'vlinseg',
+ 'vlowres',
+ 'vmap',
+ 'vmirror',
+ 'vmult',
+ 'vmult_i',
+ 'vmultv',
+ 'vmultv_i',
+ 'voice',
+ 'vosim',
+ 'vphaseseg',
+ 'vport',
+ 'vpow',
+ 'vpow_i',
+ 'vpowv',
+ 'vpowv_i',
+ 'vpvoc',
+ 'vrandh',
+ 'vrandi',
+ 'vsubv',
+ 'vsubv_i',
+ 'vtaba',
+ 'vtabi',
+ 'vtabk',
+ 'vtable1k',
+ 'vtablea',
+ 'vtablei',
+ 'vtablek',
+ 'vtablewa',
+ 'vtablewi',
+ 'vtablewk',
+ 'vtabwa',
+ 'vtabwi',
+ 'vtabwk',
+ 'vwrap',
+ 'waveset',
+ 'weibull',
+ 'wgbow',
+ 'wgbowedbar',
+ 'wgbrass',
+ 'wgclar',
+ 'wgflute',
+ 'wgpluck',
+ 'wgpluck2',
+ 'wguide1',
+ 'wguide2',
+ 'wiiconnect',
+ 'wiidata',
+ 'wiirange',
+ 'wiisend',
+ 'window',
+ 'wrap',
+ 'writescratch',
+ 'wterrain',
+ 'xadsr',
+ 'xin',
+ 'xout',
+ 'xscanmap',
+ 'xscans',
+ 'xscansmap',
+ 'xscanu',
+ 'xtratim',
+ 'xyin',
+ 'zacl',
+ 'zakinit',
+ 'zamod',
+ 'zar',
+ 'zarg',
+ 'zaw',
+ 'zawm',
+ 'zfilter2',
+ 'zir',
+ 'ziw',
+ 'ziwm',
+ 'zkcl',
+ 'zkmod',
+ 'zkr',
+ 'zkw',
+ 'zkwm'
+))
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 2e855570..08cd4e3a 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -86,6 +86,8 @@ LEXERS = {
'CppObjdumpLexer': ('pygments.lexers.asm', 'cpp-objdump', ('cpp-objdump', 'c++-objdumb', 'cxx-objdump'), ('*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'), ('text/x-cpp-objdump',)),
'CrocLexer': ('pygments.lexers.d', 'Croc', ('croc',), ('*.croc',), ('text/x-crocsrc',)),
'CryptolLexer': ('pygments.lexers.haskell', 'Cryptol', ('cryptol', 'cry'), ('*.cry',), ('text/x-cryptol',)),
+ 'CsoundOrchestraLexer': ('pygments.lexers.csound', 'Csound Orchestra', (), ('*.orc',), ()),
+ 'CsoundScoreLexer': ('pygments.lexers.csound', 'Csound Score', (), ('*.sco',), ()),
'CssDjangoLexer': ('pygments.lexers.templates', 'CSS+Django/Jinja', ('css+django', 'css+jinja'), (), ('text/css+django', 'text/css+jinja')),
'CssErbLexer': ('pygments.lexers.templates', 'CSS+Ruby', ('css+erb', 'css+ruby'), (), ('text/css+ruby',)),
'CssGenshiLexer': ('pygments.lexers.templates', 'CSS+Genshi Text', ('css+genshitext', 'css+genshi'), (), ('text/css+genshi',)),
diff --git a/pygments/lexers/csound.py b/pygments/lexers/csound.py
new file mode 100644
index 00000000..b2f9819a
--- /dev/null
+++ b/pygments/lexers/csound.py
@@ -0,0 +1,326 @@
+# -*- coding: utf-8 -*-
+
+import re
+
+from pygments.lexer import RegexLexer, bygroups, default, include, using, words
+from pygments.token import Comment, Keyword, Name, Number, Operator, Punctuation, String, Text, Whitespace
+
+# The CsoundDocumentLexer casuses a Pygments test to fail.
+__all__ = ['CsoundScoreLexer', 'CsoundOrchestraLexer']#, 'CsoundDocumentLexer']
+
+newline = (r'((?:;|//).*)*(\n)', bygroups(Comment.Single, Text))
+
+
+class CsoundLexer(RegexLexer):
+ # Subclasses must define a 'single-line string' state.
+ tokens = {
+ 'whitespace': [
+ (r'[ \t]+', Text),
+ (r'\\\n', Text),
+ (r'/[*](.|\n)*?[*]/', Comment.Multiline)
+ ],
+
+ 'macro call': [
+ (r'(\$\w+\.?)(\()', bygroups(Comment.Preproc, Punctuation), 'function macro call'),
+ (r'\$\w+(\.?|\b)', Comment.Preproc)
+ ],
+ 'function macro call': [
+ (r"((?:\\['\)]|[^'\)])+)(')", bygroups(Comment.Preproc, Punctuation)),
+ (r"([^'\)]+)(\))", bygroups(Comment.Preproc, Punctuation), '#pop')
+ ],
+
+ 'whitespace or macro call': [
+ include('whitespace'),
+ include('macro call')
+ ],
+
+ 'preprocessor directives': [
+ (r'#(e(nd(if)?|lse)|ifn?def|undef)\b|##', Comment.Preproc),
+ (r'#include\b', Comment.Preproc, 'include'),
+ (r'#[ \t]*define\b', Comment.Preproc, 'macro name'),
+ (r'@+[ \t]*\d*', Comment.Preproc)
+ ],
+
+ 'include': [
+ include('whitespace'),
+ (r'"', String, 'single-line string')
+ ],
+
+ 'macro name': [
+ include('whitespace'),
+ (r'(\w+)(\()', bygroups(Comment.Preproc, Text), 'function macro argument list'),
+ (r'\w+', Comment.Preproc, 'object macro definition after name')
+ ],
+ 'object macro definition after name': [
+ include('whitespace'),
+ (r'#', Punctuation, 'object macro replacement text')
+ ],
+ 'object macro replacement text': [
+ (r'(\\#|[^#])+', Comment.Preproc),
+ (r'#', Punctuation, '#pop:3')
+ ],
+ 'function macro argument list': [
+ (r"(\w+)(['#])", bygroups(Comment.Preproc, Punctuation)),
+ (r'(\w+)(\))', bygroups(Comment.Preproc, Punctuation), 'function macro definition after name')
+ ],
+ 'function macro definition after name': [
+ (r'[ \t]+', Text),
+ (r'#', Punctuation, 'function macro replacement text')
+ ],
+ 'function macro replacement text': [
+ (r'(\\#|[^#])+', Comment.Preproc),
+ (r'#', Punctuation, '#pop:4')
+ ]
+ }
+
+
+class CsoundScoreLexer(CsoundLexer):
+ """
+ For `Csound <http://csound.github.io>`_ scores.
+ """
+
+ name = 'Csound Score'
+ filenames = ['*.sco']
+
+ tokens = {
+ 'partial statement': [
+ include('preprocessor directives'),
+ (r'\d+e[+-]?\d+|(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?', Number.Float),
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
+ (r'\d+', Number.Integer),
+ (r'"', String, 'single-line string'),
+ (r'[+\-*/%^!=<>|&#~.]', Operator),
+ (r'[]()[]', Punctuation),
+ (r'\w+', Comment.Preproc)
+ ],
+
+ 'statement': [
+ include('whitespace or macro call'),
+ newline + ('#pop',),
+ include('partial statement')
+ ],
+
+ 'root': [
+ newline,
+ include('whitespace or macro call'),
+ (r'[{}]', Punctuation, 'statement'),
+ (r'[abefimq-tv-z]|[nN][pP]?', Keyword, 'statement')
+ ],
+
+ 'single-line string': [
+ (r'"', String, '#pop'),
+ (r'[^\\"]+', String)
+ ],
+ }
+
+
+from pygments.lexers._csound_builtins import OPCODES
+from pygments.lexers.python import PythonLexer
+from pygments.lexers.scripting import LuaLexer
+
+class CsoundOrchestraLexer(CsoundLexer):
+ """
+ For `Csound <http://csound.github.io>`_ orchestras.
+ """
+
+ name = 'Csound Orchestra'
+ filenames = ['*.orc']
+
+ user_defined_opcodes = set()
+
+ def opcode_name_callback(lexer, match):
+ opcode = match.group(0)
+ lexer.user_defined_opcodes.add(opcode)
+ yield match.start(), Name.Function, opcode
+
+ def name_callback(lexer, match):
+ name = match.group(0)
+ if re.match('p\d+$', name) or name in OPCODES:
+ yield match.start(), Name.Builtin, name
+ elif name in lexer.user_defined_opcodes:
+ yield match.start(), Name.Function, name
+ else:
+ nameMatch = re.search(r'^(g?[aikSw])(\w+)', name)
+ if nameMatch:
+ yield nameMatch.start(1), Keyword.Type, nameMatch.group(1)
+ yield nameMatch.start(2), Name, nameMatch.group(2)
+ else:
+ yield match.start(), Name, name
+
+ tokens = {
+ 'label': [
+ (r'\b(\w+)(:)', bygroups(Name.Label, Punctuation))
+ ],
+
+ 'partial expression': [
+ include('preprocessor directives'),
+ (r'\b(0dbfs|k(r|smps)|nchnls(_i)?|sr)\b', Name.Variable.Global),
+ (r'\d+e[+-]?\d+|(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?', Number.Float),
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
+ (r'\d+', Number.Integer),
+ (r'"', String, 'single-line string'),
+ (r'{{', String, 'multi-line string'),
+ (r'[+\-*/%^!=&|<>#~¬]', Operator),
+ (r'[](),?:[]', Punctuation),
+ (words((
+ # Keywords
+ 'do', 'else', 'elseif', 'endif', 'enduntil', 'fi', 'if', 'ithen', 'kthen', 'od', 'then', 'until', 'while',
+ # Opcodes that act as control structures
+ 'return', 'timout'
+ ), prefix=r'\b', suffix=r'\b'), Keyword),
+ (words(('goto', 'igoto', 'kgoto', 'rigoto', 'tigoto'), prefix=r'\b', suffix=r'\b'), Keyword, 'goto label'),
+ (words(('cggoto', 'cigoto', 'cingoto', 'ckgoto', 'cngoto'), prefix=r'\b', suffix=r'\b'), Keyword, ('goto label', 'goto expression')),
+ (words(('loop_ge', 'loop_gt', 'loop_le', 'loop_lt'), prefix=r'\b', suffix=r'\b'), Keyword, ('goto label', 'goto expression', 'goto expression', 'goto expression')),
+ (r'\bscoreline(_i)?\b', Name.Builtin, 'scoreline opcode'),
+ (r'\bpyl?run[it]?\b', Name.Builtin, 'python opcode'),
+ (r'\blua_(exec|opdef)\b', Name.Builtin, 'lua opcode'),
+ (r'\b[a-zA-Z_]\w*\b', name_callback)
+ ],
+
+ 'expression': [
+ include('whitespace or macro call'),
+ newline + ('#pop',),
+ include('partial expression')
+ ],
+
+ 'root': [
+ newline,
+ include('whitespace or macro call'),
+ (r'\binstr\b', Keyword, ('instrument block', 'instrument name list')),
+ (r'\bopcode\b', Keyword, ('opcode block', 'opcode parameter list', 'opcode types', 'opcode types', 'opcode name')),
+ include('label'),
+ default('expression')
+ ],
+
+ 'instrument name list': [
+ include('whitespace or macro call'),
+ (r'\d+|\+?[a-zA-Z_]\w*', Name.Function),
+ (r',', Punctuation),
+ newline + ('#pop',)
+ ],
+ 'instrument block': [
+ newline,
+ include('whitespace or macro call'),
+ (r'\bendin\b', Keyword, '#pop'),
+ include('label'),
+ default('expression')
+ ],
+
+ 'opcode name': [
+ include('whitespace or macro call'),
+ (r'[a-zA-Z_]\w*', opcode_name_callback, '#pop')
+ ],
+ 'opcode types': [
+ include('whitespace or macro call'),
+ (r'0|[]afijkKoOpPStV[]+', Keyword.Type, '#pop'),
+ (r',', Punctuation)
+ ],
+ 'opcode parameter list': [
+ include('whitespace or macro call'),
+ newline + ('#pop',)
+ ],
+ 'opcode block': [
+ newline,
+ include('whitespace or macro call'),
+ (r'\bendop\b', Keyword, '#pop'),
+ include('label'),
+ default('expression')
+ ],
+
+ 'goto label': [
+ include('whitespace or macro call'),
+ (r'\w+', Name.Label, '#pop'),
+ default('#pop')
+ ],
+ 'goto expression': [
+ include('whitespace or macro call'),
+ (r',', Punctuation, '#pop'),
+ include('partial expression')
+ ],
+
+ 'escaped character': [
+ (r'\\([\\aAbBnNrRtT"]|[0-7]{1,3})', String.Escape)
+ ],
+ 'single-line string': [
+ include('macro call'),
+ (r'"', String, '#pop'),
+ # From https://github.com/csound/csound/blob/develop/Opcodes/fout.c#L1405
+ (r'%\d*(\.\d+)?[cdhilouxX]', String.Interpol),
+ (r'%[!%nNrRtT]|[~^]', String.Escape),
+ include('escaped character'),
+ (r'[^\\"~$%\^\n]+', String),
+ (r'[\\"~$%\^\n]', String)
+ ],
+ 'multi-line string': [
+ (r'}}', String, '#pop'),
+ (r'[^\}]+|\}(?!\})', String)
+ ],
+
+ 'scoreline opcode': [
+ include('whitespace or macro call'),
+ (r'{{', String, 'scoreline'),
+ default('#pop')
+ ],
+ 'scoreline': [
+ (r'}}', String, '#pop'),
+ (r'([^\}]+)|\}(?!\})', using(CsoundScoreLexer))
+ ],
+
+ 'python opcode': [
+ include('whitespace or macro call'),
+ (r'{{', String, 'python'),
+ default('#pop')
+ ],
+ 'python': [
+ (r'}}', String, '#pop'),
+ (r'([^\}]+)|\}(?!\})', using(PythonLexer))
+ ],
+
+ 'lua opcode': [
+ include('whitespace or macro call'),
+ (r'"', String, 'single-line string'),
+ (r'{{', String, 'lua'),
+ (r',', Punctuation),
+ default('#pop')
+ ],
+ 'lua': [
+ (r'}}', String, '#pop'),
+ (r'([^\}]+)|\}(?!\})', using(LuaLexer))
+ ]
+ }
+
+
+# Below is a lexer for Csound documents, but it causes a Pygments test to fail.
+
+# import copy
+# from pygments.lexers.html import HtmlLexer, XmlLexer
+#
+# class CsoundDocumentLexer(XmlLexer):
+# """
+# For `Csound <http://csound.github.io>`_ documents.
+# """
+#
+# name = 'Csound Document'
+# aliases = ['csound']
+# filenames = ['*.csd']
+#
+# tokens = copy.deepcopy(XmlLexer.tokens)
+# for i, item in enumerate(tokens['root']):
+# if len(item) > 2 and item[2] == 'tag':
+# (tokens['root']).insert(i, (r'(<)(\s*)(CsInstruments)(\s*)', bygroups(Name.Tag, Text, Name.Tag, Text), ('orchestra content', 'tag')))
+# (tokens['root']).insert(i, (r'(<)(\s*)(CsScore)(\s*)', bygroups(Name.Tag, Text, Name.Tag, Text), ('score content', 'tag')))
+# (tokens['root']).insert(i, (r'(<)(\s*)(html)(\s*)', bygroups(Name.Tag, Text, Name.Tag, Text), ('HTML', 'tag')))
+# break
+#
+# tokens['orchestra content'] = [
+# (r'(<)(\s*)(/)(\s*)(CsInstruments)(\s*)(>)', bygroups(Name.Tag, Text, Name.Tag, Text, Name.Tag, Text, Name.Tag), '#pop'),
+# (r'.+?(?=<\s*/\s*CsInstruments\s*>)', using(CsoundOrchestraLexer))
+# ]
+# tokens['score content'] = [
+# (r'(<)(\s*)(/)(\s*)(CsScore)(\s*)(>)', bygroups(Name.Tag, Text, Name.Tag, Text, Name.Tag, Text, Name.Tag), '#pop'),
+# (r'.+?(?=<\s*/\s*CsScore\s*>)', using(CsoundScoreLexer))
+# ]
+# tokens['HTML'] = [
+# (r'(<)(\s*)(/)(\s*)(html)(\s*)(>)', bygroups(Name.Tag, Text, Name.Tag, Text, Name.Tag, Text, Name.Tag), '#pop'),
+# (r'.+?(?=<\s*/\s*html\s*>)', using(HtmlLexer))
+# ]
diff --git a/tests/examplefiles/test.orc b/tests/examplefiles/test.orc
new file mode 100644
index 00000000..fc52b4e7
--- /dev/null
+++ b/tests/examplefiles/test.orc
@@ -0,0 +1,255 @@
+; This is a Csound orchestra file for testing a Pygments <http://pygments.org>
+; lexer. Csound single-line comments can be preceded by a semicolon...
+// ...or a pair of forward slashes.
+
+/* Block comments begin with /* and end with */
+
+; Orchestras begin with a header of audio parameters.
+sr = 44100
+ksmps = 10
+nchnls = 1
+nchnls_i = 1
+0dbfs = 1
+
+; The control rate kr = sr / ksmps can be omitted when the number of audio
+; samples in a control period (ksmps) is set, but kr may appear in older
+; orchestras.
+kr = 4410
+
+; Orchestras contain instruments. These begin with the keyword instr followed by
+; a comma-separated list of numbers or names of the instrument. Instruments end
+; at the endin keyword and cannot be nested.
+
+instr 1, N_a_M_e_, +Name
+ ; Instruments contain statements. Here is a typical statement:
+ aout oscil 0dbfs, 440, 1
+ ; Statements are terminated with a newline (possibly preceded by a comment).
+ ; To write a statement on several lines, precede the newline with a backslash.
+ prints \
+ "hello, world\n";comment
+
+ ; Csound 6 introduced function syntax for opcodes with one or zero outputs.
+ ; The oscil statement above is the same as
+ aout = oscil(0dbfs, 440, 1)
+
+ ; Instruments can contain control structures.
+ knote = p3
+ if knote == 0 then
+ kfrequency = 220
+ elseif (knote == 1) then ; Parentheses around binary expressions are optional.
+ kfrequency = 440
+ endif
+
+ ; Csound 6 introduced looping structures.
+ icount = 0
+ while icount < 5 do
+ print icount
+ icount += 1
+ od
+ icount = 0
+ until icount >= 5 do
+ print icount
+ icount += 1
+ enduntil
+ ; Both kinds of loops can be terminated by either od or enduntil.
+
+ ; Single-line strings are enclosed in double-quotes.
+ prints "string\\\r\n\t\""
+ ; Multi-line strings are enclosed in pairs of curly braces.
+ prints {{
+ hello,
+
+ world
+ }}
+
+ ; Instruments often end with a statement containing an output opcode.
+ outc aout
+endin
+
+; Orchestras can also contain user-defined opcodes (UDOs). Here is an oscillator
+; with one audio-rate output and two control-rate inputs:
+opcode anOscillator, a, kk
+ kamplitude, kfrequency xin
+ aout vco2 kamplitude, kfrequency
+ xout aout
+endop
+instr TestOscillator
+ outc(anOscillator(0dbfs, 110))
+endin
+
+; Python can be executed in Csound
+; <http://www.csounds.com/manual/html/pyrun.html>. So can Lua
+; <http://www.csounds.com/manual/html/lua.html>.
+pyruni {{
+import random
+
+pool = [(1 + i / 10.0) ** 1.2 for i in range(100)]
+
+def get_number_from_pool(n, p):
+ if random.random() < p:
+ i = int(random.random() * len(pool))
+ pool[i] = n
+ return random.choice(pool)
+}}
+
+; The Csound preprocessor supports conditional compilation and including files.
+#ifdef DEBUG
+#undef DEBUG
+#include "filename.orc"
+#endif
+
+; The preprocessor also supports object- and function-like macros. This is an
+; object-like macro that defines a number:
+#define A_HZ #440#
+
+; This is a function-like macro:
+#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
+
+; Bodies of macros are enclosed in # and can contain newlines. The arguments of
+; function-like macros are separated by single-quotes. Uses of macros are
+; prefixed with a dollar sign.
+instr TestMacro
+ aout $OSCIL_MACRO(1'$A_HZ'1)
+ ; Not unlike PHP, macros expand in double-quoted strings.
+ prints "The frequency of the oscillator is $A_HZ Hz.\n"
+ out aout
+endin
+
+; Here are other things to note about Csound.
+
+; There are two bitwise NOT operators, ~ and ¬ (U+00AC). The latter is common on
+; keyboards in the United Kingdom
+; <https://en.wikipedia.org/wiki/British_and_American_keyboards>.
+instr TestBitwiseNOT
+ print ~42
+ print ¬42
+endin
+
+; Csound uses # for bitwise XOR, which the Csound manual calls bitwise
+; non-equivalence <http://www.csounds.com/manual/html/opnonequiv.html>.
+instr TestBitwiseXOR
+ print 0 # 0
+ print 0 # 1
+ print 1 # 0
+ print 1 # 1
+endin
+
+; Loops and if-then statements are relatively recent additions to Csound. There
+; are many flow-control opcodes that involve goto and labels.
+instr TestGoto
+ ; This...
+ if p3 > 0 goto if_label
+ goto else_label
+if_label:
+ prints "if branch\n"
+ goto endif_label
+else_label:
+ prints "else branch\n"
+endif_label:
+
+ ; ...is the same as this.
+ if p3 > 0 then
+ prints "if branch\n"
+ else
+ prints "else branch\n"
+ endif
+
+ ; This...
+ icount = 0
+loop_label:
+ print icount
+ icount += 1
+ if icount < 10 goto loop_label
+
+ ; ...is the same as this...
+ icount = 0
+loop_lt_label:
+ print icount
+ loop_lt icount, 1, 10, loop_lt_label
+
+ ; ...and this.
+ icount = 0
+ while icount < 10 do
+ print icount
+ icount += 1
+ od
+endin
+
+; The prints and printks opcodes
+; <https://github.com/csound/csound/blob/develop/OOps/ugrw1.c#L831>, arguably
+; the primary methods of logging output, treat certain sequences of characters
+; different from printf in C.
+instr TestPrints
+ ; ^ prints an ESCAPE character (U+001B), not a CIRCUMFLEX ACCENT character
+ ; (U+005E). ^^ prints a CIRCUMFLEX ACCENT.
+ prints "^^\n"
+ ; ~ prints an ESCAPE character (U+001B) followed by a [, not a TILDE
+ ; character (U+007E). ~~ prints a TILDE.
+ prints "~~\n"
+ ; \A, \B, \N, \R, and \T correspond to the escaped lowercase characters (that
+ ; is, BELL (U+0007), BACKSPACE (U+0008), new line (U+000A), CARRIAGE RETURN
+ ; (U+000D), and tab (U+0009)).
+ prints "\T\R\N"
+ ; %n, %r, and %t are the same as \n, \r, and \t, as are %N, %R, and %T.
+ prints "%t%r%n"
+ ; %! prints a semicolon. This is a hold-over from old versions of Csound that
+ ; allowed comments to begin in strings.
+ prints "; %!\n"
+endin
+
+; The arguments of function-like macros can be separated by # instead of '.
+; These two macro definitions are equivalent.
+#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
+#define OSCIL_MACRO(VOLUME#FREQUENCY#TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
+
+; Uses of macros can optionally be suffixed with a period.
+instr TestMacroPeriodSuffix
+ aout $OSCIL_MACRO.(1'$A_HZ'1)
+ prints "The frequency of the oscillator is $A_HZ.Hz.\n"
+ out aout
+endin
+
+; Csound has @ and @@ operator-like macros that, when followed by a literal
+; integer, expand to the next power of 2 and the next power of 2 plus 1:
+; @x = 2^(ceil(log2(x + 1))), x >= 0
+; @@0 = 2
+; @@x = 2^(ceil(log2(x))) + 1, x > 0
+; These macros are in
+; <https://github.com/csound/csound/blob/develop/Engine/csound_orc.l#L542> (and
+; <https://github.com/csound/csound/blob/develop/Engine/csound_sco.lex#L202>),
+; but they seem to be undocumented.
+instr TestAt
+ prints "%d %2d %2d\n", 0, @0, @@0
+ prints "%d %2d %2d\n", 1, @1, @@1
+ prints "%d %2d %2d\n", 2, @2, @@2
+ prints "%d %2d %2d\n", 3, @3, @@3
+ prints "%d %2d %2d\n", 4, @4, @@4
+ prints "%d %2d %2d\n", 5, @5, @@5
+ prints "%d %2d %2d\n", 6, @6, @@6
+ prints "%d %2d %2d\n", 7, @7, @@7
+ prints "%d %2d %2d\n", 8, @8, @@8
+ prints "%d %2d %2d\n", 9, @9, @@9
+endin
+
+; Including newlines in macros can lead to confusing code, but it tests the
+; lexer.
+instr MacroAbuse
+ if 1 == 1 then
+ prints "on\n"
+#define FOO#
+BAR
+#endif // This ends the if statement. It is not a preprocessor directive.
+endin
+
+scoreline_i {{
+f 1 0 16384 10 1
+i "N_a_M_e_" 0 2
+i "TestOscillator" 2 2
+i "TestBitwiseNOT" 0 1
+i "TestBitwiseXOR" 0 1
+i "TestGoto" 0 1
+i "TestMacroPeriodSuffix" 4 1
+i "TestAt" 0 1
+i "MacroAbuse" 0 1
+e
+}}