X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/6e93d810ca7b3ea73aaa4ff2aa06c0d948797d0a..31b2b07ef765e9e8734ca273308094804fcc9763:/data/location.cc diff --git a/data/location.cc b/data/location.cc index 869320e7..156115ca 100644 --- a/data/location.cc +++ b/data/location.cc @@ -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