mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Add comparison operators for C++ location classes. Discussed at
<http://lists.gnu.org/archive/html/bison-patches/2006-06/msg00092.html>. * data/c++.m4 (b4_define_location_comparison): New boolean %define declaration indicating whether filename_type has an operator==. If filename_type is `std::string', it defaults to `1', `0' otherwise. * data/location.cc: Iff b4_define_location_comparison is `1', add operator== and operator!= for class position and for class location. Some minor fixes. * src/scan-action.l: Remove unused file. * src/symtab.c (symbol_printer_set): Use printer_location not destructor_location. * src/symtab.h (struct symbol): Replace incorrect source comment for printer members. * tests/input.at (Incompatible Aliases): Update output with correct printer location.
This commit is contained in:
@@ -119,7 +119,24 @@ namespace ]b4_namespace[
|
||||
{
|
||||
return begin + -width;
|
||||
}
|
||||
]m4_if(b4_define_location_comparison, [1], [[
|
||||
/// Compare two position objects.
|
||||
inline bool
|
||||
operator== (const position& pos1, const position& pos2)
|
||||
{
|
||||
return
|
||||
(pos1.filename == pos2.filename
|
||||
|| pos1.filename && pos2.filename && *pos1.filename == *pos2.filename)
|
||||
&& pos1.line == pos2.line && pos1.column == pos2.column;
|
||||
}
|
||||
|
||||
/// 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
|
||||
@@ -224,7 +241,21 @@ namespace ]b4_namespace[
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
]m4_if(b4_define_location_comparison, [1], [[
|
||||
/// 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
|
||||
|
||||
Reference in New Issue
Block a user