mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
skeletons: avoid b4_error_verbose_if, which is confusing
parse.error has more than two possible values. * data/skeletons/bison.m4 (b4_error_verbose_if, b4_error_verbose_flag): Remove. (b4_parse_error_case, b4_parse_error_bmatch): New. Adjust dependencies.
This commit is contained in:
@@ -1016,20 +1016,24 @@ m4_define([b4_bison_locations_if],
|
||||
[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])])
|
||||
|
||||
|
||||
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
|
||||
|
||||
# %define parse.error "(custom|detailed|simple|verbose)"
|
||||
# ------------------------------------------------------
|
||||
# Map %define parse.error "(custom|detailed|simple|verbose)" to
|
||||
# b4_error_verbose_if and b4_error_verbose_flag.
|
||||
b4_percent_define_default([[parse.error]], [[simple]])
|
||||
b4_percent_define_check_values([[[[parse.error]],
|
||||
[[custom]], [[detailed]], [[simple]], [[verbose]]]])
|
||||
m4_define([b4_error_verbose_flag],
|
||||
[m4_case(b4_percent_define_get([[parse.error]]),
|
||||
[custom], [[1]],
|
||||
[detailed], [[1]],
|
||||
[simple], [[0]],
|
||||
[verbose], [[1]])])
|
||||
b4_define_flag_if([error_verbose])
|
||||
|
||||
# b4_parse_error_case(CASE1, THEN1, CASE2, THEN2, ..., ELSE)
|
||||
# ----------------------------------------------------------
|
||||
m4_define([b4_parse_error_case],
|
||||
[m4_case(b4_percent_define_get([[parse.error]]), $@)])
|
||||
|
||||
# b4_parse_error_bmatch(PATTERN1, THEN1, PATTERN2, THEN2, ..., ELSE)
|
||||
# ------------------------------------------------------------------
|
||||
m4_define([b4_parse_error_bmatch],
|
||||
[m4_bmatch(b4_percent_define_get([[parse.error]]), $@)])
|
||||
|
||||
|
||||
|
||||
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
||||
# ----------------------------------------------
|
||||
|
||||
@@ -607,13 +607,12 @@ yyMemoryExhausted (yyGLRStack* yystackp)
|
||||
YYLONGJMP (yystackp->yyexception_buffer, 2);
|
||||
}
|
||||
|
||||
#if ]b4_error_verbose_if([[1]], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag])[
|
||||
#if ]b4_parse_error_case([simple], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag], [[1]])[
|
||||
/* The user-facing name of the symbol whose (internal) number is
|
||||
YYSYMBOL. No bounds checking. */
|
||||
static const char *yysymbol_name (yySymbol yysymbol) YY_ATTRIBUTE_UNUSED;
|
||||
|
||||
]m4_bmatch(b4_percent_define_get([[parse.error]]),
|
||||
[simple\|verbose],
|
||||
]b4_parse_error_bmatch([simple\|verbose],
|
||||
[[/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||
static const char *const yytname[] =
|
||||
|
||||
@@ -284,8 +284,7 @@ m4_define([b4_shared_declarations],
|
||||
|
||||
// Tables.
|
||||
]b4_parser_tables_declare[
|
||||
]m4_case(b4_percent_define_get([[parse.error]]),
|
||||
[verbose], [[
|
||||
]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);
|
||||
|
||||
@@ -560,7 +559,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
#define YYERROR goto yyerrorlab
|
||||
#define YYRECOVERING() (!!yyerrstatus_)
|
||||
|
||||
]b4_namespace_open[]b4_error_verbose_if([[
|
||||
]b4_namespace_open[]b4_parse_error_case([verbose], [[
|
||||
|
||||
/* Return YYSTR after stripping away unnecessary quotes and
|
||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||
@@ -1311,10 +1310,10 @@ b4_dollar_popdef])[]dnl
|
||||
|
||||
// Generate an error message.
|
||||
std::string
|
||||
]b4_parser_class[::yysyntax_error_ (]dnl
|
||||
b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
]b4_parser_class[::yysyntax_error_ (]b4_parse_error_case([verbose],
|
||||
[state_type yystate, const symbol_type& yyla],
|
||||
[state_type, const symbol_type&])[) const
|
||||
{]b4_error_verbose_if([[
|
||||
{]b4_parse_error_case([verbose], [[
|
||||
// Number of reported tokens (one for the "unexpected", one per
|
||||
// "expected").
|
||||
std::ptrdiff_t yycount = 0;
|
||||
|
||||
@@ -679,7 +679,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
// Generate an error message.
|
||||
private final string yysyntax_error (int yystate, int tok)
|
||||
{]b4_error_verbose_if([[
|
||||
{]b4_parse_error_case([verbose], [[
|
||||
/* There are many possibilities here to consider:
|
||||
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||
See
|
||||
|
||||
@@ -429,7 +429,7 @@ typedef int yy_state_fast_t;
|
||||
]],
|
||||
[[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
|
||||
|
||||
#if ]b4_lac_if([[1]], [b4_error_verbose_if([[1]], [[!defined yyoverflow]])])[
|
||||
#if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[
|
||||
|
||||
/* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
|
||||
b4_push_if([], [b4_lac_if([], [[
|
||||
@@ -496,7 +496,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# endif]b4_lac_if([[
|
||||
# define YYCOPY_NEEDED 1]])[
|
||||
#endif]b4_lac_if([], [b4_error_verbose_if([], [[/* !defined yyoverflow */]])])[
|
||||
#endif]b4_lac_if([], [b4_parse_error_case([simple], [[/* !defined yyoverflow */]])])[
|
||||
|
||||
#if (! defined yyoverflow \
|
||||
&& (! defined __cplusplus \
|
||||
@@ -602,7 +602,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
||||
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
||||
#endif
|
||||
|
||||
#if ]b4_error_verbose_if([[1]], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag])[
|
||||
#if ]b4_parse_error_case([simple], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag], [[1]])[
|
||||
/* The user-facing name of the symbol whose (internal) number is
|
||||
YYSYMBOL. No bounds checking. */
|
||||
static const char *yysymbol_name (int yysymbol) YY_ATTRIBUTE_UNUSED;
|
||||
@@ -2010,7 +2010,7 @@ yyabortlab:
|
||||
goto yyreturn;
|
||||
|
||||
|
||||
#if ]b4_lac_if([[1]], [b4_error_verbose_if([[1]], [[!defined yyoverflow]])])[
|
||||
#if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[
|
||||
/*-------------------------------------------------.
|
||||
| yyexhaustedlab -- memory exhaustion comes here. |
|
||||
`-------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user