mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
examples: d: fix the handling of unary +
It was interpreting "+exp" as "-exp". * examples/d/calc.y: Fix. * examples/d/calc.test: Check it.
This commit is contained in:
committed by
Akim Demaille
parent
325ec7d324
commit
f3bcb3de0e
@@ -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
|
||||
|
||||
@@ -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; }
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user