]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3516: Let parser accept symbols after \new, \context, \unset and implicit \set
authorDavid Kastrup <dak@gnu.org>
Sun, 25 Aug 2013 15:53:27 +0000 (17:53 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 30 Aug 2013 07:17:12 +0000 (09:17 +0200)
After the symbol list changes of issue 2883, not allowing single
symbols in these places seems like an anachronism.

lily/parser.yy
scm/ly-syntax-constructors.scm

index 53bddf5eaf64dcf48824e05740d20d330919faab..5ac60f65bc4aa3c3aaf08bc10c494b0bf2a31a09 100644 (file)
@@ -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
index 01fc9bcef820c41cdc6c6add54c9b7459f5efb7c..8b6f4ffefbf01c2ff05fdedce13467e679872e1e 100644 (file)
@@ -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))