[PATCH for Dlang support 1/4] examples: d: fix the handling of unary +

Adela Vais <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
It was interpreting "+exp" as "-exp".

* examples/d/calc.y: Fix.
* examples/d/calc.test: Check it.
---
 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; }
 ;
-- 
2.17.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.