librostlab-blast
1.0.0
|
00001 00002 /* A Bison parser, made by GNU Bison 2.4.1. */ 00003 00004 /* Locations for Bison parsers in C++ 00005 00006 Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software 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_ROSTLAB_BLAST_PARSER_LOCATION_H 00040 # define BISON_ROSTLAB_BLAST_PARSER_LOCATION_H 00041 00042 # include <iostream> 00043 # include <string> 00044 # include "rostlab/blast-parser-position.h" 00045 00046 00047 /* Line 162 of location.cc */ 00048 #line 22 "blast-parser-parser.ypp" 00049 namespace rostlab { namespace blast { 00050 00051 /* Line 162 of location.cc */ 00052 #line 53 "rostlab/blast-parser-location.h" 00053 00055 class location 00056 { 00057 public: 00058 00060 location () 00061 : begin (), end () 00062 { 00063 } 00064 00065 00067 inline void initialize (std::string* fn) 00068 { 00069 begin.initialize (fn); 00070 end = begin; 00071 } 00072 00075 public: 00077 inline void step () 00078 { 00079 begin = end; 00080 } 00081 00083 inline void columns (unsigned int count = 1) 00084 { 00085 end += count; 00086 } 00087 00089 inline void lines (unsigned int count = 1) 00090 { 00091 end.lines (count); 00092 } 00096 public: 00098 position begin; 00100 position end; 00101 }; 00102 00104 inline const location operator+ (const location& begin, const location& end) 00105 { 00106 location res = begin; 00107 res.end = end.end; 00108 return res; 00109 } 00110 00112 inline const location operator+ (const location& begin, unsigned int width) 00113 { 00114 location res = begin; 00115 res.columns (width); 00116 return res; 00117 } 00118 00120 inline location& operator+= (location& res, unsigned int width) 00121 { 00122 res.columns (width); 00123 return res; 00124 } 00125 00127 inline bool 00128 operator== (const location& loc1, const location& loc2) 00129 { 00130 return loc1.begin == loc2.begin && loc1.end == loc2.end; 00131 } 00132 00134 inline bool 00135 operator!= (const location& loc1, const location& loc2) 00136 { 00137 return !(loc1 == loc2); 00138 } 00139 00146 inline std::ostream& operator<< (std::ostream& ostr, const location& loc) 00147 { 00148 position last = loc.end - 1; 00149 ostr << loc.begin; 00150 if (last.filename 00151 && (!loc.begin.filename 00152 || *loc.begin.filename != *last.filename)) 00153 ostr << '-' << last; 00154 else if (loc.begin.line != last.line) 00155 ostr << '-' << last.line << '.' << last.column; 00156 else if (loc.begin.column != last.column) 00157 ostr << '-' << last.column; 00158 return ostr; 00159 } 00160 00161 00162 /* Line 271 of location.cc */ 00163 #line 22 "blast-parser-parser.ypp" 00164 } } // rostlab::blast 00165 00166 /* Line 271 of location.cc */ 00167 #line 168 "rostlab/blast-parser-location.h" 00168 00169 #endif // not BISON_ROSTLAB_BLAST_PARSER_LOCATION_H