]> git.saurik.com Git - bison.git/commitdiff
Reductions in web2c.y are improperly reported.
authorAkim Demaille <akim@epita.fr>
Sat, 22 Dec 2001 14:41:15 +0000 (14:41 +0000)
committerAkim Demaille <akim@epita.fr>
Sat, 22 Dec 2001 14:41:15 +0000 (14:41 +0000)
Reported by Mike Castle.
* src/conflicts.c (print_reductions): Fix.
* tests/regression.at (Web2c): New.

ChangeLog
NEWS
THANKS
doc/version.texi
src/conflicts.c
tests/regression.at

index b3d98fdf059dc5ee8d1d3edc3b942671f9cc667a..4d3bab3351ecfa8fb3e73ecfc1e221d9c07ff950 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-12-22  Akim Demaille  <akim@epita.fr>
+
+       Reductions in web2c.y are improperly reported.
+       Reported by Mike Castle.
+
+       * src/conflicts.c (print_reductions): Fix.
+       * tests/regression.at (Web2c): New.
+
 2001-12-18  Akim Demaille  <akim@epita.fr>
 
        Version 1.30h.
 2001-12-18  Akim Demaille  <akim@epita.fr>
 
        Version 1.30h.
diff --git a/NEWS b/NEWS
index 9095c43aacc2f26290e45c6de824dbe753e1cdff..cb5c0325faddf96618099956a7e2197946258d3b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ Changes in version 1.30i:
   If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use
   malloc exclusively.  Since 1.29, but was not NEWS'ed.
 
   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
 Changes in version 1.30h:
 
 * When the generated parser lacks debugging code, YYDEBUG is now 0
diff --git a/THANKS b/THANKS
index 638e9d401152f4deb2b89b02d34c34cf8613f0cd..3bf90c06951261be5055daa25cc70136e6687f99 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -18,6 +18,7 @@ Juan Manuel Guerrero    ST001906@HRZ1.HRZ.TU-Darmstadt.De
 Keith Browne            kbrowne@legato.com
 Laurent Mascherpa       laurent.mascherpa@epita.fr
 Marc Autret             autret_m@epita.fr
 Keith Browne            kbrowne@legato.com
 Laurent Mascherpa       laurent.mascherpa@epita.fr
 Marc Autret             autret_m@epita.fr
+Mike Castle             dalgoda@ix.netcom.com
 Neil Booth              NeilB@earthling.net
 Nelson H. F. Beebe      beebe@math.utah.edu
 Noah Friedman           friedman@gnu.org
 Neil Booth              NeilB@earthling.net
 Nelson H. F. Beebe      beebe@math.utah.edu
 Noah Friedman           friedman@gnu.org
index 5a6f20b5fd4316aa087de876a7ea11827002a29b..e0422930748905b4aea0211603277cc2cceb51d0 100644 (file)
@@ -1,4 +1,4 @@
 @set UPDATED 18 December 2001
 @set UPDATED-MONTH December 2001
 @set UPDATED 18 December 2001
 @set UPDATED-MONTH December 2001
-@set EDITION 1.30h
-@set VERSION 1.30h
+@set EDITION 1.30i
+@set VERSION 1.30i
index a9ea208ad4114a04739d0857949be9d1bc834b1a..21c1f11c73ad7a30320bf141974b98680daa90c4 100644 (file)
@@ -414,7 +414,6 @@ void
 print_reductions (FILE *out, int state)
 {
   int i;
 print_reductions (FILE *out, int state)
 {
   int i;
-  int j;
   int m;
   int n;
   shifts *shiftp;
   int m;
   int n;
   shifts *shiftp;
@@ -463,8 +462,6 @@ print_reductions (FILE *out, int state)
     }
   else if (n - m >= 1)
     {
     }
   else if (n - m >= 1)
     {
-      int k;
-
       int cmax = 0;
       int default_LA = -1;
       int default_rule = 0;
       int cmax = 0;
       int default_LA = -1;
       int default_rule = 0;
@@ -473,6 +470,7 @@ print_reductions (FILE *out, int state)
        for (i = m; i < n; i++)
          {
            int count = 0;
        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];
 
            for (k = 0; k < tokensetsize; ++k)
              lookaheadset[k] = LA (i)[k] & ~shiftset[k];
@@ -501,12 +499,13 @@ print_reductions (FILE *out, int state)
 
       for (i = 0; i < ntokens; i++)
        {
 
       for (i = 0; i < ntokens; i++)
        {
+         int j;
          int defaulted = 0;
          int count = BITISSET (shiftset, i);
 
          for (j = m; j < n; 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)
                    {
                {
                  if (count == 0)
                    {
index f141c4b852bfbd76c91ddec1e37a2df3ccbdd203..9ce267ee25433f8ffa99914d16bfd465b89915c7 100644 (file)
@@ -611,3 +611,108 @@ AT_CLEANUP
 
 AT_TEST_CPP_GUARD_H([input/input])
 AT_TEST_CPP_GUARD_H([9foo])
 
 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
+\f
+%%
+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