spot  1.0
location.hh
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 2.5. */
2 
3 /* Locations for Bison parsers in C++
4 
5  Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
38 #ifndef BISON_LOCATION_HH
39 # define BISON_LOCATION_HH
40 
41 # include <iostream>
42 # include <string>
43 # include "position.hh"
44 
45 
46 namespace eltlyy {
47 
48 /* Line 162 of location.cc */
49 #line 50 "location.hh"
50 
52  class location
53  {
54  public:
55 
58  : begin (), end ()
59  {
60  }
61 
62 
64  inline void initialize (std::string* fn)
65  {
66  begin.initialize (fn);
67  end = begin;
68  }
69 
72  public:
74  inline void step ()
75  {
76  begin = end;
77  }
78 
80  inline void columns (unsigned int count = 1)
81  {
82  end += count;
83  }
84 
86  inline void lines (unsigned int count = 1)
87  {
88  end.lines (count);
89  }
93  public:
98  };
99 
101  inline const location operator+ (const location& begin, const location& end)
102  {
103  location res = begin;
104  res.end = end.end;
105  return res;
106  }
107 
109  inline const location operator+ (const location& begin, unsigned int width)
110  {
111  location res = begin;
112  res.columns (width);
113  return res;
114  }
115 
117  inline location& operator+= (location& res, unsigned int width)
118  {
119  res.columns (width);
120  return res;
121  }
122 
124  inline bool
125  operator== (const location& loc1, const location& loc2)
126  {
127  return loc1.begin == loc2.begin && loc1.end == loc2.end;
128  }
129 
131  inline bool
132  operator!= (const location& loc1, const location& loc2)
133  {
134  return !(loc1 == loc2);
135  }
136 
143  inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
144  {
145  position last = loc.end - 1;
146  ostr << loc.begin;
147  if (last.filename
148  && (!loc.begin.filename
149  || *loc.begin.filename != *last.filename))
150  ostr << '-' << last;
151  else if (loc.begin.line != last.line)
152  ostr << '-' << last.line << '.' << last.column;
153  else if (loc.begin.column != last.column)
154  ostr << '-' << last.column;
155  return ostr;
156  }
157 
158 
159 } // eltlyy
160 
161 /* Line 271 of location.cc */
162 #line 163 "location.hh"
163 
164 #endif // not BISON_LOCATION_HH

Please comment this page and report errors about it on the RefDocComments page.
Generated on Sat Oct 27 2012 09:34:32 for spot by doxygen 1.8.1.2