[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: Both: Serious LALR bug
From: |
Akim Demaille |
Subject: |
FYI: Both: Serious LALR bug |
Date: |
22 Dec 2001 15:43:34 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Civil Service) |
I'm still shocked that all the tests passed with such a bug in the
guts... And ashamed to have introduced it...
Index: ChangeLog
from Akim Demaille <address@hidden>
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.
Index: src/lalr.c
===================================================================
RCS file: /cvsroot/bison/bison/src/lalr.c,v
retrieving revision 1.16.2.21
diff -u -u -r1.16.2.21 lalr.c
--- src/lalr.c 10 Dec 2001 08:43:37 -0000 1.16.2.21
+++ src/lalr.c 22 Dec 2001 14:43:49 -0000
@@ -103,7 +103,7 @@
break;
for (k = 0; k < size; ++k)
- F (i)[k] = F (j)[k];
+ F (j)[k] = F (i)[k];
}
}
Index: tests/regression.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/regression.at,v
retrieving revision 1.1.2.23
diff -u -u -r1.1.2.23 regression.at
--- tests/regression.at 22 Dec 2001 14:41:15 -0000 1.1.2.23
+++ tests/regression.at 22 Dec 2001 14:43:49 -0000
@@ -614,16 +614,16 @@
-## ------- ##
-## 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
@@ -713,6 +713,131 @@
$ go to state 11
state 11
$default accept
+]])
+
+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 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, 0
+};
+static const short yydefgoto[] =
+{
+ 8, 2, 3, 6
+};
+static const short yypact[] =
+{
+ -2, -1,-32768, -4, 1, -2,-32768, -2,-32768,-32768,
+ 4, 5,-32768
+};
+static const short yypgoto[] =
+{
+ 0,-32768,-32768,-32768
+};
+static const short yytable[] =
+{
+ 10, 1, 5, 4, 11, 12, 7, 9
+};
+static const short yycheck[] =
+{
+ 0, 3, 6, 4, 0, 0, 5, 7
+};
]])
AT_CLEANUP
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: Both: Serious LALR bug,
Akim Demaille <=