]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
Issue 4938 (2/3) Refactor handling of MIDI control changes
[lilypond.git] / lily / parser.yy
index f184c5acb2685087d8add9fb12508d9c2b35b880..159786b93c1dbc13268e72140f1cf7a485996177 100644 (file)
@@ -346,7 +346,6 @@ If we give names, Bison complains.
 %token BOOK_IDENTIFIER
 %token CHORD_MODIFIER
 %token CHORD_REPETITION
-%token CONTEXT_MOD_IDENTIFIER
 %token DRUM_PITCH
  /* Artificial token for durations in argument lists */
 %token DURATION_ARG
@@ -976,16 +975,12 @@ book_body:
                        SCM proc = parser->lexer_->lookup_identifier ("book-score-handler");
                        scm_call_2 (proc, $1, $2);
                } else if (Output_def *od = unsmob<Output_def> ($2)) {
-                       SCM id = SCM_EOL;
-
-                       if (to_boolean (od->c_variable ("is-paper")))
-                               id = ly_symbol2scm ("$defaultpaper");
-                       else if (to_boolean (od->c_variable ("is-midi")))
-                               id = ly_symbol2scm ("$defaultmidi");
-                       else if (to_boolean (od->c_variable ("is-layout")))
-                               id = ly_symbol2scm ("$defaultlayout");
-
-                       parser->lexer_->set_identifier (id, $2);
+                       if (to_boolean (od->lookup_variable (ly_symbol2scm ("is-paper")))) {
+                               unsmob<Book> ($1)->paper_ = od;
+                               set_paper (parser, od);
+                       } else {
+                               parser->parser_error (@2, _ ("need \\paper for paper block"));
+                       }
                } else if (ly_is_module ($2))
                {
                        ly_module_copy (unsmob<Book> ($1)->header_, $2);
@@ -1060,16 +1055,11 @@ bookpart_body:
                        SCM proc = parser->lexer_->lookup_identifier ("bookpart-score-handler");
                        scm_call_2 (proc, $1, $2);
                } else if (Output_def *od = unsmob<Output_def> ($2)) {
-                       SCM id = SCM_EOL;
-
-                       if (to_boolean (od->c_variable ("is-paper")))
-                               id = ly_symbol2scm ("$defaultpaper");
-                       else if (to_boolean (od->c_variable ("is-midi")))
-                               id = ly_symbol2scm ("$defaultmidi");
-                       else if (to_boolean (od->c_variable ("is-layout")))
-                               id = ly_symbol2scm ("$defaultlayout");
-
-                       parser->lexer_->set_identifier (id, $2);
+                       if (to_boolean (od->lookup_variable (ly_symbol2scm ("is-paper")))) {
+                               unsmob<Book> ($1)->paper_ = od;
+                       } else {
+                               parser->parser_error (@2, _ ("need \\paper for paper block"));
+                       }
                } else if (ly_is_module ($2)) {
                        Book *book = unsmob<Book> ($1);
                        if (!ly_is_module (book->header_))
@@ -1503,14 +1493,6 @@ context_modification:
                 parser->lexer_->pop_state ();
                 $$ = $4;
         }
-        | WITH CONTEXT_MOD_IDENTIFIER
-        {
-                $$ = $2;
-        }
-        | CONTEXT_MOD_IDENTIFIER
-        {
-                $$ = $1;
-        }
        | WITH context_modification_arg
        {
                if (unsmob<Music> ($2)) {
@@ -1520,7 +1502,10 @@ context_modification:
                if (unsmob<Context_mod> ($2))
                        $$ = $2;
                else {
-                       parser->parser_error (@2, _ ("not a context mod"));
+                       // let's permit \with #*unspecified* to go for
+                       // an empty context mod
+                       if (!scm_is_eq ($2, SCM_UNSPECIFIED))
+                               parser->parser_error (@2, _ ("not a context mod"));
                        $$ = Context_mod ().smobbed_copy ();
                }
        }
@@ -1573,24 +1558,16 @@ context_mod_list:
                if (!SCM_UNBNDP ($2))
                        unsmob<Context_mod> ($1)->add_context_mod ($2);
         }
-        | context_mod_list CONTEXT_MOD_IDENTIFIER {
-                 Context_mod *md = unsmob<Context_mod> ($2);
-                 if (md)
-                     unsmob<Context_mod> ($1)->add_context_mods (md->get_mods ());
-        }
        | context_mod_list context_mod_arg {
-               if (scm_is_eq ($2, SCM_UNSPECIFIED))
-                       ;
-               else if (unsmob<Music> ($2)) {
+               if (unsmob<Music> ($2)) {
                        SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
                        $2 = scm_call_1 (proc, $2);
                }
                if (unsmob<Context_mod> ($2))
                        unsmob<Context_mod> ($$)->add_context_mods
                                (unsmob<Context_mod> ($2)->get_mods ());
-               else {
+               else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
                        parser->parser_error (@2, _ ("not a context mod"));
-               }
         }
         ;
 
@@ -2965,15 +2942,11 @@ event_chord:
                }
        } %prec ':'
        | CHORD_REPETITION optional_notemode_duration post_events {
-               Input i;
-               i.set_location (@1, @3);
-               $$ = MAKE_SYNTAX (repetition_chord, i,
+               $$ = MAKE_SYNTAX (repetition_chord, @$,
                                  $2, scm_reverse_x ($3, SCM_EOL));
        } %prec ':'
        | MULTI_MEASURE_REST optional_notemode_duration post_events {
-               Input i;
-               i.set_location (@1, @3);
-               $$ = MAKE_SYNTAX (multi_measure_rest, i, $2,
+               $$ = MAKE_SYNTAX (multi_measure_rest, @$, $2,
                                  scm_reverse_x ($3, SCM_EOL));
        } %prec ':'
        | tempo_event
@@ -4097,7 +4070,7 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                return SCM_IDENTIFIER;
         } else if (unsmob<Context_mod> (sid)) {
                 *destination = unsmob<Context_mod> (sid)->smobbed_copy ();
-                return CONTEXT_MOD_IDENTIFIER;
+                return SCM_IDENTIFIER;
        } else if (Music *mus = unsmob<Music> (sid)) {
                mus = mus->clone ();
                *destination = mus->self_scm ();