ct_common
1.0.1
Common library for combinatorial testing
|
00001 /* A Bison parser, made by GNU Bison 2.5. */ 00002 00003 /* Positions for Bison parsers in C++ 00004 00005 Copyright (C) 2002-2007, 2009-2011 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 BISON_POSITION_HH 00039 # define BISON_POSITION_HH 00040 00041 # include <iostream> 00042 # include <string> 00043 # include <algorithm> 00044 00045 00046 namespace yy { 00047 00048 /* Line 37 of location.cc */ 00049 #line 50 "position.hh" 00050 00051 class position 00052 { 00053 public: 00054 00056 position () 00057 : filename (0), line (1), column (1) 00058 { 00059 } 00060 00061 00063 inline void initialize (std::string* fn) 00064 { 00065 filename = fn; 00066 line = 1; 00067 column = 1; 00068 } 00069 00072 public: 00074 inline void lines (int count = 1) 00075 { 00076 column = 1; 00077 line += count; 00078 } 00079 00081 inline void columns (int count = 1) 00082 { 00083 column = std::max (1u, column + count); 00084 } 00087 public: 00089 std::string* filename; 00091 unsigned int line; 00093 unsigned int column; 00094 }; 00095 00097 inline const position& 00098 operator+= (position& res, const int width) 00099 { 00100 res.columns (width); 00101 return res; 00102 } 00103 00105 inline const position 00106 operator+ (const position& begin, const int width) 00107 { 00108 position res = begin; 00109 return res += width; 00110 } 00111 00113 inline const position& 00114 operator-= (position& res, const int width) 00115 { 00116 return res += -width; 00117 } 00118 00120 inline const position 00121 operator- (const position& begin, const int width) 00122 { 00123 return begin + -width; 00124 } 00125 00127 inline bool 00128 operator== (const position& pos1, const position& pos2) 00129 { 00130 return (pos1.line == pos2.line 00131 && pos1.column == pos2.column 00132 && (pos1.filename == pos2.filename 00133 || (pos1.filename && pos2.filename 00134 && *pos1.filename == *pos2.filename))); 00135 } 00136 00138 inline bool 00139 operator!= (const position& pos1, const position& pos2) 00140 { 00141 return !(pos1 == pos2); 00142 } 00143 00148 inline std::ostream& 00149 operator<< (std::ostream& ostr, const position& pos) 00150 { 00151 if (pos.filename) 00152 ostr << *pos.filename << ':'; 00153 return ostr << pos.line << '.' << pos.column; 00154 } 00155 00156 00157 } // yy 00158 00159 /* Line 144 of location.cc */ 00160 #line 161 "position.hh" 00161 #endif // not BISON_POSITION_HH