bison-patches
[Top][All Lists]
Advanced

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

Re: push parser documentation


From: Joel E. Denny
Subject: Re: push parser documentation
Date: Sat, 11 Aug 2007 19:08:13 -0400 (EDT)

On Sat, 11 Aug 2007, Joel E. Denny wrote:

> In this and your other examples, symbols named by users (yystatus, yyps) 
> should not start with yy.  The yy namespace is reserved for Bison symbols.  
> (I'll correct this in the test suite.)

I committed this.

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1717
diff -p -u -r1.1717 ChangeLog
--- ChangeLog   3 Aug 2007 23:24:25 -0000       1.1717
+++ ChangeLog   11 Aug 2007 23:04:46 -0000
@@ -1,3 +1,11 @@
+2007-08-11  Joel E. Denny  <address@hidden>
+
+       * tests/push.at (Push Parsing: Memory Leak for Early Deletion): Do not
+       name user variables starting with `yy'.  Just pass NULL instead of a
+       dummy local &yylval to yypush_parse.
+       * tests/torture.at (AT_DATA_STACK_TORTURE): Do not name user variables
+       starting with `yy'.
+
 2007-08-03  Joel E. Denny  <address@hidden>
 
        * data/yacc.c (yyexhaustedlab): Define it when YYERROR_VERBOSE is
Index: tests/push.at
===================================================================
RCS file: /sources/bison/bison/tests/push.at,v
retrieving revision 1.1
diff -p -u -r1.1 push.at
--- tests/push.at       28 Jul 2007 04:27:32 -0000      1.1
+++ tests/push.at       11 Aug 2007 23:04:46 -0000
@@ -52,24 +52,22 @@ yyerror (char const *msg)
 int
 main (void)
 {
-  yypstate *yyps;
-  YYSTYPE yylval;
+  yypstate *ps;
 
-  /* Make sure we don't try to free yyps->yyss in this case.  */
-  yyps = yypstate_new ();
-  yypstate_delete (yyps);
-
-  /* yypstate_delete used to leak yyps->yyss if the stack was reallocated but
-     the parse did not return on success, syntax error, or memory
-     exhaustion.  */
-  yyps = yypstate_new ();
-  assert (yypush_parse (yyps, 'a', &yylval) == YYPUSH_MORE);
-  yypstate_delete (yyps);
-
-  yyps = yypstate_new ();
-  assert (yypush_parse (yyps, 'a', &yylval) == YYPUSH_MORE);
-  assert (yypush_parse (yyps, 'b', &yylval) == YYPUSH_MORE);
-  yypstate_delete (yyps);
+  /* Make sure we don't try to free ps->yyss in this case.  */
+  ps = yypstate_new ();
+  yypstate_delete (ps);
+
+  /* yypstate_delete used to leak ps->yyss if the stack was reallocated but the
+     parse did not return on success, syntax error, or memory exhaustion.  */
+  ps = yypstate_new ();
+  assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE);
+  yypstate_delete (ps);
+
+  ps = yypstate_new ();
+  assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE);
+  assert (yypush_parse (ps, 'b', NULL) == YYPUSH_MORE);
+  yypstate_delete (ps);
 
   return 0;
 }
Index: tests/torture.at
===================================================================
RCS file: /sources/bison/bison/tests/torture.at,v
retrieving revision 1.37
diff -p -u -r1.37 torture.at
--- tests/torture.at    17 Jan 2007 08:36:07 -0000      1.37
+++ tests/torture.at    11 Aug 2007 23:04:46 -0000
@@ -444,13 +444,13 @@ main (int argc, const char **argv)
     int count;
     int status;
 ]m4_bmatch([$2], [%push-],
-[[    yypstate *yyps = yypstate_new ();
+[[    yypstate *ps = yypstate_new ();
 ]])[    for (count = 0; count < 2; ++count)
       {
         int new_status;
         yylval = yylval_init;
 ]m4_bmatch([$2], [%push-],
-[[        new_status = yypull_parse (yyps);
+[[        new_status = yypull_parse (ps);
 ]],
 [[        new_status = yyparse ();
 ]])[        if (count > 0 && new_status != status)
@@ -458,7 +458,7 @@ main (int argc, const char **argv)
         status = new_status;
       }
 ]m4_bmatch([$2], [%push-],
-[[    yypstate_delete (yyps);
+[[    yypstate_delete (ps);
 ]])[    return status;
   }
 }




reply via email to

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