00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef BISON_STACK_HH
00036 # define BISON_STACK_HH
00037
00038 #include <deque>
00039
00040
00041
00042 #line 44 "parser.yy"
00043 namespace torc { namespace generic {
00044
00045
00046 #line 47 "stack.hh"
00047 template <class T, class S = std::deque<T> >
00048 class stack
00049 {
00050 public:
00051
00052
00053 typedef typename S::reverse_iterator iterator;
00054 typedef typename S::const_reverse_iterator const_iterator;
00055
00056 stack () : seq_ ()
00057 {
00058 }
00059
00060 stack (unsigned int n) : seq_ (n)
00061 {
00062 }
00063
00064 inline
00065 T&
00066 operator [] (unsigned int i)
00067 {
00068 return seq_[i];
00069 }
00070
00071 inline
00072 const T&
00073 operator [] (unsigned int i) const
00074 {
00075 return seq_[i];
00076 }
00077
00078 inline
00079 void
00080 push (const T& t)
00081 {
00082 seq_.push_front (t);
00083 }
00084
00085 inline
00086 void
00087 pop (unsigned int n = 1)
00088 {
00089 for (; n; --n)
00090 seq_.pop_front ();
00091 }
00092
00093 inline
00094 unsigned int
00095 height () const
00096 {
00097 return seq_.size ();
00098 }
00099
00100 inline const_iterator begin () const { return seq_.rbegin (); }
00101 inline const_iterator end () const { return seq_.rend (); }
00102
00103 private:
00104
00105 S seq_;
00106 };
00107
00108
00109 template <class T, class S = stack<T> >
00110 class slice
00111 {
00112 public:
00113
00114 slice (const S& stack,
00115 unsigned int range) : stack_ (stack),
00116 range_ (range)
00117 {
00118 }
00119
00120 inline
00121 const T&
00122 operator [] (unsigned int i) const
00123 {
00124 return stack_[range_ - i];
00125 }
00126
00127 private:
00128
00129 const S& stack_;
00130 unsigned int range_;
00131 };
00132
00133
00134 #line 44 "parser.yy"
00135 } }
00136
00137
00138 #line 139 "stack.hh"
00139
00140 #endif // not BISON_STACK_HH[]dnl
00141