source_file = { definition } .
definition = conductor_def
| "$" key_stmt
| "$default" key_default
| "extern" prim_defines
| defines .
conductor_def = "conductor" block .
prim_defines = note_def
| phrase_def
| chord_def
| var_def
| template_def
| procedure_def
| function_def
| envelope_def .
prim_defines = note_def [ ASSIGN note ]
| phrase_def [ ASSIGN phrase ]
| chord_def [ ASSIGN chord ]
| var_def [ ASSIGN expression ]
| template_defset
| procedure_defset
| function_defset
| envelope_def [ ASSIGN envelope ] .
note_def = "note" IDENTIFIER .
phrase_def = "phrase" IDENTIFIER .
chord_def = "chord" IDENTIFIER .
var_def = "var" IDENTIFIER .
template_def = "template" IDENTIFIER .
procedure_def = "procedure" IDENTIFIER .
function_def = "function" IDENTIFIER .
envelope_def = "envelope" IDENTIFIER .
template_defset = template_def [ ASSIGN TEMPLATE_IDENT |
"(" temp_params ")" ] .
temp_params = { attribute } { "," { attribute } } .
procedure_defset = procedure_def [ ASSIGN PROCEDURE_IDENT
| "(" [ param { "," param } ] ")" block ] .
function_defset = function_def [ ASSIGN FUNCTION_IDENT
| "(" [ prim_defines { "," prim_defines } ] ")" block ] .
block = phrase | chord .
attribute = delay [ expression | rel_expr ]
| velocity [ expression | rel_expr ]
| duration [ expression | rel_expr ]
| pressure [ expression | rel_expr ]
| patch [ expression | rel_expr ]
| channel [ expression | rel_expr ]
| "." factor [ rel_expr ]
| ":" factor [ rel_expr ]
| "^"
| "_" .
rel_expr = ( "+" | "-" | "*" | "/" | "mod" ) expression .
note = ( key_factor | pitch expression | NOTE_IDENT )
{ attribute } .
phrase = ( BEGIN_PHRASE statement_list END_PHRASE | PHRASE_IDENT )
{ attribute } .
chord = ( BEGIN_CHORD statement_list END_CHORD | CHORD_IDENT )
{ attribute } .
envelope = /* unimplemented */ .
statement_list = [ statement { [ BAR ] statement } ] .
statement = defines
| note
| phrase
| chord
| envelope
| key_stmt
| tempo_stmt
| default_stmt
| set_stmt
| call_stmt
| repeat_stmt
| while_stmt
| do_stmt
| return_stmt .
key_stmt = "key" ( KEYNAME ( "major" | "minor" )
| "(" KEYNAME { "," KEYNAME } ")" ) .
tempo_stmt = "tempo" expression ASSIGN expression .
default_stmt = "default" ( key_default | attribute ) .
key_default = KEYNAME ASSIGN ( key_factor | expression ) .
set_stmt = NOTE_IDENT ASSIGN note
| PHRASE_IDENT ASSIGN phrase
| CHORD_IDENT ASSIGN chord
| ENVELOPE_IDENT ASSIGN envelope
| VAR_IDENT ASSIGN expression .
call_stmt = PROCEDURE_IDENT "(" [ call_param { "," call_param } ] ")"
| TEMPLATE_IDENT "(" note { "," note } ")" .
call_param = note | phrase | chord | envelope | expression
| procedure | template | function .
repeat_stmt = "repeat" expression "do" statement .
while_stmt = "while" expression "do" statement .
do_stmt = "do" statement "while" expression .
return_stmt = "return" expression .
expression = expression binop expression |
unop expression |
factor .
binop = "+" | "-" | "*" | "/" | "mod"
| "and" | "or" | "==" | "<>"
| "<" | ">" | "<=" | ">=" .
unop = "~" | "not" | "." | ":" .
factor = NUMBER | VAR_IDENT
| KEY key_factor |
"(" expression ")" |
CURRENT
| FUNCTION_IDENT "(" [ call_param { "," call_param } ] ")" .
key_factor = KEYNAME { INCPIT | DECPIT } .
KEYNAME = ( "a" | "b" | "c" | "d" | "e" | "f" | "g"
| "A" | "B" | "C" | "D" | "E" | "F" | "G" )
{ "#" | "$" | "%" } .
pitch = "pitch" | "&" .
delay = "pitch" | "\" .
duration = "duration" | "!" .
velocity = "velocity" | ";" .
pressure = "pressure" | "@" .
patch = "patch" .
channel = "channel" .
Next: Appendix 2: INSTRUCTION SET REFERENCE
Previous: Appendix 1: EBNF GRAMMAR OF THE Rubato LANGUAGE
Back to: Table of Contents