mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
skeletons: decorelate %token-table from verbose error messages
Reported by Adrian Vogelsgesang. * data/skeletons/bison.m4: Here. * data/skeletons/lalr1.cc: Adjust.
This commit is contained in:
@@ -1031,10 +1031,6 @@ m4_define([b4_error_verbose_flag],
|
|||||||
[verbose], [[1]])])
|
[verbose], [[1]])])
|
||||||
b4_define_flag_if([error_verbose])
|
b4_define_flag_if([error_verbose])
|
||||||
|
|
||||||
# yytoken_table is needed to support verbose errors.
|
|
||||||
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
b4_percent_define_if_define([variant])
|
b4_percent_define_if_define([variant])
|
||||||
|
|||||||
@@ -30,6 +30,15 @@ m4_define([b4_lac_flag],
|
|||||||
[none], [[0]], [[1]])])
|
[none], [[0]], [[1]])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_tname_if(TNAME-NEEDED, TNAME-NOT-NEEDED)
|
||||||
|
# -------------------------------------------
|
||||||
|
m4_define([b4_tname_if],
|
||||||
|
[m4_case(b4_percent_define_get([[parse.error]]),
|
||||||
|
[verbose], [$1],
|
||||||
|
[b4_token_table_if([$1],
|
||||||
|
[$2])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
|
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
|
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
|
||||||
@@ -274,15 +283,23 @@ m4_define([b4_shared_declarations],
|
|||||||
static token_number_type yytranslate_ (int t);
|
static token_number_type yytranslate_ (int t);
|
||||||
|
|
||||||
// Tables.
|
// Tables.
|
||||||
]b4_parser_tables_declare[]b4_error_verbose_if([
|
]b4_parser_tables_declare[
|
||||||
|
]m4_case(b4_percent_define_get([[parse.error]]),
|
||||||
|
[verbose], [[
|
||||||
/// 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);
|
||||||
|
|
||||||
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
|
||||||
/// For a symbol, its name in clear.
|
/// For a symbol, its name in clear.
|
||||||
static const char* const yytname_[];
|
static const char* const yytname_[];
|
||||||
]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
|
]],
|
||||||
|
[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
|
||||||
]b4_integral_parser_table_declare([rline], [b4_rline],
|
]b4_integral_parser_table_declare([rline], [b4_rline],
|
||||||
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
||||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
/// Report on the debug stream that the rule \a r is going to be reduced.
|
||||||
@@ -1416,7 +1433,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
|||||||
|
|
||||||
]b4_parser_tables_define[
|
]b4_parser_tables_define[
|
||||||
|
|
||||||
]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
]b4_tname_if([], [[#if ]b4_api_PREFIX[DEBUG]])[
|
||||||
// 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*
|
||||||
@@ -1424,8 +1441,9 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
|||||||
{
|
{
|
||||||
]b4_tname[
|
]b4_tname[
|
||||||
};
|
};
|
||||||
|
]b4_tname_if([], [[#endif]])[
|
||||||
|
|
||||||
]b4_token_table_if([[#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])[
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user