]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
Issue 3516: Let parser accept symbols after \new, \context, \unset and implicit \set
[lilypond.git] / lily / parser.yy
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