mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 00:03:03 +00:00
Accept a token number in a %left, %right, or %nonassoc for POSIX
conformance. Reported by Tim Josling at <http://lists.gnu.org/archive/html/bug-bison/2008-01/msg00010.html>. * NEWS (2.3a+): Mention. * doc/bison.texinfo (Precedence Decl): Describe how literal strings and code numbers are treated by precedence declarations. * src/parse-gram.y (precedence_declaration): Use symbols.prec instead of symbols.1. (symbols.prec): New, just like symbols.1 but uses symbol.prec instead of symbol. (symbol.prec): New, just like symbol but allows INT. * src/symtab.c (symbol_user_token_number_set): Remove an aver that no longer holds. * tests/regression.at (Token number in precedence declaration): New test case.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Bison Regressions. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
|
||||
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -1181,3 +1181,64 @@ state 2
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
|
||||
## ---------------------------------------- ##
|
||||
## Token number in precedence declaration. ##
|
||||
## ---------------------------------------- ##
|
||||
|
||||
AT_SETUP([[Token number in precedence declaration.]])
|
||||
|
||||
# POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
|
||||
# we lost this in Bison 1.50.
|
||||
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[[%{
|
||||
#include <stdio.h>
|
||||
void yyerror (char const *);
|
||||
int yylex (void);
|
||||
%}
|
||||
|
||||
%error-verbose
|
||||
%left TK1 1 TK2 2 "tok alias" 3
|
||||
|
||||
%%
|
||||
|
||||
start: TK1 sr_conflict "tok alias" ;
|
||||
|
||||
sr_conflict:
|
||||
TK2
|
||||
| TK2 "tok alias"
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
void
|
||||
yyerror (char const *msg)
|
||||
{
|
||||
fprintf (stderr, "%s\n", msg);
|
||||
}
|
||||
|
||||
int
|
||||
yylex (void)
|
||||
{
|
||||
static int const input[] = { 1, 2, 3, 0 };
|
||||
static int const *inputp = input;
|
||||
return *inputp++;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return yyparse ();
|
||||
}
|
||||
]])
|
||||
|
||||
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"
|
||||
]])
|
||||
AT_COMPILE([[input]])
|
||||
AT_PARSER_CHECK([[./input]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user