Hi Adela, > Le 1 sept. 2020 à 20:54, Adela Vais <[email protected]> a écrit : > > --- > examples/d/calc.y | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/examples/d/calc.y b/examples/d/calc.y > index b0dee929..15b4f7c7 100644 > --- a/examples/d/calc.y > +++ b/examples/d/calc.y > @@ -61,7 +61,7 @@ exp: > | exp "-" exp { $$ = $1 - $3; } > | exp "*" exp { $$ = $1 * $3; } > | exp "/" exp { $$ = $1 / $3; } > -| "+" exp %prec UNARY { $$ = -$2; } > +| "+" exp %prec UNARY { $$ = $2; } > | "-" exp %prec UNARY { $$ = -$2; } > | "(" exp ")" { $$ = $2; } > ;
Thanks! I will install your patch as follows. Please, rewrite your commit messages to match our style (have a look at git log to get some idea). Cheers! commit f3bcb3de0e4bf9eb3e771857917e19aa271b4c30 Author: Adela Vais <[email protected]> Date: Tue Sep 1 21:54:34 2020 +0300 examples: d: fix the handling of unary + It was interpreting "+exp" as "-exp". * examples/d/calc.y: Fix. * examples/d/calc.test: Check it. diff --git a/examples/d/calc.test b/examples/d/calc.test index cf4f80a8..6b237592 100644 --- a/examples/d/calc.test +++ b/examples/d/calc.test @@ -20,6 +20,16 @@ cat >input <<EOF EOF run 0 7 +cat >input <<EOF ++1 + +2 * +3 +EOF +run 0 7 + +cat >input <<EOF +-1 + -2 * -3 +EOF +run 0 5 + cat >input <<EOF 1 + 2 * * 3 EOF diff --git a/examples/d/calc.y b/examples/d/calc.y index b0dee929..15b4f7c7 100644 --- a/examples/d/calc.y +++ b/examples/d/calc.y @@ -61,7 +61,7 @@ exp: | exp "-" exp { $$ = $1 - $3; } | exp "*" exp { $$ = $1 * $3; } | exp "/" exp { $$ = $1 / $3; } -| "+" exp %prec UNARY { $$ = -$2; } +| "+" exp %prec UNARY { $$ = $2; } | "-" exp %prec UNARY { $$ = -$2; } | "(" exp ")" { $$ = $2; } ;
