]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
* input/regression/instrument-switch.ly: new file.
[lilypond.git] / lily / parser.yy
index 17b0cd25a72a7c3ede72fc293e677818b164291f..d0109edac543f80487894843f6c18e2297b23c63 100644 (file)
@@ -250,6 +250,7 @@ If we give names, Bison complains.
 %token CHORDMODIFIERS
 %token LYRIC_MARKUP
 %token MULTI_MEASURE_REST
+%token SCM_T
 
 
 %token <i> DIGIT
@@ -300,7 +301,7 @@ If we give names, Bison complains.
 %token <scm> REAL
 %token <scm> RESTNAME
 %token <scm> SCM_IDENTIFIER
-%token <scm> SCM_TOKEN
+%token <scm> SCM_T
 %token <scm> SCORE_IDENTIFIER
 %token <scm> STRING
 %token <scm> STRING_IDENTIFIER
@@ -503,7 +504,7 @@ toplevel_expression:
        ;
 
 embedded_scm:
-       SCM_TOKEN
+       SCM_T
        | SCM_IDENTIFIER
        ;
 
@@ -534,6 +535,15 @@ assignment_id:
 
 assignment:
        assignment_id '=' identifier_init  {
+               if (! is_regular_identifier ($1))
+               {
+#if 0
+                       /* no longer valid with dashes in \paper{} block. */ 
+                       @1.warning (_ ("identifier should have alphabetic characters only"));
+#endif
+               }
+
+
                PARSER->lexer_->set_identifier ($1, $3);
 
 /*
@@ -694,7 +704,6 @@ score_body:
        }
        | SCORE_IDENTIFIER {
                $$ = unsmob_score ($1);
-               $$->protect ();
                $$->set_spot (@$);
        }
        | score_body object_id_setting {
@@ -731,7 +740,6 @@ paper_block:
                if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
                {
                        PARSER->parser_error (@1, _ ("need \\paper for paper block"));
-                       $1->unprotect ();
                        $$ = get_paper (PARSER);
                }
        }
@@ -780,11 +788,9 @@ output_def_body:
        }
        | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER    {
                $1->unprotect ();
-
                Output_def *o = unsmob_output_def ($3);
                o->input_origin_.set_spot (@$);
                $$ = o;
-               $$->protect ();
                PARSER->lexer_->remove_scope ();
                PARSER->lexer_->add_scope (o->scope_);
        }
@@ -794,6 +800,15 @@ 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 {
 
        }
@@ -801,8 +816,11 @@ output_def_body:
 
 tempo_event:
        TEMPO steno_duration '=' bare_unsigned  {
-               $$ = MAKE_SYNTAX ("tempo", @$, $2, scm_int2num ($4));
-       }                               
+               Music *m = MY_MAKE_MUSIC ("MetronomeChangeEvent");
+               m->set_property ("tempo-unit", $2);
+               m->set_property ("metronome-count", scm_from_int ( $4));
+               $$ = m->unprotect ();
+       }
        ;
 
 /*
@@ -1717,7 +1735,7 @@ gen_text_def:
                $$ = t->unprotect ();
        }
        | DIGIT {
-               Music *t = MY_MAKE_MUSIC ("FingeringEvent");
+               Music *t = MY_MAKE_MUSIC ("FingerEvent");
                t->set_property ("digit", scm_from_int ($1));
                t->set_spot (@$);
                $$ = t->unprotect ();
@@ -2354,26 +2372,17 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                *destination = sid;
                return STRING_IDENTIFIER;
        } else if (unsmob_book (sid)) {
-               Book *book =  unsmob_book (sid)->clone ();
-               *destination = book->self_scm ();
-               book->unprotect ();
-
+               *destination = unsmob_book (sid)->clone ()->self_scm ();
                return BOOK_IDENTIFIER;
        } else if (scm_is_number (sid)) {
                *destination = sid;
                return NUMBER_IDENTIFIER;
        } else if (unsmob_context_def (sid)) {
-               Context_def *def= unsmob_context_def (sid)->clone ();
-
-               *destination = def->self_scm ();
-               def->unprotect ();
-               
+               *destination = unsmob_context_def (sid)->clone_scm ();
                return CONTEXT_DEF_IDENTIFIER;
        } else if (unsmob_score (sid)) {
                Score *score = new Score (*unsmob_score (sid));
                *destination = score->self_scm ();
-
-               score->unprotect ();
                return SCORE_IDENTIFIER;
        } else if (Music *mus = unsmob_music (sid)) {
                mus = mus->clone ();
@@ -2384,7 +2393,6 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                bool is_event = scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
                        != SCM_BOOL_F;
 
-               mus->unprotect ();
                return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
        } else if (unsmob_duration (sid)) {
                *destination = unsmob_duration (sid)->smobbed_copy ();
@@ -2392,9 +2400,8 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
        } else if (unsmob_output_def (sid)) {
                Output_def *p = unsmob_output_def (sid);
                p = p->clone ();
-       
+
                *destination = p->self_scm ();
-               p->unprotect ();
                return OUTPUT_DEF_IDENTIFIER;
        } else if (Text_interface::is_markup (sid)) {
                *destination = sid;