diagnostics: %pure-parser is obsolete

Reported by Uxio Prego.
http://lists.gnu.org/archive/html/bug-bison/2018-12/msg00029.html

* src/scan-gram.l, src/parse-gram.y (PERCENT_PURE_PARSER)
(handle_pure_parser): New.
Issue a deprecation/update notice for %pure-parser.
* doc/bison.texi (Java Bison Interface): Don't mention %pure-parser.
* tests/actions.at, tests/input.at: Adjust.
This commit is contained in:
Akim Demaille
2019-05-19 08:15:08 +02:00
parent cae8132690
commit de5207244b
6 changed files with 30 additions and 10 deletions

1
THANKS
View File

@@ -179,6 +179,7 @@ Tom Tromey tromey@cygnus.com
Tommy Nordgren tommy.nordgren@chello.se Tommy Nordgren tommy.nordgren@chello.se
Troy A. Johnson troyj@ecn.purdue.edu Troy A. Johnson troyj@ecn.purdue.edu
Tys Lefering gccbison@gmail.com Tys Lefering gccbison@gmail.com
Uxio Prego uxio.prego@gmail.com
Valentin Tolmer nitnelave1@gmail.com Valentin Tolmer nitnelave1@gmail.com
wcventure wcventure@126.com wcventure wcventure@126.com
Victor Khomenko victor.khomenko@newcastle.ac.uk Victor Khomenko victor.khomenko@newcastle.ac.uk

View File

@@ -12416,8 +12416,8 @@ You can create documentation for generated parsers using Javadoc.
Contrary to C parsers, Java parsers do not use global variables; the state Contrary to C parsers, Java parsers do not use global variables; the state
of the parser is always local to an instance of the parser class. of the parser is always local to an instance of the parser class.
Therefore, all Java parsers are ``pure'', and the @code{%pure-parser} and Therefore, all Java parsers are ``pure'', and the @code{%define api.pure}
@code{%define api.pure} directives do nothing when used in Java. directive does nothing when used in Java.
Push parsers are currently unsupported in Java and @code{%define Push parsers are currently unsupported in Java and @code{%define
api.push-pull} have no effect. api.push-pull} have no effect.

View File

@@ -94,6 +94,9 @@
static void handle_name_prefix (location const *loc, static void handle_name_prefix (location const *loc,
char const *directive, char const *value); char const *directive, char const *value);
/* Handle a %pure-parser directive. */
static void handle_pure_parser (location const *loc, char const *directive);
/* Handle a %require directive. */ /* Handle a %require directive. */
static void handle_require (location const *loc, char const *version); static void handle_require (location const *loc, char const *version);
@@ -181,6 +184,7 @@
PERCENT_NONDETERMINISTIC_PARSER PERCENT_NONDETERMINISTIC_PARSER
"%nondeterministic-parser" "%nondeterministic-parser"
PERCENT_OUTPUT "%output" PERCENT_OUTPUT "%output"
PERCENT_PURE_PARSER "%pure-parser"
PERCENT_REQUIRE "%require" PERCENT_REQUIRE "%require"
PERCENT_SKELETON "%skeleton" PERCENT_SKELETON "%skeleton"
PERCENT_START "%start" PERCENT_START "%start"
@@ -219,7 +223,7 @@
%type <uniqstr> %type <uniqstr>
BRACKETED_ID ID ID_COLON BRACKETED_ID ID ID_COLON
PERCENT_ERROR_VERBOSE PERCENT_FILE_PREFIX PERCENT_FLAG PERCENT_NAME_PREFIX PERCENT_ERROR_VERBOSE PERCENT_FILE_PREFIX PERCENT_FLAG PERCENT_NAME_PREFIX
PERCENT_YACC PERCENT_PURE_PARSER PERCENT_YACC
TAG tag tag.opt variable TAG tag tag.opt variable
%printer { fputs ($$, yyo); } <uniqstr> %printer { fputs ($$, yyo); } <uniqstr>
%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID %printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
@@ -343,6 +347,7 @@ prologue_declaration:
| "%nondeterministic-parser" { nondeterministic_parser = true; } | "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" STRING { spec_outfile = $2; } | "%output" STRING { spec_outfile = $2; }
| "%param" { current_param = $1; } params { current_param = param_none; } | "%param" { current_param = $1; } params { current_param = param_none; }
| "%pure-parser" { handle_pure_parser (&@$, $1); }
| "%require" STRING { handle_require (&@2, $2); } | "%require" STRING { handle_require (&@2, $2); }
| "%skeleton" STRING { handle_skeleton (&@2, $2); } | "%skeleton" STRING { handle_skeleton (&@2, $2); }
| "%token-table" { token_table_flag = true; } | "%token-table" { token_table_flag = true; }
@@ -910,6 +915,7 @@ handle_file_prefix (location const *loc,
deprecated_directive (dir_loc, directive, "%file-prefix"); deprecated_directive (dir_loc, directive, "%file-prefix");
} }
static void static void
handle_name_prefix (location const *loc, handle_name_prefix (location const *loc,
char const *directive, char const *value) char const *directive, char const *value)
@@ -944,6 +950,16 @@ handle_name_prefix (location const *loc,
} }
static void
handle_pure_parser (location const *loc, char const *directive)
{
bison_directive (loc, directive);
deprecated_directive (loc, directive, "%define api.pure");
muscle_percent_define_insert ("api.pure", *loc, muscle_keyword, "",
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
}
static void static void
handle_require (location const *loc, char const *version) handle_require (location const *loc, char const *version)
{ {
@@ -1006,6 +1022,7 @@ handle_skeleton (location const *loc, char const *skel)
skeleton_arg (skeleton_user, grammar_prio, *loc); skeleton_arg (skeleton_user, grammar_prio, *loc);
} }
static void static void
handle_yacc (location const *loc, char const *directive) handle_yacc (location const *loc, char const *directive)
{ {
@@ -1026,6 +1043,7 @@ handle_yacc (location const *loc, char const *directive)
deprecated_directive (loc, directive, "%fixed-output-files"); deprecated_directive (loc, directive, "%fixed-output-files");
} }
static void static void
gram_error (location const *loc, char const *msg) gram_error (location const *loc, char const *msg)
{ {

View File

@@ -252,7 +252,6 @@ eqopt ({sp}=)?
"%prec" return PERCENT_PREC; "%prec" return PERCENT_PREC;
"%precedence" return BISON_DIRECTIVE (PRECEDENCE); "%precedence" return BISON_DIRECTIVE (PRECEDENCE);
"%printer" return BISON_DIRECTIVE (PRINTER); "%printer" return BISON_DIRECTIVE (PRINTER);
"%pure-parser" RETURN_PERCENT_FLAG ("api.pure");
"%require" return BISON_DIRECTIVE (REQUIRE); "%require" return BISON_DIRECTIVE (REQUIRE);
"%right" return PERCENT_RIGHT; "%right" return PERCENT_RIGHT;
"%skeleton" return BISON_DIRECTIVE (SKELETON); "%skeleton" return BISON_DIRECTIVE (SKELETON);
@@ -265,6 +264,10 @@ eqopt ({sp}=)?
"%verbose" return BISON_DIRECTIVE (VERBOSE); "%verbose" return BISON_DIRECTIVE (VERBOSE);
"%yacc" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext)); "%yacc" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext));
/* Deprecated since Bison 2.3b (2008-05-27), but the warning is
issued only since Bison 3.4. */
"%pure"[-_]"parser" RETURN_VALUE (PERCENT_PURE_PARSER, uniqstr_new (yytext));
/* Deprecated since Bison 3.0 (2013-07-25), but the warning is /* Deprecated since Bison 3.0 (2013-07-25), but the warning is
issued only since Bison 3.3. */ issued only since Bison 3.3. */
"%error-verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext)); "%error-verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
@@ -282,7 +285,6 @@ eqopt ({sp}=)?
"%no"[-_]"default"[-_]"prec" DEPRECATED ("%no-default-prec"); "%no"[-_]"default"[-_]"prec" DEPRECATED ("%no-default-prec");
"%no"[-_]"lines" DEPRECATED ("%no-lines"); "%no"[-_]"lines" DEPRECATED ("%no-lines");
"%output"{eqopt} DEPRECATED ("%output"); "%output"{eqopt} DEPRECATED ("%output");
"%pure"[-_]"parser" DEPRECATED ("%pure-parser");
"%token"[-_]"table" DEPRECATED ("%token-table"); "%token"[-_]"table" DEPRECATED ("%token-table");
"%"{id} { "%"{id} {

View File

@@ -1870,7 +1870,7 @@ AT_DATA_GRAMMAR([input.y],
[[ [[
%define parse.error verbose %define parse.error verbose
%debug %debug
%pure-parser %define api.pure
%code { %code {
# include <stdio.h> # include <stdio.h>
# include <stdlib.h> # include <stdlib.h>

View File

@@ -2556,8 +2556,8 @@ input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wd
fix-it:"input.y":{23:1-23:10}:"%no-lines" fix-it:"input.y":{23:1-23:10}:"%no-lines"
input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated] input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
fix-it:"input.y":{24:1-24:10}:"%output" fix-it:"input.y":{24:1-24:10}:"%output"
input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated] input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%define api.pure' [-Wdeprecated]
fix-it:"input.y":{25:1-25:13}:"%pure-parser" fix-it:"input.y":{25:1-25:13}:"%define api.pure"
input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated] input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
fix-it:"input.y":{26:1-26:13}:"%token-table" fix-it:"input.y":{26:1-26:13}:"%token-table"
input.y:27.1-14: warning: %define variable 'parse.error' redefined [-Wother] input.y:27.1-14: warning: %define variable 'parse.error' redefined [-Wother]
@@ -2603,7 +2603,7 @@ AT_CHECK([sed -e '1,8d' input.y], [],
%no-default-prec %no-default-prec
%no-lines %no-lines
%output "output.c" %output "output.c"
%pure-parser %define api.pure
%token-table %token-table
%glr-parser %glr-parser
%% %%
@@ -2678,7 +2678,6 @@ AT_DATA_GRAMMAR([[input.y]],
%no-default-prec %no-default-prec
%no-lines %no-lines
%output "foo" %output "foo"
%pure-parser
%token-table %token-table
%% exp : '0' %% exp : '0'
]]) ]])