1 # C++ skeleton for Bison
3 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4 # 2010 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 m4_pushdef([b4_copyright_years],
20 [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010])
22 # We do want M4 expansion after # for CPP macros.
25 @output(b4_dir_prefix[]stack.hh@)@
26 b4_copyright([Stack handling for Bison parsers in C++])[
28 #ifndef BISON_STACK_HH
29 # define BISON_STACK_HH
34 template <class T, class S = std::deque<T> >
38 // Hide our reversed order.
39 typedef typename S::reverse_iterator iterator;
40 typedef typename S::const_reverse_iterator const_iterator;
47 stack (unsigned int n)
54 operator [] (unsigned int i)
61 operator [] (unsigned int i) const
75 pop (unsigned int n = 1)
92 return seq_.rbegin ();
103 /// The wrapped container.
107 /// Present a slice of the top of a stack.
108 template <class T, class S = stack<T> >
112 slice (const S& stack, unsigned int range)
120 operator [] (unsigned int i) const
122 return stack_[range_ - i];
131 #endif // not BISON_STACK_HH[]dnl
134 m4_popdef([b4_copyright_years])dnl