|
1 | | -/* A Bison parser, made by GNU Bison 2.3. */ |
2 | 1 |
|
3 | | -/* Locations for Bison parsers in C++ |
4 | | -
|
5 | | - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
| 2 | +/* A Bison parser, made by GNU Bison 2.4.1. */ |
6 | 3 |
|
7 | | - This program is free software; you can redistribute it and/or modify |
| 4 | +/* Locations for Bison parsers in C++ |
| 5 | + |
| 6 | + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
| 7 | + |
| 8 | + This program is free software: you can redistribute it and/or modify |
8 | 9 | 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) |
10 | | - any later version. |
11 | | -
|
| 10 | + the Free Software Foundation, either version 3 of the License, or |
| 11 | + (at your option) any later version. |
| 12 | + |
12 | 13 | This program is distributed in the hope that it will be useful, |
13 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | 16 | GNU General Public License for more details. |
16 | | -
|
| 17 | + |
17 | 18 | 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. */ |
| 19 | + along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
21 | 20 |
|
22 | 21 | /* As a special exception, you may create a larger work that contains |
23 | 22 | part or all of the Bison parser skeleton and distribute that work |
|
28 | 27 | special exception, which will cause the skeleton and the resulting |
29 | 28 | Bison output files to be licensed under the GNU General Public |
30 | 29 | License without this special exception. |
31 | | -
|
| 30 | + |
32 | 31 | This special exception was added by the Free Software Foundation in |
33 | 32 | version 2.2 of Bison. */ |
34 | 33 |
|
|
44 | 43 | # include <string> |
45 | 44 | # include "position.hh" |
46 | 45 |
|
| 46 | + |
| 47 | +/* Line 162 of location.cc */ |
| 48 | +#line 1 "[Bison:b4_percent_define_default]" |
| 49 | + |
47 | 50 | namespace example { |
48 | 51 |
|
49 | | -/// Abstract a location. |
50 | | -class location |
51 | | -{ |
52 | | -public: |
| 52 | +/* Line 162 of location.cc */ |
| 53 | +#line 54 "location.hh" |
| 54 | + |
| 55 | + /// Abstract a location. |
| 56 | + class location |
| 57 | + { |
| 58 | + public: |
53 | 59 |
|
54 | 60 | /// Construct a location. |
55 | 61 | location () |
56 | | - : begin (), end () |
| 62 | + : begin (), end () |
57 | 63 | { |
58 | 64 | } |
59 | 65 |
|
| 66 | + |
60 | 67 | /// Initialization. |
61 | 68 | inline void initialize (std::string* fn) |
62 | 69 | { |
63 | | - begin.initialize (fn); |
64 | | - end = begin; |
| 70 | + begin.initialize (fn); |
| 71 | + end = begin; |
65 | 72 | } |
66 | 73 |
|
67 | 74 | /** \name Line and Column related manipulators |
68 | 75 | ** \{ */ |
69 | | -public: |
| 76 | + public: |
70 | 77 | /// Reset initial location to final location. |
71 | 78 | inline void step () |
72 | 79 | { |
73 | | - begin = end; |
| 80 | + begin = end; |
74 | 81 | } |
75 | 82 |
|
76 | 83 | /// Extend the current location to the COUNT next columns. |
77 | 84 | inline void columns (unsigned int count = 1) |
78 | 85 | { |
79 | | - end += count; |
| 86 | + end += count; |
80 | 87 | } |
81 | 88 |
|
82 | 89 | /// Extend the current location to the COUNT next lines. |
83 | 90 | inline void lines (unsigned int count = 1) |
84 | 91 | { |
85 | | - end.lines (count); |
| 92 | + end.lines (count); |
86 | 93 | } |
87 | 94 | /** \} */ |
88 | 95 |
|
89 | 96 |
|
90 | | -public: |
| 97 | + public: |
91 | 98 | /// Beginning of the located region. |
92 | 99 | position begin; |
93 | 100 | /// End of the located region. |
94 | 101 | position end; |
95 | | -}; |
| 102 | + }; |
96 | 103 |
|
97 | | -/// Join two location objects to create a location. |
98 | | -inline const location operator+ (const location& begin, const location& end) |
99 | | -{ |
| 104 | + /// Join two location objects to create a location. |
| 105 | + inline const location operator+ (const location& begin, const location& end) |
| 106 | + { |
100 | 107 | location res = begin; |
101 | 108 | res.end = end.end; |
102 | 109 | return res; |
103 | | -} |
| 110 | + } |
104 | 111 |
|
105 | | -/// Add two location objects. |
106 | | -inline const location operator+ (const location& begin, unsigned int width) |
107 | | -{ |
| 112 | + /// Add two location objects. |
| 113 | + inline const location operator+ (const location& begin, unsigned int width) |
| 114 | + { |
108 | 115 | location res = begin; |
109 | 116 | res.columns (width); |
110 | 117 | return res; |
111 | | -} |
| 118 | + } |
112 | 119 |
|
113 | | -/// Add and assign a location. |
114 | | -inline location& operator+= (location& res, unsigned int width) |
115 | | -{ |
| 120 | + /// Add and assign a location. |
| 121 | + inline location& operator+= (location& res, unsigned int width) |
| 122 | + { |
116 | 123 | res.columns (width); |
117 | 124 | return res; |
118 | | -} |
119 | | - |
120 | | -/** \brief Intercept output stream redirection. |
121 | | - ** \param ostr the destination output stream |
122 | | - ** \param loc a reference to the location to redirect |
123 | | - ** |
124 | | - ** Avoid duplicate information. |
125 | | - */ |
126 | | -inline std::ostream& operator<< (std::ostream& ostr, const location& loc) |
127 | | -{ |
| 125 | + } |
| 126 | + |
| 127 | + /// Compare two location objects. |
| 128 | + inline bool |
| 129 | + operator== (const location& loc1, const location& loc2) |
| 130 | + { |
| 131 | + return loc1.begin == loc2.begin && loc1.end == loc2.end; |
| 132 | + } |
| 133 | + |
| 134 | + /// Compare two location objects. |
| 135 | + inline bool |
| 136 | + operator!= (const location& loc1, const location& loc2) |
| 137 | + { |
| 138 | + return !(loc1 == loc2); |
| 139 | + } |
| 140 | + |
| 141 | + /** \brief Intercept output stream redirection. |
| 142 | + ** \param ostr the destination output stream |
| 143 | + ** \param loc a reference to the location to redirect |
| 144 | + ** |
| 145 | + ** Avoid duplicate information. |
| 146 | + */ |
| 147 | + inline std::ostream& operator<< (std::ostream& ostr, const location& loc) |
| 148 | + { |
128 | 149 | position last = loc.end - 1; |
129 | 150 | ostr << loc.begin; |
130 | 151 | if (last.filename |
131 | 152 | && (!loc.begin.filename |
132 | 153 | || *loc.begin.filename != *last.filename)) |
133 | | - ostr << '-' << last; |
| 154 | + ostr << '-' << last; |
134 | 155 | else if (loc.begin.line != last.line) |
135 | | - ostr << '-' << last.line << '.' << last.column; |
| 156 | + ostr << '-' << last.line << '.' << last.column; |
136 | 157 | else if (loc.begin.column != last.column) |
137 | | - ostr << '-' << last.column; |
| 158 | + ostr << '-' << last.column; |
138 | 159 | return ostr; |
139 | | -} |
| 160 | + } |
| 161 | + |
| 162 | + |
| 163 | +/* Line 271 of location.cc */ |
| 164 | +#line 1 "[Bison:b4_percent_define_default]" |
| 165 | + |
| 166 | +} // example |
140 | 167 |
|
141 | | -} |
| 168 | +/* Line 271 of location.cc */ |
| 169 | +#line 170 "location.hh" |
142 | 170 |
|
143 | 171 | #endif // not BISON_LOCATION_HH |
0 commit comments