Quoc Peyrot <chojin@lrde.epita.fr>,
authorAkim Demaille <akim@epita.fr>
Mon, 13 Jan 2003 15:42:31 +0000 (15:42 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 13 Jan 2003 15:42:31 +0000 (15:42 +0000)
Robert Anisko <anisko_r@lrde.epita.fr>
* data/lalr1.cc (parse::yyerrlab1): When popping the stack, stop
when the stacks contain one element, as the loop would otherwise
free the last state, and then use the top state (the one we just
popped).  This means that the initial elements will not be freed
explicitly, as is the case in yacc.c; it is not a problem, as
these elements have fake values.

ChangeLog
data/lalr1.cc

index 33b038c2b7a24698c08b3a2d2e37a415ba06cdf9..15d9871d1e6bd88cf8d9d6fe692b61eeb4705f1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-01-13  Akim Demaille  <akim@epita.fr>,
+               Quoc Peyrot <chojin@lrde.epita.fr>,
+               Robert Anisko <anisko_r@lrde.epita.fr>
+
+       * data/lalr1.cc (parse::yyerrlab1): When popping the stack, stop
+       when the stacks contain one element, as the loop would otherwise
+       free the last state, and then use the top state (the one we just
+       popped).  This means that the initial elements will not be freed
+       explicitly, as is the case in yacc.c; it is not a problem, as
+       these elements have fake values.
+
 2003-01-11  Paul Eggert  <eggert@twinsun.com>
 
        * NEWS: %expect-violations are now just warnings, reverting
index bab5e5f66f64d3139a09f6f1dcd636ba7ae2f155..a2329e3a04fb2fcd7d715d6214a2075e6caec5f1 100644 (file)
@@ -302,7 +302,10 @@ yy::]b4_parser_class_name[::parse ()
   int nerrs = 0;
   int errstatus = 0;
 
-  /* Initialize stack.  */
+  /* Initialize the stacks.  The initial state will be pushed in
+     yynewstate, since the latter expects the semantical and the
+     location values to have been already stored, initialize these
+     stacks with a primary value.  */
   state_stack_ = StateStack (0);
   semantic_stack_ = SemanticStack (1);
   location_stack_ = LocationStack (1);
@@ -545,7 +548,7 @@ b4_syncline([@oline@], [@ofile@])[
        }
 
       /* Pop the current state because it cannot handle the error token.  */
-      if (!state_stack_.height ())
+      if (state_stack_.height () == 1)
        goto yyabortlab;
 
 #if YYDEBUG