spot  1.0.1
stack.hh
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 2.5. */
2 
3 /* Stack handling for Bison parsers in C++
4 
5  Copyright (C) 2002-2011 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
33 #ifndef BISON_STACK_HH
34 # define BISON_STACK_HH
35 
36 #include <deque>
37 
38 
39 namespace ltlyy {
40 
41 /* Line 1149 of lalr1.cc */
42 #line 43 "stack.hh"
43  template <class T, class S = std::deque<T> >
44  class stack
45  {
46  public:
47 
48  // Hide our reversed order.
49  typedef typename S::reverse_iterator iterator;
50  typedef typename S::const_reverse_iterator const_iterator;
51 
52  stack () : seq_ ()
53  {
54  }
55 
56  stack (unsigned int n) : seq_ (n)
57  {
58  }
59 
60  inline
61  T&
62  operator [] (unsigned int i)
63  {
64  return seq_[i];
65  }
66 
67  inline
68  const T&
69  operator [] (unsigned int i) const
70  {
71  return seq_[i];
72  }
73 
74  inline
75  void
76  push (const T& t)
77  {
78  seq_.push_front (t);
79  }
80 
81  inline
82  void
83  pop (unsigned int n = 1)
84  {
85  for (; n; --n)
86  seq_.pop_front ();
87  }
88 
89  inline
90  unsigned int
91  height () const
92  {
93  return seq_.size ();
94  }
95 
96  inline const_iterator begin () const { return seq_.rbegin (); }
97  inline const_iterator end () const { return seq_.rend (); }
98 
99  private:
100 
101  S seq_;
102  };
103 
105  template <class T, class S = stack<T> >
106  class slice
107  {
108  public:
109 
110  slice (const S& stack,
111  unsigned int range) : stack_ (stack),
112  range_ (range)
113  {
114  }
115 
116  inline
117  const T&
118  operator [] (unsigned int i) const
119  {
120  return stack_[range_ - i];
121  }
122 
123  private:
124 
125  const S& stack_;
126  unsigned int range_;
127  };
128 
129 } // ltlyy
130 
131 /* Line 1235 of lalr1.cc */
132 #line 133 "stack.hh"
133 
134 #endif // not BISON_STACK_HH[]dnl
135 

Please comment this page and report errors about it on the RefDocComments page.
Generated on Wed Jan 23 2013 15:00:00 for spot by doxygen 1.8.1.2