From 7b486351e47a4459277f0dd4eff5796f76aea50d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 20 Apr 2001 15:44:19 +0200 Subject: [PATCH] patch::: 1.3.149.jcn2 1.3.149.jcn2 ============ * Fixed one more shift/reduce rule in parser: c1/e NOT --- CHANGES | 5 ++++ VERSION | 2 +- input/no-notation/parse5.ly | 12 ++++++++ lily/parser.yy | 58 +++++++++++++++++++++++++++++++++---- 4 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 input/no-notation/parse5.ly diff --git a/CHANGES b/CHANGES index 6ef74cf32f..b7adacbb30 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +1.3.149.jcn2 +============ + +* Fixed one more shift/reduce rule in parser: c1/e NOT + 1.3.149.jcn1 ============ diff --git a/VERSION b/VERSION index 5303002d8d..1139b03c0f 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=149 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/no-notation/parse5.ly b/input/no-notation/parse5.ly new file mode 100644 index 0000000000..da016ea1f0 --- /dev/null +++ b/input/no-notation/parse5.ly @@ -0,0 +1,12 @@ + +\score { + \context ChordNames \chords { + c1 /e % trivial + + c1 * 1/2 % think + c1 * 3 /e % think + + c1 * 1/3 /e % hard + c1/2 % must have parse error here + } +} diff --git a/lily/parser.yy b/lily/parser.yy index 39ebda46bb..bf19d07cc1 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -8,6 +8,13 @@ (c) 1997--2001 Han-Wen Nienhuys Jan Nieuwenhuizen */ + +/* + Two shift/reduce problems: + - + - + */ + #include #include @@ -294,11 +301,33 @@ yylex (YYSTYPE *s, void * v_l) %type script_abbreviation - +/* + left association: must reduce + a - b - c = (a - b) - c + */ %left '-' '+' %left '*' '/' %left UNARY_MINUS + + +/* + multiplied_duration precedence + `* 3 / c' and `* 1 / 2' should be equal, try shift rather than + forced reduce, and take higher precedence than plain `*' and `/' + + -- ugr, but it doesn't really work? input/no-notation/parse5.ly + it seems that: + + %left *forces* reduce + %right *forces* shift + + but we need (the default): *try* shift, and we can't override + above %left '*' '/' with `%prec default setting'? + + */ +%right MUL1 MUL2 INVERSION + %% lilypond: /* empty */ @@ -1584,15 +1613,32 @@ steno_duration: +/* + Multiplied durations are always multiplied, ie, + c1 * INT or c1 * RAT. + + No support for c1 /4 and c1 /2/2. + + '*' and '/' are declared %left, with makes them reduce rather than + shift. + + Because there are no a/b/c association problems anymore, it is + safe to allow '*' and '/' to shift. + + * 1 / 4 shifts to match second rule: '* 1 / 4' + + '/' TONIC_NAME shifts to match rule: chord_inversion + + */ multiplied_duration: steno_duration { $$ = $1; } - | multiplied_duration '*' bare_unsigned { - $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy (); + | multiplied_duration '*' bare_unsigned %prec MUL1 { + $$ = unsmob_duration ($$)->compressed ($3).smobbed_copy (); } - | multiplied_duration '/' bare_unsigned { - $$ = unsmob_duration ($$)->compressed (Moment (1,$3)).smobbed_copy (); + | multiplied_duration '*' bare_unsigned '/' bare_unsigned %prec MUL2 { + $$ = unsmob_duration ($$)->compressed (Moment ($3, $5)).smobbed_copy (); } ; @@ -1751,7 +1797,7 @@ chord_inversion: { $$ = SCM_EOL; } - | '/' steno_tonic_pitch { + | '/' steno_tonic_pitch %prec INVERSION { $$ = $2; } ; -- 2.39.5