From 3b617fc949192eacf627413dac0420ebc54aebf6 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sun, 15 Sep 2013 15:53:51 +0200 Subject: [PATCH] Issue 3555: Parse context definitions and context modifications in \notemode 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 | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lily/parser.yy b/lily/parser.yy index daf25c94ae..a99dffcf38 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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; -- 2.39.5