From: Theophile Ranquet Date: Fri, 21 Dec 2012 15:46:05 +0000 (+0100) Subject: lalr1.cc: use a vector for the symbol stack X-Git-Tag: v2.7.90~190 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/e7b26e942d1466974e40a70a30d9044c4a90fd85 lalr1.cc: use a vector for the symbol stack * data/lalr1.cc: Adjust includes. * data/stack.hh (push, pop): Use push_back and pop_back. (operator []): Access vector from the end. --- diff --git a/data/lalr1.cc b/data/lalr1.cc index 930119f1..40446b71 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -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 ])[ -# include +# include # include # include # include ]b4_defines_if([[ diff --git a/data/stack.hh b/data/stack.hh index 4fd136fd..22d89fbb 100644 --- a/data/stack.hh +++ b/data/stack.hh @@ -21,7 +21,7 @@ m4_pushdef([b4_copyright_years], # b4_stack_define # --------------- m4_define([b4_stack_define], -[[ template > +[[ template > class stack { public: @@ -43,21 +43,21 @@ m4_define([b4_stack_define], T& operator [] (unsigned int i) { - return seq_[i]; + return seq_[seq_.size () - 1 - i]; } inline const T& operator [] (unsigned int i) const { - return seq_[i]; + return seq_[seq_.size () - 1 - i]; } inline void push (const T& t) { - seq_.push_front (t); + seq_.push_back (t); } inline @@ -65,7 +65,7 @@ m4_define([b4_stack_define], pop (unsigned int n = 1) { for (; n; --n) - seq_.pop_front (); + seq_.pop_back (); } inline @@ -129,7 +129,7 @@ b4_copyright([Stack handling for Bison parsers in C++])[ ]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[ -# include +# include ]b4_namespace_open[ ]b4_stack_define[