bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

diagnostics: %pure-parser is obsolete (was: I need simpler examples)


From: Akim Demaille
Subject: diagnostics: %pure-parser is obsolete (was: I need simpler examples)
Date: Sun, 19 May 2019 10:07:29 +0200

Hi!

> Le 12 déc. 2018 à 12:06, Uxio Prego <address@hidden> a écrit :
> 
> Hi, judging these docs and multiple changelog entries mentioning
> `%define api.pure` as a replacement for `%pure-parser`, and the
> latter being turned to wrapper on the former at some point, etc.;
> 
> I would expect that tests/input.at recommend, for `%pure_parser`,
> `%define api.pure` optionally `%define api.pure full`, instead of
> `%pure-parser`? Around line 2372, that’s the test side. I don't
> know where is the non-test code side of that, and I don't feel that
> much momentum to find out and propose a patch.

You are fully right.  Sorry it took so long...

Thanks a lot for the report!

I'm installing this.

commit a250c6d6b3ea144af6f9021715753878462ff32e
Author: Akim Demaille <address@hidden>
Date:   Sun May 19 08:15:08 2019 +0200

    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.

diff --git a/doc/bison.texi b/doc/bison.texi
index 821a5b4c..d5913e8f 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -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
 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
address@hidden api.pure} directives do nothing when used in Java.
+Therefore, all Java parsers are ``pure'', and the @code{%define api.pure}
+directive does nothing when used in Java.
 
 Push parsers are currently unsupported in Java and @code{%define
 api.push-pull} have no effect.
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 175cfd62..c7cc35fd 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -94,6 +94,9 @@
   static void handle_name_prefix (location const *loc,
                                   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.  */
   static void handle_require (location const *loc, char const *version);
 
@@ -181,6 +184,7 @@
   PERCENT_NONDETERMINISTIC_PARSER
                           "%nondeterministic-parser"
   PERCENT_OUTPUT          "%output"
+  PERCENT_PURE_PARSER     "%pure-parser"
   PERCENT_REQUIRE         "%require"
   PERCENT_SKELETON        "%skeleton"
   PERCENT_START           "%start"
@@ -219,7 +223,7 @@
 %type <uniqstr>
   BRACKETED_ID ID ID_COLON
   PERCENT_ERROR_VERBOSE PERCENT_FILE_PREFIX PERCENT_FLAG PERCENT_NAME_PREFIX
-  PERCENT_YACC
+  PERCENT_PURE_PARSER PERCENT_YACC
   TAG tag tag.opt variable
 %printer { fputs ($$, yyo); } <uniqstr>
 %printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
@@ -343,6 +347,7 @@ prologue_declaration:
 | "%nondeterministic-parser"    { nondeterministic_parser = true; }
 | "%output" STRING              { spec_outfile = $2; }
 | "%param" { current_param = $1; } params { current_param = param_none; }
+| "%pure-parser"                { handle_pure_parser (&@$, $1); }
 | "%require" STRING             { handle_require (&@2, $2); }
 | "%skeleton" STRING            { handle_skeleton (&@2, $2); }
 | "%token-table"                { token_table_flag = true; }
@@ -910,6 +915,7 @@ handle_file_prefix (location const *loc,
     deprecated_directive (dir_loc, directive, "%file-prefix");
 }
 
+
 static void
 handle_name_prefix (location const *loc,
                     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
 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);
 }
 
+
 static void
 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");
 }
 
+
 static void
 gram_error (location const *loc, char const *msg)
 {
diff --git a/src/scan-gram.l b/src/scan-gram.l
index ca4173b8..66a8caa7 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -252,7 +252,6 @@ eqopt    ({sp}=)?
   "%prec"                           return PERCENT_PREC;
   "%precedence"                     return BISON_DIRECTIVE (PRECEDENCE);
   "%printer"                        return BISON_DIRECTIVE (PRINTER);
-  "%pure-parser"                    RETURN_PERCENT_FLAG ("api.pure");
   "%require"                        return BISON_DIRECTIVE (REQUIRE);
   "%right"                          return PERCENT_RIGHT;
   "%skeleton"                       return BISON_DIRECTIVE (SKELETON);
@@ -265,6 +264,10 @@ eqopt    ({sp}=)?
   "%verbose"                        return BISON_DIRECTIVE (VERBOSE);
   "%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
      issued only since Bison 3.3. */
   "%error-verbose"                  RETURN_VALUE (PERCENT_ERROR_VERBOSE, 
uniqstr_new (yytext));
@@ -282,7 +285,6 @@ eqopt    ({sp}=)?
   "%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");
 
   "%"{id} {
diff --git a/tests/actions.at b/tests/actions.at
index 1f279a89..ee49b2ba 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -1870,7 +1870,7 @@ AT_DATA_GRAMMAR([input.y],
 [[
 %define parse.error verbose
 %debug
-%pure-parser
+%define api.pure
 %code {
 # include <stdio.h>
 # include <stdlib.h>
diff --git a/tests/input.at b/tests/input.at
index c2a4478d..cc5e41fb 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -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"
 input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' 
[-Wdeprecated]
 fix-it:"input.y":{24:1-24:10}:"%output"
-input.y:25.1-12: warning: deprecated directive: '%pure_parser', use 
'%pure-parser' [-Wdeprecated]
-fix-it:"input.y":{25:1-25:13}:"%pure-parser"
+input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%define 
api.pure' [-Wdeprecated]
+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]
 fix-it:"input.y":{26:1-26:13}:"%token-table"
 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-lines
 %output "output.c"
-%pure-parser
+%define api.pure
 %token-table
 %glr-parser
 %%
@@ -2678,7 +2678,6 @@ AT_DATA_GRAMMAR([[input.y]],
 %no-default-prec
 %no-lines
 %output "foo"
-%pure-parser
 %token-table
 %% exp : '0'
 ]])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]