mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
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.
This commit is contained in:
@@ -146,7 +146,7 @@ b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
|
|||||||
m4_define([b4_shared_declarations],
|
m4_define([b4_shared_declarations],
|
||||||
[b4_percent_code_get([[requires]])[
|
[b4_percent_code_get([[requires]])[
|
||||||
]b4_parse_assert_if([# include <cassert>])[
|
]b4_parse_assert_if([# include <cassert>])[
|
||||||
# include <deque>
|
# include <vector>
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
# include <stdexcept>
|
# include <stdexcept>
|
||||||
# include <string>]b4_defines_if([[
|
# include <string>]b4_defines_if([[
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ m4_pushdef([b4_copyright_years],
|
|||||||
# b4_stack_define
|
# b4_stack_define
|
||||||
# ---------------
|
# ---------------
|
||||||
m4_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
|
class stack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -43,21 +43,21 @@ m4_define([b4_stack_define],
|
|||||||
T&
|
T&
|
||||||
operator [] (unsigned int i)
|
operator [] (unsigned int i)
|
||||||
{
|
{
|
||||||
return seq_[i];
|
return seq_[seq_.size () - 1 - i];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
const T&
|
const T&
|
||||||
operator [] (unsigned int i) const
|
operator [] (unsigned int i) const
|
||||||
{
|
{
|
||||||
return seq_[i];
|
return seq_[seq_.size () - 1 - i];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
push (const T& t)
|
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)
|
pop (unsigned int n = 1)
|
||||||
{
|
{
|
||||||
for (; n; --n)
|
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_namespace_open[
|
||||||
]b4_stack_define[
|
]b4_stack_define[
|
||||||
|
|||||||
Reference in New Issue
Block a user