* data/lalr1.cc (Stack::Iterator, Stack::ConstIterator): Rename as...
authorAkim Demaille <akim@epita.fr>
Thu, 16 Sep 2004 14:41:18 +0000 (14:41 +0000)
committerAkim Demaille <akim@epita.fr>
Thu, 16 Sep 2004 14:41:18 +0000 (14:41 +0000)
(iterator, const_iterator): these, to be more in the C++ spirit.
Also, return reverse iterators so that when displaying the stack
we display its bottom first.
(Parser::stack_print_, Parser::reduce_print_): Match the messages
from yacc.c.
We should probably use vector here though.

ChangeLog
data/lalr1.cc

index 75df12e..f9818fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2004-09-16  Akim Demaille  <akim@epita.fr>
 
+       * data/lalr1.cc (Stack::Iterator, Stack::ConstIterator): Rename as...
+       (iterator, const_iterator): these, to be more in the C++ spirit.
+       Also, return reverse iterators so that when displaying the stack
+       we display its bottom first.
+       (Parser::stack_print_, Parser::reduce_print_): Match the messages
+       from yacc.c.
+       We should probably use vector here though.
+
+2004-09-16  Akim Demaille  <akim@epita.fr>
+
        Have more complete shift traces.
 
        * data/yacc.c, data/lalr1.c, data/glr.c: Use YY_SYMBOL_PRINT
index f246d0b..74db24c 100644 (file)
@@ -889,8 +889,8 @@ yy::]b4_parser_class_name[::rline_[] =
 void
 yy::]b4_parser_class_name[::stack_print_ ()
 {
-  cdebug_ << "state stack now";
-  for (StateStack::ConstIterator i = state_stack_.begin ();
+  cdebug_ << "Stack now";
+  for (StateStack::const_iterator i = state_stack_.begin ();
        i != state_stack_.end (); ++i)
     cdebug_ << ' ' << *i;
   cdebug_ << std::endl;
@@ -903,7 +903,7 @@ yy::]b4_parser_class_name[::reduce_print_ (int yyrule)
 {
   unsigned int yylno = rline_[yyrule];
   /* Print the symbols being reduced, and their result.  */
-  cdebug_ << "Reducing via rule " << n_ - 1 << " (line " << yylno << "), ";
+  cdebug_ << "Reducing stack by rule " << n_ - 1 << " (line " << yylno << "), ";
   for (]b4_int_type_for([b4_prhs])[ i = prhs_[n_];
        0 <= rhs_[i]; ++i)
     cdebug_ << name_[rhs_[i]] << ' ';
@@ -956,8 +956,9 @@ namespace yy
   {
   public:
 
-    typedef typename S::iterator Iterator;
-    typedef typename S::const_iterator ConstIterator;
+    // Hide our reversed order.
+    typedef typename S::reverse_iterator iterator;
+    typedef typename S::const_reverse_iterator const_iterator;
 
     Stack () : seq_ ()
     {
@@ -1003,8 +1004,8 @@ namespace yy
       return seq_.size ();
     }
 
-    inline ConstIterator begin () const { return seq_.begin (); }
-    inline ConstIterator end () const { return seq_.end (); }
+    inline const_iterator begin () const { return seq_.rbegin (); }
+    inline const_iterator end () const { return seq_.rend (); }
 
   private: