From 50feadce8c92ae4e9b8de85fe55dd775054f2572 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Mon, 30 Jul 2012 18:10:13 +0200 Subject: [PATCH] Issue 2705: Parse music inside of output definitions in "notes" mode. This makes \midi { \tempo 4. = 120 } work properly (without parsing 4. as a REAL token). The next token after music will in rare circumstances be scanned still in the lexer's "notes" mode. This could be problematic because of the currently different word syntax of "notes" and "INITIAL" mode (cf. issue 2702). --- lily/parser.yy | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/lily/parser.yy b/lily/parser.yy index cee385cc7d..3365511158 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -406,6 +406,7 @@ If we give names, Bison complains. %type music_arg %type music_assign %type music_embedded +%type music_or_context_def %type complex_music %type complex_music_prefix %type mode_changed_music @@ -1091,6 +1092,25 @@ output_def_head_with_mode_switch: } ; +// We need this weird nonterminal because both music as well as a +// context definition can start with \context and the difference is +// only apparent after looking at the next token. If it is '{', there +// is still time to escape from notes mode. + +music_or_context_def: + music_arg + { + parser->lexer_->pop_state (); + } + | CONTEXT + { + parser->lexer_->pop_state (); + } '{' context_def_spec_body '}' + { + $$ = $4; + } + ; + output_def_body: output_def_head_with_mode_switch '{' { $$ = $1; @@ -1109,12 +1129,21 @@ output_def_body: | output_def_body assignment { } - | output_def_body context_def_spec_block { - assign_context_def ($$, $2); - } - | output_def_body music_arg { - SCM proc = parser->lexer_->lookup_identifier ("output-def-music-handler"); - scm_call_3 (proc, parser->self_scm (), $1->self_scm (), $2); + | output_def_body + { + SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); + parser->lexer_->push_note_state (nn); + } music_or_context_def + { + if (unsmob_context_def ($3)) + assign_context_def ($$, $3); + else { + + SCM proc = parser->lexer_->lookup_identifier + ("output-def-music-handler"); + scm_call_3 (proc, parser->self_scm (), + $1->self_scm (), $3); + } } | output_def_body error { -- 2.39.2