Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

ltlparse/stack.hh

Go to the documentation of this file.
00001 /* A Bison parser, made by GNU Bison 1.875c. */ 00002 00003 /* Stack handling for Bison C++ parsers, 00004 Copyright (C) 2002, 2003 Free Software Foundation, Inc. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2, or (at your option) 00009 any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. */ 00020 00021 #ifndef BISON_STACK_HH 00022 # define BISON_STACK_HH 00023 00024 #include <deque> 00025 00026 namespace yy 00027 { 00028 template < class T, class S = std::deque< T > > 00029 class Stack 00030 { 00031 public: 00032 00033 typedef typename S::iterator Iterator; 00034 typedef typename S::const_iterator ConstIterator; 00035 00036 Stack () : seq_ () 00037 { 00038 } 00039 00040 Stack (unsigned n) : seq_ (n) 00041 { 00042 } 00043 00044 inline 00045 T& 00046 operator [] (unsigned i) 00047 { 00048 return seq_[i]; 00049 } 00050 00051 inline 00052 const T& 00053 operator [] (unsigned i) const 00054 { 00055 return seq_[i]; 00056 } 00057 00058 inline 00059 void 00060 push (const T& t) 00061 { 00062 seq_.push_front (t); 00063 } 00064 00065 inline 00066 void 00067 pop (unsigned n = 1) 00068 { 00069 for (; n; --n) 00070 seq_.pop_front (); 00071 } 00072 00073 inline 00074 unsigned 00075 height () const 00076 { 00077 return seq_.size (); 00078 } 00079 00080 inline ConstIterator begin () const { return seq_.begin (); } 00081 inline ConstIterator end () const { return seq_.end (); } 00082 00083 private: 00084 00085 S seq_; 00086 }; 00087 00088 template < class T, class S = Stack< T > > 00089 class Slice 00090 { 00091 public: 00092 00093 Slice (const S& stack, 00094 unsigned range) : stack_ (stack), 00095 range_ (range) 00096 { 00097 } 00098 00099 inline 00100 const T& 00101 operator [] (unsigned i) const 00102 { 00103 return stack_[range_ - i]; 00104 } 00105 00106 private: 00107 00108 const S& stack_; 00109 unsigned range_; 00110 }; 00111 } 00112 00113 #endif // not BISON_STACK_HH

Generated on Tue Jun 29 17:00:35 2004 for spot by doxygen 1.3.7