bison-patches
[Top][All Lists]
Advanced

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

belt-and-suspenders for 'location zero' bugs


From: Paul Eggert
Subject: belt-and-suspenders for 'location zero' bugs
Date: 11 Dec 2003 13:32:30 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

I realize that we added %initial-action on August 25 to address the
problem of the "location" of the empty token before parsing starts,
but in reviewing and responding to another bug report on this subject
<http://mail.gnu.org/archive/html/bug-bison/2003-11/msg00018.html> I'm
becoming more inclined to also set that location to a known value
before the user gets hold of it, so that the errors are less likely to
occur.  This is the approach taken by glr.c.  It can't hurt the
correctness of existing code, since it merely sets a value that is
currently uninitialized.  And it will lower the number of bug reports
in the future.  Here's a proposed patch.

2003-12-11  Paul Eggert  <address@hidden>

        * data/yacc.c (yyloc_default): New static var.
        (yyparse): Use it to provide an initial value for "location zero".

--- yacc.c.~1.62.~      Mon Aug 25 08:16:24 2003
+++ yacc.c      Thu Dec 11 13:25:29 2003
@@ -206,6 +206,10 @@ typedef struct YYLTYPE
 # define YYLTYPE_IS_DECLARED 1
 # define YYLTYPE_IS_TRIVIAL 1
 #endif
+
+/* Default (constant) value used to initialize the default location
+   just before parsing starts.  */
+static YYLTYPE yyloc_default;
 ])[
 
 /* Copy the second part of user declarations.  */
@@ -806,7 +810,8 @@ b4_c_function_def([yyparse], [int], b4_p
 
   yyssp = yyss;
   yyvsp = yyvs;
-]b4_location_if([  yylsp = yyls;])[
+]b4_location_if([  yylsp = yyls;
+  *yylsp = yyloc_default;])[
 ]m4_ifdef([b4_initial_action], [
 m4_pushdef([b4_at_dollar],     [(*yylsp)])dnl
 m4_pushdef([b4_dollar_dollar], [(*yyvsp)])dnl





reply via email to

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