00001 /* A Bison parser, made by GNU Bison 2.7. */ 00002 00003 /* Positions 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_POSITION_HH_INCLUDED 00039 # define YY_YY_POSITION_HH_INCLUDED 00040 00041 # include <algorithm> // std::max 00042 # include <iostream> 00043 # include <string> 00044 00045 # ifndef YY_NULL 00046 # if defined __cplusplus && 201103L <= __cplusplus 00047 # define YY_NULL nullptr 00048 # else 00049 # define YY_NULL 0 00050 # endif 00051 # endif 00052 00053 00054 namespace yy { 00055 /* Line 36 of location.cc */ 00056 #line 57 "position.hh" 00058 class position 00059 { 00060 public: 00061 00063 explicit position (std::string* f = YY_NULL, 00064 unsigned int l = 1u, 00065 unsigned int c = 1u) 00066 : filename (f) 00067 , line (l) 00068 , column (c) 00069 { 00070 } 00071 00072 00074 void initialize (std::string* fn = YY_NULL, 00075 unsigned int l = 1u, 00076 unsigned int c = 1u) 00077 { 00078 filename = fn; 00079 line = l; 00080 column = c; 00081 } 00082 00085 00086 void lines (int count = 1) 00087 { 00088 column = 1u; 00089 line += count; 00090 } 00091 00093 void columns (int count = 1) 00094 { 00095 column = std::max (1u, column + count); 00096 } 00099 00100 std::string* filename; 00102 unsigned int line; 00104 unsigned int column; 00105 }; 00106 00108 inline position& 00109 operator+= (position& res, const int width) 00110 { 00111 res.columns (width); 00112 return res; 00113 } 00114 00116 inline const position 00117 operator+ (const position& begin, const int width) 00118 { 00119 position res = begin; 00120 return res += width; 00121 } 00122 00124 inline position& 00125 operator-= (position& res, const int width) 00126 { 00127 return res += -width; 00128 } 00129 00131 inline const position 00132 operator- (const position& begin, const int width) 00133 { 00134 return begin + -width; 00135 } 00136 00138 inline bool 00139 operator== (const position& pos1, const position& pos2) 00140 { 00141 return (pos1.line == pos2.line 00142 && pos1.column == pos2.column 00143 && (pos1.filename == pos2.filename 00144 || (pos1.filename && pos2.filename 00145 && *pos1.filename == *pos2.filename))); 00146 } 00147 00149 inline bool 00150 operator!= (const position& pos1, const position& pos2) 00151 { 00152 return !(pos1 == pos2); 00153 } 00154 00159 template <typename YYChar> 00160 inline std::basic_ostream<YYChar>& 00161 operator<< (std::basic_ostream<YYChar>& ostr, const position& pos) 00162 { 00163 if (pos.filename) 00164 ostr << *pos.filename << ':'; 00165 return ostr << pos.line << '.' << pos.column; 00166 } 00167 00168 00169 } // yy 00170 /* Line 148 of location.cc */ 00171 #line 172 "position.hh" 00172 #endif /* !YY_YY_POSITION_HH_INCLUDED */
|
hosts this site. |
Send comments to: QJson Developers |