]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
* python/convertrules.py (conv): warning on \tempo{}
[lilypond.git] / lily / parser.yy
index 1c39e1c06057ba4e922c95f98d44ac05155c763d..7c04cb0c262f46160f64e10044a6a2f92f29eb55 100644 (file)
@@ -160,7 +160,7 @@ void set_music_properties (Music *p, SCM a);
 %token ADDQUOTE "\\addquote"
 %token ALIAS "\\alias"
 %token ALTERNATIVE "\\alternative"
-%token BOOK "\book"
+%token BOOK "\\book"
 %token CHANGE "\\change"
 %token CHORDMODE "\\chordmode"
 %token CHORDS "\\chords"
@@ -206,7 +206,6 @@ void set_music_properties (Music *p, SCM a);
 %token TEMPO "\\tempo"
 %token TIMES "\\times"
 %token TRANSPOSE "\\transpose"
-%token TRANSPOSITION "\\transposition"
 %token TYPE "\\type"
 %token UNSET "\\unset"
 %token WITH "\\with"
@@ -223,8 +222,10 @@ void set_music_properties (Music *p, SCM a);
 %token CHORD_COLON ":"
 %token CHORD_MINUS "-"
 %token CHORD_SLASH "/"
-%token DOUBLE_ANGLE_CLOSE ">>"
+%token ANGLE_OPEN "<"
+%token ANGLE_CLOSE ">"
 %token DOUBLE_ANGLE_OPEN "<<"
+%token DOUBLE_ANGLE_CLOSE ">>"
 %token E_BACKSLASH "\\"
 %token E_ANGLE_CLOSE "\\>"
 %token E_CHAR "\\C[haracter]"
@@ -348,7 +349,6 @@ If we give names, Bison complains.
 %type <scm> simple_music_property_def
 %type <scm> string_number_event
 %type <scm> tempo_event
-%type <scm> toplevel_music
 
 %type <outputdef> output_def_body
 %type <outputdef> output_def_head
@@ -365,6 +365,7 @@ If we give names, Bison complains.
 %type <scm> music_function_event
 %type <scm> music_function_chord_body
 %type <scm> music_function_musicless_prefix
+%type <scm> music_function_musicless_function
 %type <scm> bass_figure
 %type <scm> figured_bass_modification
 %type <scm> br_bass_figure
@@ -477,7 +478,7 @@ toplevel_expression:
                scm_call_2 (proc, PARSER->self_scm (), score->self_scm ());
                score->unprotect ();
        }
-       | toplevel_music {
+       | composite_music {
                Music *music = unsmob_music ($1);
                SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-music-handler");
                scm_call_2 (proc, PARSER->self_scm (), music->self_scm ());
@@ -502,11 +503,6 @@ toplevel_expression:
        }
        ;
 
-toplevel_music:
-       composite_music {
-       }
-       ;
-
 embedded_scm:
        SCM_T
        | SCM_IDENTIFIER
@@ -579,7 +575,16 @@ identifier_init:
                $$ = $1;
        }
        | music  {
-               $$ = $1;
+               /* Hack: Create event-chord around standalone events.
+                  Prevents the identifier from being interpreted as a post-event. */
+               Music *mus = unsmob_music ($1);
+               bool is_event = mus &&
+                       (scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
+                               != SCM_BOOL_F);
+               if (!is_event)
+                       $$ = $1;
+               else
+                       $$ = MAKE_SYNTAX ("event-chord", @$, scm_list_1 ($1));
        }
        | post_event {
                $$ = $1;
@@ -795,15 +800,6 @@ output_def_body:
        | output_def_body context_def_spec_block        {
                assign_context_def ($$, $2);
        }
-       | output_def_body tempo_event  {
-               /*
-                       junk this ? there already is tempo stuff in
-                       music.
-               */
-               int m = scm_to_int (unsmob_music($2)->get_property ("metronome-count"));
-               Duration *d = unsmob_duration (unsmob_music($2)->get_property ("tempo-unit"));
-               set_tempo ($$, d->get_length (), m);
-       }
        | output_def_body error {
 
        }
@@ -811,11 +807,8 @@ output_def_body:
 
 tempo_event:
        TEMPO steno_duration '=' bare_unsigned  {
-               Music *m = MY_MAKE_MUSIC ("MetronomeChangeEvent");
-               m->set_property ("tempo-unit", $2);
-               m->set_property ("metronome-count", scm_from_int ( $4));
-               $$ = m->unprotect ();
-       }
+               $$ = MAKE_SYNTAX ("tempo", @$, $2, scm_int2num ($4));
+       }                               
        ;
 
 /*
@@ -893,7 +886,7 @@ simultaneous_music:
        SIMULTANEOUS '{' music_list '}'{
                $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_car ($3));
        }
-       | simul_open music_list simul_close     {
+       | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE       {
                $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_car ($2));
        }
        ;
@@ -940,7 +933,7 @@ function_scm_argument:
 /*
 TODO: use code generation for this
 */
-generic_prefix_music_scm:
+music_function_musicless_function:
        MUSIC_FUNCTION {
                $$ = scm_list_2 ($1, make_input (@$));
        }
@@ -950,21 +943,48 @@ generic_prefix_music_scm:
        | MUSIC_FUNCTION_MARKUP full_markup {
                $$ = scm_list_3 ($1, make_input (@$), $2);
        }
-       | music_function_musicless_prefix music {
-               $$ = ly_append2 ($1, scm_list_1 ($2));
-       }
        | MUSIC_FUNCTION_SCM_SCM function_scm_argument function_scm_argument {
                $$ = scm_list_4 ($1, make_input (@$), $2, $3);
        }
        | MUSIC_FUNCTION_SCM_SCM_SCM function_scm_argument function_scm_argument function_scm_argument {
                $$ = scm_list_5 ($1, make_input (@$), $2, $3, $4);
        }
-       | MUSIC_FUNCTION_MARKUP_MUSIC full_markup music {
+       | MUSIC_FUNCTION_MARKUP_MARKUP full_markup full_markup {
                $$ = scm_list_4 ($1, make_input (@$), $2, $3);
        }
-       | MUSIC_FUNCTION_MARKUP_MARKUP full_markup full_markup {
+       ;
+
+/*
+TODO: use code generation for this
+*/
+music_function_musicless_prefix:
+       MUSIC_FUNCTION_MUSIC {
+               $$ = scm_list_2 ($1, make_input (@$));
+       }
+       | MUSIC_FUNCTION_SCM_MUSIC function_scm_argument { 
+               $$ = scm_list_3 ($1, make_input (@$), $2);
+       }
+       | MUSIC_FUNCTION_SCM_SCM_MUSIC function_scm_argument function_scm_argument {
                $$ = scm_list_4 ($1, make_input (@$), $2, $3);
        }
+       | MUSIC_FUNCTION_SCM_SCM_SCM_MUSIC function_scm_argument function_scm_argument function_scm_argument {
+               $$ = scm_list_5 ($1, make_input (@$), $2, $3, $4);
+       }
+       | MUSIC_FUNCTION_SCM_SCM_SCM_SCM_MUSIC function_scm_argument function_scm_argument function_scm_argument function_scm_argument {
+               $$ = scm_list_n ($1, make_input (@$), $2, $3, $4, $5, SCM_UNDEFINED);
+       }
+       | MUSIC_FUNCTION_MARKUP_MUSIC full_markup {
+               $$ = scm_list_3 ($1, make_input (@$), $2);
+       }
+       ;
+
+generic_prefix_music_scm:
+       music_function_musicless_function {
+               $$ = $1;
+       }
+       | music_function_musicless_prefix music {
+               $$ = ly_append2 ($1, scm_list_1 ($2));
+       }
        | MUSIC_FUNCTION_MUSIC_MUSIC music music {
                $$ = scm_list_4 ($1, make_input (@$), $2, $3);
        }
@@ -979,6 +999,7 @@ generic_prefix_music_scm:
        }
        ;
 
+
 optional_id:
        /**/ { $$ = SCM_EOL; }
        | '=' simple_string {
@@ -1322,20 +1343,8 @@ note_chord_element:
        }
        ;
 
-chord_open: '<'
-       ;
-
-chord_close: '>'
-       ;
-
-simul_open: DOUBLE_ANGLE_OPEN
-       ;
-
-simul_close: DOUBLE_ANGLE_CLOSE
-       ;
-
 chord_body:
-       chord_open chord_body_elements chord_close
+       ANGLE_OPEN chord_body_elements ANGLE_CLOSE
        {
                $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
        }
@@ -1394,8 +1403,8 @@ chord_body_element:
        ;
 
 music_function_chord_body:
-       MUSIC_FUNCTION {
-               $$ = scm_list_2 ($1, make_input (@$));
+       music_function_musicless_function {
+               $$ = $1;
        }
        | music_function_musicless_prefix chord_body_element {
                $$ = ly_append2 ($1, scm_list_1 ($2));
@@ -1406,29 +1415,11 @@ music_function_event:
        music_function_musicless_prefix post_event {
                $$ = ly_append2 ($1, scm_list_1 ($2));
        }
-       ;
-
-/*
-TODO: use code generation for this
-*/
-music_function_musicless_prefix:
-       MUSIC_FUNCTION_MUSIC {
-               $$ = scm_list_2 ($1, make_input (@$));
-       }
-       | MUSIC_FUNCTION_SCM_MUSIC function_scm_argument { 
-               $$ = scm_list_3 ($1, make_input (@$), $2);
-       }
-       | MUSIC_FUNCTION_SCM_SCM_MUSIC function_scm_argument function_scm_argument {
-               $$ = scm_list_4 ($1, make_input (@$), $2, $3);
-       }
-       | MUSIC_FUNCTION_SCM_SCM_SCM_MUSIC function_scm_argument function_scm_argument function_scm_argument {
-               $$ = scm_list_5 ($1, make_input (@$), $2, $3, $4);
-       }
-       | MUSIC_FUNCTION_SCM_SCM_SCM_SCM_MUSIC function_scm_argument function_scm_argument function_scm_argument function_scm_argument {
-               $$ = scm_list_n ($1, make_input (@$), $2, $3, $4, $5, SCM_UNDEFINED);
+       | music_function_musicless_function {
+               $$ = $1;
        }
        ;
-
+       
 
 command_element:
        command_event {
@@ -1466,11 +1457,6 @@ command_element:
                        $$ = MAKE_SYNTAX ("bar-check", @$, SCM_UNDEFINED);
 
        }
-       | TRANSPOSITION pitch {
-               Pitch middle_c;
-               Pitch sounds_as_c = pitch_interval (*unsmob_pitch ($2), middle_c);
-               $$ = MAKE_SYNTAX ("property-operation", @$, SCM_BOOL_F, ly_symbol2scm ("Staff"), ly_symbol2scm ("PropertySet"), ly_symbol2scm ("instrumentTransposition"), sounds_as_c.smobbed_copy ());
-       }
        | PARTIAL duration_length       {
                Moment m = - unsmob_duration ($2)->get_length ();
                $$ = MAKE_SYNTAX ("property-operation", @$, SCM_BOOL_F, ly_symbol2scm ("Timing"), ly_symbol2scm ("PropertySet"), ly_symbol2scm ("measurePosition"), m.smobbed_copy ());
@@ -1737,7 +1723,7 @@ gen_text_def:
                $$ = t->unprotect ();
        }
        | DIGIT {
-               Music *t = MY_MAKE_MUSIC ("FingerEvent");
+               Music *t = MY_MAKE_MUSIC ("FingeringEvent");
                t->set_property ("digit", scm_from_int ($1));
                t->set_spot (@$);
                $$ = t->unprotect ();
@@ -1757,7 +1743,7 @@ script_abbreviation:
        | '|'           {
                $$ = scm_makfrom0str ("Bar");
        }
-       | '>'           {
+       | ANGLE_CLOSE   {
                $$ = scm_makfrom0str ("Larger");
        }
        | '.'           {