spot
0.8.2
|
00001 /* A Bison parser, made by GNU Bison 2.4.3. */ 00002 00003 /* Locations for Bison parsers in C++ 00004 00005 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software 00006 Foundation, Inc. 00007 00008 This program is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00020 00021 /* As a special exception, you may create a larger work that contains 00022 part or all of the Bison parser skeleton and distribute that work 00023 under terms of your choice, so long as that work isn't itself a 00024 parser generator using the skeleton or a modified version thereof 00025 as a parser skeleton. Alternatively, if you modify or redistribute 00026 the parser skeleton itself, you may (at your option) remove this 00027 special exception, which will cause the skeleton and the resulting 00028 Bison output files to be licensed under the GNU General Public 00029 License without this special exception. 00030 00031 This special exception was added by the Free Software Foundation in 00032 version 2.2 of Bison. */ 00033 00039 #ifndef BISON_LOCATION_HH 00040 # define BISON_LOCATION_HH 00041 00042 # include <iostream> 00043 # include <string> 00044 # include "position.hh" 00045 00046 00047 namespace neverclaimyy { 00048 00049 /* Line 163 of location.cc */ 00050 #line 51 "location.hh" 00051 00053 class location 00054 { 00055 public: 00056 00058 location () 00059 : begin (), end () 00060 { 00061 } 00062 00063 00065 inline void initialize (std::string* fn) 00066 { 00067 begin.initialize (fn); 00068 end = begin; 00069 } 00070 00073 public: 00075 inline void step () 00076 { 00077 begin = end; 00078 } 00079 00081 inline void columns (unsigned int count = 1) 00082 { 00083 end += count; 00084 } 00085 00087 inline void lines (unsigned int count = 1) 00088 { 00089 end.lines (count); 00090 } 00094 public: 00096 position begin; 00098 position end; 00099 }; 00100 00102 inline const location operator+ (const location& begin, const location& end) 00103 { 00104 location res = begin; 00105 res.end = end.end; 00106 return res; 00107 } 00108 00110 inline const location operator+ (const location& begin, unsigned int width) 00111 { 00112 location res = begin; 00113 res.columns (width); 00114 return res; 00115 } 00116 00118 inline location& operator+= (location& res, unsigned int width) 00119 { 00120 res.columns (width); 00121 return res; 00122 } 00123 00125 inline bool 00126 operator== (const location& loc1, const location& loc2) 00127 { 00128 return loc1.begin == loc2.begin && loc1.end == loc2.end; 00129 } 00130 00132 inline bool 00133 operator!= (const location& loc1, const location& loc2) 00134 { 00135 return !(loc1 == loc2); 00136 } 00137 00144 inline std::ostream& operator<< (std::ostream& ostr, const location& loc) 00145 { 00146 position last = loc.end - 1; 00147 ostr << loc.begin; 00148 if (last.filename 00149 && (!loc.begin.filename 00150 || *loc.begin.filename != *last.filename)) 00151 ostr << '-' << last; 00152 else if (loc.begin.line != last.line) 00153 ostr << '-' << last.line << '.' << last.column; 00154 else if (loc.begin.column != last.column) 00155 ostr << '-' << last.column; 00156 return ostr; 00157 } 00158 00159 00160 } // neverclaimyy 00161 00162 /* Line 272 of location.cc */ 00163 #line 164 "location.hh" 00164 00165 #endif // not BISON_LOCATION_HH