3#include <clingo/input/attributes.hh>
5#include <clingo/core/fstring.hh>
6#include <clingo/core/location.hh>
7#include <clingo/core/symbol.hh>
9#include <clingo/util/hash.hh>
10#include <clingo/util/immutable_array.hh>
11#include <clingo/util/immutable_value.hh>
12#include <clingo/util/optional.hh>
13#include <clingo/util/ordered_set.hh>
18namespace CppClingo::Input {
40using Sig = std::tuple<String, size_t, bool>;
42using SharedSig = std::tuple<SharedString, size_t, bool>;
48 std::variant<TermVariable, TermSymbol, TermTuple, TermFunction, TermAbs, TermUnary, TermBinary, TermFormatString>;
57 static constexpr auto attributes() {
return std::tuple{
a_loc = &Projection::loc_}; }
62 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
69using Argument = std::variant<Projection, Term>;
105 : loc_{std::move(
loc)}, name_{
name}, anonymous_{is_anonymous} {}
108 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
110 [[nodiscard]]
auto name() const ->
String const & {
return *name_; }
112 [[nodiscard]]
auto anonymous() const ->
bool {
return anonymous_; }
132 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
134 [[nodiscard]]
auto value() const ->
Symbol const & {
return *value_; }
146 return std::tuple{
a_loc = &FormatFieldExpression::loc_,
a_lhs = &FormatFieldExpression::lhs_,
147 a_rhs = &FormatFieldExpression::rhs_};
154 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
156 [[nodiscard]]
auto lhs() const -> Util::immutable_value<
Term> const & {
return lhs_; }
160 [[nodiscard]]
auto rhs_str() const -> std::string_view {
161 if (rhs_view_ ==
"i") {
164 rhs_view_ = out.
str();
173 mutable std::string rhs_view_ =
"i";
184 return std::tuple{
a_loc = &FormatFieldLiteral::loc_,
a_value = &FormatFieldLiteral::value_};
188 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
190 [[nodiscard]]
auto value() const ->
String const & {
return *value_; }
198using FormatField = std::variant<FormatFieldLiteral, FormatFieldExpression>;
214 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
240 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
267 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
269 [[nodiscard]]
auto name() const ->
String const & {
return *name_; }
273 [[nodiscard]]
auto external() const ->
bool {
return external_; }
296 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
323 return std::tuple{
a_loc = &TermUnary::loc_,
a_op = &TermUnary::op_,
a_rhs = &TermUnary::rhs_};
330 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
334 [[nodiscard]]
auto rhs() const -> Util::immutable_value<
Term> const & {
return rhs_; }
363 return std::tuple{
a_loc = &TermBinary::loc_,
a_lhs = &TermBinary::lhs_,
a_op = &TermBinary::op_,
364 a_rhs = &TermBinary::rhs_};
372 [[nodiscard]]
auto loc() const ->
Location const & {
return loc_; }
374 [[nodiscard]]
auto lhs() const -> Util::immutable_value<
Term> const & {
return lhs_; }
376 [[nodiscard]]
auto rhs() const -> Util::immutable_value<
Term> const & {
return rhs_; }
392 : loc_{std::move(loc)}, lhs_{std::move(lhs)}, rhs_{std::move(rhs)} {
399inline auto operator<=>(FormatFieldExpression
const &a, FormatFieldExpression
const &b) -> std::strong_ordering {
412inline auto operator<=>(ArgumentTuple
const &a, ArgumentTuple
const &b) -> std::strong_ordering {
425inline auto operator<=>(TermTuple
const &a, TermTuple
const &b) -> std::strong_ordering {
432 : loc_{std::move(loc)}, name_(name), pool_{std::move(pool)}, external_{external} {
439inline auto operator<=>(TermFunction
const &a, TermFunction
const &b) -> std::strong_ordering {
452inline auto operator<=>(
TermAbs const &a,
TermAbs const &b) -> std::strong_ordering {
459 : loc_{std::move(loc)}, op_{op}, rhs_{std::move(rhs)} {
466inline auto operator<=>(TermUnary
const &a, TermUnary
const &b) -> std::strong_ordering {
474 : loc_{std::move(loc)}, lhs_{std::move(lhs)}, rhs_{std::move(rhs)}, op_{op} {
481inline auto operator<=>(TermBinary
const &a, TermBinary
const &b) -> std::strong_ordering {
The Location of an expression in an input source.
Definition location.hh:44
Class managing the lifetime of a String.
Definition symbol.hh:93
Class managing the lifetime of a Symbol.
Definition symbol.hh:306
Reference to a string stored in a symbol store.
Definition symbol.hh:18
Variant-like class to store symbols stored in a symbol store.
Definition symbol.hh:225
Create an output buffer that bears some similarities with C++'s iostreams.
Definition print.hh:24
auto str() const -> std::string
Get a string with the current buffer content.
Definition print.hh:69
An immutable value imlementation.
Definition immutable_value.hh:19
auto location(T const &x) -> Location const &
Get the location of an expression.
Definition location.hh:123
Util::unordered_set< String > StringSet
A set of strings.
Definition symbol.hh:83
std::vector< String > StringVec
A vector of strings.
Definition symbol.hh:85
tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType > ordered_set
Alias for ordered sets.
Definition ordered_set.hh:15