-## ------- ##
-## 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
]])
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