]> git.donarmstrong.com Git - lilypond.git/commitdiff
Allow music identifiers in \addlyrics (no need for braces any more)
authorReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 29 Oct 2010 14:21:46 +0000 (16:21 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 22 Nov 2010 14:18:35 +0000 (15:18 +0100)
In particular, so far the following did not work:
    \new Staff { \m \addlyrics \l }
Instead, one had to use braces around \m and \l:
    \new Staff { {\m} \addlyrics {\l} }

This patch extends the parser to allow music identifiers,
so that no braces are needed any more.

input/regression/newaddlyrics-music-identifiers.ly [new file with mode: 0644]
lily/parser.yy

diff --git a/input/regression/newaddlyrics-music-identifiers.ly b/input/regression/newaddlyrics-music-identifiers.ly
new file mode 100644 (file)
index 0000000..61b91ef
--- /dev/null
@@ -0,0 +1,14 @@
+\version "2.13.38"
+
+\header {
+       texidoc = "addlyrics do not need braces around their arguments,
+in particular if the arguments are variables."
+}
+
+m = \relative c' { c4 d }
+l = \lyricmode { A B }
+
+% addlyrics takes music expressions as well as music identifiers. The following
+% two staves should produce the same output:
+\new Staff { {\m} \addlyrics {\l} }
+\new Staff { \m \addlyrics \l }
index abcf101386d6da55e5c7f6a511afeeadb77d3eeb..38e3e93b101d5ba40aeb2457b81df4eab8d1894a 100644 (file)
@@ -1261,18 +1261,33 @@ new_lyrics:
 
                $$ = scm_cons ($3, SCM_EOL);
        }
+       | ADDLYRICS {
+               PARSER->lexer_->push_lyric_state (); }
+       MUSIC_IDENTIFIER {
+               PARSER->lexer_->pop_state ();
+               $$ = scm_cons ($3, SCM_EOL);
+       }
        | new_lyrics ADDLYRICS {
                PARSER->lexer_->push_lyric_state ();
        } grouped_music_list {
                PARSER->lexer_->pop_state ();
                $$ = scm_cons ($4, $1);
        }
+       | new_lyrics ADDLYRICS {
+               PARSER->lexer_->push_lyric_state ();
+       } MUSIC_IDENTIFIER {
+               PARSER->lexer_->pop_state ();
+               $$ = scm_cons ($4, $1);
+       }
        ;
 
 re_rhythmed_music:
        grouped_music_list new_lyrics {
                $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
        }
+       | MUSIC_IDENTIFIER new_lyrics {
+               $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
+       }
        | LYRICSTO simple_string {
                PARSER->lexer_->push_lyric_state ();
        } music {