"L. Spiro Engine"
|
00001 /* A Bison parser, made by GNU Bison 2.4.2. */ 00002 00003 /* Stack handling for Bison parsers in C++ 00004 00005 Copyright (C) 2002-2010 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 00033 #ifndef __LSG_SHADERPARSERSTACK_H__ 00034 # define __LSG_SHADERPARSERSTACK_H__ 00035 00036 #include <deque> 00037 00038 00039 namespace yy { 00040 00041 template <class T, class S = std::deque<T> > 00042 class stack 00043 { 00044 public: 00045 00046 // Hide our reversed order. 00047 typedef typename S::reverse_iterator iterator; 00048 typedef typename S::const_reverse_iterator const_iterator; 00049 00050 stack () : seq_ () 00051 { 00052 } 00053 00054 stack (unsigned int n) : seq_ (n) 00055 { 00056 } 00057 00058 inline 00059 T& 00060 operator [] (unsigned int i) 00061 { 00062 return seq_[i]; 00063 } 00064 00065 inline 00066 const T& 00067 operator [] (unsigned int i) const 00068 { 00069 return seq_[i]; 00070 } 00071 00072 inline 00073 void 00074 push (const T& t) 00075 { 00076 seq_.push_front (t); 00077 } 00078 00079 inline 00080 void 00081 pop (unsigned int n = 1) 00082 { 00083 for (; n; --n) 00084 seq_.pop_front (); 00085 } 00086 00087 inline 00088 size_t height () const 00089 { 00090 return seq_.size (); 00091 } 00092 00093 inline const_iterator begin () const { return seq_.rbegin (); } 00094 inline const_iterator end () const { return seq_.rend (); } 00095 00096 private: 00097 00098 S seq_; 00099 }; 00100 00102 template <class T, class S = stack<T> > 00103 class slice 00104 { 00105 public: 00106 00107 slice (const S& stack, 00108 unsigned int range) : stack_ (stack), 00109 range_ (range) 00110 { 00111 } 00112 00113 inline 00114 const T& 00115 operator [] (unsigned int i) const 00116 { 00117 return stack_[range_ - i]; 00118 } 00119 00120 private: 00121 00122 const S& stack_; 00123 unsigned int range_; 00124 }; 00125 00126 } // yy 00127 00128 00129 #endif // not __LSG_SHADERPARSERSTACK_H__[]dnl 00130