Line data Source code
1 : #ifndef LOCATION_H
2 : #define LOCATION_H
3 :
4 : #include <filesystem>
5 :
6 : namespace nicole {
7 :
8 : // Represents the position of the token
9 : class Location final {
10 : private:
11 : std::filesystem::path file_;
12 : std::size_t row_;
13 : std::size_t col_;
14 :
15 : public:
16 : explicit Location(const std::filesystem::path &file, std::size_t row,
17 : std::size_t col) noexcept
18 8510 : : file_{file}, row_{row}, col_{col} {};
19 :
20 99 : [[nodiscard]] const std::filesystem::path &file() const noexcept {
21 99 : return file_;
22 99 : }
23 :
24 117 : [[nodiscard]] std::size_t row() const noexcept { return row_; }
25 :
26 135 : [[nodiscard]] std::size_t col() const noexcept { return col_; }
27 :
28 0 : [[nodiscard]] bool operator<(const Location &loc) const noexcept {
29 0 : if (row_ < loc.row_) {
30 0 : return true;
31 0 : }
32 0 : if (col_ < loc.col_) {
33 0 : return true;
34 0 : }
35 0 : return false;
36 0 : }
37 : };
38 :
39 : } // namespace nicole
40 :
41 : #endif
|