Lint Csound orchestras
This Pulsar package adds syntax checking for Csound orchestras.
The linter-csound preprocessor searches paths for files included using #include
in this order:
The paths returned by Pulsar’s Project::getPaths
. (This is usually one path that’s roughly equivalent to the current directory.)
The path of the file being preprocessed.
If there are files named .csound-include-directories in the paths returned by Project::getPaths
, the paths (one per line) contained in each .csound-include-directories file. For example, if you create a file named .csound-include-directories in the root folder of your project, and this file contains
/usr/local/csound/udos
/usr/local/csound/more-udos
then linter-csound will search /usr/local/csound/udos and /usr/local/csound/more-udos for included files.
Paths you enter in linter-csound’s Settings.
Open an issue, or fork this project and make a pull request.
To check the syntax of orchestras, linter-csound uses a preprocessor and parser generated using the GerHobbelt fork of Jison. The grammar used by the parser is based on this JavaScript grammar and this C grammar. To generate the preprocessor and parser on macOS, open a Terminal, cd
to linter-csound/lib/csound-parser, and then run:
npm install https://github.com/GerHobbelt/jison/archive/0.6.1-215.tar.gz
node generate-parser.js
The linter-csound preprocessor and parser try to match Csound’s behavior, but linter-csound’s implementations are quite different. Here is how linter-csound’s Jison files correspond to Csound’s Flex/Bison files:
This Jison file | Corresponds to this Flex/Bison file |
---|---|
preprocessor.jisonlex | csound_pre.lex |
orchestra.jisonlex | csound_orc.lex |
orchestra.jison | csound_orc.y |
Csound’s preprocessor:
permits 0-length parameter names in function-like macros. This orchestra prints hello, world
:
#define MACRO(arg') #$arg,$#
prints "$MACRO(hello' world)\n"
scoreline_i "e"
The linter-csound preprocessor treats 0-length parameter names as errors.
permits duplicate parameter names in function-like macros. The linter-csound preprocessor treats duplicate parameter names as errors.
continues to compile after attempting to #include
a directory. The linter-csound preprocessor treats this as an error.