File indexing completed on 2024-05-19 07:43:19

0001 
0002 /* A Bison parser, made by GNU Bison 2.4.1.  */
0003 
0004 /*  Stack handling for Bison parsers in C++
0005 
0006     SPDX-FileCopyrightText: 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
0007 
0008     SPDX-License-Identifier: GPL-3.0-or-later WITH Bison-exception-2.2
0009 */
0010 
0011 #ifndef BISON_STACK_HH
0012 # define BISON_STACK_HH
0013 
0014 #include <deque>
0015 
0016 
0017 /* Line 1067 of lalr1.cc  */
0018 #line 1 "[Bison:b4_percent_define_default]"
0019 
0020 namespace KHolidays {
0021 
0022 /* Line 1067 of lalr1.cc  */
0023 #line 48 "stack.hh"
0024   template <class T, class S = std::deque<T> >
0025   class stack
0026   {
0027   public:
0028 
0029     // Hide our reversed order.
0030     typedef typename S::reverse_iterator iterator;
0031     typedef typename S::const_reverse_iterator const_iterator;
0032 
0033     stack () : seq_ ()
0034     {
0035     }
0036 
0037     stack (unsigned int n) : seq_ (n)
0038     {
0039     }
0040 
0041     inline
0042     T&
0043     operator [] (unsigned int i)
0044     {
0045       return seq_[i];
0046     }
0047 
0048     inline
0049     const T&
0050     operator [] (unsigned int i) const
0051     {
0052       return seq_[i];
0053     }
0054 
0055     inline
0056     void
0057     push (const T& t)
0058     {
0059       seq_.push_front (t);
0060     }
0061 
0062     inline
0063     void
0064     pop (unsigned int n = 1)
0065     {
0066       for (; n; --n)
0067     seq_.pop_front ();
0068     }
0069 
0070     inline
0071     unsigned int
0072     height () const
0073     {
0074       return seq_.size ();
0075     }
0076 
0077     inline const_iterator begin () const { return seq_.rbegin (); }
0078     inline const_iterator end () const { return seq_.rend (); }
0079 
0080   private:
0081 
0082     S seq_;
0083   };
0084 
0085   /// Present a slice of the top of a stack.
0086   template <class T, class S = stack<T> >
0087   class slice
0088   {
0089   public:
0090 
0091     slice (const S& stack,
0092        unsigned int range) : stack_ (stack),
0093                  range_ (range)
0094     {
0095     }
0096 
0097     inline
0098     const T&
0099     operator [] (unsigned int i) const
0100     {
0101       return stack_[range_ - i];
0102     }
0103 
0104   private:
0105 
0106     const S& stack_;
0107     unsigned int range_;
0108   };
0109 
0110 /* Line 1153 of lalr1.cc  */
0111 #line 1 "[Bison:b4_percent_define_default]"
0112 
0113 } // KHolidays
0114 
0115 /* Line 1153 of lalr1.cc  */
0116 #line 141 "stack.hh"
0117 
0118 #endif // not BISON_STACK_HH[]dnl
0119