Line data Source code
1 : #ifndef SOURCE_LOCATION_H
2 : #define SOURCE_LOCATION_H
3 :
4 : #include "token.h"
5 :
6 : namespace nicole {
7 :
8 : class SourceLocation {
9 : private:
10 : Token begin_;
11 : Token end_;
12 :
13 : public:
14 : explicit SourceLocation(const Token &begin, const Token &end) noexcept
15 130 : : begin_{begin}, end_{end} {}
16 :
17 0 : [[nodiscard]] const Token &beginLoc() const noexcept { return begin_; }
18 :
19 0 : [[nodiscard]] const Token &endLoc() const noexcept { return end_; }
20 :
21 0 : [[nodiscard]] bool operator<(const SourceLocation &loc) const noexcept {
22 0 : if (begin_.location() < loc.begin_.location()) {
23 0 : return true;
24 0 : }
25 0 : if (end_.location() < loc.end_.location()) {
26 0 : return true;
27 0 : }
28 0 : return false;
29 0 : }
30 : };
31 :
32 : } // namespace nicole
33 :
34 : #endif
|