]> git.saurik.com Git - bison.git/commitdiff
Fix precedence for end token.
authorJoel E. Denny <jdenny@clemson.edu>
Mon, 2 May 2011 01:53:35 +0000 (21:53 -0400)
committerJoel E. Denny <jdenny@clemson.edu>
Mon, 2 May 2011 02:20:15 +0000 (22:20 -0400)
Since Bison 2.3b, which restored the ability of precedence
directives to assign user token numbers, doing so for user token
number 0 has produced an assertion failure.
* NEWS (2.5): Document fix.
* src/symtab.c (symbol_user_token_number_set): In the case of the
end token, don't decrement ntokens if it was never incremented.
* tests/regression.at (Token number in precedence declaration):
Extend.

ChangeLog
NEWS
src/symtab.c
tests/regression.at

index ce380959a9cf9eb4d3c429911920ee110acff0ad..d29e4f2b2b039d01dce53708855973797e109a64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-05-01  Joel E. Denny  <joeldenny@joeldenny.org>
+
+       Fix precedence for end token.
+       Since Bison 2.3b, which restored the ability of precedence
+       directives to assign user token numbers, doing so for user token
+       number 0 has produced an assertion failure.
+       * NEWS (2.5): Document fix.
+       * src/symtab.c (symbol_user_token_number_set): In the case of the
+       end token, don't decrement ntokens if it was never incremented.
+       * tests/regression.at (Token number in precedence declaration):
+       Extend.
+
 2011-05-01  Joel E. Denny  <joeldenny@joeldenny.org>
 
        Prepare for 2.5 release.
 2011-05-01  Joel E. Denny  <joeldenny@joeldenny.org>
 
        Prepare for 2.5 release.
diff --git a/NEWS b/NEWS
index 3eb2cc69d06cec6208bcbfa9ee9cd63fca63269f..e063b7824c01954db43915622d78acc65c98afca 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -343,6 +343,16 @@ Bison News
 
     bison -Wnone gram.y
 
 
     bison -Wnone gram.y
 
+** Precedence directives can now assign token number 0:
+
+  Since Bison 2.3b, which restored the ability of precedence
+  directives to assign token numbers, doing so for token number 0 has
+  produced an assertion failure.  For example:
+
+    %left END 0
+
+  This bug has been fixed.
+
 * Changes in version 2.4.3 (2010-08-05):
 
 ** Bison now obeys -Werror and --warnings=error for warnings about
 * Changes in version 2.4.3 (2010-08-05):
 
 ** Bison now obeys -Werror and --warnings=error for warnings about
index f9f78b313667e8eac55a85a5b169c753ca71090b..f065c80d30ab73b497ec7c385286409c4da36d42 100644 (file)
@@ -368,10 +368,11 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
   if (user_token_number == 0)
     {
       endtoken = sym;
   if (user_token_number == 0)
     {
       endtoken = sym;
-      endtoken->number = 0;
       /* It is always mapped to 0, so it was already counted in
         NTOKENS.  */
       /* It is always mapped to 0, so it was already counted in
         NTOKENS.  */
-      --ntokens;
+      if (endtoken->number != NUMBER_UNDEFINED)
+        --ntokens;
+      endtoken->number = 0;
     }
 }
 
     }
 }
 
index 68a41319461ffd2c694afe7e056686fecfdcc6fa..c07b7442a44729c392667fb3752840a059494877 100644 (file)
@@ -1205,12 +1205,15 @@ AT_DATA_GRAMMAR([input.y],
 %}
 
 %error-verbose
 %}
 
 %error-verbose
+%right END 0
 %left TK1 1 TK2 2 "tok alias" 3
 
 %%
 
 %left TK1 1 TK2 2 "tok alias" 3
 
 %%
 
-start: TK1 sr_conflict "tok alias" ;
-
+start:
+    TK1 sr_conflict "tok alias"
+  | start %prec END
+  ;
 sr_conflict:
   TK2
   | TK2 "tok alias"
 sr_conflict:
   TK2
   | TK2 "tok alias"
@@ -1240,7 +1243,8 @@ main (void)
 ]])
 
 AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
 ]])
 
 AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
-[[input.y:24.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias"
+[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
+input.y:27.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias"
 ]])
 AT_COMPILE([[input]])
 AT_PARSER_CHECK([[./input]])
 ]])
 AT_COMPILE([[input]])
 AT_PARSER_CHECK([[./input]])