bison-patches
[Top][All Lists]
Advanced

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

Don't let %prec take a nonterminal


From: Joel E. Denny
Subject: Don't let %prec take a nonterminal
Date: Fri, 17 Nov 2006 09:34:37 -0500 (EST)

Ok to commit?

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1607
diff -p -u -r1.1607 ChangeLog
--- ChangeLog   12 Nov 2006 07:39:37 -0000      1.1607
+++ ChangeLog   17 Nov 2006 14:31:58 -0000
@@ -1,3 +1,11 @@
+2006-11-17  Joel E. Denny  <address@hidden>
+
+       Don't let %prec take a nonterminal.
+       * src/reader.c (grammar_current_rule_prec_set): Make the %prec symbol a
+       token.
+       * tests/input.at (%prec takes a token): New test checking that %prec
+       won't take a nonterminal.
+
 2006-11-10  Joel E. Denny  <address@hidden>
 
        * tests/testsuite.at (AT_CHECK): Don't miss an exit value of 0 because
Index: src/reader.c
===================================================================
RCS file: /sources/bison/bison/src/reader.c,v
retrieving revision 1.278
diff -p -u -r1.278 reader.c
--- src/reader.c        12 Nov 2006 07:39:37 -0000      1.278
+++ src/reader.c        17 Nov 2006 14:31:58 -0000
@@ -387,6 +387,7 @@ grammar_midrule_action (void)
 void
 grammar_current_rule_prec_set (symbol *precsym, location loc)
 {
+  symbol_class_set (precsym, token_sym, loc, false);
   if (current_rule->ruleprec)
     complain_at (loc, _("only one %s allowed per rule"), "%prec");
   current_rule->ruleprec = precsym;
Index: tests/input.at
===================================================================
RCS file: /sources/bison/bison/tests/input.at,v
retrieving revision 1.61
diff -p -u -r1.61 input.at
--- tests/input.at      1 Nov 2006 06:09:40 -0000       1.61
+++ tests/input.at      17 Nov 2006 14:31:58 -0000
@@ -680,3 +680,24 @@ start: false_start ;
 AT_CHECK([bison -o input.c input.y])
 
 AT_CLEANUP
+
+
+## --------------------- ##
+## %prec takes a token.  ##
+## --------------------- ##
+
+AT_SETUP([%prec takes a token])
+
+# Bison once allowed %prec sym where sym was a nonterminal.
+
+AT_DATA([input.y],
+[[%%
+start: PREC %prec PREC ;
+PREC: ;
+]])
+
+AT_CHECK([bison input.y], [1], [],
+[[input.y:3.1-4: rule given for PREC, which is a token
+]])
+
+AT_CLEANUP





reply via email to

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