bison-patches
[Top][All Lists]
Advanced

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

Re: remove YYFAIL from lalr1.java and yacc.c


From: Joel E. Denny
Subject: Re: remove YYFAIL from lalr1.java and yacc.c
Date: Sun, 20 Dec 2009 14:18:38 -0500 (EST)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

Hi Paolo,

On Sun, 20 Dec 2009, Paolo Bonzini wrote:

> No problems for me for lalr1.java; for yacc.c however we have some uses:
> 
> http://www.google.com/codesearch?hl=en&lr=&q=YYFAIL%3B&sbtn=Search
> 
> Some of them are my own GNU Smalltalk (no problem, I now switched to recursive
> descent) and of course GCC 1.  However there are still about 5-6 other users.
> I don't think it's reasonably possible for YYFAIL to die anytime soon.

Thanks very much for that info.

Here are a couple of patches to begin to phase out YYFAIL.  Based on your 
research, the process will have to be very slow.

I'd like to push the first patch to master, branch-2.5, and branch-2.4.2 
in order to formally deprecate YYFAIL.

I'd like to push the second patch to master and branch-2.5 in order to 
generate warnings about uses of YYFAIL.  I always worry that attempts to 
decipher literal code from users is error-prone.  I'd appreciate any 
corrections or other comments.

>From 2ffce5412c9436eefc18b7198b31dce6e1c20e08 Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Sun, 20 Dec 2009 13:38:26 -0500
Subject: [PATCH] YYFAIL: deprecate.

* NEWS (2.4.2): Document deprecation.
* data/lalr1.java (YYStack::YYFAIL): Add comment about
deprecation.
* data/yacc.c (YYFAIL): Likewise.
* doc/bison.texinfo (Java Action Features): Remove YYFAIL
documentation.
(LocalWords): Remove YYFAIL.
---
 ChangeLog         |   11 +++++++++++
 NEWS              |   27 +++++++++++++++++++++++++++
 data/lalr1.java   |    3 ++-
 data/yacc.c       |    5 ++++-
 doc/bison.texinfo |    7 +------
 5 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1c15cc5..aed5998 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-12-20  Joel E. Denny  <address@hidden>
+
+       YYFAIL: deprecate.
+       * NEWS (2.4.2): Document deprecation.
+       * data/lalr1.java (YYStack::YYFAIL): Add comment about
+       deprecation.
+       * data/yacc.c (YYFAIL): Likewise.
+       * doc/bison.texinfo (Java Action Features): Remove YYFAIL
+       documentation.
+       (LocalWords): Remove YYFAIL.
+
 2009-12-18  Joel E. Denny  <address@hidden>
 
        lalr1.cc: don't discard non-existent lookahead on syntax error.
diff --git a/NEWS b/NEWS
index 92567dd..7e8bd9f 100644
--- a/NEWS
+++ b/NEWS
@@ -243,6 +243,33 @@ Bison News
   Bison's Java feature as a whole including its current usage of %code
   is still considered experimental.
 
+** YYFAIL is deprecated.
+
+  YYFAIL has existed for many years as an undocumented feature of
+  deterministic parsers in C generated by Bison.  Previously, it was
+  documented for Bison's experimental Java parsers.  YYFAIL is no longer
+  documented for Java parsers and is formally deprecated in both cases.
+  Users are strongly encouraged to migrate to YYERROR, which has been
+  documented for many years.
+
+  Like YYERROR, you can invoke YYFAIL from a semantic action in order to
+  induce a syntax error.  The most obvious difference from YYERROR is
+  that YYFAIL will automatically invoke yyerror to report the syntax
+  error so that you don't have to.  However, there are several other
+  subtle differences between YYERROR and YYFAIL, and YYFAIL suffers from
+  inherent flaws when %error-verbose is used.  For a more detailed
+  discussion, see:
+
+    http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html
+
+  YYFAIL will continue to be maintained for deterministic parsers in C
+  and Java for the immediate future.  However, because YYFAIL is already
+  flawed, it would be futile to try to make new Bison features
+  compatible with it.  During parser generation, some future release of
+  Bison will begin to produce warnings whenever it discovers YYFAIL in a
+  semantic action.  In a later release, YYFAIL will be disabled for
+  %error-verbose.  Eventually, it will be removed altogether.
+
 ** Internationalization.
 
   Fix a regression introduced in Bison 2.4: Under some circumstances,
diff --git a/data/lalr1.java b/data/lalr1.java
index 6637c3a..a9ae873 100644
--- a/data/lalr1.java
+++ b/data/lalr1.java
@@ -352,7 +352,8 @@ b4_lexer_if([[
 
   /**
    * Returned by a Bison action in order to print an error message and start
-   * error recovery.  */
+   * error recovery.  Formally deprecated in Bison 2.4.2's NEWS entry, where
+   * a plan to phase it out is discussed.  */
   public static final int YYFAIL = 3;
 
   private static final int YYNEWSTATE = 4;
diff --git a/data/yacc.c b/data/yacc.c
index 11ebbf1..6e74620 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -609,7 +609,10 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
 
 /* Like YYERROR except do call yyerror.  This remains here temporarily
    to ease the transition to the new meaning of YYERROR, for GCC.
-   Once GCC version 2 has supplanted version 1, this can go.  */
+   Once GCC version 2 has supplanted version 1, this can go.  However,
+   YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
+   in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+   discussed.  */
 
 #define YYFAIL         goto yyerrlab
 
diff --git a/doc/bison.texinfo b/doc/bison.texinfo
index 2af8917..ab2cd6c 100644
--- a/doc/bison.texinfo
+++ b/doc/bison.texinfo
@@ -9925,11 +9925,6 @@ Start error recovery without printing an error message.
 @xref{Error Recovery}.
 @end deffn
 
address@hidden {Statement} {return YYFAIL;}
-Print an error message and start error recovery.
address@hidden Recovery}.
address@hidden deffn
-
 @deftypefn {Function} {boolean} recovering ()
 Return whether error recovery is being done. In this state, the parser
 reads token until it reaches a known state, and then restarts normal
@@ -11330,5 +11325,5 @@ grammatically indivisible.  The piece of text it 
represents is a token.
 @c LocalWords: superclasses boolean getErrorVerbose setErrorVerbose deftypecv
 @c LocalWords: getDebugStream setDebugStream getDebugLevel setDebugLevel url
 @c LocalWords: bisonVersion deftypecvx bisonSkeleton getStartPos getEndPos
address@hidden LocalWords: getLVal defvar YYFAIL deftypefn deftypefnx gotos 
msgfmt
address@hidden LocalWords: getLVal defvar deftypefn deftypefnx gotos msgfmt
 @c LocalWords: subdirectory Solaris nonassociativity
-- 
1.5.4.3


>From ceba3986c7b4538001cbfa133a311b5662da158d Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Sun, 20 Dec 2009 13:47:51 -0500
Subject: [PATCH] YYFAIL: warn about uses.

* NEWS (2.5): Document.
* src/scan-gram.l (SC_BRACED_CODE): Implement.
---
 ChangeLog       |    6 ++++++
 NEWS            |    8 ++++++++
 src/scan-gram.l |    8 ++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aed5998..53dc2c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-12-20  Joel E. Denny  <address@hidden>
 
+       YYFAIL: warn about uses.
+       * NEWS (2.5): Document.
+       * src/scan-gram.l (SC_BRACED_CODE): Implement.
+
+2009-12-20  Joel E. Denny  <address@hidden>
+
        YYFAIL: deprecate.
        * NEWS (2.4.2): Document deprecation.
        * data/lalr1.java (YYStack::YYFAIL): Add comment about
diff --git a/NEWS b/NEWS
index 7e8bd9f..6b11958 100644
--- a/NEWS
+++ b/NEWS
@@ -169,6 +169,14 @@ Bison News
   POSIX Yacc whose use is reported by -Wyacc, and rejected in Yacc
   mode (--yacc).
 
+** YYFAIL is deprecated and produces warnings.
+
+  YYFAIL has existed for many years as an undocumented feature of
+  deterministic parsers in C generated by Bison.  Previously, it was
+  documented for Bison's experimental Java parsers.  As discussed in
+  Bison 2.4.2's NEWS entry, YYFAIL has been formally deprecated.  Now,
+  any appearance of YYFAIL in a semantic action also produces a warning.
+
 ** Temporary hack for adding a semicolon to the user action.
 
   Previously, Bison appended a semicolon to every user action for
diff --git a/src/scan-gram.l b/src/scan-gram.l
index aff0769..0971e3f 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -717,6 +717,14 @@ splice      (\\[ \f\t\v]*\n)*
      (as `<' `<%').  */
   "<"{splice}"<"  STRING_GROW;
 
+  /* YYFAIL is undocumented and was formally deprecated in Bison
+     2.4.2.  */
+  "YYFAIL" STRING_GROW; warn_at (*loc, "YYFAIL is deprecated");
+
+  /* The sole purpose of this is to make sure identifiers that merely
+     contain YYFAIL don't produce the above warning.  */
+  [A-Za-z_][0-9A-Za-z_]* STRING_GROW;
+
   <<EOF>> {
     unexpected_eof (code_start, "}");
     STRING_FINISH;
-- 
1.5.4.3





reply via email to

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