ppc-lang/include/utils/location.hh

35 lines
1.4 KiB
C++
Raw Normal View History

2022-09-19 07:34:19 +00:00
#pragma once
#include <string>
namespace ppc {
struct location_t {
static const location_t NONE;
2022-09-19 07:34:19 +00:00
std::size_t line;
std::size_t start;
std::size_t length;
std::size_t code_start;
2022-10-09 13:34:02 +00:00
const std::string &filename;
2022-09-19 07:34:19 +00:00
2022-10-19 11:21:05 +00:00
location_t &operator=(const location_t &other);
bool operator==(const location_t &other) const;
bool operator !=(const location_t &other) const {
return !(*this == other);
}
2022-10-09 11:18:38 +00:00
operator std::string() const { return to_string(); }
2022-09-19 07:34:19 +00:00
std::string to_string() const;
location_t intersect(location_t other) const;
location_t();
2022-10-09 13:34:02 +00:00
location_t(const location_t &other): location_t(other.filename, other.line, other.start, other.code_start, other.length) { }
location_t(const std::string &filename);
2022-09-19 07:34:19 +00:00
location_t(std::size_t line, std::size_t start);
2022-10-09 13:34:02 +00:00
location_t(const std::string &filename, std::size_t line, std::size_t start);
2022-09-19 07:34:19 +00:00
location_t(std::size_t line, std::size_t start, std::size_t code_start);
2022-10-09 13:34:02 +00:00
location_t(const std::string &filename, std::size_t line, std::size_t start, std::size_t code_start);
2022-09-19 07:34:19 +00:00
location_t(std::size_t line, std::size_t start, std::size_t code_start, std::size_t length);
2022-10-09 13:34:02 +00:00
location_t(const std::string &filename, std::size_t line, std::size_t start, std::size_t code_start, std::size_t length);
2022-09-19 07:34:19 +00:00
};
}