]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3555: Parse context definitions and context modifications in \notemode
authorDavid Kastrup <dak@gnu.org>
Sun, 15 Sep 2013 13:53:51 +0000 (15:53 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 20 Sep 2013 15:08:23 +0000 (17:08 +0200)
Since context modifications and context definitions are somewhat more
concerned with musical content, it makes sense to parse them in a mode
where note names are recognized and can be used in music and scheme
function arguments.

The main argument for a separate INITIAL lexer mode is for being able
to specify REAL number values in a lenient syntax, such as .5\cm.
However, dimensions are almost never used in context definitions
or modifications but rather in output definitions like layout, midi,
paper and header blocks.

lily/parser.yy

index daf25c94ae1bb3ce0974d0ea48ba77b076fc7bf4..a99dffcf3889056a2e4e01d128fd67639acc1bf4 100644 (file)
@@ -947,17 +947,7 @@ output_def_head_with_mode_switch:
 
 music_or_context_def:
        music_arg
-       {
-               parser->lexer_->pop_state ();
-       }
-       | CONTEXT
-       {
-               parser->lexer_->pop_state ();
-       } '{' context_def_spec_body '}'
-       {
-               $$ = $4;
-               unsmob_context_def ($$)->origin ()->set_spot (@$);
-       }
+       | context_def_spec_block
        ;
 
 output_def_body:
@@ -984,6 +974,7 @@ output_def_body:
                parser->lexer_->push_note_state (nn);
        } music_or_context_def
        {
+               parser->lexer_->pop_state ();
                if (unsmob_context_def ($3))
                        assign_context_def (unsmob_output_def ($1), $3);
                else {
@@ -1133,7 +1124,11 @@ simple_music:
        ;
 
 context_modification:
-        WITH { parser->lexer_->push_initial_state (); } '{' context_mod_list '}'
+        WITH
+       {
+               SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
+               parser->lexer_->push_note_state (nn);
+       } '{' context_mod_list '}'
         {
                 parser->lexer_->pop_state ();
                 $$ = $4;