From 1e9e51dae1c01bab7562911b958c47528b8011c8 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sun, 28 Sep 2025 22:53:30 +0200 Subject: java: Add tokens Only parses Java 8 tokens for now. --- src/location.hh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/location.hh (limited to 'src/location.hh') 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 +#include +#include + +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 -- cgit v1.3