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