"L. Spiro Engine"
|
00001 /* A Bison parser, made by GNU Bison 2.4.2. */ 00002 00003 /* Locations for Bison parsers in C++ 00004 00005 Copyright (C) 2002-2007, 2009-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 00038 #ifndef __LSG_SHADERPARSERLOCATION_H__ 00039 # define __LSG_SHADERPARSERLOCATION_H__ 00040 00041 # include <iostream> 00042 # include <string> 00043 # include "LSGShaderParserPosition.h" 00044 00045 00046 namespace yy { 00047 00048 00050 class location 00051 { 00052 public: 00053 00055 location () 00056 : begin (), end () 00057 { 00058 } 00059 00060 00062 inline void initialize (std::string* fn) 00063 { 00064 begin.initialize (fn); 00065 end = begin; 00066 } 00067 00070 public: 00072 inline void step () 00073 { 00074 begin = end; 00075 } 00076 00078 inline void columns (unsigned int count = 1) 00079 { 00080 end += count; 00081 } 00082 00084 inline void lines (unsigned int count = 1) 00085 { 00086 end.lines (count); 00087 } 00091 public: 00093 position begin; 00095 position end; 00096 }; 00097 00099 inline const location operator+ (const location& begin, const location& end) 00100 { 00101 location res = begin; 00102 res.end = end.end; 00103 return res; 00104 } 00105 00107 inline const location operator+ (const location& begin, unsigned int width) 00108 { 00109 location res = begin; 00110 res.columns (width); 00111 return res; 00112 } 00113 00115 inline location& operator+= (location& res, unsigned int width) 00116 { 00117 res.columns (width); 00118 return res; 00119 } 00120 00122 inline bool 00123 operator== (const location& loc1, const location& loc2) 00124 { 00125 return loc1.begin == loc2.begin && loc1.end == loc2.end; 00126 } 00127 00129 inline bool 00130 operator!= (const location& loc1, const location& loc2) 00131 { 00132 return !(loc1 == loc2); 00133 } 00134 00141 inline std::ostream& operator<< (std::ostream& ostr, const location& loc) 00142 { 00143 position last = loc.end - 1; 00144 ostr << loc.begin; 00145 if (last.filename 00146 && (!loc.begin.filename 00147 || *loc.begin.filename != *last.filename)) 00148 ostr << '-' << last; 00149 else if (loc.begin.line != last.line) 00150 ostr << '-' << last.line << '.' << last.column; 00151 else if (loc.begin.column != last.column) 00152 ostr << '-' << last.column; 00153 return ostr; 00154 } 00155 00156 00157 } // yy 00158 00159 00160 #endif // not __LSG_SHADERPARSERLOCATION_H__