Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
location.hh
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 2.7. */
2 
3 /* Locations for Bison parsers in C++
4 
5  Copyright (C) 2002-2007, 2009-2012 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 YY_YY_LOCATION_HH_INCLUDED
39 # define YY_YY_LOCATION_HH_INCLUDED
40 
41 # include "position.hh"
42 
43 /* Line 166 of location.cc */
44 #line 4 "evalexpr_parser.yy"
45 namespace yy {
46 /* Line 166 of location.cc */
47 #line 48 "location.hh"
48 
50  class location
51  {
52  public:
53 
55  location (const position& b, const position& e)
56  : begin (b)
57  , end (e)
58  {
59  }
60 
62  explicit location (const position& p = position ())
63  : begin (p)
64  , end (p)
65  {
66  }
67 
69  explicit location (std::string* f,
70  unsigned int l = 1u,
71  unsigned int c = 1u)
72  : begin (f, l, c)
73  , end (f, l, c)
74  {
75  }
76 
77 
79  void initialize (std::string* f = YY_NULL,
80  unsigned int l = 1u,
81  unsigned int c = 1u)
82  {
83  begin.initialize (f, l, c);
84  end = begin;
85  }
86 
89  public:
91  void step ()
92  {
93  begin = end;
94  }
95 
97  void columns (unsigned int count = 1)
98  {
99  end += count;
100  }
101 
103  void lines (unsigned int count = 1)
104  {
105  end.lines (count);
106  }
110  public:
115  };
116 
118  inline const location operator+ (const location& begin, const location& end)
119  {
120  location res = begin;
121  res.end = end.end;
122  return res;
123  }
124 
126  inline const location operator+ (const location& begin, unsigned int width)
127  {
128  location res = begin;
129  res.columns (width);
130  return res;
131  }
132 
134  inline location& operator+= (location& res, unsigned int width)
135  {
136  res.columns (width);
137  return res;
138  }
139 
141  inline bool
142  operator== (const location& loc1, const location& loc2)
143  {
144  return loc1.begin == loc2.begin && loc1.end == loc2.end;
145  }
146 
148  inline bool
149  operator!= (const location& loc1, const location& loc2)
150  {
151  return !(loc1 == loc2);
152  }
153 
160  template <typename YYChar>
161  inline std::basic_ostream<YYChar>&
162  operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
163  {
164  position last = loc.end - 1;
165  ostr << loc.begin;
166  if (last.filename
167  && (!loc.begin.filename
168  || *loc.begin.filename != *last.filename))
169  ostr << '-' << last;
170  else if (loc.begin.line != last.line)
171  ostr << '-' << last.line << '.' << last.column;
172  else if (loc.begin.column != last.column)
173  ostr << '-' << last.column;
174  return ostr;
175  }
176 
177 /* Line 296 of location.cc */
178 #line 4 "evalexpr_parser.yy"
179 } // yy
180 /* Line 296 of location.cc */
181 #line 182 "location.hh"
182 
183 #endif /* !YY_YY_LOCATION_HH_INCLUDED */
Abstract a position.
Definition: position.hh:59
bool operator!=(const location &loc1, const location &loc2)
Compare two location objects.
Definition: location.hh:149
void initialize(std::string *fn=YY_NULL, unsigned int l=1u, unsigned int c=1u)
Initialization.
Definition: position.hh:75
void columns(unsigned int count=1)
Extend the current location to the COUNT next columns.
Definition: location.hh:97
const location operator+(const location &begin, const location &end)
Join two location objects to create a location.
Definition: location.hh:118
unsigned int column
Current column number.
Definition: position.hh:105
#define YY_NULL
Definition: position.hh:49
location & operator+=(location &res, unsigned int width)
Add and assign a location.
Definition: location.hh:134
void lines(int count=1)
(line related) Advance to the COUNT next lines.
Definition: position.hh:87
location(std::string *f, unsigned int l=1u, unsigned int c=1u)
Construct a 0-width location in f, l, c.
Definition: location.hh:69
position begin
Beginning of the located region.
Definition: location.hh:112
position end
End of the located region.
Definition: location.hh:114
void lines(unsigned int count=1)
Extend the current location to the COUNT next lines.
Definition: location.hh:103
void step()
Reset initial location to final location.
Definition: location.hh:91
Abstract a location.
Definition: location.hh:50
location(const position &p=position())
Construct a 0-width location in p.
Definition: location.hh:62
location(const position &b, const position &e)
Construct a location from b to e.
Definition: location.hh:55
void initialize(std::string *f=YY_NULL, unsigned int l=1u, unsigned int c=1u)
Initialization.
Definition: location.hh:79
bool operator==(const location &loc1, const location &loc2)
Compare two location objects.
Definition: location.hh:142
unsigned int line
Current line number.
Definition: position.hh:103
std::string * filename
File name to which this position refers.
Definition: position.hh:101