]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
Let make_music_from_simple accept numbers/durations
[lilypond.git] / lily / parser.yy
index 35d0aa48dc40cd46df5961780c6f8f2fab2d822e..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_);
@@ -3671,7 +3683,7 @@ full_markup:
        ;
 
 partial_markup:
-       markup_mode markup_head_1_list ETC
+       markup_mode markup_partial_function ETC
        {
                $$ = MAKE_SYNTAX (partial_markup, @2, $2);
                parser->lexer_->pop_state ();
@@ -3693,7 +3705,7 @@ markup_top:
        ;
 
 markup_scm:
-       embedded_scm_bare
+       embedded_scm
        {
                if (Text_interface::is_markup ($1))
                        MYBACKUP (MARKUP_IDENTIFIER, $1, @1);
@@ -3789,6 +3801,37 @@ markup_command_list_arguments:
        }
        ;
 
+markup_partial_function:
+       MARKUP_FUNCTION markup_arglist_partial
+       {
+               $$ = scm_list_1 (scm_cons ($1, scm_reverse_x ($2, SCM_EOL)));
+       }
+       | markup_head_1_list MARKUP_FUNCTION markup_arglist_partial
+       {
+               $$ = scm_cons (scm_cons ($2, scm_reverse_x ($3, SCM_EOL)),
+                              $1);
+       }
+       ;
+
+markup_arglist_partial:
+       EXPECT_MARKUP markup_arglist_partial
+       {
+               $$ = $2;
+       }
+       | EXPECT_SCM markup_arglist_partial
+       {
+               $$= $2;
+       }
+       | EXPECT_MARKUP markup_command_list_arguments
+       {
+               $$ = $2;
+       }
+       | EXPECT_SCM markup_command_list_arguments
+       {
+               $$ = $2;
+       }
+       ;
+
 markup_head_1_item:
        MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
          $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
@@ -4061,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))