From: Joel E. Denny Date: Fri, 17 Nov 2006 20:07:08 +0000 (+0000) Subject: Don't let %prec take a nonterminal. X-Git-Tag: v2.3b~237 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/26b8a43805a6cfebeea1b74d1263e978eb837ec2?ds=inline 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. --- diff --git a/ChangeLog b/ChangeLog index b7b1f376..33c3e2da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-11-17 Joel E. Denny + + 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 * tests/testsuite.at (AT_CHECK): Don't miss an exit value of 0 because diff --git a/src/reader.c b/src/reader.c index d5cd629f..7b769232 100644 --- a/src/reader.c +++ b/src/reader.c @@ -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; diff --git a/tests/input.at b/tests/input.at index 1239df00..dfcebfd9 100644 --- a/tests/input.at +++ b/tests/input.at @@ -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