Working Scanner
[obcplusplus.git] / parser / stack.hh
blobbf42a58f1d5ca9ab7bba3c3aaa4a2834d63d3d6a
1 /* A Bison parser, made by GNU Bison 2.4.3. */
3 /* Stack handling for Bison parsers in C++
5 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
6 Software Foundation, Inc.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
34 #ifndef BISON_STACK_HH
35 # define BISON_STACK_HH
37 #include <deque>
40 namespace objectbuilder {
42 /* Line 1067 of lalr1.cc */
43 #line 44 "stack.hh"
44 template <class T, class S = std::deque<T> >
45 class stack
47 public:
49 // Hide our reversed order.
50 typedef typename S::reverse_iterator iterator;
51 typedef typename S::const_reverse_iterator const_iterator;
53 stack () : seq_ ()
57 stack (unsigned int n) : seq_ (n)
61 inline
63 operator [] (unsigned int i)
65 return seq_[i];
68 inline
69 const T&
70 operator [] (unsigned int i) const
72 return seq_[i];
75 inline
76 void
77 push (const T& t)
79 seq_.push_front (t);
82 inline
83 void
84 pop (unsigned int n = 1)
86 for (; n; --n)
87 seq_.pop_front ();
90 inline
91 unsigned int
92 height () const
94 return seq_.size ();
97 inline const_iterator begin () const { return seq_.rbegin (); }
98 inline const_iterator end () const { return seq_.rend (); }
100 private:
102 S seq_;
105 /// Present a slice of the top of a stack.
106 template <class T, class S = stack<T> >
107 class slice
109 public:
111 slice (const S& stack,
112 unsigned int range) : stack_ (stack),
113 range_ (range)
117 inline
118 const T&
119 operator [] (unsigned int i) const
121 return stack_[range_ - i];
124 private:
126 const S& stack_;
127 unsigned int range_;
130 } // objectbuilder
132 /* Line 1153 of lalr1.cc */
133 #line 134 "stack.hh"
135 #endif // not BISON_STACK_HH[]dnl