From dfb68d00300d837d723605790d1833b088faee9a Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Fri, 29 Oct 2010 16:21:46 +0200 Subject: [PATCH] Allow music identifiers in \addlyrics (no need for braces any more) 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. --- .../regression/newaddlyrics-music-identifiers.ly | 14 ++++++++++++++ lily/parser.yy | 15 +++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 input/regression/newaddlyrics-music-identifiers.ly diff --git a/input/regression/newaddlyrics-music-identifiers.ly b/input/regression/newaddlyrics-music-identifiers.ly new file mode 100644 index 0000000000..61b91efa69 --- /dev/null +++ b/input/regression/newaddlyrics-music-identifiers.ly @@ -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 } diff --git a/lily/parser.yy b/lily/parser.yy index abcf101386..38e3e93b10 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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 { -- 2.39.5