54 _file(
file), _line(line - 1), _column(column - 1)
62 parse_location(
int line,
int column) noexcept : _file(), _line(line - 1), _column(column - 1) {}
64 [[nodiscard]]
bool has_file() const noexcept
66 return to_bool(_file);
69 [[nodiscard]] URL file() const noexcept
78 [[nodiscard]]
int line() const noexcept
83 [[nodiscard]]
int column() const noexcept
90 return {_line + 1, _column + 1};
98 void set_file(URL file)
noexcept
100 _file = std::make_shared<URL>(
std::move(file));
103 void set_line(
int line)
noexcept
108 void set_column(
int column)
noexcept
110 _column = column - 1;
115 _line = line_and_column.first - 1;
116 _column = line_and_column.second - 1;
119 void increment_column() noexcept
124 void tab_column() noexcept
131 void increment_line() noexcept
137 parse_location &operator+=(
char c)
noexcept
140 case '\t': _column = ((_column / 8) + 1) * 8;
break;
141 case '\f': [[fallthrough]];
142 case '\n': ++_line; [[fallthrough]];
143 case '\r': _column = 0;
break;
149 parse_location &operator+=(
std::string const &s)
noexcept
157 parse_location &operator+=(
char const *s)
noexcept
159 hi_axiom(s !=
nullptr);
160 while (
hilet c = *s++) {
166 parse_location &operator+=(parse_location
const &location)
noexcept
168 if (location._line == 0) {
169 _column += location._column;
171 _line += location._line;
172 _column = location._column;
179 return std::format(
"{}:{}:{}", l.file(), l.line(), l.column());
192struct std::formatter<hi::parse_location, CharT> : std::formatter<string_view, CharT> {
193 auto format(hi::parse_location t,
auto &fc)
195 return std::formatter<string_view, CharT>::format(
to_string(t), fc);