summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Whetsell <nathan.whetsell@gmail.com>2016-12-11 12:29:56 -0500
committerNathan Whetsell <nathan.whetsell@gmail.com>2016-12-11 12:29:56 -0500
commita56edd5e77a551a3e310e25e1f204756b67d6730 (patch)
tree62603fcaf6e14353b064a117d5ab23b4b67eb82c
parent0d6d92cc895e325bc7afcad219a6cba523ab3ca9 (diff)
downloadpygments-a56edd5e77a551a3e310e25e1f204756b67d6730.tar.gz
Update for Csound 6.08.0
-rw-r--r--pygments/lexers/_csound_builtins.py201
-rw-r--r--pygments/lexers/csound.py63
-rw-r--r--tests/examplefiles/test.csd32
-rw-r--r--tests/examplefiles/test.orc32
-rw-r--r--tests/examplefiles/test.sco2
5 files changed, 180 insertions, 150 deletions
diff --git a/pygments/lexers/_csound_builtins.py b/pygments/lexers/_csound_builtins.py
index a88e0a83..c74e66ab 100644
--- a/pygments/lexers/_csound_builtins.py
+++ b/pygments/lexers/_csound_builtins.py
@@ -3,48 +3,37 @@
pygments.lexers._csound_builtins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2016 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-# 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>
-# instr <http://www.csounds.com/manual/html/instr.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 in Csound 6.08.0 at commit a1159a1 from
+# csound --list-opcodes3
+# except for
+# cggoto <https://csound.github.io/docs/manual/cggoto.html>
+# cigoto <https://csound.github.io/docs/manual/cigoto.html>
+# cingoto (undocumented)
+# ckgoto <https://csound.github.io/docs/manual/ckgoto.html>
+# cngoto <https://csound.github.io/docs/manual/cngoto.html>
+# cnkgoto (undocumented)
+# endin <https://csound.github.io/docs/manual/endin.html
+# endop <https://csound.github.io/docs/manual/endop.html
+# goto <https://csound.github.io/docs/manual/goto.html>
+# igoto <https://csound.github.io/docs/manual/igoto.html>
+# instr <https://csound.github.io/docs/manual/instr.html>
+# kgoto <https://csound.github.io/docs/manual/kgoto.html>
+# loop_ge <https://csound.github.io/docs/manual/loop_ge.html>
+# loop_gt <https://csound.github.io/docs/manual/loop_gt.html>
+# loop_le <https://csound.github.io/docs/manual/loop_le.html>
+# loop_lt <https://csound.github.io/docs/manual/loop_lt.html>
+# opcode <https://csound.github.io/docs/manual/opcode.html>
+# return <https://csound.github.io/docs/manual/return.html>
+# rireturn <https://csound.github.io/docs/manual/rireturn.html>
+# rigoto <https://csound.github.io/docs/manual/rigoto.html>
+# tigoto <https://csound.github.io/docs/manual/tigoto.html>
+# timout <https://csound.github.io/docs/manual/timout.html>
+# which are treated as keywords in csound.py.
+
OPCODES = set((
'ATSadd',
'ATSaddnz',
@@ -133,8 +122,10 @@ OPCODES = set((
'MixerSetLevel',
'MixerSetLevel_i',
'OSCinit',
+ 'OSCinitM',
'OSClisten',
'OSCsend',
+ 'S',
'a',
'abs',
'active',
@@ -151,7 +142,6 @@ OPCODES = set((
'ampmidid',
'areson',
'aresonk',
- 'array',
'atone',
'atonek',
'atonex',
@@ -163,9 +153,7 @@ OPCODES = set((
'bbcuts',
'betarand',
'bexprnd',
- 'bformdec',
'bformdec1',
- 'bformenc',
'bformenc1',
'binit',
'biquad',
@@ -192,9 +180,11 @@ OPCODES = set((
'cent',
'centroid',
'ceps',
+ 'cepsinv',
#'cggoto',
'chanctrl',
'changed',
+ 'changed2',
'chani',
'chano',
'chebyshevpoly',
@@ -219,18 +209,18 @@ OPCODES = set((
'clockon',
'cmplxprod',
#'cngoto',
+ #'cnkgoto',
'comb',
'combinv',
'compilecsd',
'compileorc',
'compilestr',
'compress',
+ 'compress2',
'connect',
'control',
'convle',
'convolve',
- 'copy2ftab',
- 'copy2ttab',
'copya2ftab',
'copyf2array',
'cos',
@@ -273,6 +263,8 @@ OPCODES = set((
'dcblock',
'dcblock2',
'dconv',
+ 'dct',
+ 'dctinv',
'delay',
'delay1',
'delayk',
@@ -286,6 +278,7 @@ OPCODES = set((
'deltapxw',
'denorm',
'diff',
+ 'directory',
'diskgrain',
'diskin',
'diskin2',
@@ -338,6 +331,7 @@ OPCODES = set((
'filelen',
'filenchnls',
'filepeak',
+ 'filescal',
'filesr',
'filevalid',
'fillarray',
@@ -385,6 +379,7 @@ OPCODES = set((
'fprints',
'frac',
'fractalnoise',
+ 'framebuffer',
'freeverb',
'ftchnls',
'ftconv',
@@ -400,6 +395,7 @@ OPCODES = set((
'ftmorf',
'ftresize',
'ftresizei',
+ 'ftsamplebank',
'ftsave',
'ftsavek',
'ftsr',
@@ -416,7 +412,9 @@ OPCODES = set((
'gendyx',
'getcfg',
'getcol',
+ 'getftargs',
'getrow',
+ 'getseed',
'gogobel',
#'goto',
'grain',
@@ -432,7 +430,6 @@ OPCODES = set((
'hdf5write',
'hilbert',
'hrtfearly',
- 'hrtfer',
'hrtfmove',
'hrtfmove2',
'hrtfreverb',
@@ -442,7 +439,6 @@ OPCODES = set((
'hvs2',
'hvs3',
'i',
- 'iceps',
#'igoto',
'ihold',
'imagecreate',
@@ -483,9 +479,7 @@ OPCODES = set((
'jspline',
'k',
#'kgoto',
- 'ktableseg',
'lenarray',
- 'lentab',
'lfo',
'limit',
'line',
@@ -533,9 +527,9 @@ OPCODES = set((
'lpshold',
'lpsholdp',
'lpslot',
- #'lua_exec',
+ 'lua_exec',
'lua_ikopcall',
- #'lua_opdef',
+ 'lua_opdef',
'mac',
'maca',
'madsr',
@@ -553,12 +547,12 @@ OPCODES = set((
'maxaccum',
'maxalloc',
'maxarray',
- 'maxtab',
'mclock',
'mdelay',
'median',
'mediank',
'metro',
+ 'mfb',
'midglobal',
'midic14',
'midic21',
@@ -590,13 +584,13 @@ OPCODES = set((
'minaccum',
'minarray',
'mincer',
- 'mintab',
'mirror',
'mode',
'modmatrix',
'monitor',
'moog',
'moogladder',
+ 'moogladder2',
'moogvcf',
'moogvcf2',
'moscil',
@@ -604,12 +598,19 @@ OPCODES = set((
'mp3in',
'mp3len',
'mp3nchnls',
+ 'mp3scal',
'mp3sr',
'mpulse',
'mrtmsg',
'multitap',
'mute',
+ 'mvchpf',
+ 'mvclpf1',
+ 'mvclpf2',
+ 'mvclpf3',
+ 'mvclpf4',
'mxadsr',
+ 'nchnls_hw',
'nestedap',
'nlalp',
'nlfilt',
@@ -626,12 +627,14 @@ OPCODES = set((
'nstance',
'nstrnum',
'ntrpol',
+ 'nxtpow2',
'octave',
'octcps',
'octmidi',
'octmidib',
'octmidinn',
'octpch',
+ 'olabuffer',
#'opcode',
'oscbnk',
'oscil',
@@ -684,12 +687,14 @@ OPCODES = set((
'pan',
'pan2',
'pareq',
+ 'part2txt',
'partials',
'partikkel',
'partikkelget',
'partikkelset',
'partikkelsync',
'passign',
+ 'paulstretch',
'pcauchy',
'pchbend',
'pchmidi',
@@ -723,8 +728,6 @@ OPCODES = set((
'pol2rect',
'polyaft',
'polynomial',
- 'pop',
- 'pop_f',
'port',
'portk',
'poscil',
@@ -732,6 +735,7 @@ OPCODES = set((
'pow',
'powershape',
'powoftwo',
+ 'pows',
'prealloc',
'prepiano',
'print',
@@ -751,8 +755,6 @@ OPCODES = set((
'ptableiw',
'ptablew',
'ptrack',
- 'push',
- 'push_f',
'puts',
'pvadd',
'pvbufread',
@@ -885,12 +887,12 @@ OPCODES = set((
'pylexec',
'pylexeci',
'pylexect',
- #'pylrun',
- #'pylruni',
- #'pylrunt',
- #'pyrun',
- #'pyruni',
- #'pyrunt',
+ 'pylrun',
+ 'pylruni',
+ 'pylrunt',
+ 'pyrun',
+ 'pyruni',
+ 'pyrunt',
'qinf',
'qnan',
'r2c',
@@ -934,7 +936,7 @@ OPCODES = set((
'rfft',
'rifft',
#'rigoto',
- 'rireturn',
+ #'rireturn',
'rms',
'rnd',
'rnd31',
@@ -947,7 +949,6 @@ OPCODES = set((
'sandpaper',
'scale',
'scalearray',
- 'scalet',
'scanhammer',
'scans',
'scantable',
@@ -956,8 +957,8 @@ OPCODES = set((
'schedkwhennamed',
'schedule',
'schedwhen',
- #'scoreline',
- #'scoreline_i',
+ 'scoreline',
+ 'scoreline_i',
'seed',
'sekere',
'semitone',
@@ -1019,7 +1020,6 @@ OPCODES = set((
'slider8table',
'slider8tablef',
'sliderKawai',
- 'sndload',
'sndloop',
'sndwarp',
'sndwarpst',
@@ -1028,28 +1028,16 @@ OPCODES = set((
'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',
@@ -1086,7 +1074,6 @@ OPCODES = set((
'subinstrinit',
'sum',
'sumarray',
- 'sumtab',
'svfilter',
'syncgrain',
'syncloop',
@@ -1096,7 +1083,7 @@ OPCODES = set((
'tab',
'tab2pvs',
'tab_i',
- 'tabgen',
+ 'tabifd',
'table',
'table3',
'table3kt',
@@ -1122,15 +1109,12 @@ OPCODES = set((
'tablewkt',
'tablexkt',
'tablexseg',
- 'tabmap',
- 'tabmap_i',
'tabmorph',
'tabmorpha',
'tabmorphak',
'tabmorphi',
'tabplay',
'tabrec',
- 'tabslice',
'tabsum',
'tabw',
'tabw_i',
@@ -1210,6 +1194,7 @@ OPCODES = set((
'unirand',
'unwrap',
'upsamp',
+ 'urandom',
'urd',
'vactrol',
'vadd',
@@ -1220,11 +1205,6 @@ OPCODES = set((
'valpass',
'vaset',
'vbap',
- 'vbap16',
- 'vbap4',
- 'vbap4move',
- 'vbap8',
- 'vbap8move',
'vbapg',
'vbapgmove',
'vbaplsinit',
@@ -1326,7 +1306,6 @@ OPCODES = set((
'xscansmap',
'xscanu',
'xtratim',
- 'xyin',
'zacl',
'zakinit',
'zamod',
@@ -1344,3 +1323,45 @@ OPCODES = set((
'zkw',
'zkwm'
))
+
+DEPRECATED_OPCODES = set((
+ 'array',
+ 'bformdec',
+ 'bformenc',
+ 'copy2ftab',
+ 'copy2ttab',
+ 'hrtfer',
+ 'ktableseg',
+ 'lentab',
+ 'maxtab',
+ 'mintab',
+ 'pop',
+ 'pop_f',
+ 'push',
+ 'push_f',
+ 'scalet',
+ 'sndload',
+ 'soundout',
+ 'soundouts',
+ 'specaddm',
+ 'specdiff',
+ 'specdisp',
+ 'specfilt',
+ 'spechist',
+ 'specptrk',
+ 'specscal',
+ 'specsum',
+ 'spectrum',
+ 'stack',
+ 'sumtab',
+ 'tabgen',
+ 'tabmap',
+ 'tabmap_i',
+ 'tabslice',
+ 'vbap16',
+ 'vbap4',
+ 'vbap4move',
+ 'vbap8',
+ 'vbap8move',
+ 'xyin'
+))
diff --git a/pygments/lexers/csound.py b/pygments/lexers/csound.py
index 080cead8..4d9ae398 100644
--- a/pygments/lexers/csound.py
+++ b/pygments/lexers/csound.py
@@ -14,7 +14,7 @@ import re
from pygments.lexer import RegexLexer, bygroups, default, include, using, words
from pygments.token import Comment, Keyword, Name, Number, Operator, Punctuation, \
String, Text
-from pygments.lexers._csound_builtins import OPCODES
+from pygments.lexers._csound_builtins import OPCODES, DEPRECATED_OPCODES
from pygments.lexers.html import HtmlLexer
from pygments.lexers.python import PythonLexer
from pygments.lexers.scripting import LuaLexer
@@ -104,8 +104,8 @@ class CsoundScoreLexer(CsoundLexer):
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+[Ee][+-]?\d+|(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?', Number.Float),
+ (r'0[Xx][0-9A-Fa-f]+', Number.Hex),
(r'\d+', Number.Integer),
(r'"', String, 'single-line string'),
(r'[+\-*/%^!=<>|&#~.]', Operator),
@@ -152,9 +152,12 @@ class CsoundOrchestraLexer(CsoundLexer):
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:
+ name = match.group(1)
+ if name in OPCODES or name in DEPRECATED_OPCODES:
yield match.start(), Name.Builtin, name
+ if match.group(2):
+ yield match.start(2), Punctuation, match.group(2)
+ yield match.start(3), Keyword.Type, match.group(3)
elif name in lexer.user_defined_opcodes:
yield match.start(), Name.Function, name
else:
@@ -167,14 +170,14 @@ class CsoundOrchestraLexer(CsoundLexer):
tokens = {
'label': [
- (r'\b(\w+)(:)', bygroups(Name.Label, Punctuation))
+ (r'^([ \t]*)(\w+)(:)', bygroups(Text, 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'\b(0dbfs|A4|k(r|smps)|nchnls(_i)?|sr)\b', Name.Variable.Global),
+ (r'\d+[Ee][+-]?\d+|(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?', Number.Float),
+ (r'0[Xx][0-9A-Fa-f]+', Number.Hex),
(r'\d+', Number.Integer),
(r'"', String, 'single-line string'),
(r'\{\{', String, 'multi-line string'),
@@ -185,20 +188,24 @@ class CsoundOrchestraLexer(CsoundLexer):
'do', 'else', 'elseif', 'endif', 'enduntil', 'fi', 'if', 'ithen', 'kthen',
'od', 'then', 'until', 'while',
# Opcodes that act as control structures
- 'return', 'timout'
+ 'return', 'rireturn'
), prefix=r'\b', suffix=r'\b'), Keyword),
- (words(('goto', 'igoto', 'kgoto', 'rigoto', 'tigoto'),
+ (words(('goto', 'igoto', 'kgoto', 'reinit', 'rigoto', 'tigoto'),
prefix=r'\b', suffix=r'\b'), Keyword, 'goto label'),
- (words(('cggoto', 'cigoto', 'cingoto', 'ckgoto', 'cngoto'),
+ (words(('cggoto', 'cigoto', 'cingoto', 'ckgoto', 'cngoto', 'cnkgoto'),
prefix=r'\b', suffix=r'\b'), Keyword,
('goto label', 'goto expression')),
+ (r'\btimout\b', Keyword,
+ ('goto label', 'goto expression', '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'\bprintk?s\b', Name.Builtin, 'prints 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)
+ (r'\bp\d+\b', Name.Builtin),
+ (r'\b([A-Z_a-z]\w*)(?:(:)([A-Za-z]))?\b', name_callback)
],
'expression': [
@@ -219,8 +226,8 @@ class CsoundOrchestraLexer(CsoundLexer):
'instrument name list': [
include('whitespace or macro use'),
- (r'\d+|\+?[a-zA-Z_]\w*', Name.Function),
- (r',', Punctuation),
+ (r'\d+|[A-Z_a-z]\w*', Name.Function),
+ (r'[+,]', Punctuation),
newline + ('#pop',)
],
'instrument block': [
@@ -233,7 +240,7 @@ class CsoundOrchestraLexer(CsoundLexer):
'opcode name': [
include('whitespace or macro use'),
- (r'[a-zA-Z_]\w*', opcode_name_callback, '#pop')
+ (r'[A-Z_a-z]\w*', opcode_name_callback, '#pop')
],
'opcode types': [
include('whitespace or macro use'),
@@ -266,11 +273,10 @@ class CsoundOrchestraLexer(CsoundLexer):
'single-line string': [
include('macro use'),
(r'"', String, '#pop'),
- # From https://github.com/csound/csound/blob/develop/Opcodes/fout.c#L1405
- (r'%\d*(\.\d+)?[cdhilouxX]', String.Interpol),
- (r'%[!%nNrRtT]|[~^]|\\([\\aAbBnNrRtT"]|[0-7]{1,3})', String.Escape),
- (r'[^\\"~$%\^\n]+', String),
- (r'[\\"~$%\^\n]', String)
+ # https://github.com/csound/csound/search?q=unquote_string+path%3AEngine+filename%3Acsound_orc_compile.c
+ (r'\\([\\abnrt"]|[0-7]{1,3})', String.Escape),
+ (r'[^\\"$\n]+', String),
+ (r'[\\"$\n]', String)
],
'multi-line string': [
(r'\}\}', String, '#pop'),
@@ -287,6 +293,21 @@ class CsoundOrchestraLexer(CsoundLexer):
(r'([^}]+)|\}(?!\})', using(CsoundScoreLexer))
],
+ 'prints opcode': [
+ include('whitespace or macro use'),
+ (r'"', String, 'prints'),
+ default('#pop')
+ ],
+ 'prints': [
+ include('macro use'),
+ (r'"', String, '#pop'),
+ # https://github.com/csound/csound/search?q=sprints1+path%3AOpcodes+filename%3Afout.c
+ (r'%\d*(\.\d+)?[cdhilouxX]', String.Interpol),
+ (r'%[!%nNrRtT]|[~^]|\\([\\aAbBnNrRtT"]|[0-7]{1,3})', String.Escape),
+ (r'[^\\"~$%\^\n]+', String),
+ (r'[\\"~$%\^\n]', String)
+ ],
+
'python opcode': [
include('whitespace or macro use'),
(r'\{\{', String, 'python'),
diff --git a/tests/examplefiles/test.csd b/tests/examplefiles/test.csd
index 9122309b..3f43bede 100644
--- a/tests/examplefiles/test.csd
+++ b/tests/examplefiles/test.csd
@@ -13,6 +13,7 @@ nchnls_i = 1
sr = 44100
0dbfs = 1
ksmps = 10
+A4 = 440
// 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
@@ -80,9 +81,8 @@ 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>.
+// You can execute Python <https://csound.github.io/docs/manual/pyrun.html> and
+// Lua <https://csound.github.io/docs/manual/lua.html> in Csound.
pyruni {{
import random
@@ -106,13 +106,13 @@ def get_number_from_pool(n, p):
#define A_HZ #440#
// This is a function-like macro:
-#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
+#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
- aSignal $OSCIL_MACRO(1'$A_HZ'1)
+ aSignal $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 aSignal
@@ -129,7 +129,7 @@ instr TestBitwiseNOT
endin
// Csound uses # for bitwise XOR, which the Csound manual calls bitwise
-// non-equivalence <http://www.csounds.com/manual/html/opnonequiv.html>.
+// non-equivalence <https://csound.github.io/docs/manual/opnonequiv.html>.
instr TestBitwiseXOR
print 0 # 0
print 0 # 1
@@ -178,10 +178,8 @@ loop_lt_label:
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.
+// The prints and printks opcodes, 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.
@@ -202,26 +200,22 @@ endin
// The arguments of function-like macros can be separated by # instead of '.
// These two lines define the same macro.
-#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
-#define OSCIL_MACRO(VOLUME#FREQUENCY#TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
+#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
- aSignal $OSCIL_MACRO.(1'$A_HZ'1)
+ aSignal $OSCIL_MACRO.(1' $A_HZ' 1)
prints "The frequency of the oscillator is $A_HZ.Hz.\n"
out aSignal
endin
// Csound has @ and @@ operator-like macros that, when followed by a literal
// non-negative integer, expand to the next power of 2 and the next power of 2
-// plus 1:
+// plus 1 <https://csound.github.io/docs/manual/ScoreEval.html>:
// @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>)
-// and are described at <http://www.csounds.com/manual/html/ScoreEval.html>.
instr TestAt
prints "%d %2d %2d\n", 0, @0, @@0
prints "%d %2d %2d\n", 1, @1, @@1
@@ -252,7 +246,7 @@ i "TestOscillator" 2 2
i "TestBitwiseNOT" 0 1
i "TestBitwiseXOR" 0 1
i "TestGoto" 0 1
-i "TestMacroPeriodSuffix" 4 1
+i "TestMacroPeriodSuffix" 0 1
i "TestAt" 0 1
i "MacroAbuse" 0 1
e
diff --git a/tests/examplefiles/test.orc b/tests/examplefiles/test.orc
index 36725342..36e35b34 100644
--- a/tests/examplefiles/test.orc
+++ b/tests/examplefiles/test.orc
@@ -11,6 +11,7 @@ nchnls_i = 1
sr = 44100
0dbfs = 1
ksmps = 10
+A4 = 440
// 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
@@ -78,9 +79,8 @@ 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>.
+// You can execute Python <https://csound.github.io/docs/manual/pyrun.html> and
+// Lua <https://csound.github.io/docs/manual/lua.html> in Csound.
pyruni {{
import random
@@ -104,13 +104,13 @@ def get_number_from_pool(n, p):
#define A_HZ #440#
// This is a function-like macro:
-#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
+#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
- aSignal $OSCIL_MACRO(1'$A_HZ'1)
+ aSignal $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 aSignal
@@ -127,7 +127,7 @@ instr TestBitwiseNOT
endin
// Csound uses # for bitwise XOR, which the Csound manual calls bitwise
-// non-equivalence <http://www.csounds.com/manual/html/opnonequiv.html>.
+// non-equivalence <https://csound.github.io/docs/manual/opnonequiv.html>.
instr TestBitwiseXOR
print 0 # 0
print 0 # 1
@@ -176,10 +176,8 @@ loop_lt_label:
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.
+// The prints and printks opcodes, 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.
@@ -200,26 +198,22 @@ endin
// The arguments of function-like macros can be separated by # instead of '.
// These two lines define the same macro.
-#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
-#define OSCIL_MACRO(VOLUME#FREQUENCY#TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
+#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
- aSignal $OSCIL_MACRO.(1'$A_HZ'1)
+ aSignal $OSCIL_MACRO.(1' $A_HZ' 1)
prints "The frequency of the oscillator is $A_HZ.Hz.\n"
out aSignal
endin
// Csound has @ and @@ operator-like macros that, when followed by a literal
// non-negative integer, expand to the next power of 2 and the next power of 2
-// plus 1:
+// plus 1 <https://csound.github.io/docs/manual/ScoreEval.html>:
// @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>)
-// and are described at <http://www.csounds.com/manual/html/ScoreEval.html>.
instr TestAt
prints "%d %2d %2d\n", 0, @0, @@0
prints "%d %2d %2d\n", 1, @1, @@1
@@ -250,7 +244,7 @@ i "TestOscillator" 2 2
i "TestBitwiseNOT" 0 1
i "TestBitwiseXOR" 0 1
i "TestGoto" 0 1
-i "TestMacroPeriodSuffix" 4 1
+i "TestMacroPeriodSuffix" 0 1
i "TestAt" 0 1
i "MacroAbuse" 0 1
e
diff --git a/tests/examplefiles/test.sco b/tests/examplefiles/test.sco
index a0b39251..07818133 100644
--- a/tests/examplefiles/test.sco
+++ b/tests/examplefiles/test.sco
@@ -4,7 +4,7 @@ i "TestOscillator" 2 2
i "TestBitwiseNOT" 0 1
i "TestBitwiseXOR" 0 1
i "TestGoto" 0 1
-i "TestMacroPeriodSuffix" 4 1
+i "TestMacroPeriodSuffix" 0 1
i "TestAt" 0 1
i "MacroAbuse" 0 1
e