diagnostics: improve the accuracy for %error-verbose

Avoid duplicate warnings about %error-verbose, once for deprecation,
another for duplicate.  Keep only the duplicate warning for the second
occurrence of %error-verbose.

This will help removal fixits.

* src/scan-gram.l (%error-verbose): Return as a PERCENT_ERROR_VERBOSE
token.
* src/parse-gram.y (do_error_verbose): New.
Use it.
* src/muscle-tab.c (muscle_percent_variable_update): Handle pseudo
variables such as %error-verbose.
This commit is contained in:
Akim Demaille
2019-01-13 13:13:21 +01:00
parent 8580b268c3
commit ba469451d8
4 changed files with 33 additions and 18 deletions

View File

@@ -446,6 +446,8 @@ muscle_percent_variable_update (char const *variable,
} conversion_type;
const conversion_type conversion[] =
{
{ "%error-verbose", "parse.error=verbose", muscle_keyword },
{ "%error_verbose", "parse.error=verbose", muscle_keyword },
{ "abstract", "api.parser.abstract", muscle_keyword },
{ "annotations", "api.parser.annotations", muscle_code },
{ "api.push_pull", "api.push-pull", muscle_keyword },
@@ -477,7 +479,9 @@ muscle_percent_variable_update (char const *variable,
: STREQ (c->obsolete, variable))
{
/* Generate the deprecation warning. */
*old = define_directive (c->obsolete, kind, *value);
*old = c->obsolete[0] == '%'
? xstrdup (c->obsolete)
: define_directive (c->obsolete, kind, *value);
*upd = define_directive (c->updated, c->kind, *value);
/* Update the variable and its value. */
{

View File

@@ -82,6 +82,9 @@
string from the scanner (should be CODE). */
static char const *translate_code_braceless (char *code, location loc);
/* Handle a %error-verbose directive. */
static void do_error_verbose (location const *loc, char const *directive);
/* Handle a %name-prefix directive. */
static void do_name_prefix (location const *loc,
char const *directive, char const *value);
@@ -151,6 +154,7 @@
PERCENT_DEFAULT_PREC "%default-prec"
PERCENT_DEFINE "%define"
PERCENT_DEFINES "%defines"
PERCENT_ERROR_VERBOSE "%error-verbose"
PERCENT_EXPECT "%expect"
PERCENT_EXPECT_RR "%expect-rr"
PERCENT_FLAG "%<flag>"
@@ -196,7 +200,8 @@
%printer { fprintf (yyo, "{\n%s\n}", $$); } <char*>
%type <uniqstr>
BRACKETED_ID ID ID_COLON PERCENT_FLAG PERCENT_NAME_PREFIX TAG
BRACKETED_ID ID ID_COLON
PERCENT_ERROR_VERBOSE PERCENT_FLAG PERCENT_NAME_PREFIX TAG
tag tag.opt variable
%printer { fputs ($$, yyo); } <uniqstr>
%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
@@ -300,6 +305,7 @@ prologue_declaration:
defines_flag = true;
spec_defines_file = xstrdup ($2);
}
| "%error-verbose" { do_error_verbose (&@$, $1); }
| "%expect" INT { expected_sr_conflicts = $2; }
| "%expect-rr" INT { expected_rr_conflicts = $2; }
| "%file-prefix" STRING { spec_file_prefix = $2; }
@@ -853,6 +859,15 @@ add_param (param_type type, char *decl, location loc)
}
static void
do_error_verbose (location const *loc, char const *directive)
{
bison_directive (loc, directive);
muscle_percent_define_insert (directive, *loc, muscle_keyword, "",
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
}
static void
do_name_prefix (location const *loc,
char const *directive, char const *value)

View File

@@ -263,7 +263,7 @@ eqopt ({sp}=)?
/* Deprecated since Bison 3.0 (2013-07-25), but the warning is
issued only since Bison 3.3. */
"%error-verbose" DEPRECATED ("%define parse.error verbose");
"%error-verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
/* Deprecated since Bison 2.6 (2012-07-19), but the warning is
issued only since Bison 3.3. */
@@ -271,7 +271,7 @@ eqopt ({sp}=)?
/* Deprecated since Bison 2.7.90, 2012. */
"%default"[-_]"prec" DEPRECATED ("%default-prec");
"%error"[-_]"verbose" DEPRECATED ("%define parse.error verbose");
"%error"[-_]"verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
"%expect"[-_]"rr" DEPRECATED ("%expect-rr");
"%file-prefix"{eqopt} DEPRECATED ("%file-prefix");
"%fixed"[-_]"output"[-_]"files" DEPRECATED ("%fixed-output-files");