]> git.saurik.com Git - bison.git/commitdiff
lalr1.cc: use a vector for the symbol stack
authorTheophile Ranquet <ranquet@lrde.epita.fr>
Fri, 21 Dec 2012 15:46:05 +0000 (16:46 +0100)
committerTheophile Ranquet <ranquet@lrde.epita.fr>
Fri, 11 Jan 2013 17:57:08 +0000 (18:57 +0100)
* data/lalr1.cc: Adjust includes.
* data/stack.hh (push, pop): Use push_back and pop_back.
(operator []): Access vector from the end.

data/lalr1.cc
data/stack.hh

index 930119f1926ed003e95ef35eee6c8a85483ecd2c..40446b7198ca46727ba90d32d90379902c395690 100644 (file)
@@ -146,7 +146,7 @@ b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
 m4_define([b4_shared_declarations],
 [b4_percent_code_get([[requires]])[
 ]b4_parse_assert_if([# include <cassert>])[
 m4_define([b4_shared_declarations],
 [b4_percent_code_get([[requires]])[
 ]b4_parse_assert_if([# include <cassert>])[
-# include <deque>
+# include <vector>
 # include <iostream>
 # include <stdexcept>
 # include <string>]b4_defines_if([[
 # include <iostream>
 # include <stdexcept>
 # include <string>]b4_defines_if([[
index 4fd136fd2d55f9203aed75b2728be67665aeae9e..22d89fbb3c7c1330baa2fc21e7cb654d922dc547 100644 (file)
@@ -21,7 +21,7 @@ m4_pushdef([b4_copyright_years],
 # b4_stack_define
 # ---------------
 m4_define([b4_stack_define],
 # b4_stack_define
 # ---------------
 m4_define([b4_stack_define],
-[[  template <class T, class S = std::deque<T> >
+[[  template <class T, class S = std::vector<T> >
   class stack
   {
   public:
   class stack
   {
   public:
@@ -43,21 +43,21 @@ m4_define([b4_stack_define],
     T&
     operator [] (unsigned int i)
     {
     T&
     operator [] (unsigned int i)
     {
-      return seq_[i];
+      return seq_[seq_.size () - 1 - i];
     }
 
     inline
     const T&
     operator [] (unsigned int i) const
     {
     }
 
     inline
     const T&
     operator [] (unsigned int i) const
     {
-      return seq_[i];
+      return seq_[seq_.size () - 1 - i];
     }
 
     inline
     void
     push (const T& t)
     {
     }
 
     inline
     void
     push (const T& t)
     {
-      seq_.push_front (t);
+      seq_.push_back (t);
     }
 
     inline
     }
 
     inline
@@ -65,7 +65,7 @@ m4_define([b4_stack_define],
     pop (unsigned int n = 1)
     {
       for (; n; --n)
     pop (unsigned int n = 1)
     {
       for (; n; --n)
-        seq_.pop_front ();
+        seq_.pop_back ();
     }
 
     inline
     }
 
     inline
@@ -129,7 +129,7 @@ b4_copyright([Stack handling for Bison parsers in C++])[
 
 ]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
 
 
 ]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
 
-# include <deque>
+# include <vector>
 
 ]b4_namespace_open[
 ]b4_stack_define[
 
 ]b4_namespace_open[
 ]b4_stack_define[