mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
c++: always define symbol_name
* data/skeletons/lalr1.cc (symbol_name): Always define it, even when it's actually yytname which is used.
This commit is contained in:
@@ -305,27 +305,36 @@ m4_define([b4_shared_declarations],
|
|||||||
/// In theory \a t should be a token_kind_type, but character literals
|
/// In theory \a t should be a token_kind_type, but character literals
|
||||||
/// are valid, yet not members of the token_type enum.
|
/// are valid, yet not members of the token_type enum.
|
||||||
static symbol_kind_type yytranslate_ (int t);
|
static symbol_kind_type yytranslate_ (int t);
|
||||||
]b4_parse_error_bmatch([custom\|detailed], [[
|
|
||||||
|
]b4_parse_error_bmatch(
|
||||||
|
[custom\|detailed],
|
||||||
|
[[ /// The user-facing name of the symbol whose (internal) number is
|
||||||
|
/// YYSYMBOL. No bounds checking.
|
||||||
|
static const char *symbol_name (symbol_kind_type yysymbol);]],
|
||||||
|
[simple],
|
||||||
|
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||||
/// The user-facing name of the symbol whose (internal) number is
|
/// The user-facing name of the symbol whose (internal) number is
|
||||||
/// YYSYMBOL. No bounds checking.
|
/// YYSYMBOL. No bounds checking.
|
||||||
static const char *symbol_name (symbol_kind_type yysymbol);
|
static const char *symbol_name (symbol_kind_type yysymbol);
|
||||||
|
|
||||||
|
/// For a symbol, its name in clear.
|
||||||
|
static const char* const yytname_[];
|
||||||
|
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||||
|
]],
|
||||||
|
[verbose],
|
||||||
|
[[ /// The user-facing name of the symbol whose (internal) number is
|
||||||
|
/// YYSYMBOL. No bounds checking.
|
||||||
|
static std::string symbol_name (symbol_kind_type yysymbol);
|
||||||
|
|
||||||
|
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||||
|
static std::string yytnamerr_ (const char *yystr);
|
||||||
|
|
||||||
|
/// For a symbol, its name in clear.
|
||||||
|
static const char* const yytname_[];
|
||||||
]])[
|
]])[
|
||||||
|
|
||||||
// Tables.
|
// Tables.
|
||||||
]b4_parser_tables_declare[
|
]b4_parser_tables_declare[
|
||||||
]b4_parse_error_case([verbose], [[
|
|
||||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
|
||||||
static std::string yytnamerr_ (const char *n);
|
|
||||||
|
|
||||||
/// For a symbol, its name in clear.
|
|
||||||
static const char* const yytname_[];
|
|
||||||
]],
|
|
||||||
[b4_token_table_if([], [[
|
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
|
||||||
/// For a symbol, its name in clear.
|
|
||||||
static const char* const yytname_[];
|
|
||||||
#endif
|
|
||||||
]])])[
|
|
||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
]b4_integral_parser_table_declare([rline], [b4_rline],
|
]b4_integral_parser_table_declare([rline], [b4_rline],
|
||||||
@@ -587,16 +596,15 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
#define YYERROR goto yyerrorlab
|
#define YYERROR goto yyerrorlab
|
||||||
#define YYRECOVERING() (!!yyerrstatus_)
|
#define YYRECOVERING() (!!yyerrstatus_)
|
||||||
|
|
||||||
]b4_namespace_open[]b4_parse_error_bmatch([custom\|detailed], [[
|
]b4_namespace_open[
|
||||||
/* The user-facing name of the symbol whose (internal) number is
|
]b4_parse_error_bmatch([custom\|detailed],
|
||||||
YYSYMBOL. No bounds checking. */
|
[[ const char *
|
||||||
const char *
|
|
||||||
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||||
{
|
{
|
||||||
static const char *const yy_sname[] =
|
static const char *const yy_sname[] =
|
||||||
{
|
{
|
||||||
]b4_symbol_names[
|
]b4_symbol_names[
|
||||||
};]m4_ifdef([b4_translatable], [[
|
};]b4_has_translations_if([[
|
||||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
||||||
internationalizable. */
|
internationalizable. */
|
||||||
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
||||||
@@ -608,10 +616,18 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
: yy_sname[yysymbol]);]], [[
|
: yy_sname[yysymbol]);]], [[
|
||||||
return yy_sname[yysymbol];]])[
|
return yy_sname[yysymbol];]])[
|
||||||
}
|
}
|
||||||
]])
|
]],
|
||||||
b4_parse_error_case([verbose], [[
|
[simple],
|
||||||
|
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||||
/* Return YYSTR after stripping away unnecessary quotes and
|
const char *
|
||||||
|
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||||
|
{
|
||||||
|
return yytname_[yysymbol];
|
||||||
|
}
|
||||||
|
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||||
|
]],
|
||||||
|
[verbose],
|
||||||
|
[[ /* Return YYSTR after stripping away unnecessary quotes and
|
||||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||||
that double-quoting is unnecessary unless the string contains an
|
that double-quoting is unnecessary unless the string contains an
|
||||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||||
@@ -650,6 +666,12 @@ b4_parse_error_case([verbose], [[
|
|||||||
|
|
||||||
return yystr;
|
return yystr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
||||||
|
{
|
||||||
|
return yytnamerr_ (yytname_[yysymbol]);
|
||||||
|
}
|
||||||
]])[
|
]])[
|
||||||
|
|
||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
@@ -786,7 +808,7 @@ b4_parse_error_case([verbose], [[
|
|||||||
std::abort ();
|
std::abort ();
|
||||||
#endif
|
#endif
|
||||||
yyo << (yykind < YYNTOKENS ? "token" : "nterm")
|
yyo << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||||
<< ' ' << yytname_[yykind] << " ("]b4_locations_if([
|
<< ' ' << symbol_name (yykind) << " ("]b4_locations_if([
|
||||||
<< yysym.location << ": "])[;
|
<< yysym.location << ": "])[;
|
||||||
]b4_symbol_actions([printer])[
|
]b4_symbol_actions([printer])[
|
||||||
yyo << ')';
|
yyo << ')';
|
||||||
@@ -1298,7 +1320,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
yylac_stack_.clear ();
|
yylac_stack_.clear ();
|
||||||
// Reduce until we encounter a shift and thereby accept the token.
|
// Reduce until we encounter a shift and thereby accept the token.
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
YYCDEBUG << "LAC: checking lookahead " << yytname_[yytoken] << ':';
|
YYCDEBUG << "LAC: checking lookahead " << symbol_name (yytoken) << ':';
|
||||||
#endif
|
#endif
|
||||||
std::ptrdiff_t lac_top = 0;
|
std::ptrdiff_t lac_top = 0;
|
||||||
while (true)
|
while (true)
|
||||||
@@ -1398,7 +1420,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
{
|
{
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
YYCDEBUG << "LAC: initial context established for "
|
YYCDEBUG << "LAC: initial context established for "
|
||||||
<< yytname_[yytoken] << '\n';
|
<< symbol_name (yytoken) << '\n';
|
||||||
#endif
|
#endif
|
||||||
yy_lac_established_ = true;
|
yy_lac_established_ = true;
|
||||||
return yy_lac_check_ (yytoken);
|
return yy_lac_check_ (yytoken);
|
||||||
@@ -1507,9 +1529,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
for (char const* yyp = yyformat; *yyp; ++yyp)
|
for (char const* yyp = yyformat; *yyp; ++yyp)
|
||||||
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
|
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
|
||||||
{
|
{
|
||||||
yyres += ]b4_parse_error_case([verbose],
|
yyres += symbol_name (yyarg[yyi++]);
|
||||||
[[yytnamerr_ (yytname_[yyarg[yyi++]])]],
|
|
||||||
[[symbol_name (yyarg[yyi++])]])[;
|
|
||||||
++yyp;
|
++yyp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1524,7 +1544,8 @@ b4_dollar_popdef])[]dnl
|
|||||||
|
|
||||||
]b4_parser_tables_define[
|
]b4_parser_tables_define[
|
||||||
|
|
||||||
]b4_tname_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
]b4_parse_error_bmatch([simple\|verbose],
|
||||||
|
[[#if ]b4_api_PREFIX[DEBUG]b4_tname_if([[ || 1]])[
|
||||||
// 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*
|
||||||
@@ -1532,7 +1553,8 @@ b4_dollar_popdef])[]dnl
|
|||||||
{
|
{
|
||||||
]b4_tname[
|
]b4_tname[
|
||||||
};
|
};
|
||||||
]b4_tname_if([], [[#endif]])[
|
#endif
|
||||||
|
]])[
|
||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG][
|
#if ]b4_api_PREFIX[DEBUG][
|
||||||
]b4_integral_parser_table_define([rline], [b4_rline])[
|
]b4_integral_parser_table_define([rline], [b4_rline])[
|
||||||
|
|||||||
@@ -7510,8 +7510,10 @@ If @var{argv} is null, return the size needed to store all the possible
|
|||||||
values, which is always less than @code{YYNTOKENS}.
|
values, which is always less than @code{YYNTOKENS}.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@deftypefun {const char *} yysymbol_name (@code{symbol_kind_t} @var{symbol})
|
@deftypefun {@r{string type}} yysymbol_name (@code{symbol_kind_t} @var{symbol})
|
||||||
The name of the symbol whose kind is @var{symbol}, possibly translated.
|
The name of the symbol whose kind is @var{symbol}, possibly translated.
|
||||||
|
Depending on the options, may return a @code{const char*} or a
|
||||||
|
@code{std::string}.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
A custom syntax error function looks as follows. This implementation is
|
A custom syntax error function looks as follows. This implementation is
|
||||||
|
|||||||
Reference in New Issue
Block a user