summaryrefslogtreecommitdiff
path: root/src/location.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-09-28 22:53:30 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-09-29 09:39:17 +0200
commit1e9e51dae1c01bab7562911b958c47528b8011c8 (patch)
tree73e0c97545d1cf833a4205c8ced41c822b4bb348 /src/location.hh
parent0ca22c7d6d650c80906bd1217fccf32066cc2502 (diff)
java: Add tokens
Only parses Java 8 tokens for now.
Diffstat (limited to 'src/location.hh')
-rw-r--r--src/location.hh31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/location.hh b/src/location.hh
new file mode 100644
index 0000000..1a210cb
--- /dev/null
+++ b/src/location.hh
@@ -0,0 +1,31 @@
+#ifndef LOCATION_HH
+#define LOCATION_HH
+
+#include <compare>
+#include <cstdint>
+#include <iosfwd>
+
+namespace src {
+
+struct Location {
+ uint64_t line;
+ uint16_t column;
+
+ constexpr Location() : line(0), column(0) {}
+
+ Location(uint64_t line, uint16_t column) : line(line), column(column) {}
+
+ [[nodiscard]]
+ std::strong_ordering operator<=>(Location const& loc) const {
+ auto ret = line <=> loc.line;
+ if (ret == std::strong_ordering::equal)
+ return column <=> loc.column;
+ return ret;
+ }
+};
+
+std::ostream& operator<<(std::ostream& out, Location const& loc);
+
+} // namespace src
+
+#endif // LOCATION_HH