The Mus Syntax

Lexical tokens

Comments

% to end of line, or %{ ... %} allowing nesting

$get!filename;


Reserved words start with a letter followed by letters.

<int> is an optinal + or - sign followed by a sequence of one or more
decimal digits.

<num> is an <int> optionally followed by a dot (.) and one to three
decimal digits. It encodes a scaled number with three digits after the
decimal point.

<notename> ->
          a
       |  aes
       |  aeses
       |  ais
       |  aisis
etc
       |  gisis

<note> -> <notename> <commas> <primes>

<commas> -> zero or more commas
<primes> -> zero or more primes
<dots> -> zero or more dots
<notelen> -> empty or 1, 2, 4, 8, 16, 32, 64, 128
<tie> -> empty or ~
<rest> -> r <notelen> <dots>
<space> -> s <notelen> <dots>
<mode> -> \major
       |  \minor
<barline> -> |
          |  ||

S -> empty
  |  <note> <notelen> <dots> <tie>
  |  r <notelen> <dots>
  |  s <notelen> <dots>
  |  \control(<num> <num>)
  |  \pedon
  |  \pedoff
  |  \pedoffon
  |  \portaon
  |  \portaoff
  |  \legon
  |  \legoff

  |  <barline>
  |  \transpose(<note>)
  |  \transposition ( <note> <note> )
  |  \timesig ( <digs> <digs> )
  |  \keysig ( <note> <mode> )
  |  \trebleclef
  |  \altoclef
  |  \tenorclef
  |  \bassclef

  |  S \vol <shape>
  |  S \voladj <shape>
  |  S \legato <shape>
  |  S \legatoadj <shape>
  |  S \tempo <shape>
  |  S \tempoadj <shape>
  |  S \tune <shape>
  |  S \tuneadj <shape>

  |  S ... S
  |  [ S .. S ]                  -- simultaneous sequences


<shape> ->
     empty
  |  <shape> num
  |  <shape> shape>

The Parse Tree Structure

N -> <name>      // Macro names eg horn_1_part coda

I -> <integer>   // signed integers for note numbers and accidentals

K -> <number>    // K numbers are scaled ddd.ddd
                 // eg 123.456  234  -0.123  -5
 
<note> -> I      // MIDI number of natural note

<accs> -> I  // -2 .. +2  -- double flat to double sharp

<len> -> K // 1, 2, 4, 8, etc for breve, minim, crochet etc

L -> <line number>     // Line and file number

- -> E                 // Link to next item

E -> 0                            // End of list
  |  [Def - L N E]                // eg def abc = { a8 b, cis'}
  |  [Name - L N]                 // eg abc -- expand a macro name
  |  [Note - L <note> <accs> <len> <dots>]
                                  // eg fis'8.
  |  [Rest - L <len> <dots>]      // eg r4
  |  [Space - L <len> <dots>]     // eg s2.
  |  [Barline - L]                // eg | -- to help debugging
  |  [Tie - L E]                  // eg a8~
  |  [Comp E L E E]               // eg E vol{...}
  |  [Transpose - L <note> <accs> <note> <accs>]
                                  // eg transpose(c f)
  |  [Transposition - L <note> <accs>]
                                  // eg transposition(f)
  |  [Vol - L E]                  // eg vol {65 78 90 90}
  |  [Voladj - L E]               // eg voladj {.8 .9 .6 .2}
  |  [Tune - L E]                 // eg tune {440 442 440}
  |  [Tuneadj - L E]              // eg tuneadj {0 .4 0 -.4 0}
  |  [Tempo - L E]                // eg tempo {0:120 1:150 8:160}
  |  [Tempoadj - L E]             // eg tempoadj {0 .2 .3 .1 0}
  |  [Par - L E E]                // eg E || E
                                  // or << E .. E >>
  |  [Scale - L I I E]            // eg scale(3 2){a8 b cis}
                                  // ie 3 notes in the time for 2
  |  [Timesig - L I I]               // eg timesig(3 4)
  |  [Keysig - L <rawnum> <accs> <mode>]
                                  // eg keysig(bes major)
  |  [Trebleclef - L]            // eg clef(treble)
  |  [Instrumentname - L S]       // eg instrumentname("frenchhorn" "Hn")
  |  [Instrumentshortname - L S]  // eg instrumentshortname("Hn")
  |  [Instrument - L I]           // eg instrument(piano)
  |  [Num - L K]                  // eg 120.5
  |  [Numpair - L K K]            // eg 50:96

P -> 0
  |  [Score P L E]                // E is the entire score, once only
  |  [Interval N]                 // Interval of N seconds between movements