deprecation: issue warnings in scanner

* src/parse-gram.y: Move the handling of (three) deprecated constructs ...
* src/scan-gram.l: ...Here, and issue warnings.
(DEPRECATED): New.
This commit is contained in:
Theophile Ranquet
2012-10-18 18:00:51 +00:00
parent d949eefdd3
commit 2062d72deb
4 changed files with 42 additions and 17 deletions

View File

@@ -317,7 +317,6 @@ prologue_declaration:
| "%expect" INT { expected_sr_conflicts = $2; }
| "%expect-rr" INT { expected_rr_conflicts = $2; }
| "%file-prefix" STRING { spec_file_prefix = $2; }
| "%file-prefix" "=" STRING { spec_file_prefix = $3; } /* deprecated */
| "%glr-parser"
{
nondeterministic_parser = true;
@@ -334,11 +333,9 @@ prologue_declaration:
}
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
| "%name-prefix" STRING { spec_name_prefix = $2; }
| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
| "%no-lines" { no_lines_flag = true; }
| "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" STRING { spec_outfile = $2; }
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
| "%param" { current_param = $1; } params { current_param = param_none; }
| "%require" STRING { version_check (&@2, $2); }
| "%skeleton" STRING
@@ -724,7 +721,6 @@ epilogue.opt:
%%
/* Return the location of the left-hand side of a rule whose
right-hand side is RHS[1] ... RHS[N]. Ignore empty nonterminals in
the right-hand side, and return an empty location equal to the end

View File

@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
%option debug nodefault noinput nounput noyywrap never-interactive
%option debug nodefault noinput noyywrap never-interactive
%option prefix="gram_" outfile="lex.yy.c"
%{
@@ -31,6 +31,7 @@
#include <src/complain.h>
#include <src/files.h>
#include <src/getargs.h>
#include <src/gram.h>
#include <quotearg.h>
#include <src/reader.h>
@@ -73,6 +74,17 @@ static size_t no_cr_read (FILE *, char *, size_t);
yyless (0); \
} while (0)
#define DEPRECATED(Msg) \
do { \
size_t i; \
complain (loc, Wdeprecated, \
_("deprecated directive: %s, use %s"), \
quote (yytext), quote_n (1, Msg)); \
scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \
for (i = strlen (Msg); i != 0; --i) \
unput (Msg[i - 1]); \
} while (0)
/* A string representing the most recently saved token. */
static char *last_string;
@@ -134,6 +146,10 @@ tag [^\0<>]+
white space between the backslash and the newline. */
splice (\\[ \f\t\v]*\n)*
/* An equal sign, with optional leading whitespaces. This is used in some
deprecated constructs. */
eqopt ([[:space:]]*=)?
%%
%{
/* Nesting level. Either for nested braces, or nested angle brackets
@@ -198,16 +214,16 @@ splice (\\[ \f\t\v]*\n)*
"%binary" return PERCENT_NONASSOC;
"%code" return PERCENT_CODE;
"%debug" RETURN_PERCENT_FLAG("parse.trace");
"%default"[-_]"prec" return PERCENT_DEFAULT_PREC;
"%default-prec" return PERCENT_DEFAULT_PREC;
"%define" return PERCENT_DEFINE;
"%defines" return PERCENT_DEFINES;
"%destructor" return PERCENT_DESTRUCTOR;
"%dprec" return PERCENT_DPREC;
"%error"[-_]"verbose" return PERCENT_ERROR_VERBOSE;
"%error-verbose" return PERCENT_ERROR_VERBOSE;
"%expect" return PERCENT_EXPECT;
"%expect"[-_]"rr" return PERCENT_EXPECT_RR;
"%expect-rr" return PERCENT_EXPECT_RR;
"%file-prefix" return PERCENT_FILE_PREFIX;
"%fixed"[-_]"output"[-_]"files" return PERCENT_YACC;
"%fixed-output-files" return PERCENT_YACC;
"%initial-action" return PERCENT_INITIAL_ACTION;
"%glr-parser" return PERCENT_GLR_PARSER;
"%language" return PERCENT_LANGUAGE;
@@ -215,9 +231,9 @@ splice (\\[ \f\t\v]*\n)*
"%lex-param" RETURN_PERCENT_PARAM(lex);
"%locations" RETURN_PERCENT_FLAG("locations");
"%merge" return PERCENT_MERGE;
"%name"[-_]"prefix" return PERCENT_NAME_PREFIX;
"%no"[-_]"default"[-_]"prec" return PERCENT_NO_DEFAULT_PREC;
"%no"[-_]"lines" return PERCENT_NO_LINES;
"%name-prefix" return PERCENT_NAME_PREFIX;
"%no-default-prec" return PERCENT_NO_DEFAULT_PREC;
"%no-lines" return PERCENT_NO_LINES;
"%nonassoc" return PERCENT_NONASSOC;
"%nondeterministic-parser" return PERCENT_NONDETERMINISTIC_PARSER;
"%nterm" return PERCENT_NTERM;
@@ -227,19 +243,32 @@ splice (\\[ \f\t\v]*\n)*
"%prec" return PERCENT_PREC;
"%precedence" return PERCENT_PRECEDENCE;
"%printer" return PERCENT_PRINTER;
"%pure"[-_]"parser" RETURN_PERCENT_FLAG("api.pure");
"%pure-parser" RETURN_PERCENT_FLAG("api.pure");
"%require" return PERCENT_REQUIRE;
"%right" return PERCENT_RIGHT;
"%skeleton" return PERCENT_SKELETON;
"%start" return PERCENT_START;
"%term" return PERCENT_TOKEN;
"%token" return PERCENT_TOKEN;
"%token"[-_]"table" return PERCENT_TOKEN_TABLE;
"%token-table" return PERCENT_TOKEN_TABLE;
"%type" return PERCENT_TYPE;
"%union" return PERCENT_UNION;
"%verbose" return PERCENT_VERBOSE;
"%yacc" return PERCENT_YACC;
/* deprecated */
"%default"[-_]"prec" DEPRECATED("%default-prec");
"%error"[-_]"verbose" DEPRECATED("%define parse.error verbose");
"%expect"[-_]"rr" DEPRECATED("%expect-rr");
"%file-prefix"{eqopt} DEPRECATED("%file-prefix");
"%fixed"[-_]"output"[-_]"files" DEPRECATED("%fixed-output-files");
"%name"[-_]"prefix"{eqopt} DEPRECATED("%name-prefix");
"%no"[-_]"default"[-_]"prec" DEPRECATED("%no-default-prec");
"%no"[-_]"lines" DEPRECATED("%no-lines");
"%output"{eqopt} DEPRECATED("%output");
"%pure"[-_]"parser" DEPRECATED("%pure-parser");
"%token"[-_]"table" DEPRECATED("%token-table");
{directive} {
complain (loc, complaint, _("invalid directive: %s"), quote (yytext));
}