From b9752825a023753145900b00a3f16394e183be60 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 22 Dec 2001 14:58:53 +0000 Subject: [PATCH] Some actions of web2c.y are improperly triggered. Reported by Mike Castle. * src/lalr.c (traverse): s/F (i)[k] = F (j)[k]/F (j)[k] = F (i)[k]/. * tests/regression.at (Web2c): Rename as... (Web2c Report): this. (Web2c Actions): New. --- ChangeLog | 10 ++++ src/lalr.c | 2 +- tests/regression.at | 137 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 144 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a10936f6..2950ad52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-12-22 Akim Demaille + + Some actions of web2c.y are improperly triggered. + Reported by Mike Castle. + + * src/lalr.c (traverse): s/F (i)[k] = F (j)[k]/F (j)[k] = F (i)[k]/. + * tests/regression.at (Web2c): Rename as... + (Web2c Report): this. + (Web2c Actions): New. + 2001-12-22 Akim Demaille Reductions in web2c.y are improperly reported. diff --git a/src/lalr.c b/src/lalr.c index a4150cb7..df0865ed 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -103,7 +103,7 @@ traverse (int i) break; for (k = 0; k < size; ++k) - F (i)[k] = F (j)[k]; + F (j)[k] = F (i)[k]; } } diff --git a/tests/regression.at b/tests/regression.at index 2f10d066..bf863671 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -608,16 +608,16 @@ AT_TEST_CPP_GUARD_H([9foo]) -## ------- ## -## Web2c. ## -## ------- ## +## -------------- ## +## Web2c Report. ## +## -------------- ## # 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_SETUP([Web2c Report]) AT_DATA([input.y], [[%token undef_id_tok const_id_tok @@ -708,3 +708,132 @@ state 10 ]]) AT_CLEANUP + + +## --------------- ## +## Web2c Actions. ## +## --------------- ## + +# The generation of the mapping `state -> action' was once wrong in +# extremely specific situations. web2c.y exhibits this situation. +# Below is a stripped version of the grammar. It looks like one can +# simplify it further, but just don't: it is tuned to exhibit a bug, +# which disapears when applying sane grammar transformations. +# +# It used to be wrong on yydefact only: +# +# static const short yydefact[] = +# { +# - 2, 0, 1, 0, 0, 2, 3, 2, 5, 4, +# + 2, 0, 1, 0, 0, 0, 3, 2, 5, 4, +# 0, 0 +# }; +# +# but let's check all the tables. + + +AT_SETUP([Web2c Actions]) + +AT_DATA([input.y], +[[%% +statement: struct_stat; +struct_stat: /* empty. */ | if else; +if: "if" "const" "then" statement; +else: "else" statement; +%% +]]) + +AT_CHECK([bison -v input.y -o input.c]) + +# Check only the tables. We don't use --no-parser, because it is +# still to be implemented in the experimental branch of Bison. +AT_CHECK([[sed -n 's/ *$//;/^static const.*\[\] =/,/^}/p' input.c]], 0, +[[static const char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, + 6 +}; +static const short yyprhs[] = +{ + 0, 0, 2, 3, 6, 11 +}; +static const short yyrhs[] = +{ + 8, 0, 0, 9, 10, 0, 3, 4, 5, 7, + 0, 6, 7, 0 +}; +static const short yyrline[] = +{ + 0, 2, 3, 3, 4, 5 +}; +static const char *const yytname[] = +{ + "$", "error", "$undefined.", "\"if\"", "\"const\"", "\"then\"", + "\"else\"", "statement", "struct_stat", "if", "else", NULL +}; +static const short yytoknum[] = +{ + 0, 256, 2, 257, 258, 259, 260, -1 +}; +static const short yyr1[] = +{ + 0, 7, 8, 8, 9, 10 +}; +static const short yyr2[] = +{ + 0, 1, 0, 2, 4, 2 +}; +static const short yydefact[] = +{ + 2, 0, 1, 0, 0, 2, 3, 2, 5, 4, + 0, 0 +}; +static const short yydefgoto[] = +{ + 8, 2, 3, 6 +}; +static const short yypact[] = +{ + -2, -1,-32768, -4, 1, -2,-32768, -2,-32768,-32768, + 4,-32768 +}; +static const short yypgoto[] = +{ + 0,-32768,-32768,-32768 +}; +static const short yytable[] = +{ + 10, 1, 5, 4, 11, 0, 7, 9 +}; +static const short yycheck[] = +{ + 0, 3, 6, 4, 0, -1, 5, 7 +}; +]]) + +AT_CLEANUP -- 2.47.2