]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
Let make_music_from_simple accept numbers/durations
[lilypond.git] / lily / parser.yy
index c60c6ed64c1157fa00e516efdcd98b8cb9e9eb0b..1cbb98f35f8860efd2fda3416212df5b3186e547 100644 (file)
@@ -1756,7 +1756,7 @@ function_arglist_nonbackup:
                                               (parser, @3, $3),
                                               $1, $2);
        }
-       | function_arglist_nonbackup_reparse REPARSE duration_length
+       | function_arglist_nonbackup_reparse REPARSE multiplied_duration
        {
                $$ = check_scheme_arg (parser, @3, $3, $1, $2);
        }
@@ -2073,7 +2073,7 @@ function_arglist_backup:
                $$ = check_scheme_arg (parser, @3,
                                       $3, $1, $2);
        }
-       | function_arglist_backup REPARSE duration_length
+       | function_arglist_backup REPARSE multiplied_duration
        {
                $$ = check_scheme_arg (parser, @3,
                                       $3, $1, $2);
@@ -2204,7 +2204,7 @@ function_arglist_common:
                $$ = check_scheme_arg (parser, @3,
                                       $3, $1, $2);
        }
-       | function_arglist_common_reparse REPARSE duration_length
+       | function_arglist_common_reparse REPARSE multiplied_duration
        {
                $$ = check_scheme_arg (parser, @3,
                                       $3, $1, $2);
@@ -3179,12 +3179,6 @@ script_dir:
        | '-'   { $$ = SCM_UNDEFINED; }
        ;
 
-duration_length:
-       multiplied_duration {
-               $$ = $1;
-       }
-       ;
-
 maybe_notemode_duration:
        {
                $$ = SCM_UNDEFINED;
@@ -3224,16 +3218,12 @@ steno_duration:
        ;
 
 multiplied_duration:
-       steno_duration {
-               $$ = $1;
-       }
-       | multiplied_duration '*' UNSIGNED {
-               $$ = unsmob<Duration> ($$)->compressed (scm_to_int ($3)).smobbed_copy ();
-       }
-       | multiplied_duration '*' FRACTION {
-               Rational  m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
-
-               $$ = unsmob<Duration> ($$)->compressed (m).smobbed_copy ();
+       steno_duration multipliers {
+               if (scm_is_number ($2)) {
+                       Rational m (ly_scm2rational ($2));
+                       $$ = unsmob<Duration> ($1)->compressed (m).smobbed_copy ();
+               } else
+                       $$ = $1;
        }
        ;
 
@@ -3246,6 +3236,28 @@ dots:
        }
        ;
 
+multipliers:
+       /* empty */
+       {
+               $$ = SCM_UNDEFINED;
+       }
+       | multipliers '*' UNSIGNED
+       {
+               if (!SCM_UNBNDP ($1))
+                       $$ = scm_product ($1, $3);
+               else
+                       $$ = $3;
+       }
+       | multipliers '*' FRACTION
+       {
+               if (!SCM_UNBNDP ($1))
+                       $$ = scm_product ($1, scm_divide (scm_car ($3),
+                                                         scm_cdr ($3)));
+               else
+                       $$ = scm_divide (scm_car ($3), scm_cdr ($3));
+       }
+       ;
+
 tremolo_type:
        ':'     {
                $$ = scm_from_int (parser->default_tremolo_type_);
@@ -3693,7 +3705,7 @@ markup_top:
        ;
 
 markup_scm:
-       embedded_scm_bare
+       embedded_scm
        {
                if (Text_interface::is_markup ($1))
                        MYBACKUP (MARKUP_IDENTIFIER, $1, @1);
@@ -4092,6 +4104,14 @@ make_music_from_simple (Lily_parser *parser, Input loc, SCM simple)
                        n->set_property ("pitch", simple);
                        return n->unprotect ();
                }
+               SCM d = simple;
+               if (scm_is_integer (simple))
+                       d = make_duration (simple);
+               if (unsmob<Duration> (d)) {
+                       Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
+                       n->set_property ("duration", d);
+                       return n->unprotect ();
+               }
                return simple;
        } else if (parser->lexer_->is_lyric_state ()) {
                if (Text_interface::is_markup (simple))