bison-patches
[Top][All Lists]
Advanced

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

Re: push parser


From: Joel E. Denny
Subject: Re: push parser
Date: Thu, 7 Dec 2006 20:05:53 -0500 (EST)

On Thu, 7 Dec 2006, Bob Rossi wrote:

> OK, here you go. This fixes the valgrind bug. It also makes changes the
> return type of yypvarsinit from void* to struct yypvars* like suggested
> earlier.

>         * data/push.c (yypvarsinit): Change return type from void* to struct
>         yypvars*. Initialized yylen. No longer cast to void* on return.
> 

Thanks for debugging this.  It appears that yylen doesn't need to be in 
yypvars at all.  I installed the following patch instead.  At some point, 
we should hunt down other unnecessary members as well.

By the way, if yypvarsinit is declared with b4_c_function_decl, shouldn't 
it be defined with b4_c_function_def?

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1613
diff -p -u -r1.1613 ChangeLog
--- ChangeLog   7 Dec 2006 02:21:13 -0000       1.1613
+++ ChangeLog   8 Dec 2006 00:24:04 -0000
@@ -1,3 +1,12 @@
+2006-12-07  Bob Rossi  <address@hidden>
+       and Joel Denny  <address@hidden>
+
+       * data/push.c (yypvarsinit): Change return type from void* to struct
+       yypvars*. No longer cast to void* on return.
+       (struct yypvars): Remove yylen since it need not be remembered between
+       yypushparse invocations.
+       (yypushparse): Don't copy between yylen and pv->yylen.
+
 2006-12-05  Bob Rossi  <address@hidden>
 
        * data/push.c (yychar_set, yylval_set, yylloc_set): Delete.
Index: data/push.c
===================================================================
RCS file: /sources/bison/bison/data/push.c,v
retrieving revision 1.9
diff -p -u -r1.9 push.c
--- data/push.c 7 Dec 2006 02:21:13 -0000       1.9
+++ data/push.c 8 Dec 2006 00:24:04 -0000
@@ -970,7 +970,7 @@ yysyntax_error (char *yyresult, int yyst
 ]b4_push_if([
 struct yypvars;
 enum { YYPUSH_MORE = 4 };
-]b4_c_function_decl([yypvarsinit], [void *], [[void], []])[
+]b4_c_function_decl([yypvarsinit], [struct yypvars *], [[void], []])[
 ]b4_c_function_decl([yypushparse], [int],
    [[struct yypvars *yypvars], [yypvars]],
    [[int yynchar], [yynchar]],
@@ -1038,7 +1038,6 @@ m4_define([b4_declare_yyparse_variables]
     /* The locations where the error started and ended.  */
     YYLTYPE yyerror_range[2];]]])[
     YYSIZE_T yystacksize;
-    int yylen;
     /* The variables used to return semantic value and location from the
        action routines.  */
     YYSTYPE yyval;
@@ -1048,7 +1047,7 @@ m4_define([b4_declare_yyparse_variables]
   };
 
 /* Initialize the parser data structure.  */
-void *
+struct yypvars*
 yypvarsinit (void)
 {
   struct yypvars *pv = (struct yypvars *) malloc (sizeof *pv);
@@ -1071,7 +1070,7 @@ yypvarsinit (void)
 
 ]b4_locations_if([  pv->yylsp = pv->yyls;])[
 
-  return (void *) pv;
+  return pv;
 }])
 m4_divert_pop([KILL])dnl# ====================== End of M4 code.
 
@@ -1208,7 +1207,6 @@ m4_ifdef([b4_at_dollar_used], [[  yylsp[
        yylsp = pv->yylsp;]])[
 
        yystacksize = pv->yystacksize;
-       yylen = pv->yylen;
        yyval = pv->yyval;
        ]b4_locations_if([yyloc = pv->yyloc;])[
       if (pv->yynew == 0)
@@ -1339,7 +1337,6 @@ yybackup:
        pv->yylsp = yylsp;]])[
 
        pv->yystacksize = yystacksize;
-       pv->yylen = yylen;
        pv->yyval = yyval;
        ]b4_locations_if([pv->yyloc = yyloc;])[
        goto yypushreturn;




reply via email to

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