3#include <clingo/input/statement.hh>
5#include <clingo/core/logger.hh>
7#include <clingo/util/enum.hh>
8#include <clingo/util/ordered_map.hh>
9#include <clingo/util/ordered_set.hh>
11#include <forward_list>
13namespace CppClingo::Input {
62 std::vector<Stm const *>
srcs;
79 [[nodiscard]]
auto empty() const ->
bool;
141 void meta(std::vector<Stm>
const &stms) { do_meta(stms); }
143 void fact(std::vector<Symbol>
const &facts) { do_fact(facts); }
149 virtual void do_meta(std::vector<Stm>
const &stms) = 0;
150 virtual void do_fact(
SymbolVec const &facts) = 0;
151 [[nodiscard]]
virtual auto do_components(
Components const &comps) ->
bool = 0;
170 for (
auto const &stm : script_stms_) {
173 if (default_parts_) {
174 fun(*default_parts_);
176 for (
auto const &stm : defined_stms_) {
179 for (
auto const &[
id, sym] : const_map_) {
180 fun(
Stm{
StmConst{sym.first.
loc(), sym.first.type(), sym.first.name(),
181 TermSymbol{location(sym.first.value()), *sym.second}}});
183 for (
auto const &stm : thy_stms_) {
186 for (
auto const &stm : meta_stms_) {
189 for (
auto const &[
sig, part] : parts_) {
190 auto pum = param_map_(store, part);
191 auto loc = part.part.loc();
194 for (
auto const &fact : part.facts) {
197 for (
auto const &stm : part.stms) {
198 if (
auto unmapped = unmap_(store, pum, stm); unmapped) {
199 fun(std::move(unmapped).value());
228 [[nodiscard]]
auto default_parts() -> std::optional<StmParts> & {
return default_parts_; }
237 using Signature = std::pair<SharedString, size_t>;
257 std::vector<StmScript> script_stms_;
259 std::vector<StmDefined> defined_stms_;
261 std::vector<StmTheory> thy_stms_;
263 std::optional<StmParts> default_parts_;
267 std::forward_list<Stm> sources_;
269 std::forward_list<Stm>::iterator last_source_ = sources_.before_begin();
277 size_t depend_offset_ = 0;
Simple logger to report message to stderr or via a callback.
Definition logger.hh:63
Helper class to mark owned symbols.
Definition symbol.hh:429
A store for symbols.
Definition symbol.hh:454
auto begin() const noexcept -> const_iterator
Get an iterator pointing to the beginning of the array.
Definition immutable_array.hh:117
std::vector< Symbol > SymbolVec
A vector of symbols.
Definition symbol.hh:220
std::vector< TheorySig > TheorySigVec
A vector of theory atom signatures.
Definition core.hh:184
tsl::hopscotch_set< Key, Hash, KeyEqual, Allocator, NeighborhoodSize, StoreHash, GrowthPolicy > unordered_set
Alias for unordered sets.
Definition unordered_set.hh:16
tsl::ordered_map< Key, T, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType > ordered_map
Alias for ordered maps.
Definition ordered_map.hh:16
#define CLINGO_ENABLE_BITSET_ENUM(E,...)
Opt-in macro for enabling bit operations for a given enum type.
Definition enum.hh:18