From: David Kastrup Date: Sun, 25 Aug 2013 15:53:27 +0000 (+0200) Subject: Issue 3516: Let parser accept symbols after \new, \context, \unset and implicit \set X-Git-Tag: release/2.17.26-1~18^2~5 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=3c6b011ceedc9f3eb7908acac19cf7fe7bf54f5c;p=lilypond.git Issue 3516: Let parser accept symbols after \new, \context, \unset and implicit \set After the symbol list changes of issue 2883, not allowing single symbols in these places seems like an anachronism. --- diff --git a/lily/parser.yy b/lily/parser.yy index 53bddf5eaf..5ac60f65bc 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1877,14 +1877,14 @@ complex_music: ; complex_music_prefix: - CONTEXT simple_string optional_id optional_context_mod { + CONTEXT symbol optional_id optional_context_mod { Context_mod *ctxmod = unsmob_context_mod ($4); SCM mods = SCM_EOL; if (ctxmod) mods = ctxmod->get_mods (); $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F); } - | NEWCONTEXT simple_string optional_id optional_context_mod { + | NEWCONTEXT symbol optional_id optional_context_mod { Context_mod *ctxmod = unsmob_context_mod ($4); SCM mods = SCM_EOL; if (ctxmod) @@ -2024,13 +2024,11 @@ property_path: ; property_operation: - STRING '=' scalar { - $$ = scm_list_3 (ly_symbol2scm ("assign"), - scm_string_to_symbol ($1), $3); + symbol '=' scalar { + $$ = scm_list_3 (ly_symbol2scm ("assign"), $1, $3); } - | UNSET simple_string { - $$ = scm_list_2 (ly_symbol2scm ("unset"), - scm_string_to_symbol ($2)); + | UNSET symbol { + $$ = scm_list_2 (ly_symbol2scm ("unset"), $2); } | OVERRIDE property_path '=' scalar { if (scm_ilength ($2) < 2) { @@ -2296,6 +2294,26 @@ simple_string: STRING { } ; +symbol: + STRING { + $$ = scm_string_to_symbol ($1); + } + | embedded_scm_bare + { + // This is a bit of overkill but makes the same + // routine responsible for all symbol interpretations. + $$ = try_string_variants (ly_lily_module_constant ("symbol?"), + $1); + if (SCM_UNBNDP ($$)) + { + parser->parser_error (@1, (_ ("symbol expected"))); + // Generate a unique symbol in case it is used + // for an assignment or similar + $$ = scm_make_symbol (ly_string2scm ("undefined")); + } + } + ; + scalar: embedded_scm_arg | SCM_IDENTIFIER diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm index 01fc9bcef8..8b6f4ffefb 100644 --- a/scm/ly-syntax-constructors.scm +++ b/scm/ly-syntax-constructors.scm @@ -152,8 +152,7 @@ into a @code{MultiMeasureTextEvent}." 'origin location)) (define-ly-syntax-simple (context-specification type id ops create-new mus) - (let* ((type-sym (if (symbol? type) type (string->symbol type))) - (csm (context-spec-music mus type-sym id))) + (let ((csm (context-spec-music mus type id))) (set! (ly:music-property csm 'property-operations) ops) (if create-new (set! (ly:music-property csm 'create-new) #t)) csm))