[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for Dlang support 1/4] Changed rule that was interpreting +nu
From: |
Akim Demaille |
Subject: |
Re: [PATCH for Dlang support 1/4] Changed rule that was interpreting +number as -number |
Date: |
Wed, 2 Sep 2020 07:41:22 +0200 |
Hi Adela,
> Le 1 sept. 2020 à 20:54, Adela Vais <adela.vais99@gmail.com> 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 <adela.vais99@gmail.com>
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; }
;