]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 2854: parser.yy: remove STRING_IDENTIFIER token
authorDavid Kastrup <dak@gnu.org>
Sat, 22 Sep 2012 13:35:42 +0000 (15:35 +0200)
committerDavid Kastrup <dak@gnu.org>
Wed, 26 Sep 2012 08:48:00 +0000 (10:48 +0200)
A STRING_IDENTIFIER always was a special case of a MARKUP_IDENTIFIER
without being treated equally at top level.  That led to craziness
like

xxx=\markup "test"
\xxx

being invalid, while

xxx=\markup \italic "test"
\xxx

was valid code.  This change just removes the STRING_IDENTIFIER
category altogether.  Where it was used previously, MARKUP_IDENTIFIER
is accepted now syntactically, and where the semantics indeed require
a plain string, an error is generated explicitly in the action instead
of leaving it to the parser to complain about bad grammar.

lily/parser.yy

index 19c0d90624c52eaa0bcb0083df5ded045eabf2f5..a50957fa8bb07ba2f07bf3ab0daa1f1133f229ca 100644 (file)
@@ -380,7 +380,6 @@ If we give names, Bison complains.
 %token SCM_TOKEN
 %token SCORE_IDENTIFIER
 %token STRING
-%token STRING_IDENTIFIER
 %token TONICNAME_PITCH
 
 %left '-' '+'
@@ -473,7 +472,6 @@ embedded_scm_bare:
 embedded_scm_bare_arg:
        embedded_scm_bare
        | STRING
-       | STRING_IDENTIFIER
        | full_markup
        | full_markup_list
        | context_modification
@@ -576,7 +574,6 @@ identifier_init:
        | FRACTION
        | string
         | embedded_scm
-       | full_markup
        | full_markup_list
         | context_modification
        ;
@@ -1859,10 +1856,16 @@ string:
        STRING {
                $$ = $1;
        }
-       | STRING_IDENTIFIER {
-               $$ = $1;
-       }
+       | full_markup
        | string '+' string {
+               if (!scm_is_string ($1)) {
+                       parser->parser_error (@1, (_ ("simple string expected")));
+                       $1 = scm_string (SCM_EOL);
+               }
+               if (!scm_is_string ($3)) {
+                       parser->parser_error (@3, (_ ("simple string expected")));
+                       $3 = scm_string (SCM_EOL);
+               }
                $$ = scm_string_append (scm_list_2 ($1, $3));
        }
        ;
@@ -1873,8 +1876,23 @@ simple_string: STRING {
        | LYRICS_STRING {
                $$ = $1;
        }
-       | STRING_IDENTIFIER {
-               $$ = $1;
+       | MARKUP_IDENTIFIER
+       {
+               if (scm_is_string ($1)) {
+                       $$ = $1;
+               } else {
+                       parser->parser_error (@1, (_ ("simple string expected")));
+                       $$ = scm_string (SCM_EOL);
+               }
+       }
+       | LYRIC_MARKUP_IDENTIFIER
+       {
+               if (scm_is_string ($1)) {
+                       $$ = $1;
+               } else {
+                       parser->parser_error (@1, (_ ("simple string expected")));
+                       $$ = scm_string (SCM_EOL);
+               }
        }
        ;
 
@@ -2309,7 +2327,13 @@ gen_text_def:
                t->set_property ("text", $1);
                $$ = t->unprotect ();
        }
-       | simple_string {
+       | STRING {
+               Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
+               t->set_property ("text",
+                       make_simple_markup ($1));
+               $$ = t->unprotect ();
+       }
+       | LYRICS_STRING {
                Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
                t->set_property ("text",
                        make_simple_markup ($1));
@@ -2974,9 +2998,6 @@ simple_markup:
        | LYRIC_MARKUP_IDENTIFIER {
                $$ = $1;
        }
-       | STRING_IDENTIFIER {
-               $$ = $1;
-       }
        | SCORE {
                SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
                parser->lexer_->push_note_state (nn);
@@ -3032,10 +3053,7 @@ otherwise, we have to import music classes into the lexer.
 int
 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
 {
-       if (scm_is_string (sid)) {
-               *destination = sid;
-               return STRING_IDENTIFIER;
-       } else if (unsmob_book (sid)) {
+       if (unsmob_book (sid)) {
                Book *book =  unsmob_book (sid)->clone ();
                *destination = book->self_scm ();
                book->unprotect ();