]> git.donarmstrong.com Git - lilypond.git/commitdiff
parser.yy: allow postevents in function arguments in general
authorDavid Kastrup <dak@gnu.org>
Sat, 5 Nov 2011 09:26:17 +0000 (10:26 +0100)
committerDavid Kastrup <dak@gnu.org>
Thu, 10 Nov 2011 09:58:06 +0000 (10:58 +0100)
lily/parser.yy

index 281c7eff13cc5c76119ece6fb1a1be601d97addb..8d7f82eeb7f5b7bec71a2e2d712628dab5af032a 100644 (file)
@@ -463,7 +463,6 @@ If we give names, Bison complains.
 %type <scm> embedded_scm_bare_arg
 %type <scm> embedded_scm_closed
 %type <scm> embedded_scm_chord_body
-%type <scm> embedded_scm_event
 %type <scm> event_function_event
 %type <scm> figure_list
 %type <scm> figure_spec
@@ -506,7 +505,6 @@ If we give names, Bison complains.
 %type <scm> mode_changing_head_with_context
 %type <scm> multiplied_duration
 %type <scm> music_function_event
-%type <scm> music_function_event_arglist
 %type <scm> music_function_chord_body
 %type <scm> music_function_chord_body_arglist
 %type <scm> new_chord
@@ -1278,6 +1276,10 @@ function_arglist_nonbackup:
        {
                $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
        }
+       | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed post_event
+       {
+               $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
+       }
        ;
 
 
@@ -1302,6 +1304,16 @@ function_arglist_backup:
                        MYBACKUP (SCM_IDENTIFIER, $4, @4);
                }
        }
+       | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_keep post_event
+       {
+               if (scm_is_true (scm_call_1 ($2, $4)))
+               {
+                       $$ = scm_cons ($4, $3);
+               } else {
+                       $$ = scm_cons (loc_on_music (@3, $1), $3);
+                       MYBACKUP (EVENT_IDENTIFIER, $4, @4);
+               }
+       }
        | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep lyric_element
        {
                // There is no point interpreting a lyrics string as
@@ -1413,6 +1425,11 @@ function_arglist_common:
                $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
                                       $3, $2, $1);
        }
+       | EXPECT_SCM function_arglist_closed_optional post_event
+       {
+               $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
+                                      $3, $2, $1);
+       }
        | function_arglist_common_lyric
        ;
 
@@ -1473,6 +1490,11 @@ function_arglist_closed_common:
                $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
                                       $3, $2, $1);
        }
+       | EXPECT_SCM function_arglist_closed_optional post_event
+       {
+               $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
+                                      $3, $2, $1);
+       }
        | EXPECT_SCM function_arglist_closed_optional FRACTION
        {
                $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
@@ -2012,41 +2034,20 @@ music_function_chord_body:
        }
        ;
 
-/* We could accept a closed music argument before the post events
- * indicated by a trailing argument list.  For symmetry with chord
- * bodies and in order to avoid too tricky and complex behavior, we
- * refrain from doing so.
- */
-music_function_event_arglist:
-       function_arglist_bare
-       | EXPECT_SCM music_function_event_arglist embedded_scm_event
-       {
-               $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
-                                      $3, $2, $1);
-       }
-       ;
-
-embedded_scm_event:
-       embedded_scm_bare_arg
-       | SCM_FUNCTION music_function_event_arglist {
-               $$ = MAKE_SYNTAX ("music-function", @$,
-                                        $1, $2);
-       }
-       | bare_number
-       | fraction
-       | lyric_element
-       | post_event
-       ;
+// Event functions may only take closed arglists, otherwise it would
+// not be clear whether a following postevent should be associated
+// with the last argument of the event function or with the expression
+// for which the function call acts itself as event.
 
 music_function_event:
-       MUSIC_FUNCTION music_function_event_arglist {
+       MUSIC_FUNCTION function_arglist_closed {
                $$ = MAKE_SYNTAX ("music-function", @$,
                                         $1, $2);
        }
        ;
 
 event_function_event:
-       EVENT_FUNCTION music_function_event_arglist {
+       EVENT_FUNCTION function_arglist_closed {
                $$ = MAKE_SYNTAX ("music-function", @$,
                                         $1, $2);
        }
@@ -2318,7 +2319,7 @@ gen_text_def:
                t->set_property ("text", $1);
                $$ = t->unprotect ();
        }
-       | string {
+       | simple_string {
                Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
                t->set_property ("text",
                        make_simple_markup ($1));