diff options
author | Wlodek Wencel <wlodek@isc.org> | 2021-09-27 08:29:37 +0200 |
---|---|---|
committer | Wlodzimierz Wencel <wlodek@isc.org> | 2021-09-27 09:39:31 +0200 |
commit | 4125b128d01ceabd7b107c8700ffd81a991c8a9a (patch) | |
tree | b67bd4e9b62b99b289a0656a06a6bf8bee4afff3 /src/bin/dhcp4/location.hh | |
parent | [2017] copyright dates, changelog, messages files changed for release (diff) | |
download | kea-4125b128d01ceabd7b107c8700ffd81a991c8a9a.tar.xz kea-4125b128d01ceabd7b107c8700ffd81a991c8a9a.zip |
[#2107] parsers regen for release
Diffstat (limited to 'src/bin/dhcp4/location.hh')
-rw-r--r-- | src/bin/dhcp4/location.hh | 132 |
1 files changed, 58 insertions, 74 deletions
diff --git a/src/bin/dhcp4/location.hh b/src/bin/dhcp4/location.hh index 42bb34703f..3c542905df 100644 --- a/src/bin/dhcp4/location.hh +++ b/src/bin/dhcp4/location.hh @@ -1,8 +1,8 @@ -// A Bison parser, made by GNU Bison 3.3.1. +// A Bison parser, made by GNU Bison 3.7.6. // Locations for Bison parsers in C++ -// Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc. +// Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ // GNU General Public License for more details. // You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <https://www.gnu.org/licenses/>. // As a special exception, you may create a larger work that contains // part or all of the Bison parser skeleton and distribute that work @@ -38,7 +38,6 @@ #ifndef YY_PARSER4_LOCATION_HH_INCLUDED # define YY_PARSER4_LOCATION_HH_INCLUDED -# include <algorithm> // std::max # include <iostream> # include <string> @@ -54,17 +53,23 @@ # endif # endif -#line 14 "dhcp4_parser.yy" // location.cc:339 +#line 14 "dhcp4_parser.yy" namespace isc { namespace dhcp { -#line 60 "location.hh" // location.cc:339 +#line 59 "location.hh" + /// A point in a source file. class position { public: + /// Type for file name. + typedef const std::string filename_type; + /// Type for line and column numbers. + typedef int counter_type; + /// Construct a position. - explicit position (std::string* f = YY_NULLPTR, - unsigned l = 1u, - unsigned c = 1u) + explicit position (filename_type* f = YY_NULLPTR, + counter_type l = 1, + counter_type c = 1) : filename (f) , line (l) , column (c) @@ -72,9 +77,9 @@ namespace isc { namespace dhcp { /// Initialization. - void initialize (std::string* fn = YY_NULLPTR, - unsigned l = 1u, - unsigned c = 1u) + void initialize (filename_type* fn = YY_NULLPTR, + counter_type l = 1, + counter_type c = 1) { filename = fn; line = l; @@ -84,41 +89,40 @@ namespace isc { namespace dhcp { /** \name Line and Column related manipulators ** \{ */ /// (line related) Advance to the COUNT next lines. - void lines (int count = 1) + void lines (counter_type count = 1) { if (count) { - column = 1u; + column = 1; line = add_ (line, count, 1); } } /// (column related) Advance to the COUNT next columns. - void columns (int count = 1) + void columns (counter_type count = 1) { column = add_ (column, count, 1); } /** \} */ /// File name to which this position refers. - std::string* filename; + filename_type* filename; /// Current line number. - unsigned line; + counter_type line; /// Current column number. - unsigned column; + counter_type column; private: /// Compute max (min, lhs+rhs). - static unsigned add_ (unsigned lhs, int rhs, int min) + static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min) { - return static_cast<unsigned> (std::max (min, - static_cast<int> (lhs) + rhs)); + return lhs + rhs < min ? min : lhs + rhs; } }; /// Add \a width columns, in place. inline position& - operator+= (position& res, int width) + operator+= (position& res, position::counter_type width) { res.columns (width); return res; @@ -126,43 +130,25 @@ namespace isc { namespace dhcp { /// Add \a width columns. inline position - operator+ (position res, int width) + operator+ (position res, position::counter_type width) { return res += width; } /// Subtract \a width columns, in place. inline position& - operator-= (position& res, int width) + operator-= (position& res, position::counter_type width) { return res += -width; } /// Subtract \a width columns. inline position - operator- (position res, int width) + operator- (position res, position::counter_type width) { return res -= width; } - /// Compare two position objects. - inline bool - operator== (const position& pos1, const position& pos2) - { - return (pos1.line == pos2.line - && pos1.column == pos2.column - && (pos1.filename == pos2.filename - || (pos1.filename && pos2.filename - && *pos1.filename == *pos2.filename))); - } - - /// Compare two position objects. - inline bool - operator!= (const position& pos1, const position& pos2) - { - return !(pos1 == pos2); - } - /** \brief Intercept output stream redirection. ** \param ostr the destination output stream ** \param pos a reference to the position to redirect @@ -180,6 +166,10 @@ namespace isc { namespace dhcp { class location { public: + /// Type for file name. + typedef position::filename_type filename_type; + /// Type for line and column numbers. + typedef position::counter_type counter_type; /// Construct a location from \a b to \a e. location (const position& b, const position& e) @@ -194,18 +184,18 @@ namespace isc { namespace dhcp { {} /// Construct a 0-width location in \a f, \a l, \a c. - explicit location (std::string* f, - unsigned l = 1u, - unsigned c = 1u) + explicit location (filename_type* f, + counter_type l = 1, + counter_type c = 1) : begin (f, l, c) , end (f, l, c) {} /// Initialization. - void initialize (std::string* f = YY_NULLPTR, - unsigned l = 1u, - unsigned c = 1u) + void initialize (filename_type* f = YY_NULLPTR, + counter_type l = 1, + counter_type c = 1) { begin.initialize (f, l, c); end = begin; @@ -221,13 +211,13 @@ namespace isc { namespace dhcp { } /// Extend the current location to the COUNT next columns. - void columns (int count = 1) + void columns (counter_type count = 1) { end += count; } /// Extend the current location to the COUNT next lines. - void lines (int count = 1) + void lines (counter_type count = 1) { end.lines (count); } @@ -242,57 +232,49 @@ namespace isc { namespace dhcp { }; /// Join two locations, in place. - inline location& operator+= (location& res, const location& end) + inline location& + operator+= (location& res, const location& end) { res.end = end.end; return res; } /// Join two locations. - inline location operator+ (location res, const location& end) + inline location + operator+ (location res, const location& end) { return res += end; } /// Add \a width columns to the end position, in place. - inline location& operator+= (location& res, int width) + inline location& + operator+= (location& res, location::counter_type width) { res.columns (width); return res; } /// Add \a width columns to the end position. - inline location operator+ (location res, int width) + inline location + operator+ (location res, location::counter_type width) { return res += width; } /// Subtract \a width columns to the end position, in place. - inline location& operator-= (location& res, int width) + inline location& + operator-= (location& res, location::counter_type width) { return res += -width; } /// Subtract \a width columns to the end position. - inline location operator- (location res, int width) + inline location + operator- (location res, location::counter_type width) { return res -= width; } - /// Compare two location objects. - inline bool - operator== (const location& loc1, const location& loc2) - { - return loc1.begin == loc2.begin && loc1.end == loc2.end; - } - - /// Compare two location objects. - inline bool - operator!= (const location& loc1, const location& loc2) - { - return !(loc1 == loc2); - } - /** \brief Intercept output stream redirection. ** \param ostr the destination output stream ** \param loc a reference to the location to redirect @@ -303,7 +285,8 @@ namespace isc { namespace dhcp { std::basic_ostream<YYChar>& operator<< (std::basic_ostream<YYChar>& ostr, const location& loc) { - unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; + location::counter_type end_col + = 0 < loc.end.column ? loc.end.column - 1 : 0; ostr << loc.begin; if (loc.end.filename && (!loc.begin.filename @@ -316,7 +299,8 @@ namespace isc { namespace dhcp { return ostr; } -#line 14 "dhcp4_parser.yy" // location.cc:339 +#line 14 "dhcp4_parser.yy" } } // isc::dhcp -#line 322 "location.hh" // location.cc:339 +#line 305 "location.hh" + #endif // !YY_PARSER4_LOCATION_HH_INCLUDED |