bison-patches
[Top][All Lists]
Advanced

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

[PATCH 2/4] c++: display the stack in the same order as in C


From: Akim Demaille
Subject: [PATCH 2/4] c++: display the stack in the same order as in C
Date: Wed, 15 Jan 2020 06:27:01 +0100

Currently the C and C++ parse traces differ in the order in which the
stack is displayed: bottom up in C, top down in C++.  Let's stick to
the C order.

* data/skeletons/stack.hh (stack::iterator, stack::const_iterator)
(begin, end): Be forward, not backward.
---
 data/skeletons/lalr1.cc | 2 --
 data/skeletons/stack.hh | 8 ++++----
 tests/c++.at            | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index 9036575b..c338e436 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -1425,7 +1425,6 @@ b4_error_verbose_if([state_type yystate, const 
symbol_type& yyla],
 ]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[
 ]b4_integral_parser_table_define([rline], [b4_rline])[
 
-  // Print the state stack on the debug stream.
   void
   ]b4_parser_class[::yystack_print_ ()
   {
@@ -1438,7 +1437,6 @@ b4_error_verbose_if([state_type yystate, const 
symbol_type& yyla],
     *yycdebug_ << '\n';
   }
 
-  // Report on the debug stream that the rule \a yyrule is going to be reduced.
   void
   ]b4_parser_class[::yy_reduce_print_ (int yyrule)
   {
diff --git a/data/skeletons/stack.hh b/data/skeletons/stack.hh
index 5eb48569..4cbc7917 100644
--- a/data/skeletons/stack.hh
+++ b/data/skeletons/stack.hh
@@ -32,8 +32,8 @@ m4_define([b4_stack_define],
     {
     public:
       // Hide our reversed order.
-      typedef typename S::reverse_iterator iterator;
-      typedef typename S::const_reverse_iterator const_iterator;
+      typedef typename S::iterator iterator;
+      typedef typename S::const_iterator const_iterator;
       typedef typename S::size_type size_type;
       typedef typename std::ptrdiff_t index_type;
 
@@ -101,14 +101,14 @@ m4_define([b4_stack_define],
       const_iterator
       begin () const YY_NOEXCEPT
       {
-        return seq_.rbegin ();
+        return seq_.begin ();
       }
 
       /// Bottom of the stack.
       const_iterator
       end () const YY_NOEXCEPT
       {
-        return seq_.rend ();
+        return seq_.end ();
       }
 
       /// Present a slice of the top of a stack.
diff --git a/tests/c++.at b/tests/c++.at
index 98f2b7a4..f1afd738 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -660,7 +660,7 @@ Entering state 2
 Reading a token: Next token is token NUMBER (30)
 Reducing stack by rule 2 (line 35):
 -> $$ = nterm @1 (20)
-Stack now 2 0
+Stack now 0 2
 Entering state 4
 Next token is token NUMBER (30)
 Shifting token NUMBER (30)
-- 
2.24.1




reply via email to

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