Report rules which are never reduced by the parser: those hidden

by conflicts.
* src/LR0.c (save_reductions): Don't make the final state too
different: save its reduction (accept) instead of having a state
without any action (no shift or goto, no reduce).
Note: the final state is now a ``regular'' state, i.e., the
parsers now contain `reduce 0' as default reduction.
Nevertheless, since they decide to `accept' when yystate =
final_state, they still will not reduce rule 0.
* src/print.c (print_actions, print_reduction): Adjust.
* src/output.c (action_row): Track reduced rules.
(token_actions): Report rules never reduced.
* tests/conflicts.at, tests/regression.at: Adjust.
This commit is contained in:
Akim Demaille
2002-07-30 11:06:50 +00:00
parent caf23d249c
commit e8832397ea
7 changed files with 68 additions and 30 deletions

View File

@@ -37,7 +37,9 @@ exp: e 'e';
e: 'e' | /* Nothing. */;
]])
AT_CHECK([bison input.y -o input.c])
AT_CHECK([bison input.y -o input.c], 0, [],
[[input.y:4.8: warning: rule never reduced because of conflicts: e: /* empty */
]])
AT_CLEANUP
@@ -203,7 +205,7 @@ state 3
0 $accept: exp $end .
$default accept
$default accept
state 4
@@ -306,7 +308,7 @@ state 3
0 $accept: exp $end .
$default accept
$default accept
state 4
@@ -369,8 +371,9 @@ id : '0';
]])
AT_CHECK([bison input.y -o input.c --report=all], 0, [],
[input.y contains 1 reduce/reduce conflict.
])
[[input.y contains 1 reduce/reduce conflict.
input.y:4.4-8: warning: rule never reduced because of conflicts: id: '0'
]])
# Check the contents of the report.
AT_CHECK([cat input.output], [],
@@ -458,7 +461,7 @@ state 5
0 $accept: exp $end .
$default accept
$default accept
]])
AT_CLEANUP

View File

@@ -228,7 +228,7 @@ state 5
0 $accept: expr $end .
$default accept
$default accept
state 6
@@ -456,7 +456,7 @@ state 5
0 $accept: CONST_DEC_PART $end .
$default accept
$default accept
state 6
@@ -601,7 +601,7 @@ static const unsigned char yyr2[] =
};
static const unsigned char yydefact[] =
{
3, 0, 0, 2, 0, 0, 0, 3, 4, 3,
3, 0, 0, 2, 0, 0, 1, 3, 4, 3,
6, 5
};
static const signed char yydefgoto[] =