48 _file(std::make_shared<std::filesystem::path>(
hi_forward(
file))), _line(0), _column(0)
66 parse_location(
int line,
int column) noexcept : _file(), _line(line - 1), _column(column - 1) {}
68 [[nodiscard]]
bool has_file() const noexcept
70 return to_bool(_file);
73 [[nodiscard]] std::filesystem::path file() const noexcept
82 [[nodiscard]]
int line() const noexcept
87 [[nodiscard]]
int column() const noexcept
94 return {_line + 1, _column + 1};
102 void set_file(forward_of<std::filesystem::path>
auto &&file)
noexcept
104 _file = std::make_shared<std::filesystem::path>(
hi_forward(file));
107 void set_line(
int line)
noexcept
112 void set_column(
int column)
noexcept
114 _column = column - 1;
119 _line = line_and_column.first - 1;
120 _column = line_and_column.second - 1;
123 void increment_column() noexcept
128 void tab_column() noexcept
135 void increment_line() noexcept
141 parse_location& operator+=(
char c)
noexcept
145 _column = ((_column / 8) + 1) * 8;
161 parse_location& operator+=(
std::string const& s)
noexcept
169 parse_location& operator+=(
char const *s)
noexcept
171 hi_axiom(s !=
nullptr);
172 while (
hilet c = *s++) {
178 parse_location& operator+=(parse_location
const& location)
noexcept
180 if (location._line == 0) {
181 _column += location._column;
183 _line += location._line;
184 _column = location._column;
191 return std::format(
"{}:{}:{}", l.file().generic_string(), l.line(), l.column());
204struct std::formatter<
hi::parse_location, CharT> : std::formatter<string_view, CharT> {
205 auto format(hi::parse_location t,
auto& fc)
207 return std::formatter<string_view, CharT>::format(
to_string(t), fc);
parse_location(forward_of< std::shared_ptr< std::filesystem::path > > auto &&file, int line, int column) noexcept
Construct a location.
Definition parse_location.hpp:57