1
/* A Bison parser, made by GNU Bison 2.3. */
3
/* Locations for Bison parsers in C++
5
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
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 2, or (at your option)
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.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
Boston, MA 02110-1301, USA. */
22
/* As a special exception, you may create a larger work that contains
23
part or all of the Bison parser skeleton and distribute that work
24
under terms of your choice, so long as that work isn't itself a
25
parser generator using the skeleton or a modified version thereof
26
as a parser skeleton. Alternatively, if you modify or redistribute
27
the parser skeleton itself, you may (at your option) remove this
28
special exception, which will cause the skeleton and the resulting
29
Bison output files to be licensed under the GNU General Public
30
License without this special exception.
32
This special exception was added by the Free Software Foundation in
33
version 2.2 of Bison. */
37
** Define the pgscript::location class.
40
#ifndef BISON_LOCATION_HH
41
# define BISON_LOCATION_HH
45
# include "position.hh"
50
/// Abstract a location.
55
/// Construct a location.
63
inline void initialize (std::string* fn)
65
begin.initialize (fn);
69
/** \name Line and Column related manipulators
72
/// Reset initial location to final location.
78
/// Extend the current location to the COUNT next columns.
79
inline void columns (unsigned int count = 1)
84
/// Extend the current location to the COUNT next lines.
85
inline void lines (unsigned int count = 1)
93
/// Beginning of the located region.
95
/// End of the located region.
99
/// Join two location objects to create a location.
100
inline const location operator+ (const location& begin, const location& end)
102
location res = begin;
107
/// Add two location objects.
108
inline const location operator+ (const location& begin, unsigned int width)
110
location res = begin;
115
/// Add and assign a location.
116
inline location& operator+= (location& res, unsigned int width)
122
/** \brief Intercept output stream redirection.
123
** \param ostr the destination output stream
124
** \param loc a reference to the location to redirect
126
** Avoid duplicate information.
128
inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
130
position last = loc.end - 1;
133
&& (!loc.begin.filename
134
|| *loc.begin.filename != *last.filename))
136
else if (loc.begin.line != last.line)
137
ostr << '-' << last.line << '.' << last.column;
138
else if (loc.begin.column != last.column)
139
ostr << '-' << last.column;
145
#endif // not BISON_LOCATION_HH