3#include <clingo/core/symbol.hh>
20 [[nodiscard]]
auto file() const ->
String const & {
return *file_; }
22 [[nodiscard]]
auto line() const ->
size_t {
return line_; }
24 [[nodiscard]]
auto column() const ->
size_t {
return column_; }
33 out << pos.file() <<
":" << pos.line() <<
":" << pos.column();
52 [[nodiscard]]
auto end() const ->
Position const & {
return end_; }
61 return {a.begin_, b.value()};
81 a.end_ = std::move(b);
87 a.end_ = *std::move(b);
99 out << loc.begin() <<
"-";
100 if (loc.end().file() != loc.begin().file()) {
102 }
else if (loc.end().line() != loc.begin().line()) {
103 out << loc.end().line() <<
":" << loc.end().column();
105 out << loc.end().column();
117 return {std::move(a), std::move(b)};
122 requires requires(T
const &x) { x.loc(); }
129 requires requires(T
const &...x) { (location(x), ...); }
131 return std::visit([](
auto const &y) ->
Location const & {
return location(y); }, x);
The Location of an expression in an input source.
Definition location.hh:44
auto end() const -> Position const &
The position where the expression ends.
Definition location.hh:52
Location(Position begin, Position end)
Construct a location.
Definition location.hh:47
friend auto operator+(Location const &a, std::optional< Position > b) -> Location
Create a new location from the given one optionally adjusting its end position.
Definition location.hh:59
friend auto operator+(Location const &a, Location const &b) -> Location
Create a new location from the beginning and end of the given two locations.
Definition location.hh:55
friend auto operator<=>(Location const &a, Location const &b)=default
Compare two positions.
friend auto operator<<(T &out, Location const &loc) -> T &
Output the location to the given stream.
Definition location.hh:98
friend auto operator+(Location const &a, Position b) -> Location
Create a new location from the beginning of the location and the position.
Definition location.hh:57
friend auto operator+(std::optional< Position > a, Location const &b) -> Location
Create a new location from the given one optionally adjusting its start position.
Definition location.hh:68
friend auto operator==(Location const &a, Location const &b) -> bool=default
Compare two positions.
friend auto operator+=(Location &a, Location const &b) -> Location &
See the corresponding + operator.
Definition location.hh:75
friend auto operator+=(Location &a, Position b) -> Location &
See the corresponding + operator.
Definition location.hh:80
auto begin() const -> Position const &
The position where the expression starts.
Definition location.hh:50
friend auto operator+(Position a, Location const &b) -> Location
Create a new location from the position of the end of the location.
Definition location.hh:66
friend auto operator+=(Location &a, std::optional< Position > b) -> Location &
See the corresponding + operator.
Definition location.hh:85
A point in an input source.
Definition location.hh:15
auto column() const -> size_t
The column number.
Definition location.hh:24
friend auto operator<=>(Position const &a, Position const &b)=default
Compare two positions.
auto file() const -> String const &
The name of a file/stream/string.
Definition location.hh:20
friend auto operator==(Position const &a, Position const &b) -> bool=default
Compare two positions.
auto line() const -> size_t
The line number.
Definition location.hh:22
friend auto operator<<(T &out, Position const &pos) -> T &
Output the position to the given stream.
Definition location.hh:32
Position(String file, size_t line, size_t column)
Construct a position.
Definition location.hh:18
Class managing the lifetime of a String.
Definition symbol.hh:93
Reference to a string stored in a symbol store.
Definition symbol.hh:18
auto location(T const &x) -> Location const &
Get the location of an expression.
Definition location.hh:123
auto operator+(Sign a, Sign b) -> Sign
Combine two signs.