* NEWS: Version 2.1.

* NEWS: Remove notice of yytname change, since it was never in an
official release.
* data/glr.c (yydestroyGLRState): Rename local var to avoid shadowing
diagnostic.
* src/output.c (prepare): Likewise.
* data/lalr1.cc (YYERROR_VERBOSE_IF): New macro.
(yysyntax_error_): Use it to avoid GCC warning when YYERROR_VERBOSE
is not defined.  This is an awful hack, but it's enough for now.
All callers changed.
* tests/glr-regression-at (make_value): Args are const pointers now,
to avoid GCC warning.
(Duplicated user destructor for lookahead): New test.  Currently
skipped.  It fails on my host but I'm not sure it'll always fail.
This commit is contained in:
Paul Eggert
2005-09-16 22:54:21 +00:00
parent c1432f6538
commit 1bd0dedaaa
7 changed files with 122 additions and 23 deletions

View File

@@ -1,11 +1,29 @@
2005-09-16 Akim <akim@epita.fr> 2005-09-16 Paul Eggert <eggert@cs.ucla.edu>
* NEWS: Version 2.1.
* NEWS: Remove notice of yytname change, since it was never in an
official release.
* data/glr.c (yydestroyGLRState): Rename local var to avoid shadowing
diagnostic.
* src/output.c (prepare): Likewise.
* data/lalr1.cc (YYERROR_VERBOSE_IF): New macro.
(yysyntax_error_): Use it to avoid GCC warning when YYERROR_VERBOSE
is not defined. This is an awful hack, but it's enough for now.
All callers changed.
* tests/glr-regression-at (make_value): Args are const pointers now,
to avoid GCC warning.
(Duplicated user destructor for lookahead): New test. Currently
skipped. It fails on my host but I'm not sure it'll always fail.
2005-09-16 Akim Demaille <akim@epita.fr>
* src/symtab.h (struct symbol): Declare the printer and destructor * src/symtab.h (struct symbol): Declare the printer and destructor
as const, to avoid accidental calls to free. as const, to avoid accidental calls to free.
(symbol_destructor_set, symbol_printer_set): Adjust. (symbol_destructor_set, symbol_printer_set): Adjust.
* src/symtab.c: Adjust. * src/symtab.c: Adjust.
2005-09-16 Akim <akim@epita.fr> 2005-09-16 Akim Demaille <akim@epita.fr>
* data/c.m4 (b4_token_enums): New. * data/c.m4 (b4_token_enums): New.
(b4_token_defines): Rename as... (b4_token_defines): Rename as...

7
NEWS
View File

@@ -1,7 +1,7 @@
Bison News Bison News
---------- ----------
Changes in version 2.0b, 2005-07-24: Changes in version 2.1, 2005-09-16:
* Bison-generated parsers now support the translation of diagnostics like * Bison-generated parsers now support the translation of diagnostics like
"syntax error" into languages other than English. The default "syntax error" into languages other than English. The default
@@ -19,11 +19,6 @@ Changes in version 2.0b, 2005-07-24:
behind on the stack. Also, the start symbol is now destroyed after a behind on the stack. Also, the start symbol is now destroyed after a
successful parse. In both cases, the behavior was formerly inconsistent. successful parse. In both cases, the behavior was formerly inconsistent.
* The yytname array now contains the same contents that it did in 2.0,
undoing an incompatible and undocumented change made in 2.0a.
Changes in version 2.0a, 2005-05-22:
* When generating verbose diagnostics, Bison-generated parsers no longer * When generating verbose diagnostics, Bison-generated parsers no longer
quote the literal strings associated with tokens. For example, for quote the literal strings associated with tokens. For example, for
a syntax error associated with '%token NUM "number"' they might a syntax error associated with '%token NUM "number"' they might

View File

@@ -23,7 +23,7 @@
# least Autoconf 2.59. # least Autoconf 2.59.
AC_PREREQ(2.59) AC_PREREQ(2.59)
AC_INIT([GNU Bison], [2.0c], [bug-bison@gnu.org]) AC_INIT([GNU Bison], [2.1], [bug-bison@gnu.org])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])

View File

@@ -920,12 +920,12 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys)
if (yys->yysemantics.yyfirstVal) if (yys->yysemantics.yyfirstVal)
{ {
yySemanticOption *yyoption = yys->yysemantics.yyfirstVal; yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;
yyGLRState *yyrhs; yyGLRState *yyrh;
int yyn; int yyn;
for (yyrhs = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule); for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
yyn > 0; yyn > 0;
yyrhs = yyrhs->yypred, yyn -= 1) yyrh = yyrh->yypred, yyn -= 1)
yydestroyGLRState (yymsg, yyrhs); yydestroyGLRState (yymsg, yyrh);
} }
} }
} }

View File

@@ -69,6 +69,12 @@ b4_syncline([@oline@], [@ofile@])[
# define YYERROR_VERBOSE ]b4_error_verbose[ # define YYERROR_VERBOSE ]b4_error_verbose[
#endif #endif
#if YYERROR_VERBOSE
# define YYERROR_VERBOSE_IF(x) x
#else
# define YYERROR_VERBOSE_IF(x) /* empty */
#endif
/* Enabling the token table. */ /* Enabling the token table. */
#ifndef YYTOKEN_TABLE #ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE ]b4_token_table[ # define YYTOKEN_TABLE ]b4_token_table[
@@ -176,7 +182,7 @@ namespace yy
/// Generate an error message. /// Generate an error message.
/// \param tok the look-ahead token. /// \param tok the look-ahead token.
virtual std::string yysyntax_error_ (int tok); virtual std::string yysyntax_error_ (YYERROR_VERBOSE_IF (int tok));
#if YYDEBUG #if YYDEBUG
/// \brief Report a symbol on the debug stream. /// \brief Report a symbol on the debug stream.
@@ -695,7 +701,7 @@ yyerrlab:
if (!yyerrstatus_) if (!yyerrstatus_)
{ {
++yynerrs_; ++yynerrs_;
error (yylloc, yysyntax_error_ (yyilooka)); error (yylloc, yysyntax_error_ (YYERROR_VERBOSE_IF (yyilooka)));
} }
yyerror_range[0] = yylloc; yyerror_range[0] = yylloc;
@@ -816,7 +822,7 @@ yyreturn:
// Generate an error message. // Generate an error message.
std::string std::string
yy::]b4_parser_class_name[::yysyntax_error_ (int tok) yy::]b4_parser_class_name[::yysyntax_error_ (YYERROR_VERBOSE_IF (int tok))
{ {
std::string res; std::string res;
#if YYERROR_VERBOSE #if YYERROR_VERBOSE

View File

@@ -618,8 +618,8 @@ prepare (void)
/* About the skeletons. */ /* About the skeletons. */
{ {
char const* p = getenv ("BISON_PKGDATADIR"); char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
MUSCLE_INSERT_STRING ("pkgdatadir", p ? p : PKGDATADIR); MUSCLE_INSERT_STRING ("pkgdatadir", pkgdatadir ? pkgdatadir : PKGDATADIR);
MUSCLE_INSERT_C_STRING ("skeleton", skeleton); MUSCLE_INSERT_C_STRING ("skeleton", skeleton);
} }
} }

View File

@@ -338,7 +338,8 @@ AT_CLEANUP
AT_SETUP([Duplicate representation of merged trees]) AT_SETUP([Duplicate representation of merged trees])
AT_DATA_GRAMMAR([glr-regr4.y], AT_DATA_GRAMMAR([glr-regr4.y],
[[%union { char *ptr; } [[
%union { char *ptr; }
%type <ptr> S A A1 A2 B %type <ptr> S A A1 A2 B
%glr-parser %glr-parser
@@ -347,7 +348,7 @@ AT_DATA_GRAMMAR([glr-regr4.y],
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static char *merge (YYSTYPE, YYSTYPE); static char *merge (YYSTYPE, YYSTYPE);
static char *make_value (char *, char *); static char *make_value (char const *, char const *);
static void yyerror (char const *); static void yyerror (char const *);
static int yylex (void); static int yylex (void);
%} %}
@@ -386,7 +387,7 @@ main (void)
} }
static char * static char *
make_value (char *parent, char *child) make_value (char const *parent, char const *child)
{ {
char const format[] = "%s <- %s"; char const format[] = "%s <- %s";
char *value = char *value =
@@ -433,7 +434,8 @@ AT_CLEANUP
AT_SETUP([User destructor for unresolved GLR semantic value]) AT_SETUP([User destructor for unresolved GLR semantic value])
AT_DATA_GRAMMAR([glr-regr5.y], AT_DATA_GRAMMAR([glr-regr5.y],
[[%{ [[
%{
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
static void yyerror (char const *); static void yyerror (char const *);
@@ -503,7 +505,8 @@ AT_CLEANUP
AT_SETUP([User destructor after an error during a split parse]) AT_SETUP([User destructor after an error during a split parse])
AT_DATA_GRAMMAR([glr-regr6.y], AT_DATA_GRAMMAR([glr-regr6.y],
[[%{ [[
%{
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
static void yyerror (char const *); static void yyerror (char const *);
@@ -556,3 +559,80 @@ AT_CHECK([[./glr-regr6]], 0,
]) ])
AT_CLEANUP AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Duplicated user destructor for lookahead ##
## Thanks to Joel E. Denny for this test; see ##
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00035.html>. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Duplicated user destructor for lookahead])
AT_DATA_GRAMMAR([glr-regr7.y],
[[
%{
#include <stdio.h>
#include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
#define YYSTACKEXPANDABLE 0
%}
%glr-parser
%union { int *count; }
%type <count> 'a'
%destructor {
if ((*$$)++)
fprintf (stderr, "Destructor called on same value twice.\n");
} 'a'
%%
start:
stack1 start
| stack2 start
| /* empty */
;
stack1: 'a' ;
stack2: 'a' ;
%%
static int
yylex (void)
{
yylval.count = malloc (sizeof (int));
if (!yylval.count)
{
fprintf (stderr, "Test inconclusive.\n");
exit (EXIT_FAILURE);
}
*yylval.count = 0;
return 'a';
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
main (void)
{
return yyparse ();
}
]])
AT_CHECK([[bison -o glr-regr7.c glr-regr7.y]], 0, [],
[glr-regr7.y: conflicts: 2 reduce/reduce
])
AT_COMPILE([glr-regr7])
AT_CHECK([[exit 77; ./glr-regr7]], 2, [],
[memory exhausted
])
AT_CLEANUP