From 730386c10cc3a8a73f6e27d0c9ed0cb150ff607c Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Thu, 25 Feb 2016 14:04:00 +0100 Subject: [PATCH] parser.yy: factor out "multipliers" from "multiplied_duration" --- lily/parser.yy | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/lily/parser.yy b/lily/parser.yy index 55a6ad41a6..e85aa336e5 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -3218,16 +3218,12 @@ steno_duration: ; multiplied_duration: - steno_duration { - $$ = $1; - } - | multiplied_duration '*' UNSIGNED { - $$ = unsmob ($$)->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 ($$)->compressed (m).smobbed_copy (); + steno_duration multipliers { + if (scm_is_number ($2)) { + Rational m (ly_scm2rational ($2)); + $$ = unsmob ($1)->compressed (m).smobbed_copy (); + } else + $$ = $1; } ; @@ -3240,6 +3236,28 @@ dots: } ; +multipliers: + /* empty */ + { + $$ = SCM_UNSPECIFIED; + } + | multipliers '*' UNSIGNED + { + if (scm_is_number ($1)) + $$ = scm_product ($1, $3); + else + $$ = $3; + } + | multipliers '*' FRACTION + { + if (scm_is_number ($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_); -- 2.39.2