bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: both: bug in print_reduction


From: Akim Demaille
Subject: FYI: both: bug in print_reduction
Date: 22 Dec 2001 15:39:58 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Civil Service)

Benign, but painful and stupid...

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        Reductions in web2c.y are improperly reported.
        Reported by Mike Castle.

        * src/conflicts.c (print_reductions): Fix.
        * tests/regression.at (Web2c): New.

Index: NEWS
===================================================================
RCS file: /cvsroot/bison/bison/NEWS,v
retrieving revision 1.21.2.39
diff -u -u -r1.21.2.39 NEWS
--- NEWS 22 Dec 2001 14:39:43 -0000 1.21.2.39
+++ NEWS 22 Dec 2001 14:40:14 -0000
@@ -7,6 +7,8 @@
   If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use
   malloc exclusively.  Since 1.29, but was not NEWS'ed.
 
+* Bug fixes
+
 Changes in version 1.30h:
 
 * When the generated parser lacks debugging code, YYDEBUG is now 0
Index: THANKS
===================================================================
RCS file: /cvsroot/bison/bison/THANKS,v
retrieving revision 1.10.2.18
diff -u -u -r1.10.2.18 THANKS
--- THANKS 18 Dec 2001 09:58:07 -0000 1.10.2.18
+++ THANKS 22 Dec 2001 14:40:14 -0000
@@ -18,6 +18,7 @@
 Keith Browne            address@hidden
 Laurent Mascherpa       address@hidden
 Marc Autret             address@hidden
+Mike Castle             address@hidden
 Neil Booth              address@hidden
 Nelson H. F. Beebe      address@hidden
 Noah Friedman           address@hidden
Index: doc/version.texi
===================================================================
RCS file: /cvsroot/bison/bison/doc/Attic/version.texi,v
retrieving revision 1.9.2.29
diff -u -u -r1.9.2.29 version.texi
--- doc/version.texi 18 Dec 2001 09:33:23 -0000 1.9.2.29
+++ doc/version.texi 22 Dec 2001 14:40:14 -0000
@@ -1,4 +1,4 @@
 @set UPDATED 18 December 2001
 @set UPDATED-MONTH December 2001
address@hidden EDITION 1.30h
address@hidden VERSION 1.30h
address@hidden EDITION 1.30i
address@hidden VERSION 1.30i
Index: src/conflicts.c
===================================================================
RCS file: /cvsroot/bison/bison/src/conflicts.c,v
retrieving revision 1.22.2.30
diff -u -u -r1.22.2.30 conflicts.c
--- src/conflicts.c 5 Dec 2001 09:24:54 -0000 1.22.2.30
+++ src/conflicts.c 22 Dec 2001 14:40:14 -0000
@@ -414,7 +414,6 @@
 print_reductions (FILE *out, int state)
 {
   int i;
-  int j;
   int m;
   int n;
   shifts *shiftp;
@@ -463,8 +462,6 @@
     }
   else if (n - m >= 1)
     {
-      int k;
-
       int cmax = 0;
       int default_LA = -1;
       int default_rule = 0;
@@ -473,6 +470,7 @@
        for (i = m; i < n; i++)
          {
            int count = 0;
+           int j, k;
 
            for (k = 0; k < tokensetsize; ++k)
              lookaheadset[k] = LA (i)[k] & ~shiftset[k];
@@ -501,12 +499,13 @@
 
       for (i = 0; i < ntokens; i++)
        {
+         int j;
          int defaulted = 0;
          int count = BITISSET (shiftset, i);
 
          for (j = m; j < n; j++)
            {
-             if (BITISSET (LA (m), j))
+             if (BITISSET (LA (j), i))
                {
                  if (count == 0)
                    {
Index: tests/regression.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/regression.at,v
retrieving revision 1.1.2.22
diff -u -u -r1.1.2.22 regression.at
--- tests/regression.at 13 Dec 2001 10:59:37 -0000 1.1.2.22
+++ tests/regression.at 22 Dec 2001 14:40:14 -0000
@@ -611,3 +611,108 @@
 
 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
address@hidden (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]