1 // A Bison parser, made by GNU Bison 3.8.2.
2 
3 // Locations for Bison parsers in C++
4 
5 // Copyright (C) 2002-2015, 2018-2021 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 <https://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 
33 /**
34  ** \file out/soong/.intermediates/system/tools/aidl/libaidl-common/linux_glibc_x86_64_static/gen/yacc/system/tools/aidl/location.hh
35  ** Define the yy::location class.
36  */
37 
38 #ifndef YY_YY_OUT_SOONG_TEMP_SBOX_3B9FF9D3CA22BEAB2CC2D3F37232599303FBE04F_OUT_SYSTEM_TOOLS_AIDL_LOCATION_HH_INCLUDED
39 # define YY_YY_OUT_SOONG_TEMP_SBOX_3B9FF9D3CA22BEAB2CC2D3F37232599303FBE04F_OUT_SYSTEM_TOOLS_AIDL_LOCATION_HH_INCLUDED
40 
41 # include <iostream>
42 # include <string>
43 
44 # ifndef YY_NULLPTR
45 #  if defined __cplusplus
46 #   if 201103L <= __cplusplus
47 #    define YY_NULLPTR nullptr
48 #   else
49 #    define YY_NULLPTR 0
50 #   endif
51 #  else
52 #   define YY_NULLPTR ((void*)0)
53 #  endif
54 # endif
55 
56 namespace yy {
57 #line 58 "out/soong/.intermediates/system/tools/aidl/libaidl-common/linux_glibc_x86_64_static/gen/yacc/system/tools/aidl/location.hh"
58 
59   /// A point in a source file.
60   class position
61   {
62   public:
63     /// Type for file name.
64     typedef const std::string filename_type;
65     /// Type for line and column numbers.
66     typedef int counter_type;
67 
68     /// Initialization.
initialize(filename_type * fn=YY_NULLPTR,counter_type l=1,counter_type c=1)69     void initialize (filename_type* fn = YY_NULLPTR,
70                      counter_type l = 1,
71                      counter_type c = 1)
72     {
73       filename = fn;
74       line = l;
75       column = c;
76     }
77 
78     /** \name Line and Column related manipulators
79      ** \{ */
80     /// (line related) Advance to the COUNT next lines.
lines(counter_type count=1)81     void lines (counter_type count = 1)
82     {
83       if (count)
84         {
85           column = 1;
86           line = add_ (line, count, 1);
87         }
88     }
89 
90     /// (column related) Advance to the COUNT next columns.
columns(counter_type count=1)91     void columns (counter_type count = 1)
92     {
93       column = add_ (column, count, 1);
94     }
95     /** \} */
96 
97     /// File name to which this position refers.
98     filename_type* filename;
99     /// Current line number.
100     counter_type line;
101     /// Current column number.
102     counter_type column;
103 
104   private:
105     /// Compute max (min, lhs+rhs).
add_(counter_type lhs,counter_type rhs,counter_type min)106     static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
107     {
108       return lhs + rhs < min ? min : lhs + rhs;
109     }
110   };
111 
112   /// Add \a width columns, in place.
113   inline position&
operator +=(position & res,position::counter_type width)114   operator+= (position& res, position::counter_type width)
115   {
116     res.columns (width);
117     return res;
118   }
119 
120   /// Add \a width columns.
121   inline position
operator +(position res,position::counter_type width)122   operator+ (position res, position::counter_type width)
123   {
124     return res += width;
125   }
126 
127   /// Subtract \a width columns, in place.
128   inline position&
operator -=(position & res,position::counter_type width)129   operator-= (position& res, position::counter_type width)
130   {
131     return res += -width;
132   }
133 
134   /// Subtract \a width columns.
135   inline position
operator -(position res,position::counter_type width)136   operator- (position res, position::counter_type width)
137   {
138     return res -= width;
139   }
140 
141   /** \brief Intercept output stream redirection.
142    ** \param ostr the destination output stream
143    ** \param pos a reference to the position to redirect
144    */
145   template <typename YYChar>
146   std::basic_ostream<YYChar>&
operator <<(std::basic_ostream<YYChar> & ostr,const position & pos)147   operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
148   {
149     if (pos.filename)
150       ostr << *pos.filename << ':';
151     return ostr << pos.line << '.' << pos.column;
152   }
153 
154   /// Two points in a source file.
155   class location
156   {
157   public:
158     /// Type for file name.
159     typedef position::filename_type filename_type;
160     /// Type for line and column numbers.
161     typedef position::counter_type counter_type;
162 
163     /// Initialization.
initialize(filename_type * f=YY_NULLPTR,counter_type l=1,counter_type c=1)164     void initialize (filename_type* f = YY_NULLPTR,
165                      counter_type l = 1,
166                      counter_type c = 1)
167     {
168       begin.initialize (f, l, c);
169       end = begin;
170     }
171 
172     /** \name Line and Column related manipulators
173      ** \{ */
174   public:
175     /// Reset initial location to final location.
step()176     void step ()
177     {
178       begin = end;
179     }
180 
181     /// Extend the current location to the COUNT next columns.
columns(counter_type count=1)182     void columns (counter_type count = 1)
183     {
184       end += count;
185     }
186 
187     /// Extend the current location to the COUNT next lines.
lines(counter_type count=1)188     void lines (counter_type count = 1)
189     {
190       end.lines (count);
191     }
192     /** \} */
193 
194 
195   public:
196     /// Beginning of the located region.
197     position begin;
198     /// End of the located region.
199     position end;
200   };
201 
202   /// Join two locations, in place.
203   inline location&
operator +=(location & res,const location & end)204   operator+= (location& res, const location& end)
205   {
206     res.end = end.end;
207     return res;
208   }
209 
210   /// Join two locations.
211   inline location
operator +(location res,const location & end)212   operator+ (location res, const location& end)
213   {
214     return res += end;
215   }
216 
217   /// Add \a width columns to the end position, in place.
218   inline location&
operator +=(location & res,location::counter_type width)219   operator+= (location& res, location::counter_type width)
220   {
221     res.columns (width);
222     return res;
223   }
224 
225   /// Add \a width columns to the end position.
226   inline location
operator +(location res,location::counter_type width)227   operator+ (location res, location::counter_type width)
228   {
229     return res += width;
230   }
231 
232   /// Subtract \a width columns to the end position, in place.
233   inline location&
operator -=(location & res,location::counter_type width)234   operator-= (location& res, location::counter_type width)
235   {
236     return res += -width;
237   }
238 
239   /// Subtract \a width columns to the end position.
240   inline location
operator -(location res,location::counter_type width)241   operator- (location res, location::counter_type width)
242   {
243     return res -= width;
244   }
245 
246   /** \brief Intercept output stream redirection.
247    ** \param ostr the destination output stream
248    ** \param loc a reference to the location to redirect
249    **
250    ** Avoid duplicate information.
251    */
252   template <typename YYChar>
253   std::basic_ostream<YYChar>&
operator <<(std::basic_ostream<YYChar> & ostr,const location & loc)254   operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
255   {
256     location::counter_type end_col
257       = 0 < loc.end.column ? loc.end.column - 1 : 0;
258     ostr << loc.begin;
259     if (loc.end.filename
260         && (!loc.begin.filename
261             || *loc.begin.filename != *loc.end.filename))
262       ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
263     else if (loc.begin.line < loc.end.line)
264       ostr << '-' << loc.end.line << '.' << end_col;
265     else if (loc.begin.column < end_col)
266       ostr << '-' << end_col;
267     return ostr;
268   }
269 
270 } // yy
271 #line 272 "out/soong/.intermediates/system/tools/aidl/libaidl-common/linux_glibc_x86_64_static/gen/yacc/system/tools/aidl/location.hh"
272 
273 #endif // !YY_YY_OUT_SOONG_TEMP_SBOX_3B9FF9D3CA22BEAB2CC2D3F37232599303FBE04F_OUT_SYSTEM_TOOLS_AIDL_LOCATION_HH_INCLUDED
274