[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/4] deprecation: issue warnings in scanner
From: |
Akim Demaille |
Subject: |
Re: [PATCH 1/4] deprecation: issue warnings in scanner |
Date: |
Wed, 24 Oct 2012 14:14:03 +0200 |
Hi Théophile,
Le 24 oct. 2012 à 14:12, Theophile Ranquet a écrit :
> * src/parse-gram.y: Move 3 deprecated constructs…
You didn't move the constructs, just their handling.
> * src/scan-gram.l: ...Here, and issue warnings.
> (DEPRECATED): New.
> ---
> src/parse-gram.y | 4 ----
> src/scan-gram.l | 47 +++++++++++++++++++++++++++++++++++++----------
> tests/calc.at | 2 +-
> tests/output.at | 4 ++--
> 4 files changed, 40 insertions(+), 17 deletions(-)
>
> diff --git a/src/parse-gram.y b/src/parse-gram.y
> index f0187fb..1624dde 100644
> --- a/src/parse-gram.y
> +++ b/src/parse-gram.y
> @@ -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
> diff --git a/src/scan-gram.l b/src/scan-gram.l
> index 8e48148..a958db0 100644
> --- a/src/scan-gram.l
> +++ b/src/scan-gram.l
> @@ -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)
Can't this be a function?
> +
> /* A string representing the most recently saved token. */
> static char *last_string;
>
> @@ -134,6 +146,8 @@ tag [^\0<>]+
> white space between the backslash and the newline. */
> splice (\\[ \f\t\v]*\n)*
>
> +eqopt ([[:space:]]*=)?
A comment would be nice.
> +
> %%
> %{
> /* Nesting level. Either for nested braces, or nested angle brackets
> @@ -198,16 +212,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 +229,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 +241,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");
I believe this should be "%define api.pure".
> + "%token"[-_]"table" DEPRECATED("%token-table");
> +
> {directive} {
> complain (loc, complaint, _("invalid directive: %s"), quote (yytext));
> }
> diff --git a/tests/calc.at b/tests/calc.at
> index a6c6742..5a6af10 100644
> --- a/tests/calc.at
> +++ b/tests/calc.at
> @@ -637,7 +637,7 @@ AT_CHECK_CALC_LALR()
> AT_CHECK_CALC_LALR([%defines])
> AT_CHECK_CALC_LALR([%locations])
>
> -AT_CHECK_CALC_LALR([%name-prefix="calc"]) dnl test deprecated `='
> +AT_CHECK_CALC_LALR([%name-prefix "calc"]) dnl test deprecated `='
Obviously the comment is to be removed, if the test is indeed
performed elsewhere.
> AT_CHECK_CALC_LALR([%verbose])
> AT_CHECK_CALC_LALR([%yacc])
> AT_CHECK_CALC_LALR([%define parse.error verbose])
> diff --git a/tests/output.at b/tests/output.at
> index 3a13fd3..d3e3e6e 100644
> --- a/tests/output.at
> +++ b/tests/output.at
> @@ -81,10 +81,10 @@ AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
> # Exercise %output and %file-prefix including deprecated '='
> AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
> [bar.output bar.tab.c bar.tab.h])
> -AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[],
> +AT_CHECK_OUTPUT([foo.y], [%output "bar.c" %defines %verbose %yacc],[],
> [bar.c bar.h bar.output])
> AT_CHECK_OUTPUT([foo.y],
> - [%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
> + [%file-prefix "baz" %output "bar.c" %defines %verbose %yacc],
> [],
> [bar.c bar.h bar.output])
>
> --
> 1.7.11.4
>
- [PATCH 0/4] deprecation in scanner, Theophile Ranquet, 2012/10/24
- [PATCH 1/4] deprecation: issue warnings in scanner, Theophile Ranquet, 2012/10/24
- Re: [PATCH 1/4] deprecation: issue warnings in scanner,
Akim Demaille <=
- [PATCH 4/4] misc: document TESTSUITEFLAGS in README-hacking, Theophile Ranquet, 2012/10/24
- [PATCH 3/4] deprecation: add tests, Theophile Ranquet, 2012/10/24
- [PATCH 2/4] regen, Theophile Ranquet, 2012/10/24
- Re: [PATCH 0/4] deprecation in scanner, Akim Demaille, 2012/10/24