spot  0.8.2
stack.hh
Go to the documentation of this file.
00001 /* A Bison parser, made by GNU Bison 2.4.3.  */
00002 
00003 /* Stack handling for Bison parsers in C++
00004    
00005       Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
00006    Software Foundation, Inc.
00007    
00008    This program is free software: you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation, either version 3 of the License, or
00011    (at your option) any later version.
00012    
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017    
00018    You should have received a copy of the GNU General Public License
00019    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00020 
00021 /* As a special exception, you may create a larger work that contains
00022    part or all of the Bison parser skeleton and distribute that work
00023    under terms of your choice, so long as that work isn't itself a
00024    parser generator using the skeleton or a modified version thereof
00025    as a parser skeleton.  Alternatively, if you modify or redistribute
00026    the parser skeleton itself, you may (at your option) remove this
00027    special exception, which will cause the skeleton and the resulting
00028    Bison output files to be licensed under the GNU General Public
00029    License without this special exception.
00030    
00031    This special exception was added by the Free Software Foundation in
00032    version 2.2 of Bison.  */
00033 
00034 #ifndef BISON_STACK_HH
00035 # define BISON_STACK_HH
00036 
00037 #include <deque>
00038 
00039 
00040 namespace neverclaimyy {
00041 
00042 /* Line 1067 of lalr1.cc  */
00043 #line 44 "stack.hh"
00044   template <class T, class S = std::deque<T> >
00045   class stack
00046   {
00047   public:
00048 
00049     // Hide our reversed order.
00050     typedef typename S::reverse_iterator iterator;
00051     typedef typename S::const_reverse_iterator const_iterator;
00052 
00053     stack () : seq_ ()
00054     {
00055     }
00056 
00057     stack (unsigned int n) : seq_ (n)
00058     {
00059     }
00060 
00061     inline
00062     T&
00063     operator [] (unsigned int i)
00064     {
00065       return seq_[i];
00066     }
00067 
00068     inline
00069     const T&
00070     operator [] (unsigned int i) const
00071     {
00072       return seq_[i];
00073     }
00074 
00075     inline
00076     void
00077     push (const T& t)
00078     {
00079       seq_.push_front (t);
00080     }
00081 
00082     inline
00083     void
00084     pop (unsigned int n = 1)
00085     {
00086       for (; n; --n)
00087         seq_.pop_front ();
00088     }
00089 
00090     inline
00091     unsigned int
00092     height () const
00093     {
00094       return seq_.size ();
00095     }
00096 
00097     inline const_iterator begin () const { return seq_.rbegin (); }
00098     inline const_iterator end () const { return seq_.rend (); }
00099 
00100   private:
00101 
00102     S seq_;
00103   };
00104 
00106   template <class T, class S = stack<T> >
00107   class slice
00108   {
00109   public:
00110 
00111     slice (const S& stack,
00112            unsigned int range) : stack_ (stack),
00113                                  range_ (range)
00114     {
00115     }
00116 
00117     inline
00118     const T&
00119     operator [] (unsigned int i) const
00120     {
00121       return stack_[range_ - i];
00122     }
00123 
00124   private:
00125 
00126     const S& stack_;
00127     unsigned int range_;
00128   };
00129 
00130 } // neverclaimyy
00131 
00132 /* Line 1153 of lalr1.cc  */
00133 #line 134 "stack.hh"
00134 
00135 #endif // not BISON_STACK_HH[]dnl
00136 

Please comment this page and report errors about it on the RefDocComments page.
Generated on Thu Jan 19 2012 19:33:03 for spot by doxygen 1.7.6.1