c++: do not export YYTOKEN_TABLE and YYERROR_VERBOSE.

* src/output.c (prepare_symbols): Do not define b4_token_table.
(prepare): Define b4_token_table_flag.
* data/bison.m4 (b4_token_table_if): New.
Arm it when error-verbose.
* data/glr.c, data/yacc.c (YYTOKEN_TABLE): Remove.
Use m4.
* data/lalr1.cc: Likewise.
(YYERROR_VERBOSE): Remove.
* NEWS, doc/bison.texi: Document this.
This commit is contained in:
Akim Demaille
2012-06-25 16:52:30 +02:00
parent 9bcffa0c13
commit 258cddbc36
7 changed files with 42 additions and 55 deletions

26
NEWS
View File

@@ -13,14 +13,16 @@ GNU Bison NEWS
generated for C supprt ISO C90, and are tested with ISO C99 and ISO C11 generated for C supprt ISO C90, and are tested with ISO C99 and ISO C11
compilers. compilers.
*** Deprecated features *** Features deprecated since Bison 1.875
The definitions of yystype and yyltype will be removed, as announced since The definitions of yystype and yyltype will be removed; use YYSTYPE and
Bison 1.875. Use YYSTYPE and YYLTYPE only. YYLTYPE.
YYPARSE_PARAM and YYLEX_PARAM, which were deprecated in favor of YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
%parse-param and %lex-param (introduced in Bison 1.875), will no longer be %lex-param, will no longer be supported.
supported.
Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use
%error-verbose.
*** The generated header will be included (yacc.c) *** The generated header will be included (yacc.c)
@@ -30,9 +32,9 @@ GNU Bison NEWS
because existing versions of ylwrap (e.g., Automake 1.12.1) do not support because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
it. it.
** Headers (yacc.c, glr.c, glr.cc) ** Headers
*** Guards *** Guards (yacc.c, glr.c, glr.cc)
The generated headers are now guarded, as is already the case for C++ The generated headers are now guarded, as is already the case for C++
parsers (lalr1.cc). For intance, with --defines=foo.h: parsers (lalr1.cc). For intance, with --defines=foo.h:
@@ -42,7 +44,7 @@ GNU Bison NEWS
... ...
#endif /* !YY_FOO_H */ #endif /* !YY_FOO_H */
*** New declarations *** New declarations (yacc.c, glr.c)
The generated header now declares yydebug and yyparse. Both honor The generated header now declares yydebug and yyparse. Both honor
--name-prefix=bar_, and yield --name-prefix=bar_, and yield
@@ -57,6 +59,12 @@ GNU Bison NEWS
in order to facilitate the inclusion of several parser headers inside a in order to facilitate the inclusion of several parser headers inside a
single compilation unit. single compilation unit.
*** Exported symbols in C++
The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
header, are removed, as they prevent the possibility of including several
generated headers from a single compilation unit.
* Noteworthy changes in release 2.5.1 (2012-06-05) [stable] * Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
** Future changes: ** Future changes:

View File

@@ -233,9 +233,9 @@ m4_define([b4_define_flag_if],
# _b4_define_flag_if($1, $2, FLAG) # _b4_define_flag_if($1, $2, FLAG)
# -------------------------------- # --------------------------------
# This macro works around the impossibility to define macros # Work around the impossibility to define macros inside macros,
# inside macros, because issuing `[$1]' is not possible in M4 :(. # because issuing `[$1]' is not possible in M4. GNU M4 should provide
# This sucks hard, GNU M4 should really provide M5 like $$1. # $$1 a la M5/TeX.
m4_define([_b4_define_flag_if], m4_define([_b4_define_flag_if],
[m4_if([$1$2], $[1]$[2], [], [m4_if([$1$2], $[1]$[2], [],
[m4_fatal([$0: Invalid arguments: $@])])dnl [m4_fatal([$0: Invalid arguments: $@])])dnl
@@ -251,8 +251,12 @@ b4_define_flag_if([error_verbose]) # Whether error are verbose.
b4_define_flag_if([glr]) # Whether a GLR parser is requested. b4_define_flag_if([glr]) # Whether a GLR parser is requested.
b4_define_flag_if([locations]) # Whether locations are tracked. b4_define_flag_if([locations]) # Whether locations are tracked.
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled. b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
# yytoken_table is needed to support verbose errors.
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
## ------------------------- ## ## ------------------------- ##
## Assigning token numbers. ## ## Assigning token numbers. ##

View File

@@ -215,11 +215,6 @@ b4_percent_code_get([[top]])[
# define YYERROR_VERBOSE ]b4_error_verbose_flag[ # define YYERROR_VERBOSE ]b4_error_verbose_flag[
#endif #endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE ]b4_token_table[
#endif
/* Default (constant) value used for initialization for null /* Default (constant) value used for initialization for null
right-hand sides. Unlike the standard yacc.c template, right-hand sides. Unlike the standard yacc.c template,
here we set the default value of $$ to a zeroed-out value. here we set the default value of $$ to a zeroed-out value.
@@ -367,7 +362,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
}; };
#endif #endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE #if YYDEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] = static const char *const yytname[] =

View File

@@ -62,19 +62,6 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
# define YYDEBUG ]b4_debug_flag[ # define YYDEBUG ]b4_debug_flag[
#endif #endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
#endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE ]b4_token_table[
#endif
]b4_namespace_open[ ]b4_namespace_open[
/// A Bison parser. /// A Bison parser.
@@ -211,17 +198,15 @@ b4_user_stype
/// For a rule, its LHS. /// For a rule, its LHS.
static const ]b4_int_type_for([b4_r1])[ yyr1_[]; static const ]b4_int_type_for([b4_r1])[ yyr1_[];
/// For a rule, its RHS length. /// For a rule, its RHS length.
static const ]b4_int_type_for([b4_r2])[ yyr2_[]; static const ]b4_int_type_for([b4_r2])[ yyr2_[]; ]b4_error_verbose_if([
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/// For a symbol, its name in clear.
static const char* const yytname_[];
#endif]b4_error_verbose_if([
/// Convert the symbol name \a n to a form suitable for a diagnostic. /// Convert the symbol name \a n to a form suitable for a diagnostic.
static std::string yytnamerr_ (const char *n);])[ static std::string yytnamerr_ (const char *n);])[
#if YYDEBUG ]b4_token_table_if([], [[#if YYDEBUG]])[
/// For a symbol, its name in clear.
static const char* const yytname_[];
]b4_token_table_if([[#if YYDEBUG]])[
/// A type to store symbol numbers and -1. /// A type to store symbol numbers and -1.
typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type; typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type;
/// A `-1'-separated list of the rules' RHS. /// A `-1'-separated list of the rules' RHS.
@@ -1051,7 +1036,7 @@ b4_error_verbose_if([int yystate, int yytoken],
]b4_r2[ ]b4_r2[
}; };
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE ]b4_token_table_if([], [[#if YYDEBUG]])[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at \a yyntokens_, nonterminals. */ First, the terminals, then, starting at \a yyntokens_, nonterminals. */
const char* const char*
@@ -1059,9 +1044,8 @@ b4_error_verbose_if([int yystate, int yytoken],
{ {
]b4_tname[ ]b4_tname[
}; };
#endif
#if YYDEBUG ]b4_token_table_if([[#if YYDEBUG]])[
/* YYRHS -- A `-1'-separated list of the rules' RHS. */ /* YYRHS -- A `-1'-separated list of the rules' RHS. */
const ]b4_parser_class_name[::rhs_number_type const ]b4_parser_class_name[::rhs_number_type
]b4_parser_class_name[::yyrhs_[] = ]b4_parser_class_name[::yyrhs_[] =

View File

@@ -336,11 +336,6 @@ m4_if(b4_prefix, [yy], [],
# define YYERROR_VERBOSE ]b4_error_verbose_flag[ # define YYERROR_VERBOSE ]b4_error_verbose_flag[
#endif #endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE ]b4_token_table[
#endif
/* In a future release of Bison, this section will be replaced /* In a future release of Bison, this section will be replaced
by #include "@basename(]b4_spec_defines_file[@)". */ by #include "@basename(]b4_spec_defines_file[@)". */
]b4_shared_declarations[ ]b4_shared_declarations[
@@ -607,7 +602,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
}; };
#endif #endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE #if YYDEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] = static const char *const yytname[] =

View File

@@ -11216,7 +11216,8 @@ Reporting Function @code{yyerror}}.
An obsolete macro that you define with @code{#define} in the prologue An obsolete macro that you define with @code{#define} in the prologue
to request verbose, specific error message strings to request verbose, specific error message strings
when @code{yyerror} is called. It doesn't matter what definition you when @code{yyerror} is called. It doesn't matter what definition you
use for @code{YYERROR_VERBOSE}, just whether you define it. Using use for @code{YYERROR_VERBOSE}, just whether you define it.
Supported by the C skeletons only; using
@code{%error-verbose} is preferred. @xref{Error Reporting}. @code{%error-verbose} is preferred. @xref{Error Reporting}.
@end deffn @end deffn

View File

@@ -142,7 +142,6 @@ escaped_output (FILE *out, char const *string)
static void static void
prepare_symbols (void) prepare_symbols (void)
{ {
MUSCLE_INSERT_BOOL ("token_table", token_table_flag);
MUSCLE_INSERT_INT ("tokens_number", ntokens); MUSCLE_INSERT_INT ("tokens_number", ntokens);
MUSCLE_INSERT_INT ("nterms_number", nvars); MUSCLE_INSERT_INT ("nterms_number", nvars);
MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number); MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
@@ -624,6 +623,7 @@ prepare (void)
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser); MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag); MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen); MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag);
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag); MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag); MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);