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