Vcsn  2.4
Be Rational
location.hh
Go to the documentation of this file.
1 // A Bison parser, made by GNU Bison 3.0.4.19-fbaf-dirty.
2 
3 // Locations for Bison parsers in C++
4 
5 // Copyright (C) 2002-2015 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_USERS_AKIM_SRC_LRDE_2_LIB_VCSN_RAT_LOCATION_HH_INCLUDED
39 # define YY_YY_USERS_AKIM_SRC_LRDE_2_LIB_VCSN_RAT_LOCATION_HH_INCLUDED
40 
41 # include "position.hh"
42 
43 #line 11 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // location.cc:296
44 namespace vcsn { namespace rat {
45 #line 46 "/Users/akim/src/lrde/2/lib/vcsn/rat/location.hh" // location.cc:296
46  class location
48  {
49  public:
50 
52  location (const position& b, const position& e)
53  : begin (b)
54  , end (e)
55  {
56  }
57 
59  explicit location (const position& p = position ())
60  : begin (p)
61  , end (p)
62  {
63  }
64 
66  explicit location (std::string* f,
67  unsigned int l = 1u,
68  unsigned int c = 1u)
69  : begin (f, l, c)
70  , end (f, l, c)
71  {
72  }
73 
74 
76  void initialize (std::string* f = YY_NULLPTR,
77  unsigned int l = 1u,
78  unsigned int c = 1u)
79  {
80  begin.initialize (f, l, c);
81  end = begin;
82  }
83 
86  public:
88  void step ()
89  {
90  begin = end;
91  }
92 
94  void columns (int count = 1)
95  {
96  end += count;
97  }
98 
100  void lines (int count = 1)
101  {
102  end.lines (count);
103  }
107  public:
112  };
113 
115  inline location& operator+= (location& res, const location& end)
116  {
117  res.end = end.end;
118  return res;
119  }
120 
123  {
124  return res += end;
125  }
126 
128  inline location& operator+= (location& res, int width)
129  {
130  res.columns (width);
131  return res;
132  }
133 
135  inline location operator+ (location res, int width)
136  {
137  return res += width;
138  }
139 
141  inline location& operator-= (location& res, int width)
142  {
143  return res += -width;
144  }
145 
147  inline location operator- (location res, int width)
148  {
149  return res -= width;
150  }
151 
153  inline bool
154  operator== (const location& loc1, const location& loc2)
155  {
156  return loc1.begin == loc2.begin && loc1.end == loc2.end;
157  }
158 
160  inline bool
161  operator!= (const location& loc1, const location& loc2)
162  {
163  return !(loc1 == loc2);
164  }
165 
172  template <typename YYChar>
173  inline std::basic_ostream<YYChar>&
174  operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
175  {
176  unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
177  ostr << loc.begin;
178  if (loc.end.filename
179  && (!loc.begin.filename
180  || *loc.begin.filename != *loc.end.filename))
181  ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
182  else if (loc.begin.line < loc.end.line)
183  ostr << '-' << loc.end.line << '.' << end_col;
184  else if (loc.begin.column < end_col)
185  ostr << '-' << end_col;
186  return ostr;
187  }
188 
189 #line 11 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // location.cc:296
190 } } // vcsn::rat
191 #line 192 "/Users/akim/src/lrde/2/lib/vcsn/rat/location.hh" // location.cc:296
192 #endif // !YY_YY_USERS_AKIM_SRC_LRDE_2_LIB_VCSN_RAT_LOCATION_HH_INCLUDED
location(const position &p=position())
Construct a 0-width location in p.
Definition: location.hh:59
void lines(int count=1)
(line related) Advance to the COUNT next lines.
Definition: position.hh:84
location(std::string *f, unsigned int l=1u, unsigned int c=1u)
Construct a 0-width location in f, l, c.
Definition: location.hh:66
void lines(int count=1)
Extend the current location to the COUNT next lines.
Definition: location.hh:100
location & operator-=(location &res, int width)
Subtract width columns to the end position, in place.
Definition: location.hh:141
mutable_automaton< Context > u(const Context &ctx, unsigned n)
The Brzozowski universal witness.
Definition: u.hh:15
location operator+(location res, const location &end)
Join two locations.
Definition: location.hh:122
return res
Definition: multiply.hh:398
location(const position &b, const position &e)
Construct a location from b to e.
Definition: location.hh:52
location operator-(location res, int width)
Subtract width columns to the end position.
Definition: location.hh:147
position begin
Beginning of the located region.
Definition: location.hh:109
location & operator+=(location &res, const location &end)
Join two locations, in place.
Definition: location.hh:115
unsigned int column
Current column number.
Definition: position.hh:105
position end
End of the located region.
Definition: location.hh:111
if(exp.max==-1)
Definition: multiply.hh:381
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
void step()
Reset initial location to final location.
Definition: location.hh:88
Abstract a position.
Definition: position.hh:57
Definition: a-star.hh:8
bool operator==(const location &loc1, const location &loc2)
Compare two location objects.
Definition: location.hh:154
void initialize(std::string *fn=0, unsigned int l=1u, unsigned int c=1u)
Initialization.
Definition: position.hh:72
#define YY_NULLPTR
Definition: parse.cc:60
Define the vcsn::rat::position class.
void columns(int count=1)
Extend the current location to the COUNT next columns.
Definition: location.hh:94
void initialize(std::string *f=0, unsigned int l=1u, unsigned int c=1u)
Initialization.
Definition: location.hh:76
vcsn::rat::location location
Definition: scan.hh:17
Abstract a location.
Definition: location.hh:47
bool operator!=(const location &loc1, const location &loc2)
Compare two location objects.
Definition: location.hh:161