Reductions in web2c.y are improperly reported.

Reported by Mike Castle.
* src/conflicts.c (print_reductions): Fix.
* tests/regression.at (Web2c): New.
This commit is contained in:
Akim Demaille
2001-12-22 14:41:15 +00:00
parent 12a04365ce
commit 55b4181996
6 changed files with 121 additions and 6 deletions

View File

@@ -611,3 +611,108 @@ AT_CLEANUP
AT_TEST_CPP_GUARD_H([input/input])
AT_TEST_CPP_GUARD_H([9foo])
## ------- ##
## Web2c. ##
## ------- ##
# The generation of the reduction was once wrong in Bison, and made it
# miss some reductions. In the following test case, the reduction on
# `undef_id_tok' in state 1 was missing. This is stripped down from
# the actual web2c.y.
AT_SETUP([Web2c])
AT_DATA([input.y],
[[%token undef_id_tok const_id_tok
%start CONST_DEC_PART
%%
CONST_DEC_PART:
CONST_DEC_LIST
;
CONST_DEC_LIST:
CONST_DEC
| CONST_DEC_LIST CONST_DEC
;
CONST_DEC:
{ } undef_id_tok '=' const_id_tok ';'
;
%%
]])
AT_CHECK([bison -v input.y])
AT_CHECK([sed -n 's/ *$//;/^$/!p' input.output], 0,
[[Grammar
Number, Line, Rule
1 6 CONST_DEC_PART -> CONST_DEC_LIST
2 10 CONST_DEC_LIST -> CONST_DEC
3 12 CONST_DEC_LIST -> CONST_DEC_LIST CONST_DEC
4 15 @1 -> /* empty */
5 15 CONST_DEC -> @1 undef_id_tok '=' const_id_tok ';'
Terminals, with rules where they appear
$ (-1)
';' (59) 5
'=' (61) 5
error (256)
undef_id_tok (257) 5
const_id_tok (258) 5
Nonterminals, with rules where they appear
CONST_DEC_PART (7)
on left: 1
CONST_DEC_LIST (8)
on left: 2 3, on right: 1 3
CONST_DEC (9)
on left: 5, on right: 2 3
@1 (10)
on left: 4, on right: 5
state 0
$default reduce using rule 4 (@1)
CONST_DEC_PART go to state 9
CONST_DEC_LIST go to state 1
CONST_DEC go to state 2
@1 go to state 3
state 1
CONST_DEC_PART -> CONST_DEC_LIST . (rule 1)
CONST_DEC_LIST -> CONST_DEC_LIST . CONST_DEC (rule 3)
undef_id_tok reduce using rule 4 (@1)
$default reduce using rule 1 (CONST_DEC_PART)
CONST_DEC go to state 4
@1 go to state 3
state 2
CONST_DEC_LIST -> CONST_DEC . (rule 2)
$default reduce using rule 2 (CONST_DEC_LIST)
state 3
CONST_DEC -> @1 . undef_id_tok '=' const_id_tok ';' (rule 5)
undef_id_tok shift, and go to state 5
state 4
CONST_DEC_LIST -> CONST_DEC_LIST CONST_DEC . (rule 3)
$default reduce using rule 3 (CONST_DEC_LIST)
state 5
CONST_DEC -> @1 undef_id_tok . '=' const_id_tok ';' (rule 5)
'=' shift, and go to state 6
state 6
CONST_DEC -> @1 undef_id_tok '=' . const_id_tok ';' (rule 5)
const_id_tok shift, and go to state 7
state 7
CONST_DEC -> @1 undef_id_tok '=' const_id_tok . ';' (rule 5)
';' shift, and go to state 8
state 8
CONST_DEC -> @1 undef_id_tok '=' const_id_tok ';' . (rule 5)
$default reduce using rule 5 (CONST_DEC)
state 9
$ go to state 10
state 10
$ go to state 11
state 11
$default accept
]])
AT_CLEANUP