1
/* A Bison parser, made by GNU Bison 2.3. */
3
/* Positions 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 QMake::position class.
40
#ifndef BISON_POSITION_HH
41
# define BISON_POSITION_HH
48
/// Abstract a position.
53
/// Construct a position.
55
: filename (0), line (1), column (0)
61
inline void initialize (std::string* fn)
68
/** \name Line and Column related manipulators
71
/// (line related) Advance to the COUNT next lines.
72
inline void lines (int count = 1)
78
/// (column related) Advance to the COUNT next columns.
79
inline void columns (int count = 1)
83
if (leftmost <= current + count)
91
/// File name to which this position refers.
92
std::string* filename;
93
/// Current line number.
95
/// Current column number.
99
/// Add and assign a position.
100
inline const position&
101
operator+= (position& res, const int width)
107
/// Add two position objects.
108
inline const position
109
operator+ (const position& begin, const int width)
111
position res = begin;
115
/// Add and assign a position.
116
inline const position&
117
operator-= (position& res, const int width)
119
return res += -width;
122
/// Add two position objects.
123
inline const position
124
operator- (const position& begin, const int width)
126
return begin + -width;
129
/** \brief Intercept output stream redirection.
130
** \param ostr the destination output stream
131
** \param pos a reference to the position to redirect
134
operator<< (std::ostream& ostr, const position& pos)
137
ostr << *pos.filename << ':';
138
return ostr << pos.line << '.' << pos.column;
142
#endif // not BISON_POSITION_HH