mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
diagnostics: improve them for %name-prefix
Currently the diagnostics for %name-prefix are not precise enough. In
particular, they does not show that braces must be used instead of
quotes.
Before:
foo.y:3.1-14: warning: deprecated directive, use '%define api.prefix' [-Wdeprecated]
%name-prefix = "foo"
^^^^^^^^^^^^^^
After:
foo.y:3.1-20: warning: deprecated directive, use '%define api.prefix {foo}' [-Wdeprecated]
%name-prefix = "foo"
^^^^^^^^^^^^^^^^^^^^
To do this we need the value passed to %name-prefix, so move the
warning from the scanner to the parser.
Accuracy will be very important for the forthcoming changes.
* src/parse-gram.y (do_name_prefix): New.
(PERCENT_NAME_PREFIX): Have a semantic value: the raw source, with
possibly underscores, equal sign, and spaces. This is used to provide
a more accurate message. It does not take comments into account,
but...
* src/scan-gram.l (%name-prefix): Delegate the warnings to the parser.
* tests/headers.at, tests/input.at: Adjust expectations.
This commit is contained in:
@@ -144,7 +144,8 @@ splice (\\[ \f\t\v]*\n)*
|
||||
|
||||
/* An equal sign, with optional leading whitespaces. This is used in some
|
||||
deprecated constructs. */
|
||||
eqopt ([[:space:]]*=)?
|
||||
sp [[:space:]]*
|
||||
eqopt ({sp}=)?
|
||||
|
||||
%%
|
||||
%{
|
||||
@@ -266,10 +267,7 @@ eqopt ([[:space:]]*=)?
|
||||
|
||||
/* Deprecated since Bison 2.6 (2012-07-19), but the warning is
|
||||
issued only since Bison 3.3. */
|
||||
"%name"[-_]"prefix"{eqopt} {
|
||||
deprecated_directive (loc, yytext, "%define api.prefix");
|
||||
return BISON_DIRECTIVE (NAME_PREFIX);
|
||||
}
|
||||
"%name"[-_]"prefix"{eqopt}{sp} RETURN_VALUE (PERCENT_NAME_PREFIX, uniqstr_new (yytext));
|
||||
|
||||
/* Deprecated since Bison 2.7.90, 2012. */
|
||||
"%default"[-_]"prec" DEPRECATED ("%default-prec");
|
||||
|
||||
Reference in New Issue
Block a user