lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make music functions and identifiers and expressions take articulati


From: dak
Subject: Re: Make music functions and identifiers and expressions take articulations (issue 78690043)
Date: Fri, 21 Mar 2014 08:40:26 +0000

Reviewers: lemzwerg,

Message:
On 2014/03/21 08:27:41, lemzwerg wrote:
LGTM.  Does this change deserve a regtest?

It deserves several regtests, change entry, documentation, and probably
additional work to cover more cases.  There are LSR examples and Scheme
programming examples based on the premise that you cannot add
articulations in LilyPond once a music expression has left the parser.

Doing this thoroughly is a lot more work.  Still, this change should in
the current form hopefully not affect currently valid programs: at least
it did not require additional precedence rules and did not cause
reduce/reduce conflicts.  That's not a full guarantee (if there are new
conflicts, existing precedence rules might suffice to resolve them, but
with changed results).  But if this passes regtests, it is at least
encouraging.

Description:
Make music functions and identifiers and expressions take articulations

Since the resulting mess would be too large when doing this in music
function arguments and similar locations, for now this is possible only
inside of chords and inside of music sequences.

Please review this at https://codereview.appspot.com/78690043/

Affected files (+43, -5 lines):
  M lily/parser.yy


Index: lily/parser.yy
diff --git a/lily/parser.yy b/lily/parser.yy
index b89c561ea806d6e8404d69800fb7201f67c9177e..aa33e6455d53c8f6da2c3ca3cfed6d583d2c1ac9 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -221,6 +221,7 @@ SCM make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list);
 SCM make_chord_step (SCM step, Rational alter);
 SCM make_simple_markup (SCM a);
 SCM make_duration (SCM t, int dots = 0);
+SCM add_articulations (Lily_parser *parser, Input loc, SCM mus, Input loc2, SCM arts);
 bool is_regular_identifier (SCM id, bool multiple=false);
 SCM try_string_variants (SCM pred, SCM str);
 int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser);
@@ -1189,16 +1190,20 @@ music:  music_assign
        ;

 music_embedded:
-       music
+       music post_events
        {
                if (unsmob_music ($1)->is_mus_type ("post-event")) {
                        parser->parser_error (@1, _ ("unexpected post-event"));
                        $$ = SCM_UNSPECIFIED;
+               } else {
+                       $$ = add_articulations (parser, @1, $1, @2,
+                                               scm_reverse_x ($2, SCM_EOL));
                }
        }
-       | music_embedded_backup
+       | music_embedded_backup post_events
        {
-               $$ = $1;
+               $$ = add_articulations (parser, @1, $1, @2,
+                                       scm_reverse_x ($2, SCM_EOL));
        }
        | music_embedded_backup BACKUP lyric_element_music
        {
@@ -2646,7 +2651,7 @@ chord_body_element:
                }
                $$ = n->unprotect ();
        }
-       | music_function_chord_body
+       | music_function_chord_body post_events
        {
                Music *m = unsmob_music ($1);

@@ -2658,7 +2663,9 @@ chord_body_element:
                if (!(m && m->is_mus_type ("rhythmic-event"))) {
                        parser->parser_error (@$, _ ("not a rhythmic event"));
                        $$ = SCM_UNDEFINED;
-               }
+               } else
+                       $$ = add_articulations (parser, @1, $$, @2,
+                                               scm_reverse_x ($2, SCM_EOL));
        }
        ;

@@ -3862,6 +3869,37 @@ make_duration (SCM d, int dots)
 }

 SCM
+add_articulations (Lily_parser *parser, Input loc, SCM mus, Input loc2, SCM arts)
+{
+       if (scm_is_pair (arts))
+       {
+               Music *m = unsmob_music (mus);
+               if (m && m->is_mus_type ("rhythmic-event")) {
+                       Input i;
+                       i.set_location (loc, loc2);
+                       m->set_spot(i);
+                       m->set_property
+                               ("articulations",
+                                scm_append (scm_list_2
+                                            (m->get_property("articulations"),
+                                             arts)));
+               }
+               else if (m && m->is_mus_type ("event-chord")) {
+                       Input i;
+                       i.set_location (loc, loc2);
+                       m->set_spot(i);
+                       m->set_property
+                               ("elements",
+                                scm_append (scm_list_2
+                                            (m->get_property("elements"),
+                                             arts)));
+               } else
+ parser->parser_error (loc, _("need rhythmic event or chord for articulations"));
+       }
+       return mus;
+}
+
+SCM
 make_chord_step (SCM step_scm, Rational alter)
 {
         int step = scm_to_int (step_scm);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]