00001 /* A Bison parser, made by GNU Bison 2.7. */ 00002 00003 /* Locations for Bison parsers in C++ 00004 00005 Copyright (C) 2002-2007, 2009-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_LOCATION_HH_INCLUDED 00039 # define YY_YY_LOCATION_HH_INCLUDED 00040 00041 # include "position.hh" 00042 00043 00044 namespace yy { 00045 /* Line 166 of location.cc */ 00046 #line 47 "location.hh" 00047 00049 class location 00050 { 00051 public: 00052 00054 location (const position& b, const position& e) 00055 : begin (b) 00056 , end (e) 00057 { 00058 } 00059 00061 explicit location (const position& p = position ()) 00062 : begin (p) 00063 , end (p) 00064 { 00065 } 00066 00068 explicit location (std::string* f, 00069 unsigned int l = 1u, 00070 unsigned int c = 1u) 00071 : begin (f, l, c) 00072 , end (f, l, c) 00073 { 00074 } 00075 00076 00078 void initialize (std::string* f = YY_NULL, 00079 unsigned int l = 1u, 00080 unsigned int c = 1u) 00081 { 00082 begin.initialize (f, l, c); 00083 end = begin; 00084 } 00085 00088 public: 00090 void step () 00091 { 00092 begin = end; 00093 } 00094 00096 void columns (unsigned int count = 1) 00097 { 00098 end += count; 00099 } 00100 00102 void lines (unsigned int count = 1) 00103 { 00104 end.lines (count); 00105 } 00109 public: 00111 position begin; 00113 position end; 00114 }; 00115 00117 inline const location operator+ (const location& begin, const location& end) 00118 { 00119 location res = begin; 00120 res.end = end.end; 00121 return res; 00122 } 00123 00125 inline const location operator+ (const location& begin, unsigned int width) 00126 { 00127 location res = begin; 00128 res.columns (width); 00129 return res; 00130 } 00131 00133 inline location& operator+= (location& res, unsigned int width) 00134 { 00135 res.columns (width); 00136 return res; 00137 } 00138 00140 inline bool 00141 operator== (const location& loc1, const location& loc2) 00142 { 00143 return loc1.begin == loc2.begin && loc1.end == loc2.end; 00144 } 00145 00147 inline bool 00148 operator!= (const location& loc1, const location& loc2) 00149 { 00150 return !(loc1 == loc2); 00151 } 00152 00159 template <typename YYChar> 00160 inline std::basic_ostream<YYChar>& 00161 operator<< (std::basic_ostream<YYChar>& ostr, const location& loc) 00162 { 00163 position last = loc.end - 1; 00164 ostr << loc.begin; 00165 if (last.filename 00166 && (!loc.begin.filename 00167 || *loc.begin.filename != *last.filename)) 00168 ostr << '-' << last; 00169 else if (loc.begin.line != last.line) 00170 ostr << '-' << last.line << '.' << last.column; 00171 else if (loc.begin.column != last.column) 00172 ostr << '-' << last.column; 00173 return ostr; 00174 } 00175 00176 00177 } // yy 00178 /* Line 296 of location.cc */ 00179 #line 180 "location.hh" 00180 00181 #endif /* !YY_YY_LOCATION_HH_INCLUDED */
|
hosts this site. |
Send comments to: QJson Developers |