From a2ccd69c019202b2d41a0f8bdc0a7bd7393c41cf Mon Sep 17 00:00:00 2001 From: Dominik Drexler Date: Sat, 9 Mar 2024 23:16:25 +0100 Subject: [PATCH] work on include paths and clang format --- .clang-format | 60 + examples/multiple_problems.cpp | 8 +- examples/position_cache.cpp | 51 +- examples/single_problem.cpp | 7 +- examples/undefined_behavior.cpp | 9 +- exe/domain.cpp | 12 +- exe/problem.cpp | 14 +- include/loki/common/ast/config.hpp | 37 +- include/loki/common/ast/error_handler.hpp | 55 +- include/loki/common/ast/error_reporting.hpp | 49 +- include/loki/common/ast/parser_wrapper.hpp | 32 +- include/loki/common/collections.hpp | 10 +- include/loki/common/exceptions.hpp | 20 +- include/loki/common/filesystem.hpp | 24 +- include/loki/common/hash.hpp | 14 +- include/loki/common/memory.hpp | 7 +- include/loki/common/pddl/base.hpp | 47 +- include/loki/common/pddl/config.hpp | 8 +- include/loki/common/pddl/context.hpp | 44 +- include/loki/common/pddl/error_reporting.hpp | 273 ++- .../common/pddl/garbage_collected_factory.hpp | 58 +- .../loki/common/pddl/persistent_factory.hpp | 56 +- include/loki/common/pddl/position.hpp | 36 +- include/loki/common/pddl/position.tpp | 23 +- include/loki/common/pddl/reference.hpp | 56 +- include/loki/common/pddl/reference.tpp | 16 +- include/loki/common/pddl/scope.hpp | 160 +- include/loki/common/pddl/scope.tpp | 49 +- include/loki/common/pddl/segmented_vector.hpp | 48 +- include/loki/common/pddl/types.hpp | 102 +- include/loki/common/pddl/visitors.hpp | 25 +- include/loki/common/printer.hpp | 7 +- include/loki/domain/ast/ast.hpp | 1778 ++++++++------- include/loki/domain/ast/error_handler.hpp | 16 +- include/loki/domain/ast/parser.hpp | 24 +- include/loki/domain/ast/printer.hpp | 280 +-- include/loki/domain/parser.hpp | 14 +- include/loki/domain/pddl/action.hpp | 45 +- include/loki/domain/pddl/atom.hpp | 43 +- include/loki/domain/pddl/conditions.hpp | 140 +- include/loki/domain/pddl/declarations.hpp | 216 +- .../loki/domain/pddl/derived_predicate.hpp | 43 +- include/loki/domain/pddl/domain.hpp | 58 +- include/loki/domain/pddl/effects.hpp | 112 +- include/loki/domain/pddl/exceptions.hpp | 85 +- include/loki/domain/pddl/function.hpp | 42 +- .../loki/domain/pddl/function_expressions.hpp | 123 +- .../loki/domain/pddl/function_skeleton.hpp | 42 +- include/loki/domain/pddl/literal.hpp | 43 +- include/loki/domain/pddl/object.hpp | 45 +- include/loki/domain/pddl/parameter.hpp | 42 +- include/loki/domain/pddl/parser.hpp | 11 +- include/loki/domain/pddl/predicate.hpp | 42 +- include/loki/domain/pddl/requirements.hpp | 48 +- include/loki/domain/pddl/term.hpp | 57 +- include/loki/domain/pddl/type.hpp | 42 +- include/loki/domain/pddl/variable.hpp | 43 +- include/loki/problem/ast/ast.hpp | 565 ++--- include/loki/problem/ast/error_handler.hpp | 16 +- include/loki/problem/ast/parser.hpp | 24 +- include/loki/problem/ast/printer.hpp | 84 +- include/loki/problem/parser.hpp | 16 +- include/loki/problem/pddl/declarations.hpp | 34 +- include/loki/problem/pddl/exceptions.hpp | 39 +- include/loki/problem/pddl/ground_atom.hpp | 43 +- include/loki/problem/pddl/ground_literal.hpp | 43 +- include/loki/problem/pddl/metric.hpp | 46 +- include/loki/problem/pddl/numeric_fluent.hpp | 42 +- include/loki/problem/pddl/parser.hpp | 11 +- include/loki/problem/pddl/problem.hpp | 54 +- src/common/exceptions.cpp | 22 +- src/common/filesystem.cpp | 28 +- src/common/memory.cpp | 66 +- src/common/pddl/scope.cpp | 30 +- src/domain/ast/ast_adapted.hpp | 9 +- src/domain/ast/parser.hpp | 1109 +++++----- src/domain/ast/parser_def.hpp | 1952 +++++++++-------- src/domain/ast/parser_instantiations.cpp | 291 ++- src/domain/ast/printer.cpp | 1098 +++++----- src/domain/pddl/parser/common.cpp | 48 +- src/domain/pddl/parser/common.hpp | 15 +- src/domain/pddl/parser/conditions.cpp | 144 +- src/domain/pddl/parser/conditions.hpp | 17 +- src/domain/pddl/parser/constants.cpp | 55 +- src/domain/pddl/parser/constants.hpp | 9 +- 85 files changed, 5442 insertions(+), 5319 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..ea3b1d4c --- /dev/null +++ b/.clang-format @@ -0,0 +1,60 @@ +--- +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignEscapedNewlines: Left +AlignOperands: 'true' +AlignTrailingComments: 'true' +AllowAllArgumentsOnNextLine: 'false' +AllowAllConstructorInitializersOnNextLine: 'false' +AllowAllParametersOfDeclarationOnNextLine: 'false' +AllowShortBlocksOnASingleLine: 'true' +AllowShortCaseLabelsOnASingleLine: 'false' +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: 'false' +AlwaysBreakTemplateDeclarations: 'Yes' +BinPackArguments: 'false' +BinPackParameters: 'false' +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Allman +BreakBeforeTernaryOperators: 'false' +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterColon +ColumnLimit: '160' +CompactNamespaces: 'false' +ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' +Cpp11BracedListStyle: 'false' +FixNamespaceComments: 'false' +IncludeBlocks: Regroup +IndentAccessModifiers: 'false' +IndentCaseLabels: 'true' +IndentPPDirectives: None +IndentWidth: '4' +IndentWrappedFunctionNames: 'false' +KeepEmptyLinesAtTheStartOfBlocks: 'false' +Language: Cpp +MaxEmptyLinesToKeep: '1' +NamespaceIndentation: None +PointerAlignment: Left +SortIncludes: 'true' +SortUsingDeclarations: 'true' +SpaceAfterCStyleCast: 'true' +SpaceAfterLogicalNot: 'false' +SpaceAfterTemplateKeyword: 'false' +SpaceBeforeAssignmentOperators: 'true' +SpaceBeforeCpp11BracedList: 'true' +SpaceBeforeCtorInitializerColon: 'true' +SpaceBeforeInheritanceColon: 'true' +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: 'true' +SpaceInEmptyParentheses: 'false' +SpacesBeforeTrailingComments: '2' +SpacesInAngles: 'false' +SpacesInCStyleCastParentheses: 'false' +SpacesInParentheses: 'false' +SpacesInSquareBrackets: 'false' +Standard: Cpp11 +TabWidth: '4' +UseTab: Never +... diff --git a/examples/multiple_problems.cpp b/examples/multiple_problems.cpp index 2e1da903..8b6b34fc 100644 --- a/examples/multiple_problems.cpp +++ b/examples/multiple_problems.cpp @@ -15,13 +15,12 @@ * along with this program. If not, see . */ +#include #include #include -#include - - -int main() { +int main() +{ // Parse the domain auto domain_parser = loki::DomainParser("data/gripper/domain.pddl"); const auto domain = domain_parser.get_domain(); @@ -44,6 +43,5 @@ int main() { the idexing scheme is most likely fragmented per problem. (In this specific case, it is not fragmented because both problems are structurally equivalent) */ - return 0; } diff --git a/examples/position_cache.cpp b/examples/position_cache.cpp index 60c1ade6..f87d5126 100644 --- a/examples/position_cache.cpp +++ b/examples/position_cache.cpp @@ -15,34 +15,38 @@ * along with this program. If not, see . */ -#include -#include - #include #include - +#include +#include /// @brief Prints an error message when encourtering an And-Condition. -struct TestUnsupportedAndConditionVisitor { +struct TestUnsupportedAndConditionVisitor +{ const loki::Position position; const loki::PDDLPositionCache& position_cache; const loki::PDDLErrorHandler& error_handler; - TestUnsupportedAndConditionVisitor( - const loki::Position position_, - const loki::PDDLPositionCache& position_cache_, - const loki::PDDLErrorHandler& error_handler_) - : position(position_) - , position_cache(position_cache_) - , error_handler(error_handler_) { } + TestUnsupportedAndConditionVisitor(const loki::Position position_, + const loki::PDDLPositionCache& position_cache_, + const loki::PDDLErrorHandler& error_handler_) : + position(position_), + position_cache(position_cache_), + error_handler(error_handler_) + { + } /// @brief For leaf nodes we do not need to do anything template - void operator()(const Node&) { } + void operator()(const Node&) + { + } /// @brief For inner nodes we need to recursively call the visitor - void operator()(const loki::pddl::ConditionOrImpl& node) { - for (const auto& child_node : node.get_conditions()) { + void operator()(const loki::pddl::ConditionOrImpl& node) + { + for (const auto& child_node : node.get_conditions()) + { // We call front() to obtain the first occurence. const auto child_position = position_cache.get(child_node).front(); std::visit(TestUnsupportedAndConditionVisitor(child_position, position_cache, error_handler), *child_node); @@ -51,15 +55,16 @@ struct TestUnsupportedAndConditionVisitor { /// @brief For the unsupported And-Condition, /// we print an clang-style error message and throw an exception. - void operator()(const loki::pddl::ConditionAndImpl&) { + void operator()(const loki::pddl::ConditionAndImpl&) + { std::cout << error_handler(position, "Your awesome error message.") << std::endl; throw std::runtime_error("Unexpected And-Condition."); } }; - /// @brief In this example, we show how to print custom error message for unsupported PDDL types. -int main() { +int main() +{ // Parse the domain auto domain_parser = loki::DomainParser("data/gripper/domain.pddl"); const auto domain = domain_parser.get_domain(); @@ -68,16 +73,16 @@ int main() { const loki::PDDLPositionCache& position_cache = domain_parser.get_position_cache(); const loki::PDDLErrorHandler& error_handler = position_cache.get_error_handler(); - for (const auto& action : domain->get_actions()) { + for (const auto& action : domain->get_actions()) + { const auto condition = action->get_condition(); - if (!condition.has_value()) { + if (!condition.has_value()) + { continue; } // We call front() to obtain the first occurence. auto condition_position = position_cache.get(condition.value()).front(); - std::visit( - TestUnsupportedAndConditionVisitor(condition_position, position_cache, error_handler), - *condition.value()); + std::visit(TestUnsupportedAndConditionVisitor(condition_position, position_cache, error_handler), *condition.value()); } return 0; diff --git a/examples/single_problem.cpp b/examples/single_problem.cpp index 56f8d65a..f6cda4ed 100644 --- a/examples/single_problem.cpp +++ b/examples/single_problem.cpp @@ -15,13 +15,12 @@ * along with this program. If not, see . */ +#include #include #include -#include - - -int main() { +int main() +{ // Parse the domain auto domain_parser = loki::DomainParser("data/gripper/domain.pddl"); const auto domain = domain_parser.get_domain(); diff --git a/examples/undefined_behavior.cpp b/examples/undefined_behavior.cpp index b9a07fd1..4990a276 100644 --- a/examples/undefined_behavior.cpp +++ b/examples/undefined_behavior.cpp @@ -15,15 +15,14 @@ * along with this program. If not, see . */ +#include #include #include -#include - - /// @brief This example illustrates incorrect ownership handling -int main() { - auto domain = loki::pddl::Domain{nullptr}; +int main() +{ + auto domain = loki::pddl::Domain { nullptr }; { // Parse the domain auto domain_parser = loki::DomainParser("data/gripper/domain.pddl"); diff --git a/exe/domain.cpp b/exe/domain.cpp index c6066124..feb627a5 100644 --- a/exe/domain.cpp +++ b/exe/domain.cpp @@ -15,17 +15,17 @@ * along with this program. If not, see . */ -#include - #include +#include - -int main(int argc, char** argv) { - if (argc < 2) { +int main(int argc, char** argv) +{ + if (argc < 2) + { std::cout << "Usage: interpreter " << std::endl; return 1; } - const auto domain_file = std::string{argv[1]}; + const auto domain_file = std::string { argv[1] }; // 1. Parse the domain const auto domain_parser = loki::DomainParser(domain_file); diff --git a/exe/problem.cpp b/exe/problem.cpp index 9e5d5a0f..10f1305b 100644 --- a/exe/problem.cpp +++ b/exe/problem.cpp @@ -15,19 +15,19 @@ * along with this program. If not, see . */ +#include #include #include -#include - - -int main(int argc, char** argv) { - if (argc < 3) { +int main(int argc, char** argv) +{ + if (argc < 3) + { std::cout << "Usage: interpreter " << std::endl; return 1; } - const auto domain_file = std::string{argv[1]}; - const auto problem_file = std::string{argv[2]}; + const auto domain_file = std::string { argv[1] }; + const auto problem_file = std::string { argv[2] }; // 1. Parse the domain auto domain_parser = loki::DomainParser(domain_file); diff --git a/include/loki/common/ast/config.hpp b/include/loki/common/ast/config.hpp index 5a7ea21b..e2c50e81 100644 --- a/include/loki/common/ast/config.hpp +++ b/include/loki/common/ast/config.hpp @@ -21,42 +21,33 @@ #include #include #include - #include - /// @brief Defines types of our parsers. /// The configuration is relevant when reusing the parsers instantiated by the library. namespace loki { - namespace x3 = boost::spirit::x3; - - using Position = x3::position_tagged; - using PositionList = std::vector; - - // Our iterator type - typedef std::string::const_iterator iterator_type; +namespace x3 = boost::spirit::x3; +using Position = x3::position_tagged; +using PositionList = std::vector; - /* X3 error handler utility */ - template - using error_handler = x3::error_handler; +// Our iterator type +typedef std::string::const_iterator iterator_type; - using error_handler_tag = x3::error_handler_tag; +/* X3 error handler utility */ +template +using error_handler = x3::error_handler; - typedef error_handler error_handler_type; +using error_handler_tag = x3::error_handler_tag; +typedef error_handler error_handler_type; - /* The phrase parse context */ - typedef - x3::phrase_parse_context::type phrase_context_type; +/* The phrase parse context */ +typedef x3::phrase_parse_context::type phrase_context_type; - /* Combined error handler, pddl, and phrase parse Context */ - typedef x3::context< - error_handler_tag, - std::reference_wrapper, - phrase_context_type> - context_type; +/* Combined error handler, pddl, and phrase parse Context */ +typedef x3::context, phrase_context_type> context_type; } #endif diff --git a/include/loki/common/ast/error_handler.hpp b/include/loki/common/ast/error_handler.hpp index d284619e..e6bf11dd 100644 --- a/include/loki/common/ast/error_handler.hpp +++ b/include/loki/common/ast/error_handler.hpp @@ -18,45 +18,48 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_AST_ERROR_HANDLER_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_AST_ERROR_HANDLER_HPP_ -#include "config.hpp" +#include "loki/common/ast/config.hpp" -#include #include - +#include namespace loki { - namespace x3 = boost::spirit::x3; +namespace x3 = boost::spirit::x3; - //////////////////////////////////////////////////////////////////////////// - // Our error handler - //////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// +// Our error handler +//////////////////////////////////////////////////////////////////////////// - struct error_handler_base - { - std::unordered_map id_map; +struct error_handler_base +{ + std::unordered_map id_map; - error_handler_base() { } + error_handler_base() {} - template - x3::error_handler_result on_error( - Iterator& /*first*/, Iterator const& /*last*/ - , Exception const& x, Context const& context) { + template + x3::error_handler_result on_error(Iterator& /*first*/, + Iterator const& /*last*/ + , + Exception const& x, + Context const& context) + { + { + std::string which = x.which(); + auto iter = id_map.find(which); + if (iter != id_map.end()) { - std::string which = x.which(); - auto iter = id_map.find(which); - if (iter != id_map.end()) { - which = iter->second; - } + which = iter->second; + } - std::string message = "Error! Expecting: " + which + " here:"; - auto& error_handler = x3::get(context).get(); - error_handler(x.where(), message); + std::string message = "Error! Expecting: " + which + " here:"; + auto& error_handler = x3::get(context).get(); + error_handler(x.where(), message); - return x3::error_handler_result::fail; - } + return x3::error_handler_result::fail; } - }; + } +}; } #endif diff --git a/include/loki/common/ast/error_reporting.hpp b/include/loki/common/ast/error_reporting.hpp index 7722e961..728cdc4c 100644 --- a/include/loki/common/ast/error_reporting.hpp +++ b/include/loki/common/ast/error_reporting.hpp @@ -18,48 +18,39 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_AST_ERROR_REPORTING_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_AST_ERROR_REPORTING_HPP_ -#include "config.hpp" +#include "loki/common/ast/config.hpp" #include - // Clang-style error handling utilities namespace loki { - /* Combined error handler and output stream. */ - class X3ErrorHandler { - private: - // Order of initialization matters - std::ostringstream m_error_stream; - error_handler_type m_error_handler; +/* Combined error handler and output stream. */ +class X3ErrorHandler +{ +private: + // Order of initialization matters + std::ostringstream m_error_stream; + error_handler_type m_error_handler; - public: - X3ErrorHandler(iterator_type first, iterator_type last, const std::string& file) - : m_error_handler(error_handler_type(first, last, m_error_stream, file)) { } +public: + X3ErrorHandler(iterator_type first, iterator_type last, const std::string& file) : m_error_handler(error_handler_type(first, last, m_error_stream, file)) {} - // delete copy and move to avoid dangling references. - X3ErrorHandler(const X3ErrorHandler& other) = delete; - X3ErrorHandler& operator=(const X3ErrorHandler& other) = delete; - X3ErrorHandler(X3ErrorHandler&& other) = delete; - X3ErrorHandler& operator=(X3ErrorHandler&& other) = delete; + // delete copy and move to avoid dangling references. + X3ErrorHandler(const X3ErrorHandler& other) = delete; + X3ErrorHandler& operator=(const X3ErrorHandler& other) = delete; + X3ErrorHandler(X3ErrorHandler&& other) = delete; + X3ErrorHandler& operator=(X3ErrorHandler&& other) = delete; - const error_handler_type& get_error_handler() const { - return m_error_handler; - } + const error_handler_type& get_error_handler() const { return m_error_handler; } - error_handler_type& get_error_handler() { - return m_error_handler; - } + error_handler_type& get_error_handler() { return m_error_handler; } - const std::ostringstream& get_error_stream() const { - return m_error_stream; - } + const std::ostringstream& get_error_stream() const { return m_error_stream; } - std::ostringstream& get_error_stream() { - return m_error_stream; - } - }; + std::ostringstream& get_error_stream() { return m_error_stream; } +}; } #endif diff --git a/include/loki/common/ast/parser_wrapper.hpp b/include/loki/common/ast/parser_wrapper.hpp index f747424c..3b6e3087 100644 --- a/include/loki/common/ast/parser_wrapper.hpp +++ b/include/loki/common/ast/parser_wrapper.hpp @@ -18,50 +18,48 @@ #ifndef LOKI_INCLUDE_COMMON_AST_PARSER_WRAPPER_HPP_ #define LOKI_INCLUDE_COMMON_AST_PARSER_WRAPPER_HPP_ -#include "config.hpp" +#include "loki/common/ast/config.hpp" #include - -namespace loki { +namespace loki +{ template -bool parse_ast(Iterator& iter, Iterator end, const Parser& parser, Node& out, error_handler_type& error_handler) { - out = Node(); // reinitialize +bool parse_ast(Iterator& iter, Iterator end, const Parser& parser, Node& out, error_handler_type& error_handler) +{ + out = Node(); // reinitialize - //assert(error_handler.get_position_cache().first() <= iter && - // end < error_handler.get_position_cache().last()); + // assert(error_handler.get_position_cache().first() <= iter && + // end < error_handler.get_position_cache().last()); using boost::spirit::x3::with; - auto const wrapped_parser = - with(std::ref(error_handler)) - [ - parser - ]; + auto const wrapped_parser = with(std::ref(error_handler))[parser]; using boost::spirit::x3::ascii::space; bool success = phrase_parse(iter, end, wrapped_parser, space, out); return success; } template -bool parse_ast(const std::string& source, const Parser& parser, Node& out, error_handler_type& error_handler) { +bool parse_ast(const std::string& source, const Parser& parser, Node& out, error_handler_type& error_handler) +{ auto iter = source.begin(); return parse_ast(iter, source.end(), parser, out, error_handler); } template -void parse_ast(const std::string& source, const Parser& parser, Node& out) { +void parse_ast(const std::string& source, const Parser& parser, Node& out) +{ loki::iterator_type iter(source.begin()); const loki::iterator_type end(source.end()); error_handler_type error_handler(iter, end, std::cerr); bool success = parse_ast(source, parser, out, error_handler); - if (!success) { + if (!success) + { throw std::runtime_error("Failed parse."); } } - - } #endif diff --git a/include/loki/common/collections.hpp b/include/loki/common/collections.hpp index 100ca236..9a5705f1 100644 --- a/include/loki/common/collections.hpp +++ b/include/loki/common/collections.hpp @@ -18,20 +18,20 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_COLLECTIONS_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_COLLECTIONS_HPP_ -#include - #include +#include #include - -namespace loki { +namespace loki +{ /// @brief Returns the sorted vector /// @tparam T /// @param vec /// @return template -boost::container::small_vector get_sorted_vector(const Collection& collection) { +boost::container::small_vector get_sorted_vector(const Collection& collection) +{ boost::container::small_vector result(collection.begin(), collection.end()); std::sort(result.begin(), result.end()); return result; diff --git a/include/loki/common/exceptions.hpp b/include/loki/common/exceptions.hpp index a97b5411..a4109c78 100644 --- a/include/loki/common/exceptions.hpp +++ b/include/loki/common/exceptions.hpp @@ -20,32 +20,32 @@ #include - -namespace loki { -class FileNotExistsError : public std::runtime_error { +namespace loki +{ +class FileNotExistsError : public std::runtime_error +{ public: explicit FileNotExistsError(const std::string& path_to_file); }; - -class SyntaxParserError : public std::runtime_error { +class SyntaxParserError : public std::runtime_error +{ public: explicit SyntaxParserError(const std::string& message, const std::string& error_handler_output); }; - -class SemanticParserError : public std::runtime_error { +class SemanticParserError : public std::runtime_error +{ public: explicit SemanticParserError(const std::string& message, const std::string& error_handler_output); }; - -class NotImplementedError : public std::runtime_error { +class NotImplementedError : public std::runtime_error +{ public: explicit NotImplementedError(const std::string& message); }; - } #endif \ No newline at end of file diff --git a/include/loki/common/filesystem.hpp b/include/loki/common/filesystem.hpp index cb2726b0..e3036c03 100644 --- a/include/loki/common/filesystem.hpp +++ b/include/loki/common/filesystem.hpp @@ -18,24 +18,22 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_FILESYSTEM_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_FILESYSTEM_HPP_ - // Older versions of LibC++ does not have filesystem (e.g., ubuntu 18.04), use the experimental version // https://stackoverflow.com/questions/55474690/stdfilesystem-has-not-been-declared-after-including-experimental-filesystem #ifndef __has_include - static_assert(false, "__has_include not supported"); +static_assert(false, "__has_include not supported"); #else -# if __cplusplus >= 201703L && __has_include() -# include - namespace fs = std::filesystem; -# elif __has_include() -# include - namespace fs = std::experimental::filesystem; -# elif __has_include() -# include - namespace fs = boost::filesystem; -# endif +#if __cplusplus >= 201703L && __has_include() +#include +namespace fs = std::filesystem; +#elif __has_include() +#include +namespace fs = std::experimental::filesystem; +#elif __has_include() +#include +namespace fs = boost::filesystem; +#endif #endif - namespace loki { diff --git a/include/loki/common/hash.hpp b/include/loki/common/hash.hpp index 4c13061b..8245548f 100644 --- a/include/loki/common/hash.hpp +++ b/include/loki/common/hash.hpp @@ -18,13 +18,13 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_HASH_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_HASH_HPP_ -#include #include +#include #include #include - -namespace loki { +namespace loki +{ // -------------- // Hash functions @@ -65,13 +65,11 @@ inline std::size_t hash_container(const Container& container) } template -struct hash_container_type { - size_t operator()(const Container& container) const { - return hash_container(container); - } +struct hash_container_type +{ + size_t operator()(const Container& container) const { return hash_container(container); } }; } - #endif \ No newline at end of file diff --git a/include/loki/common/memory.hpp b/include/loki/common/memory.hpp index a28926c1..09843910 100644 --- a/include/loki/common/memory.hpp +++ b/include/loki/common/memory.hpp @@ -17,12 +17,12 @@ // Taken from: https://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-runtime-using-c -#include +#include #include #include -#include #include #include +#include ////////////////////////////////////////////////////////////////////////////// // @@ -30,7 +30,8 @@ // size and resident set size, and return the results in KB. // // On failure, returns 0.0, 0.0 -namespace loki { +namespace loki +{ extern std::tuple process_mem_usage(); diff --git a/include/loki/common/pddl/base.hpp b/include/loki/common/pddl/base.hpp index d7213097..bdc00aa9 100644 --- a/include/loki/common/pddl/base.hpp +++ b/include/loki/common/pddl/base.hpp @@ -18,14 +18,14 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_BASE_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_BASE_HPP_ -#include "../printer.hpp" +#include "loki/common/printer.hpp" #include #include #include - -namespace loki { +namespace loki +{ /// @brief Implements a common base class for PDDL objects. /// /// Each PDDL object has an identifier. @@ -50,11 +50,12 @@ namespace loki { /// For example, loki detects semantic equivalence of a conjunction of atoms /// but loki does not detect semantic equivalence of an arbitrary formula of atoms. template -class Base { +class Base +{ protected: int m_identifier; - explicit Base(int identifier) : m_identifier(identifier) { } + explicit Base(int identifier) : m_identifier(identifier) {} friend Derived; public: @@ -66,49 +67,37 @@ class Base { constexpr const auto& self() const { return static_cast(*this); } - bool operator==(const Base& other) const { - return self().is_structurally_equivalent_to_impl(other.self()); - } + bool operator==(const Base& other) const { return self().is_structurally_equivalent_to_impl(other.self()); } - bool operator!=(const Base& other) const { - return !(*this == other); - } + bool operator!=(const Base& other) const { return !(*this == other); } - bool operator<(const Base& other) const { - return m_identifier < other.m_identifier; - } + bool operator<(const Base& other) const { return m_identifier < other.m_identifier; } - bool operator>(const Base& other) const { - return m_identifier > other.m_identifier; - } + bool operator>(const Base& other) const { return m_identifier > other.m_identifier; } - size_t hash() const { - return self().hash_impl(); - } + size_t hash() const { return self().hash_impl(); } /// @brief Overload of the output stream insertion operator (operator<<). - friend std::ostream& operator<<(std::ostream& os, const Base& element) { + friend std::ostream& operator<<(std::ostream& os, const Base& element) + { os << element.str(); return os; } /// @brief Compute a string representation of this object. - void str(std::ostringstream& out, const FormattingOptions& options) const { - self().str_impl(out, options); - } + void str(std::ostringstream& out, const FormattingOptions& options) const { self().str_impl(out, options); } /// @brief Compute a string representation of this object. - std::string str() const { + std::string str() const + { std::ostringstream out; - FormattingOptions options{0, 4}; + FormattingOptions options { 0, 4 }; str(out, options); return out.str(); } /// @brief Returns the identifier - int get_identifier() const { - return m_identifier; - } + int get_identifier() const { return m_identifier; } }; } diff --git a/include/loki/common/pddl/config.hpp b/include/loki/common/pddl/config.hpp index b177b906..7a213f7b 100644 --- a/include/loki/common/pddl/config.hpp +++ b/include/loki/common/pddl/config.hpp @@ -18,14 +18,12 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_CONFIG_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_CONFIG_HPP_ -#include "error_reporting.hpp" - -#include "../ast/config.hpp" - +#include "loki/common/ast/config.hpp" +#include "loki/common/pddl/error_reporting.hpp" namespace loki { - typedef PDDLErrorHandlerImpl PDDLErrorHandler; +typedef PDDLErrorHandlerImpl PDDLErrorHandler; } #endif diff --git a/include/loki/common/pddl/context.hpp b/include/loki/common/pddl/context.hpp index 1d32cd02..7ad151d5 100644 --- a/include/loki/common/pddl/context.hpp +++ b/include/loki/common/pddl/context.hpp @@ -18,30 +18,36 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_CONTEXT_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_CONTEXT_HPP_ -#include "position.hpp" -#include "reference.hpp" -#include "scope.hpp" -#include "types.hpp" +#include "loki/common/pddl/position.hpp" +#include "loki/common/pddl/reference.hpp" +#include "loki/common/pddl/scope.hpp" +#include "loki/common/pddl/types.hpp" namespace loki { - struct Context - { - // For the unique construction of PDDL objects - PDDLFactories& factories; - // For storing the positions in the input PDDL file - PDDLPositionCache& positions; - // For referencing to existing bindings - ScopeStack& scopes; - // For checking that certain PDDL objects were referenced at least once - ReferencedPDDLObjects references; - // For convenience, to avoid an additional parameter during semantic parsing - pddl::Requirements requirements; +struct Context +{ + // For the unique construction of PDDL objects + PDDLFactories& factories; + // For storing the positions in the input PDDL file + PDDLPositionCache& positions; + // For referencing to existing bindings + ScopeStack& scopes; + // For checking that certain PDDL objects were referenced at least once + ReferencedPDDLObjects references; + // For convenience, to avoid an additional parameter during semantic parsing + pddl::Requirements requirements; - Context(PDDLFactories &factories_, PDDLPositionCache& positions_, ScopeStack &scopes_) - : factories(factories_), positions(positions_), scopes(scopes_), references(ReferencedPDDLObjects()), requirements(nullptr) {} - }; + Context(PDDLFactories& factories_, PDDLPositionCache& positions_, ScopeStack& scopes_) : + factories(factories_), + positions(positions_), + scopes(scopes_), + references(ReferencedPDDLObjects()), + requirements(nullptr) + { + } +}; } diff --git a/include/loki/common/pddl/error_reporting.hpp b/include/loki/common/pddl/error_reporting.hpp index 1bb774dc..c83c406c 100644 --- a/include/loki/common/pddl/error_reporting.hpp +++ b/include/loki/common/pddl/error_reporting.hpp @@ -18,13 +18,11 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_ERROR_REPORTING_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_ERROR_REPORTING_HPP_ -#include "../filesystem.hpp" +#include "loki/common/filesystem.hpp" #include - -#include #include - +#include // Clang-style error handling utilities @@ -35,173 +33,166 @@ namespace loki { - using position_tagged = boost::spirit::x3::position_tagged; +using position_tagged = boost::spirit::x3::position_tagged; - template - class PDDLErrorHandlerImpl - { - public: - - typedef Iterator iterator_type; - using position_cache = boost::spirit::x3::position_cache>; +template +class PDDLErrorHandlerImpl +{ +public: + typedef Iterator iterator_type; + using position_cache = boost::spirit::x3::position_cache>; - PDDLErrorHandlerImpl(position_cache pos_cache, fs::path file = "", int tabs = 4) - : pos_cache(pos_cache) - , file(file) - , tabs(tabs) {} + PDDLErrorHandlerImpl(position_cache pos_cache, fs::path file = "", int tabs = 4) : pos_cache(pos_cache), file(file), tabs(tabs) {} - std::string operator()(Iterator err_pos, std::string const& error_message) const; - std::string operator()(Iterator err_first, Iterator err_last, std::string const& error_message) const; - std::string operator()(position_tagged pos, std::string const& message) const - { - auto where = pos_cache.position_of(pos); - return (*this)(where.begin(), where.end(), message); - } - - boost::iterator_range position_of(position_tagged pos) const - { - return pos_cache.position_of(pos); - } + std::string operator()(Iterator err_pos, std::string const& error_message) const; + std::string operator()(Iterator err_first, Iterator err_last, std::string const& error_message) const; + std::string operator()(position_tagged pos, std::string const& message) const + { + auto where = pos_cache.position_of(pos); + return (*this)(where.begin(), where.end(), message); + } - private: + boost::iterator_range position_of(position_tagged pos) const { return pos_cache.position_of(pos); } - std::string print_file_line(std::size_t line) const; - std::string print_line(Iterator line_start, Iterator last) const; - std::string print_indicator(Iterator& line_start, Iterator last, char ind) const; - Iterator get_line_start(Iterator first, Iterator pos) const; - std::size_t position(Iterator i) const; +private: + std::string print_file_line(std::size_t line) const; + std::string print_line(Iterator line_start, Iterator last) const; + std::string print_indicator(Iterator& line_start, Iterator last, char ind) const; + Iterator get_line_start(Iterator first, Iterator pos) const; + std::size_t position(Iterator i) const; - position_cache pos_cache; - std::string file; - int tabs; - }; + position_cache pos_cache; + std::string file; + int tabs; +}; - template - std::string PDDLErrorHandlerImpl::print_file_line(std::size_t line) const +template +std::string PDDLErrorHandlerImpl::print_file_line(std::size_t line) const +{ + std::ostringstream err_out; + if (file != "") { - std::ostringstream err_out; - if (file != "") - { - err_out << "In file " << file << ", "; - } - else - { - err_out << "In "; - } - - err_out << "line " << line << ':' << std::endl; - return err_out.str(); + err_out << "In file " << file << ", "; } - - template - std::string PDDLErrorHandlerImpl::print_line(Iterator start, Iterator last) const + else { - std::ostringstream err_out; - auto end = start; - while (end != last) - { - auto c = *end; - if (c == '\r' || c == '\n') - break; - else - ++end; - } - typedef typename std::iterator_traits::value_type char_type; - std::basic_string line{start, end}; - err_out << boost::spirit::x3::to_utf8(line) << std::endl; - return err_out.str(); + err_out << "In "; } - template - std::string PDDLErrorHandlerImpl::print_indicator(Iterator& start, Iterator last, char ind) const + err_out << "line " << line << ':' << std::endl; + return err_out.str(); +} + +template +std::string PDDLErrorHandlerImpl::print_line(Iterator start, Iterator last) const +{ + std::ostringstream err_out; + auto end = start; + while (end != last) { - std::ostringstream err_out; - for (; start != last; ++start) - { - auto c = *start; - if (c == '\r' || c == '\n') - break; - else if (c == '\t') - for (int i = 0; i < tabs; ++i) - err_out << ind; - else - err_out << ind; - } - return err_out.str(); + auto c = *end; + if (c == '\r' || c == '\n') + break; + else + ++end; } + typedef typename std::iterator_traits::value_type char_type; + std::basic_string line { start, end }; + err_out << boost::spirit::x3::to_utf8(line) << std::endl; + return err_out.str(); +} - template - inline Iterator PDDLErrorHandlerImpl::get_line_start(Iterator first, Iterator pos) const +template +std::string PDDLErrorHandlerImpl::print_indicator(Iterator& start, Iterator last, char ind) const +{ + std::ostringstream err_out; + for (; start != last; ++start) { - Iterator latest = first; - for (Iterator i = first; i != pos;) - if (*i == '\r' || *i == '\n') - latest = ++i; - else - ++i; - return latest; + auto c = *start; + if (c == '\r' || c == '\n') + break; + else if (c == '\t') + for (int i = 0; i < tabs; ++i) + err_out << ind; + else + err_out << ind; } + return err_out.str(); +} - template - std::size_t PDDLErrorHandlerImpl::position(Iterator i) const - { - std::size_t line { 1 }; - typename std::iterator_traits::value_type prev { 0 }; +template +inline Iterator PDDLErrorHandlerImpl::get_line_start(Iterator first, Iterator pos) const +{ + Iterator latest = first; + for (Iterator i = first; i != pos;) + if (*i == '\r' || *i == '\n') + latest = ++i; + else + ++i; + return latest; +} + +template +std::size_t PDDLErrorHandlerImpl::position(Iterator i) const +{ + std::size_t line { 1 }; + typename std::iterator_traits::value_type prev { 0 }; - for (Iterator pos = pos_cache.first(); pos != i; ++pos) { - auto c = *pos; - switch (c) { + for (Iterator pos = pos_cache.first(); pos != i; ++pos) + { + auto c = *pos; + switch (c) + { case '\n': - if (prev != '\r') ++line; + if (prev != '\r') + ++line; break; case '\r': ++line; break; default: break; - } - prev = c; } - - return line; + prev = c; } - template - std::string PDDLErrorHandlerImpl::operator()( - Iterator err_pos, std::string const& error_message) const - { - Iterator first = pos_cache.first(); - Iterator last = pos_cache.last(); - - std::ostringstream err_out; - err_out << print_file_line(position(err_pos)); - err_out << error_message << std::endl; - - Iterator start = get_line_start(first, err_pos); - err_out << print_line(start, last); - err_out << print_indicator(start, err_pos, '_'); - err_out << "^_" << std::endl; - return err_out.str(); - } + return line; +} - template - std::string PDDLErrorHandlerImpl::operator()( - Iterator err_first, Iterator err_last, std::string const& error_message) const - { - Iterator first = pos_cache.first(); - Iterator last = pos_cache.last(); - - std::ostringstream err_out; - err_out << print_file_line(position(err_first)); - err_out << error_message << std::endl; - - Iterator start = get_line_start(first, err_first); - err_out << print_line(start, last); - err_out << print_indicator(start, err_first, ' '); - err_out << print_indicator(start, err_last, '~'); - err_out << " <<-- Here" << std::endl; - return err_out.str(); - } +template +std::string PDDLErrorHandlerImpl::operator()(Iterator err_pos, std::string const& error_message) const +{ + Iterator first = pos_cache.first(); + Iterator last = pos_cache.last(); + + std::ostringstream err_out; + err_out << print_file_line(position(err_pos)); + err_out << error_message << std::endl; + + Iterator start = get_line_start(first, err_pos); + err_out << print_line(start, last); + err_out << print_indicator(start, err_pos, '_'); + err_out << "^_" << std::endl; + return err_out.str(); +} + +template +std::string PDDLErrorHandlerImpl::operator()(Iterator err_first, Iterator err_last, std::string const& error_message) const +{ + Iterator first = pos_cache.first(); + Iterator last = pos_cache.last(); + + std::ostringstream err_out; + err_out << print_file_line(position(err_first)); + err_out << error_message << std::endl; + + Iterator start = get_line_start(first, err_first); + err_out << print_line(start, last); + err_out << print_indicator(start, err_first, ' '); + err_out << print_indicator(start, err_last, '~'); + err_out << " <<-- Here" << std::endl; + return err_out.str(); +} } diff --git a/include/loki/common/pddl/garbage_collected_factory.hpp b/include/loki/common/pddl/garbage_collected_factory.hpp index 6f82196e..51b3a9cf 100644 --- a/include/loki/common/pddl/garbage_collected_factory.hpp +++ b/include/loki/common/pddl/garbage_collected_factory.hpp @@ -19,14 +19,14 @@ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_GARBAGE_COLLECTED_FACTORY_HPP_ #include -#include -#include #include #include #include +#include +#include - -namespace loki { +namespace loki +{ /* Not used anymore but still a useful piece of code. */ @@ -35,18 +35,20 @@ namespace loki { /// Custom deleter idea: https://stackoverflow.com/questions/49782011/herb-sutters-10-liner-with-cleanup /// TODO: improve the quality of the answer on stackoverflow template -class GarbageCollectedFactory { +class GarbageCollectedFactory +{ private: - /// @brief Encapsulates the data of a single type. template - struct PerTypeCache { + struct PerTypeCache + { std::unordered_set uniqueness; std::unordered_map> identifier_to_object; }; /// @brief Encapsulates the data of all types. - struct Cache { + struct Cache + { std::tuple...> data; // Identifiers are shared across types since types can be polymorphic int count = 0; @@ -57,8 +59,7 @@ class GarbageCollectedFactory { std::shared_ptr m_cache; public: - GarbageCollectedFactory() - : m_cache(std::make_shared()) { } + GarbageCollectedFactory() : m_cache(std::make_shared()) {} /// @brief Gets a shared reference to the object of type T with the given arguments. /// If such an object does not exists then it creates one. @@ -66,7 +67,8 @@ class GarbageCollectedFactory { /// @param ...args /// @return template - [[nodiscard]] std::shared_ptr get_or_create(Args... args) { + [[nodiscard]] std::shared_ptr get_or_create(Args... args) + { /* we must declare sp before locking the mutex s.t. the deleter is called after the mutex was released in case of stack unwinding. */ std::shared_ptr sp; @@ -76,7 +78,8 @@ class GarbageCollectedFactory { int identifier = m_cache->count; auto key = T(identifier, args...); const auto [it, inserted] = t_cache.uniqueness.insert(key); - if (!inserted) { + if (!inserted) + { assert(t_cache.identifier_to_object.count(it->get_identifier())); return t_cache.identifier_to_object.at(it->get_identifier()).lock(); } @@ -84,27 +87,26 @@ class GarbageCollectedFactory { /* Must explicitly call the constructor of T to give exclusive access to the factory. */ // Extensions: To ensure that the memory for T and the control block is allocated once, // we could use std::allocated_shared and provide a custom allocator. - sp = std::shared_ptr( - new T(identifier, args...), - [cache=m_cache, identifier](T* x) - { - { - std::lock_guard hold(cache->mutex); - auto& t_cache = std::get>(cache->data); - t_cache.uniqueness.erase(*x); - t_cache.identifier_to_object.erase(identifier); - } - /* After cache removal, we can call the objects destructor - and recursively call the deleter of children if their ref count goes to 0 */ - delete x; - } - ); + sp = std::shared_ptr(new T(identifier, args...), + [cache = m_cache, identifier](T* x) + { + { + std::lock_guard hold(cache->mutex); + auto& t_cache = std::get>(cache->data); + t_cache.uniqueness.erase(*x); + t_cache.identifier_to_object.erase(identifier); + } + /* After cache removal, we can call the objects destructor + and recursively call the deleter of children if their ref count goes to 0 */ + delete x; + }); t_cache.identifier_to_object.emplace(identifier, sp); return sp; } template - size_t size() const { + size_t size() const + { std::lock_guard hold(m_cache->mutex); auto& t_cache = std::get>(m_cache->data); return t_cache.uniqueness.size(); diff --git a/include/loki/common/pddl/persistent_factory.hpp b/include/loki/common/pddl/persistent_factory.hpp index 66832392..af885928 100644 --- a/include/loki/common/pddl/persistent_factory.hpp +++ b/include/loki/common/pddl/persistent_factory.hpp @@ -18,18 +18,18 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_PERSISTENT_FACTORY_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_PERSISTENT_FACTORY_HPP_ -#include "declarations.hpp" -#include "segmented_vector.hpp" +#include "loki/common/pddl/declarations.hpp" +#include "loki/common/pddl/segmented_vector.hpp" -#include #include #include #include #include +#include #include - -namespace loki { +namespace loki +{ /// @brief The PersistentFactory class manages unique objects in a persistent /// and efficient manner, utilizing a combination of unordered_set for /// uniqueness checks and SegmentedVector for continuous and @@ -37,21 +37,20 @@ namespace loki { /// @tparam HolderType is the nested type which can be an std::variant. /// @tparam N is the number of elements per segment template -class PersistentFactory { +class PersistentFactory +{ private: template - struct DerferencedHash { - std::size_t operator()(const T* ptr) const { - return std::hash()(*ptr); - } + struct DerferencedHash + { + std::size_t operator()(const T* ptr) const { return std::hash()(*ptr); } }; /// @brief Equality comparison of the objects underlying the pointers. template - struct DereferencedEquality { - bool operator()(const T* left, const T* right) const { - return *left == *right; - } + struct DereferencedEquality + { + bool operator()(const T* left, const T* right) const { return *left == *right; } }; // We use an unordered_set to test for uniqueness. @@ -68,30 +67,32 @@ class PersistentFactory { /// @brief Returns a pointer to an existing object /// or creates it before if it does not exist. template - [[nodiscard]] HolderType const* get_or_create(Args&&... args) { + [[nodiscard]] HolderType const* get_or_create(Args&&... args) + { std::lock_guard hold(m_mutex); /* Construct and insert the element in persistent memory. */ size_t identifier = m_count; // Ensure that element with identifier i is stored at position i. - assert((identifier == (m_persistent_vector.size()-1)) - || (identifier == m_persistent_vector.size())); + assert((identifier == (m_persistent_vector.size() - 1)) || (identifier == m_persistent_vector.size())); // Explicitly call the constructor of T to give exclusive access to the factory. auto element = HolderType(std::move(SubType(identifier, std::forward(args)...))); bool overwrite_last_element = (identifier == m_persistent_vector.size() - 1); // The pointer to the location in persistent memory. - const auto* element_ptr = overwrite_last_element - ? &(m_persistent_vector[identifier] = std::move(element)) - : &(m_persistent_vector.push_back(std::move(element))); + const auto* element_ptr = + overwrite_last_element ? &(m_persistent_vector[identifier] = std::move(element)) : &(m_persistent_vector.push_back(std::move(element))); assert(element_ptr); /* Test for uniqueness */ auto it = m_uniqueness_set.find(element_ptr); - if (it == m_uniqueness_set.end()) { + if (it == m_uniqueness_set.end()) + { // Element is unique! m_uniqueness_set.emplace(element_ptr); // Validate the element by increasing the identifier to the next free position ++m_count; assert(m_uniqueness_set.size() == m_count); - } else { + } + else + { // Element is not unique! // Return the existing one. element_ptr = *it; @@ -100,20 +101,19 @@ class PersistentFactory { } /// @brief Returns a pointer to an existing object with the given identifier. - [[nodiscard]] HolderType const* get(size_t identifier) const { - if (identifier < m_persistent_vector.size()) { + [[nodiscard]] HolderType const* get(size_t identifier) const + { + if (identifier < m_persistent_vector.size()) + { return &(m_persistent_vector[identifier]); } throw std::invalid_argument("invalid identifier"); } - size_t size() const { - return m_count; - } + size_t size() const { return m_count; } }; } - #endif diff --git a/include/loki/common/pddl/position.hpp b/include/loki/common/pddl/position.hpp index 9086b291..84061730 100644 --- a/include/loki/common/pddl/position.hpp +++ b/include/loki/common/pddl/position.hpp @@ -18,37 +18,37 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_POSITION_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_POSITION_HPP_ -#include "config.hpp" -#include "declarations.hpp" - -#include "../ast/error_reporting.hpp" -#include "../filesystem.hpp" +#include "loki/common/ast/error_reporting.hpp" +#include "loki/common/filesystem.hpp" +#include "loki/common/pddl/config.hpp" +#include "loki/common/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template using PositionMapType = std::unordered_map, PositionList>; /// @brief Stores all occurrences of a PDDL object in the input file for each PDDL type T. template -class PositionCache { - private: - std::tuple...> m_positions; +class PositionCache +{ +private: + std::tuple...> m_positions; - PDDLErrorHandler m_error_handler; + PDDLErrorHandler m_error_handler; - public: - PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs=4); +public: + PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs = 4); - template - void push_back(const PDDLElement& element, const Position& position); + template + void push_back(const PDDLElement& element, const Position& position); - template - PositionList get(const PDDLElement& element) const; + template + PositionList get(const PDDLElement& element) const; - const PDDLErrorHandler& get_error_handler() const; + const PDDLErrorHandler& get_error_handler() const; }; } diff --git a/include/loki/common/pddl/position.tpp b/include/loki/common/pddl/position.tpp index 4a825295..ce396a86 100644 --- a/include/loki/common/pddl/position.tpp +++ b/include/loki/common/pddl/position.tpp @@ -15,34 +15,39 @@ * along with this program. If not, see . */ - -namespace loki { +namespace loki +{ template -PositionCache::PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs) - : m_error_handler(PDDLErrorHandler(error_handler.get_error_handler().get_position_cache(), file, tabs)) { } - +PositionCache::PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs) : + m_error_handler(PDDLErrorHandler(error_handler.get_error_handler().get_position_cache(), file, tabs)) +{ +} template template -void PositionCache::push_back(const PDDLElement& element, const Position& position) { +void PositionCache::push_back(const PDDLElement& element, const Position& position) +{ auto& t_positions = std::get>(m_positions); t_positions[element].push_back(position); } template template -PositionList PositionCache::get(const PDDLElement& element) const { +PositionList PositionCache::get(const PDDLElement& element) const +{ auto& t_positions = std::get>(m_positions); auto it = t_positions.find(element); - if (it != t_positions.end()) { + if (it != t_positions.end()) + { return it->second; } return {}; } template -const PDDLErrorHandler& PositionCache::get_error_handler() const { +const PDDLErrorHandler& PositionCache::get_error_handler() const +{ return m_error_handler; } diff --git a/include/loki/common/pddl/reference.hpp b/include/loki/common/pddl/reference.hpp index 6fa2a38a..4cfae8af 100644 --- a/include/loki/common/pddl/reference.hpp +++ b/include/loki/common/pddl/reference.hpp @@ -18,24 +18,23 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_REFERENCE_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_REFERENCE_HPP_ -#include "../../common/ast/config.hpp" -#include "../../domain/pddl/object.hpp" -#include "../../domain/pddl/predicate.hpp" -#include "../../domain/pddl/requirements.hpp" -#include "../../domain/pddl/function_skeleton.hpp" -#include "../../domain/pddl/variable.hpp" +#include "loki/common/ast/config.hpp" +#include "loki/domain/pddl/function_skeleton.hpp" +#include "loki/domain/pddl/object.hpp" +#include "loki/domain/pddl/predicate.hpp" +#include "loki/domain/pddl/requirements.hpp" +#include "loki/domain/pddl/variable.hpp" #include - #include -#include +#include #include -#include #include -#include - +#include +#include -namespace loki { +namespace loki +{ /// @brief Encapsulates tracking of references of PDDL objects. /// /// Example usage: @@ -45,29 +44,26 @@ namespace loki { /// 3. Verify that all variables are untracked, meaning /// that they were referenced at least once. template -class References { - private: - std::tuple...> references; +class References +{ +private: + std::tuple...> references; - public: - /// @brief Returns a pointer if it exists. - template - bool exists(T reference) const; +public: + /// @brief Returns a pointer if it exists. + template + bool exists(T reference) const; - /// @brief Inserts a pointer of type T - template - void track(T reference); + /// @brief Inserts a pointer of type T + template + void track(T reference); - /// @brief Erases a pointer of Type T - template - void untrack(T reference); + /// @brief Erases a pointer of Type T + template + void untrack(T reference); }; -using ReferencedPDDLObjects = References; +using ReferencedPDDLObjects = References; } diff --git a/include/loki/common/pddl/reference.tpp b/include/loki/common/pddl/reference.tpp index cc8df305..0dca6ee7 100644 --- a/include/loki/common/pddl/reference.tpp +++ b/include/loki/common/pddl/reference.tpp @@ -15,29 +15,29 @@ * along with this program. If not, see . */ - - -namespace loki { +namespace loki +{ template template -bool References::exists(T reference) const { +bool References::exists(T reference) const +{ const auto& t_references = std::get>(references); return t_references.count(reference); } - template template -void References::track(T reference) { +void References::track(T reference) +{ auto& t_references = std::get>(references); t_references.insert(reference); } - template template -void References::untrack(T reference) { +void References::untrack(T reference) +{ auto& t_references = std::get>(references); t_references.erase(reference); } diff --git a/include/loki/common/pddl/scope.hpp b/include/loki/common/pddl/scope.hpp index 34204d17..9875cbff 100644 --- a/include/loki/common/pddl/scope.hpp +++ b/include/loki/common/pddl/scope.hpp @@ -20,25 +20,23 @@ #include "config.hpp" #include "declarations.hpp" - -#include "../../common/ast/config.hpp" -#include "../../domain/pddl/type.hpp" -#include "../../domain/pddl/object.hpp" -#include "../../domain/pddl/predicate.hpp" -#include "../../domain/pddl/function_skeleton.hpp" -#include "../../domain/pddl/variable.hpp" +#include "loki/common/ast/config.hpp" +#include "loki/domain/pddl/function_skeleton.hpp" +#include "loki/domain/pddl/object.hpp" +#include "loki/domain/pddl/predicate.hpp" +#include "loki/domain/pddl/type.hpp" +#include "loki/domain/pddl/variable.hpp" #include - #include -#include +#include #include -#include #include -#include - +#include +#include -namespace loki { +namespace loki +{ /// @brief Encapsulates binding related information of a type T. /// The object is the entity bound to the name. @@ -51,62 +49,53 @@ using BindingValueType = std::tuple, std::optional>; template using BindingMapType = std::unordered_map>; - /// @brief Encapsulates bindings for different types. template -class Bindings { - private: - std::tuple...> bindings; - - public: - /// @brief Returns a binding if it exists. - template - std::optional> get(const std::string& key) const; - - /// @brief Inserts a binding of type T - template - void insert( - const std::string& key, - const PDDLElement& binding, - const std::optional& position); +class Bindings +{ +private: + std::tuple...> bindings; + +public: + /// @brief Returns a binding if it exists. + template + std::optional> get(const std::string& key) const; + + /// @brief Inserts a binding of type T + template + void insert(const std::string& key, const PDDLElement& binding, const std::optional& position); }; - /// @brief Wraps bindings in a scope with reference to a parent scope. -class Scope { - private: - const Scope* m_parent_scope; - - Bindings bindings; - - public: - explicit Scope(const Scope* parent_scope = nullptr); - - // delete copy and move to avoid dangling references. - Scope(const Scope& other) = delete; - Scope& operator=(const Scope& other) = delete; - Scope(Scope&& other) = delete; - Scope& operator=(Scope&& other) = delete; - - /// @brief Returns a binding if it exists. - template - std::optional> get(const std::string& name) const; - - /// @brief Insert a binding of type T. - template - void insert(const std::string& name, const PDDLElement& element, const std::optional& position); -}; +class Scope +{ +private: + const Scope* m_parent_scope; + + Bindings bindings; + +public: + explicit Scope(const Scope* parent_scope = nullptr); + + // delete copy and move to avoid dangling references. + Scope(const Scope& other) = delete; + Scope& operator=(const Scope& other) = delete; + Scope(Scope&& other) = delete; + Scope& operator=(Scope&& other) = delete; + /// @brief Returns a binding if it exists. + template + std::optional> get(const std::string& name) const; + + /// @brief Insert a binding of type T. + template + void insert(const std::string& name, const PDDLElement& element, const std::optional& position); +}; /// @brief Encapsulates the result of search for a binding with the corresponding ErrorHandler. template using ScopeStackSearchResult = std::tuple, const std::optional, const PDDLErrorHandler&>; - /// @brief Implements a scoping mechanism to store bindings which are mappings from name to a pointer to a PDDL object /// type and a position in the input stream that can be used to construct error messages with the given ErrorHandler. /// @@ -121,46 +110,45 @@ using ScopeStackSearchResult = std::tuple, const std::optio /// /// During problem file parsing, we get access to bindings from the domain through additional composition as follows: /// [ (Domain Scope Global) ], [ (Problem Scope Global), (Problem Scope Child 1), (Problem Scope Child 2), ... ] -class ScopeStack { - private: - std::deque> m_stack; +class ScopeStack +{ +private: + std::deque> m_stack; - const PDDLErrorHandler& m_error_handler; + const PDDLErrorHandler& m_error_handler; - const ScopeStack* m_parent; + const ScopeStack* m_parent; - public: - ScopeStack(const PDDLErrorHandler& error_handler, - const ScopeStack* parent=nullptr); +public: + ScopeStack(const PDDLErrorHandler& error_handler, const ScopeStack* parent = nullptr); - // delete copy and move to avoid dangling references. - ScopeStack(const ScopeStack& other) = delete; - ScopeStack& operator=(const ScopeStack& other) = delete; - ScopeStack(ScopeStack&& other) = delete; - ScopeStack& operator=(ScopeStack&& other) = delete; + // delete copy and move to avoid dangling references. + ScopeStack(const ScopeStack& other) = delete; + ScopeStack& operator=(const ScopeStack& other) = delete; + ScopeStack(ScopeStack&& other) = delete; + ScopeStack& operator=(ScopeStack&& other) = delete; - /// @brief Inserts a new scope on the top of the stack. - void open_scope(); + /// @brief Inserts a new scope on the top of the stack. + void open_scope(); - /// @brief Deletes the topmost scope from the stack. - void close_scope(); + /// @brief Deletes the topmost scope from the stack. + void close_scope(); - /// @brief Returns a binding if it exists. - template - std::optional> get(const std::string& name) const; + /// @brief Returns a binding if it exists. + template + std::optional> get(const std::string& name) const; - /// @brief Insert a binding of type T. - template - void insert(const std::string& name, const PDDLElement& element, const std::optional& position); + /// @brief Insert a binding of type T. + template + void insert(const std::string& name, const PDDLElement& element, const std::optional& position); - /// @brief Get the error handler to print an error message. - const PDDLErrorHandler& get_error_handler() const; + /// @brief Get the error handler to print an error message. + const PDDLErrorHandler& get_error_handler() const; - // For testing purposes only. - const std::deque>& get_stack() const; + // For testing purposes only. + const std::deque>& get_stack() const; }; - } #include "scope.tpp" diff --git a/include/loki/common/pddl/scope.tpp b/include/loki/common/pddl/scope.tpp index 51b69ec5..2e2561cc 100644 --- a/include/loki/common/pddl/scope.tpp +++ b/include/loki/common/pddl/scope.tpp @@ -15,70 +15,73 @@ * along with this program. If not, see . */ - -namespace loki { +namespace loki +{ template template -std::optional> Bindings::get(const std::string& key) const { +std::optional> Bindings::get(const std::string& key) const +{ const auto& t_bindings = std::get>(bindings); auto it = t_bindings.find(key); - if (it != t_bindings.end()) { - return {it->second}; + if (it != t_bindings.end()) + { + return { it->second }; } return std::nullopt; } - template template -void Bindings::insert(const std::string& key, const PDDLElement& element, const std::optional& position) { +void Bindings::insert(const std::string& key, const PDDLElement& element, const std::optional& position) +{ assert(element); auto& t_bindings = std::get>(bindings); assert(!t_bindings.count(key)); t_bindings.emplace(key, std::make_tuple(element, position)); } - template -std::optional> Scope::get(const std::string& name) const { +std::optional> Scope::get(const std::string& name) const +{ const auto result = bindings.get(name); - if (result.has_value()) return result.value(); - if (m_parent_scope) { + if (result.has_value()) + return result.value(); + if (m_parent_scope) + { return m_parent_scope->get(name); } return std::nullopt; } - template -void Scope::insert(const std::string& name, const PDDLElement& element, const std::optional& position) { +void Scope::insert(const std::string& name, const PDDLElement& element, const std::optional& position) +{ assert(element); assert(!this->get(name)); bindings.insert(name, element, position); } - template -std::optional> ScopeStack::get(const std::string& name) const { +std::optional> ScopeStack::get(const std::string& name) const +{ assert(!m_stack.empty()); auto result = m_stack.back()->get(name); - if (result.has_value()) { - return std::make_tuple( - std::get<0>(result.value()), - std::get<1>(result.value()), - std::cref(m_error_handler)); + if (result.has_value()) + { + return std::make_tuple(std::get<0>(result.value()), std::get<1>(result.value()), std::cref(m_error_handler)); } - if (m_parent) return m_parent->get(name); + if (m_parent) + return m_parent->get(name); return std::nullopt; } /// @brief Insert a binding of type T. template -void ScopeStack::insert(const std::string& name, const PDDLElement& element, const std::optional& position) { +void ScopeStack::insert(const std::string& name, const PDDLElement& element, const std::optional& position) +{ assert(!m_stack.empty()); m_stack.back()->insert(name, element, position); } - } \ No newline at end of file diff --git a/include/loki/common/pddl/segmented_vector.hpp b/include/loki/common/pddl/segmented_vector.hpp index d7ac5bdb..4084ca93 100644 --- a/include/loki/common/pddl/segmented_vector.hpp +++ b/include/loki/common/pddl/segmented_vector.hpp @@ -18,31 +18,33 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_SEGMENTED_VECTOR_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_SEGMENTED_VECTOR_HPP_ -#include "declarations.hpp" +#include "loki/common/pddl/declarations.hpp" #include #include +#include #include #include #include -#include - -namespace loki { -/// @brief The SegmentedVector persistently stores elements of type T -/// in segments of size N, ensuring that references to elements do not +namespace loki +{ +/// @brief The SegmentedVector persistently stores elements of type T +/// in segments of size N, ensuring that references to elements do not /// become invalidated upon reallocation. /// @tparam T is the nested type /// @tparam N is the number of elements per segment template -class SegmentedVector { +class SegmentedVector +{ private: std::vector> m_data; size_t m_size; size_t m_capacity; - void increase_capacity() { + void increase_capacity() + { // Add an additional vector with capacity N m_data.resize(m_data.size() + 1); m_data.back().reserve(N); @@ -50,20 +52,18 @@ class SegmentedVector { m_capacity += N; } - size_t segment_index(size_t pos) const { - return pos / N; - } + size_t segment_index(size_t pos) const { return pos / N; } - size_t element_index(size_t pos) const { - return pos % N; - } + size_t element_index(size_t pos) const { return pos % N; } public: - explicit SegmentedVector() : m_size(0), m_capacity(0) { } + explicit SegmentedVector() : m_size(0), m_capacity(0) {} - const T& push_back(T value) { + const T& push_back(T value) + { // Increase capacity if necessary - if (m_size >= m_capacity) { + if (m_size >= m_capacity) + { increase_capacity(); } auto& segment = m_data[segment_index(size())]; @@ -76,23 +76,21 @@ class SegmentedVector { return segment.back(); } - T& operator[](size_t pos) { + T& operator[](size_t pos) + { assert(pos < size()); return m_data[segment_index(pos)][element_index(pos)]; } - const T& operator[](size_t pos) const { + const T& operator[](size_t pos) const + { assert(pos < size()); return m_data[segment_index(pos)][element_index(pos)]; } - size_t size() const { - return m_size; - } + size_t size() const { return m_size; } - size_t capacity() const { - return m_capacity; - } + size_t capacity() const { return m_capacity; } }; } diff --git a/include/loki/common/pddl/types.hpp b/include/loki/common/pddl/types.hpp index 3b5cab23..72822022 100644 --- a/include/loki/common/pddl/types.hpp +++ b/include/loki/common/pddl/types.hpp @@ -18,34 +18,33 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_TYPES_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_TYPES_HPP_ -#include "position.hpp" -#include "persistent_factory.hpp" +#include "loki/common/pddl/persistent_factory.hpp" +#include "loki/common/pddl/position.hpp" +#include "loki/domain/pddl/action.hpp" +#include "loki/domain/pddl/atom.hpp" +#include "loki/domain/pddl/conditions.hpp" +#include "loki/domain/pddl/derived_predicate.hpp" +#include "loki/domain/pddl/domain.hpp" +#include "loki/domain/pddl/effects.hpp" +#include "loki/domain/pddl/function.hpp" +#include "loki/domain/pddl/function_expressions.hpp" +#include "loki/domain/pddl/function_skeleton.hpp" +#include "loki/domain/pddl/literal.hpp" +#include "loki/domain/pddl/object.hpp" +#include "loki/domain/pddl/parameter.hpp" +#include "loki/domain/pddl/predicate.hpp" +#include "loki/domain/pddl/requirements.hpp" +#include "loki/domain/pddl/term.hpp" +#include "loki/domain/pddl/type.hpp" +#include "loki/domain/pddl/variable.hpp" +#include "loki/problem/pddl/ground_atom.hpp" +#include "loki/problem/pddl/ground_literal.hpp" +#include "loki/problem/pddl/metric.hpp" +#include "loki/problem/pddl/numeric_fluent.hpp" +#include "loki/problem/pddl/problem.hpp" -#include "../../domain/pddl/action.hpp" -#include "../../domain/pddl/atom.hpp" -#include "../../domain/pddl/conditions.hpp" -#include "../../domain/pddl/derived_predicate.hpp" -#include "../../domain/pddl/domain.hpp" -#include "../../domain/pddl/effects.hpp" -#include "../../domain/pddl/function_expressions.hpp" -#include "../../domain/pddl/function_skeleton.hpp" -#include "../../domain/pddl/function.hpp" -#include "../../domain/pddl/literal.hpp" -#include "../../domain/pddl/object.hpp" -#include "../../domain/pddl/parameter.hpp" -#include "../../domain/pddl/predicate.hpp" -#include "../../domain/pddl/requirements.hpp" -#include "../../domain/pddl/term.hpp" -#include "../../domain/pddl/type.hpp" -#include "../../domain/pddl/variable.hpp" -#include "../../problem/pddl/ground_atom.hpp" -#include "../../problem/pddl/ground_literal.hpp" -#include "../../problem/pddl/problem.hpp" -#include "../../problem/pddl/metric.hpp" -#include "../../problem/pddl/numeric_fluent.hpp" - - -namespace loki { +namespace loki +{ // The segmented sizes are chosen sufficiently large to avoid // to avoid allocations and for continuous storage. // The values are just educated guesses based on the knowledge @@ -73,33 +72,32 @@ using NumericFluentFactory = PersistentFactory; using DomainFactory = PersistentFactory; using ProblemFactory = PersistentFactory; - -using PDDLPositionCache = PositionCache; - +using PDDLPositionCache = PositionCache; /// @brief Collection of factories for the unique creation of PDDL objects. -struct PDDLFactories { +struct PDDLFactories +{ RequirementFactory requirements; TypeFactory types; VariableFactory variables; diff --git a/include/loki/common/pddl/visitors.hpp b/include/loki/common/pddl/visitors.hpp index a67177ed..f0148dc7 100644 --- a/include/loki/common/pddl/visitors.hpp +++ b/include/loki/common/pddl/visitors.hpp @@ -18,34 +18,35 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_VISITORS_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_VISITORS_HPP_ -#include "../printer.hpp" +#include "loki/common/printer.hpp" #include - -namespace loki::pddl { -struct LessComparatorVisitor { +namespace loki::pddl +{ +struct LessComparatorVisitor +{ template - bool operator()(const T1& object_left, const T2& object_right) const { + bool operator()(const T1& object_left, const T2& object_right) const + { return object_left.get_identifier() < object_right.get_identifier(); } }; -struct StringifyVisitor { +struct StringifyVisitor +{ std::ostringstream& out; const FormattingOptions& options; - StringifyVisitor(std::ostringstream& out_, const FormattingOptions& options_) - : out(out_), options(options_) { } + StringifyVisitor(std::ostringstream& out_, const FormattingOptions& options_) : out(out_), options(options_) {} template - void operator()(const T& object) { + void operator()(const T& object) + { object.str(out, options); - } + } }; } - - #endif diff --git a/include/loki/common/printer.hpp b/include/loki/common/printer.hpp index 0e072b87..3d967405 100644 --- a/include/loki/common/printer.hpp +++ b/include/loki/common/printer.hpp @@ -18,10 +18,11 @@ #ifndef LOKI_INCLUDE_LOKI_COMMON_PRINTER_HPP_ #define LOKI_INCLUDE_LOKI_COMMON_PRINTER_HPP_ +namespace loki +{ -namespace loki { - -struct FormattingOptions { +struct FormattingOptions +{ // The indentation in the current level. int indent = 0; // The amount of indentation added per nesting diff --git a/include/loki/domain/ast/ast.hpp b/include/loki/domain/ast/ast.hpp index c98fb5d3..82b20bf9 100644 --- a/include/loki/domain/ast/ast.hpp +++ b/include/loki/domain/ast/ast.hpp @@ -18,925 +18,881 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_AST_AST_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_AST_AST_HPP_ +#include #include #include -#include - #include #include #include - namespace loki::domain::ast { - /////////////////////////////////////////////////////////////////////////// - // The AST - /////////////////////////////////////////////////////////////////////////// - namespace x3 = boost::spirit::x3; - - struct Name; - struct Variable; - struct FunctionSymbol; - struct Term; - struct Number; - struct Predicate; - - struct RequirementStrips; - struct RequirementTyping; - struct RequirementNegativePreconditions; - struct RequirementDisjunctivePreconditions; - struct RequirementEquality; - struct RequirementExistentialPreconditions; - struct RequirementUniversalPreconditions; - struct RequirementQuantifiedPreconditions; - struct RequirementConditionalEffects; - struct RequirementFluents; // PDDL 3.1 = :object-fluents + :numeric-fluents - struct RequirementObjectFluents; // PDDL 3.1 - struct RequirementNumericFluents; // PDDL 3.1 - struct RequirementAdl; - struct RequirementDurativeActions; - struct RequirementDerivedPredicates; - struct RequirementTimedInitialLiterals; - struct RequirementPreferences; - struct RequirementConstraints; - struct RequirementActionCosts; - struct Requirement; - - struct Type; - struct TypeObject; - struct TypeNumber; - struct TypeEither; - struct TypedListOfNamesRecursively; // :typing - struct TypedListOfNames; - struct TypedListOfVariablesRecursively; // :typing - struct TypedListOfVariables; - - struct AtomicFormulaSkeleton; - - struct AtomicFunctionSkeletonTotalCost; - struct AtomicFunctionSkeletonGeneral; - struct AtomicFunctionSkeleton; - struct FunctionTypedListOfAtomicFunctionSkeletonsRecursively; - struct FunctionTypedListOfAtomicFunctionSkeletons; - - struct AtomicFormulaOfTermsPredicate; - struct AtomicFormulaOfTermsEquality; // :equality - struct AtomicFormulaOfTerms; - struct Atom; - struct NegatedAtom; - struct Literal; - - struct MultiOperatorMul; - struct MultiOperatorPlus; - struct MultiOperator; - struct BinaryOperatorMinus; - struct BinaryOperatorDiv; - struct BinaryOperator; - - struct BinaryComparatorGreater; - struct BinaryComparatorLess; - struct BinaryComparatorEqual; - struct BinaryComparatorGreaterEqual; - struct BinaryComparatorLessEqual; - struct BinaryComparator; - - struct FunctionHead; - struct FunctionExpression; // :numeric-fluents - struct FunctionExpressionNumber; - struct FunctionExpressionBinaryOp; - struct FunctionExpressionMinus; - struct FunctionExpressionHead; - - struct GoalDescriptor; - struct GoalDescriptorAtom; - struct GoalDescriptorLiteral; // :negative-preconditions - struct GoalDescriptorAnd; - struct GoalDescriptorOr; // :disjunctive-preconditions - struct GoalDescriptorNot; // :disjunctive-preconditions - struct GoalDescriptorImply; // :disjunctive-preconditions - struct GoalDescriptorExists; // :existential-preconditions - struct GoalDescriptorForall; // :universal-preconditions - struct GoalDescriptorFunctionComparison; // :numeric-fluents - - struct ConstraintGoalDescriptor; - struct ConstraintGoalDescriptorAnd; - struct ConstraintGoalDescriptorForall; - struct ConstraintGoalDescriptorAtEnd; - struct ConstraintGoalDescriptorAlways; - struct ConstraintGoalDescriptorSometime; - struct ConstraintGoalDescriptorWithin; - struct ConstraintGoalDescriptorAtMostOnce; - struct ConstraintGoalDescriptorSometimeAfter; - struct ConstraintGoalDescriptorSometimeBefore; - struct ConstraintGoalDescriptorAlwaysWithin; - struct ConstraintGoalDescriptorHoldDuring; - struct ConstraintGoalDescriptorHoldAfter; - - struct PreferenceName; - struct PreconditionGoalDescriptor; - struct PreconditionGoalDescriptorSimple; - struct PreconditionGoalDescriptorAnd; - struct PreconditionGoalDescriptorPreference; // :preferences - struct PreconditionGoalDescriptorForall; // :universal-preconditions - - struct AssignOperatorAssign; - struct AssignOperatorScaleUp; - struct AssignOperatorScaleDown; - struct AssignOperatorIncrease; - struct AssignOperatorDecrease; - struct AssignOperator; - - struct Effect; - struct EffectProductionLiteral; - struct EffectProductionNumericFluentTotalCost; - struct EffectProductionNumericFluentGeneral; - struct EffectProduction; - struct EffectConditionalForall; - struct EffectConditionalWhen; - struct EffectConditional; - - struct ActionSymbol; - struct ActionBody; - - struct Action; - struct DerivedPredicate; // :derived-predicates - - struct DomainName; - struct Requirements; - struct Types; // : typing - struct Constants; - struct Predicates; - struct Functions; - struct Constraints; // :constraints - struct Structure; - struct Domain; - - - /* */ - struct Name : x3::position_tagged - { - std::string characters; - }; - - /* */ - struct Variable : x3::position_tagged - { - std::string characters; - }; - - /* */ - struct FunctionSymbol : x3::position_tagged - { - Name name; - }; - - /* */ - struct Term : x3::position_tagged, - x3::variant< - Name, - Variable> - { - using base_type::base_type; - using base_type::operator=; - }; - - /* */ - struct Number : x3::position_tagged - { - double value; - }; - - /* */ - struct Predicate : x3::position_tagged - { - Name name; - }; - - /* */ - struct RequirementStrips : x3::position_tagged - { - }; - - struct RequirementTyping : x3::position_tagged - { - }; - - struct RequirementNegativePreconditions : x3::position_tagged - { - }; - - struct RequirementDisjunctivePreconditions : x3::position_tagged - { - }; - - struct RequirementEquality : x3::position_tagged - { - }; - - struct RequirementExistentialPreconditions : x3::position_tagged - { - }; - - struct RequirementUniversalPreconditions : x3::position_tagged - { - }; - - struct RequirementQuantifiedPreconditions : x3::position_tagged - { - }; - - struct RequirementConditionalEffects : x3::position_tagged - { - }; - - struct RequirementFluents : x3::position_tagged - { - }; - - struct RequirementObjectFluents : x3::position_tagged - { - }; - - struct RequirementNumericFluents : x3::position_tagged - { - }; - - struct RequirementAdl : x3::position_tagged - { - }; - - struct RequirementDurativeActions : x3::position_tagged - { - }; - - struct RequirementDerivedPredicates : x3::position_tagged - { - }; - - struct RequirementTimedInitialLiterals : x3::position_tagged - { - }; - - struct RequirementPreferences : x3::position_tagged - { - }; - - struct RequirementConstraints : x3::position_tagged - { - }; - - struct RequirementActionCosts : x3::position_tagged - { - }; - - struct Requirement : x3::position_tagged, - x3::variant< - RequirementStrips, - RequirementTyping, - RequirementNegativePreconditions, - RequirementDisjunctivePreconditions, - RequirementEquality, - RequirementExistentialPreconditions, - RequirementUniversalPreconditions, - RequirementQuantifiedPreconditions, - RequirementConditionalEffects, - RequirementFluents, - RequirementObjectFluents, - RequirementNumericFluents, - RequirementAdl, - RequirementDurativeActions, - RequirementDerivedPredicates, - RequirementTimedInitialLiterals, - RequirementPreferences, - RequirementConstraints, - RequirementActionCosts> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct Requirements : x3::position_tagged - { - std::vector requirements; - }; - - /* */ - struct Type : x3::position_tagged, - x3::variant< - Name, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct TypeObject : x3::position_tagged { }; - - struct TypeNumber : x3::position_tagged { }; - - struct TypeEither : x3::position_tagged - { - std::vector types; - }; - - struct TypedListOfNamesRecursively : x3::position_tagged - { - std::vector names; - Type type; - x3::forward_ast typed_list_of_names; - }; - - struct TypedListOfNames : x3::position_tagged, - x3::variant< - std::vector, // base type is object - TypedListOfNamesRecursively> - { - using base_type::base_type; - using base_type::operator=; - }; - - /* */ - struct TypedListOfVariablesRecursively : x3::position_tagged - { - std::vector variables; - Type type; - x3::forward_ast typed_list_of_variables; - }; - - struct TypedListOfVariables : x3::position_tagged, - x3::variant< - std::vector, - TypedListOfVariablesRecursively> - { - using base_type::base_type; - using base_type::operator=; - }; - - /* */ - struct AtomicFormulaSkeleton : x3::position_tagged - { - Predicate predicate; - TypedListOfVariables typed_list_of_variables; - }; - - /* */ - struct AtomicFunctionSkeletonTotalCost : x3::position_tagged { - FunctionSymbol function_symbol; - }; - - struct AtomicFunctionSkeletonGeneral : x3::position_tagged { - FunctionSymbol function_symbol; - TypedListOfVariables arguments; - }; - - struct AtomicFunctionSkeleton : x3::position_tagged, - x3::variant< - AtomicFunctionSkeletonTotalCost, - AtomicFunctionSkeletonGeneral> { - using base_type::base_type; - using base_type::operator=; - }; - - struct FunctionTypedListOfAtomicFunctionSkeletonsRecursively : x3::position_tagged - { - std::vector atomic_function_skeletons; - TypeNumber function_type; - boost::optional> function_typed_list_of_atomic_function_skeletons; - }; - - struct FunctionTypedListOfAtomicFunctionSkeletons : x3::position_tagged, - x3::variant< - std::vector, // :numeric-fluents and deprecated (https://ipc08.icaps-conference.org/deterministic/PddlExtension.html) - FunctionTypedListOfAtomicFunctionSkeletonsRecursively> - { - using base_type::base_type; - using base_type::operator=; - }; - - /* Atomic formulas */ - struct AtomicFormulaOfTermsPredicate : x3::position_tagged - { - Predicate predicate; - std::vector terms; - }; - - struct AtomicFormulaOfTermsEquality : x3::position_tagged - { - Term term_left; - Term term_right; - }; - - struct AtomicFormulaOfTerms : x3::position_tagged, - x3::variant< - AtomicFormulaOfTermsPredicate, - AtomicFormulaOfTermsEquality> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct Atom : x3::position_tagged - { - AtomicFormulaOfTerms atomic_formula_of_terms; - }; - - struct NegatedAtom : x3::position_tagged - { - AtomicFormulaOfTerms atomic_formula_of_terms; - }; - - struct Literal : x3::position_tagged, - x3::variant< - Atom, - NegatedAtom> - { - using base_type::base_type; - using base_type::operator=; - }; - - /* Operators */ - struct MultiOperatorMul : x3::position_tagged - { - }; - - struct MultiOperatorPlus : x3::position_tagged - { - }; - - struct MultiOperator : x3::position_tagged, - x3::variant< - MultiOperatorMul, - MultiOperatorPlus> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct BinaryOperatorMinus : x3::position_tagged - { - }; - - struct BinaryOperatorDiv : x3::position_tagged - { - }; - - struct BinaryOperator : x3::position_tagged, - x3::variant< - BinaryOperatorMinus, - BinaryOperatorDiv, - MultiOperator> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct BinaryComparatorGreater : x3::position_tagged - { - }; - - struct BinaryComparatorLess : x3::position_tagged - { - }; - - struct BinaryComparatorEqual : x3::position_tagged - { - }; - - struct BinaryComparatorGreaterEqual : x3::position_tagged - { - }; - - struct BinaryComparatorLessEqual : x3::position_tagged - { - }; - - struct BinaryComparator : x3::position_tagged, - x3::variant< - BinaryComparatorGreater, - BinaryComparatorLess, - BinaryComparatorEqual, - BinaryComparatorGreaterEqual, - BinaryComparatorLessEqual> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct FunctionHead : x3::position_tagged - { - FunctionSymbol function_symbol; - std::vector terms; - }; - - struct FunctionExpression : x3::position_tagged, - x3::variant< - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct FunctionExpressionNumber : x3::position_tagged - { - Number number; - }; - - struct FunctionExpressionBinaryOp : x3::position_tagged - { - BinaryOperator binary_operator; - FunctionExpression function_expression_left; - FunctionExpression function_expression_right; - }; - - struct FunctionExpressionMinus : x3::position_tagged - { - FunctionExpression function_expression; - }; - - struct FunctionExpressionHead : x3::position_tagged - { - FunctionHead function_head; - }; - - /* Goal Descriptors */ - struct GoalDescriptor : x3::position_tagged, - x3::variant< - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct GoalDescriptorAtom : x3::position_tagged - { - Atom atom; - }; - - struct GoalDescriptorLiteral : x3::position_tagged - { - Literal literal; - }; - - struct GoalDescriptorAnd : x3::position_tagged - { - std::vector goal_descriptors; - }; - - struct GoalDescriptorOr : x3::position_tagged - { - std::vector goal_descriptors; - }; - - struct GoalDescriptorNot : x3::position_tagged - { - GoalDescriptor goal_descriptor; - }; - - struct GoalDescriptorImply : x3::position_tagged - { - GoalDescriptor goal_descriptor_left; - GoalDescriptor goal_descriptor_right; - }; - - struct GoalDescriptorExists : x3::position_tagged - { - TypedListOfVariables typed_list_of_variables; - GoalDescriptor goal_descriptor; - }; - - struct GoalDescriptorForall : x3::position_tagged - { - TypedListOfVariables typed_list_of_variables; - GoalDescriptor goal_descriptor; - }; - - struct GoalDescriptorFunctionComparison : x3::position_tagged - { - BinaryComparator binary_comparator; - FunctionExpression function_expression_left; - FunctionExpression function_expression_right; - }; - - /* */ - struct ConstraintGoalDescriptor : x3::position_tagged, - x3::variant< - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct ConstraintGoalDescriptorAnd : x3::position_tagged - { - std::vector constraint_goal_descriptors; - }; - - struct ConstraintGoalDescriptorForall : x3::position_tagged - { - TypedListOfVariables typed_list_of_variables; - ConstraintGoalDescriptor constraint_goal_descriptor; - }; - - struct ConstraintGoalDescriptorAtEnd : x3::position_tagged - { - GoalDescriptor goal_descriptor; - }; - - struct ConstraintGoalDescriptorAlways : x3::position_tagged - { - GoalDescriptor goal_descriptor; - }; - - struct ConstraintGoalDescriptorSometime : x3::position_tagged - { - GoalDescriptor goal_descriptor; - }; - - struct ConstraintGoalDescriptorWithin : x3::position_tagged - { - Number number; - GoalDescriptor goal_descriptor; - }; - - struct ConstraintGoalDescriptorAtMostOnce : x3::position_tagged - { - GoalDescriptor goal_descriptor; - }; - - struct ConstraintGoalDescriptorSometimeAfter : x3::position_tagged - { - GoalDescriptor goal_descriptor_left; - GoalDescriptor goal_descriptor_right; - }; - - struct ConstraintGoalDescriptorSometimeBefore : x3::position_tagged - { - GoalDescriptor goal_descriptor_left; - GoalDescriptor goal_descriptor_right; - }; - - struct ConstraintGoalDescriptorAlwaysWithin : x3::position_tagged - { - Number number; - GoalDescriptor goal_descriptor_left; - GoalDescriptor goal_descriptor_right; - }; - - struct ConstraintGoalDescriptorHoldDuring : x3::position_tagged - { - Number number_left; - Number number_right; - GoalDescriptor goal_descriptor; - }; - - struct ConstraintGoalDescriptorHoldAfter : x3::position_tagged - { - Number number; - GoalDescriptor goal_descriptor; - }; - - /* */ - struct PreferenceName : x3::position_tagged - { - Name name; - }; - - struct PreconditionGoalDescriptor : x3::position_tagged, - x3::variant< - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct PreconditionGoalDescriptorSimple : x3::position_tagged - { - GoalDescriptor goal_descriptor; - }; - - struct PreconditionGoalDescriptorAnd : x3::position_tagged - { - std::vector precondition_goal_descriptors; - }; - - struct PreconditionGoalDescriptorPreference : x3::position_tagged - { - PreferenceName preference_name; - GoalDescriptor goal_descriptor; - }; - - struct PreconditionGoalDescriptorForall : x3::position_tagged - { - TypedListOfVariables typed_list_of_variables; - PreconditionGoalDescriptor precondition_goal_descriptor; - }; - - /* */ - struct AssignOperatorAssign : x3::position_tagged - { - }; - - struct AssignOperatorScaleUp : x3::position_tagged - { - }; - - struct AssignOperatorScaleDown : x3::position_tagged - { - }; - - struct AssignOperatorIncrease : x3::position_tagged - { - }; - - struct AssignOperatorDecrease : x3::position_tagged - { - }; - - struct AssignOperator : x3::position_tagged, - x3::variant< - AssignOperatorAssign, - AssignOperatorScaleUp, - AssignOperatorScaleDown, - AssignOperatorIncrease, - AssignOperatorDecrease> - { - using base_type::base_type; - using base_type::operator=; - }; - - - /* */ - // - struct Effect : x3::position_tagged, - x3::variant< - x3::forward_ast, - x3::forward_ast, - std::vector> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct EffectProductionLiteral : x3::position_tagged - { - Literal literal; - }; - - struct EffectProductionNumericFluentTotalCost : x3::position_tagged - { - AssignOperatorIncrease assign_operator_increase; - FunctionSymbol function_symbol_total_cost; - FunctionExpression numeric_term; - }; - - struct EffectProductionNumericFluentGeneral : x3::position_tagged - { - AssignOperator assign_operator; - FunctionHead function_head; - FunctionExpression function_expression; - }; - - struct EffectProduction : x3::position_tagged, - x3::variant< - EffectProductionLiteral, - EffectProductionNumericFluentTotalCost, - EffectProductionNumericFluentGeneral> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct EffectConditionalForall : x3::position_tagged - { - TypedListOfVariables typed_list_of_variables; - Effect effect; - }; - - struct EffectConditionalWhen : x3::position_tagged - { - GoalDescriptor goal_descriptor; - Effect effect; - }; - - struct EffectConditional : x3::position_tagged, - x3::variant< - EffectConditionalForall, - EffectConditionalWhen> - { - using base_type::base_type; - using base_type::operator=; - }; - - /* */ - struct ActionSymbol : x3::position_tagged - { - Name name; - }; - - struct ActionBody : x3::position_tagged - { - boost::optional precondition_goal_descriptor; - boost::optional effect; - }; - - struct Action : x3::position_tagged - { - ActionSymbol action_symbol; - TypedListOfVariables typed_list_of_variables; - ActionBody action_body; - }; - - - /* */ - struct DerivedPredicate : x3::position_tagged { - TypedListOfVariables typed_list_of_variables; - GoalDescriptor goal_descriptor; - }; - - /* */ - struct Types : x3::position_tagged - { - TypedListOfNames typed_list_of_names; - }; - - /* */ - struct Constants : x3::position_tagged - { - TypedListOfNames typed_list_of_names; - }; - - /* */ - struct Predicates : x3::position_tagged - { - std::vector atomic_formula_skeletons; - }; - - /* */ - struct Functions : x3::position_tagged - { - FunctionTypedListOfAtomicFunctionSkeletons function_types_list_of_atomic_function_skeletons; - }; - - /* */ - struct Constraints : x3::position_tagged - { - ConstraintGoalDescriptor constraint_goal_descriptor; - }; - - /* */ - struct Structure : x3::position_tagged, - x3::variant< - Action, - DerivedPredicate> - { - using base_type::base_type; - using base_type::operator=; - }; - - /* */ - struct DomainName : x3::position_tagged - { - Name name; - }; - - struct Domain : x3::position_tagged - { - DomainName domain_name; - boost::optional requirements; - boost::optional types; - boost::optional constants; - boost::optional predicates; - boost::optional functions; - boost::optional constraints; - std::vector structures; - }; +/////////////////////////////////////////////////////////////////////////// +// The AST +/////////////////////////////////////////////////////////////////////////// +namespace x3 = boost::spirit::x3; + +struct Name; +struct Variable; +struct FunctionSymbol; +struct Term; +struct Number; +struct Predicate; + +struct RequirementStrips; +struct RequirementTyping; +struct RequirementNegativePreconditions; +struct RequirementDisjunctivePreconditions; +struct RequirementEquality; +struct RequirementExistentialPreconditions; +struct RequirementUniversalPreconditions; +struct RequirementQuantifiedPreconditions; +struct RequirementConditionalEffects; +struct RequirementFluents; // PDDL 3.1 = :object-fluents + :numeric-fluents +struct RequirementObjectFluents; // PDDL 3.1 +struct RequirementNumericFluents; // PDDL 3.1 +struct RequirementAdl; +struct RequirementDurativeActions; +struct RequirementDerivedPredicates; +struct RequirementTimedInitialLiterals; +struct RequirementPreferences; +struct RequirementConstraints; +struct RequirementActionCosts; +struct Requirement; + +struct Type; +struct TypeObject; +struct TypeNumber; +struct TypeEither; +struct TypedListOfNamesRecursively; // :typing +struct TypedListOfNames; +struct TypedListOfVariablesRecursively; // :typing +struct TypedListOfVariables; + +struct AtomicFormulaSkeleton; + +struct AtomicFunctionSkeletonTotalCost; +struct AtomicFunctionSkeletonGeneral; +struct AtomicFunctionSkeleton; +struct FunctionTypedListOfAtomicFunctionSkeletonsRecursively; +struct FunctionTypedListOfAtomicFunctionSkeletons; + +struct AtomicFormulaOfTermsPredicate; +struct AtomicFormulaOfTermsEquality; // :equality +struct AtomicFormulaOfTerms; +struct Atom; +struct NegatedAtom; +struct Literal; + +struct MultiOperatorMul; +struct MultiOperatorPlus; +struct MultiOperator; +struct BinaryOperatorMinus; +struct BinaryOperatorDiv; +struct BinaryOperator; + +struct BinaryComparatorGreater; +struct BinaryComparatorLess; +struct BinaryComparatorEqual; +struct BinaryComparatorGreaterEqual; +struct BinaryComparatorLessEqual; +struct BinaryComparator; + +struct FunctionHead; +struct FunctionExpression; // :numeric-fluents +struct FunctionExpressionNumber; +struct FunctionExpressionBinaryOp; +struct FunctionExpressionMinus; +struct FunctionExpressionHead; + +struct GoalDescriptor; +struct GoalDescriptorAtom; +struct GoalDescriptorLiteral; // :negative-preconditions +struct GoalDescriptorAnd; +struct GoalDescriptorOr; // :disjunctive-preconditions +struct GoalDescriptorNot; // :disjunctive-preconditions +struct GoalDescriptorImply; // :disjunctive-preconditions +struct GoalDescriptorExists; // :existential-preconditions +struct GoalDescriptorForall; // :universal-preconditions +struct GoalDescriptorFunctionComparison; // :numeric-fluents + +struct ConstraintGoalDescriptor; +struct ConstraintGoalDescriptorAnd; +struct ConstraintGoalDescriptorForall; +struct ConstraintGoalDescriptorAtEnd; +struct ConstraintGoalDescriptorAlways; +struct ConstraintGoalDescriptorSometime; +struct ConstraintGoalDescriptorWithin; +struct ConstraintGoalDescriptorAtMostOnce; +struct ConstraintGoalDescriptorSometimeAfter; +struct ConstraintGoalDescriptorSometimeBefore; +struct ConstraintGoalDescriptorAlwaysWithin; +struct ConstraintGoalDescriptorHoldDuring; +struct ConstraintGoalDescriptorHoldAfter; + +struct PreferenceName; +struct PreconditionGoalDescriptor; +struct PreconditionGoalDescriptorSimple; +struct PreconditionGoalDescriptorAnd; +struct PreconditionGoalDescriptorPreference; // :preferences +struct PreconditionGoalDescriptorForall; // :universal-preconditions + +struct AssignOperatorAssign; +struct AssignOperatorScaleUp; +struct AssignOperatorScaleDown; +struct AssignOperatorIncrease; +struct AssignOperatorDecrease; +struct AssignOperator; + +struct Effect; +struct EffectProductionLiteral; +struct EffectProductionNumericFluentTotalCost; +struct EffectProductionNumericFluentGeneral; +struct EffectProduction; +struct EffectConditionalForall; +struct EffectConditionalWhen; +struct EffectConditional; + +struct ActionSymbol; +struct ActionBody; + +struct Action; +struct DerivedPredicate; // :derived-predicates + +struct DomainName; +struct Requirements; +struct Types; // : typing +struct Constants; +struct Predicates; +struct Functions; +struct Constraints; // :constraints +struct Structure; +struct Domain; + +/* */ +struct Name : x3::position_tagged +{ + std::string characters; +}; + +/* */ +struct Variable : x3::position_tagged +{ + std::string characters; +}; + +/* */ +struct FunctionSymbol : x3::position_tagged +{ + Name name; +}; + +/* */ +struct Term : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* */ +struct Number : x3::position_tagged +{ + double value; +}; + +/* */ +struct Predicate : x3::position_tagged +{ + Name name; +}; + +/* */ +struct RequirementStrips : x3::position_tagged +{ +}; + +struct RequirementTyping : x3::position_tagged +{ +}; + +struct RequirementNegativePreconditions : x3::position_tagged +{ +}; + +struct RequirementDisjunctivePreconditions : x3::position_tagged +{ +}; + +struct RequirementEquality : x3::position_tagged +{ +}; + +struct RequirementExistentialPreconditions : x3::position_tagged +{ +}; + +struct RequirementUniversalPreconditions : x3::position_tagged +{ +}; + +struct RequirementQuantifiedPreconditions : x3::position_tagged +{ +}; + +struct RequirementConditionalEffects : x3::position_tagged +{ +}; + +struct RequirementFluents : x3::position_tagged +{ +}; + +struct RequirementObjectFluents : x3::position_tagged +{ +}; + +struct RequirementNumericFluents : x3::position_tagged +{ +}; + +struct RequirementAdl : x3::position_tagged +{ +}; + +struct RequirementDurativeActions : x3::position_tagged +{ +}; + +struct RequirementDerivedPredicates : x3::position_tagged +{ +}; + +struct RequirementTimedInitialLiterals : x3::position_tagged +{ +}; + +struct RequirementPreferences : x3::position_tagged +{ +}; + +struct RequirementConstraints : x3::position_tagged +{ +}; + +struct RequirementActionCosts : x3::position_tagged +{ +}; + +struct Requirement : + x3::position_tagged, + x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct Requirements : x3::position_tagged +{ + std::vector requirements; +}; + +/* */ +struct Type : x3::position_tagged, x3::variant, x3::forward_ast, x3::forward_ast> +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct TypeObject : x3::position_tagged +{ +}; + +struct TypeNumber : x3::position_tagged +{ +}; + +struct TypeEither : x3::position_tagged +{ + std::vector types; +}; + +struct TypedListOfNamesRecursively : x3::position_tagged +{ + std::vector names; + Type type; + x3::forward_ast typed_list_of_names; +}; + +struct TypedListOfNames : + x3::position_tagged, + x3::variant, // base type is object + TypedListOfNamesRecursively> +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* */ +struct TypedListOfVariablesRecursively : x3::position_tagged +{ + std::vector variables; + Type type; + x3::forward_ast typed_list_of_variables; +}; + +struct TypedListOfVariables : x3::position_tagged, x3::variant, TypedListOfVariablesRecursively> +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* */ +struct AtomicFormulaSkeleton : x3::position_tagged +{ + Predicate predicate; + TypedListOfVariables typed_list_of_variables; +}; + +/* */ +struct AtomicFunctionSkeletonTotalCost : x3::position_tagged +{ + FunctionSymbol function_symbol; +}; + +struct AtomicFunctionSkeletonGeneral : x3::position_tagged +{ + FunctionSymbol function_symbol; + TypedListOfVariables arguments; +}; + +struct AtomicFunctionSkeleton : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct FunctionTypedListOfAtomicFunctionSkeletonsRecursively : x3::position_tagged +{ + std::vector atomic_function_skeletons; + TypeNumber function_type; + boost::optional> function_typed_list_of_atomic_function_skeletons; +}; + +struct FunctionTypedListOfAtomicFunctionSkeletons : + x3::position_tagged, + x3::variant, // :numeric-fluents and deprecated (https://ipc08.icaps-conference.org/deterministic/PddlExtension.html) + FunctionTypedListOfAtomicFunctionSkeletonsRecursively> +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* Atomic formulas */ +struct AtomicFormulaOfTermsPredicate : x3::position_tagged +{ + Predicate predicate; + std::vector terms; +}; + +struct AtomicFormulaOfTermsEquality : x3::position_tagged +{ + Term term_left; + Term term_right; +}; + +struct AtomicFormulaOfTerms : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct Atom : x3::position_tagged +{ + AtomicFormulaOfTerms atomic_formula_of_terms; +}; + +struct NegatedAtom : x3::position_tagged +{ + AtomicFormulaOfTerms atomic_formula_of_terms; +}; + +struct Literal : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* Operators */ +struct MultiOperatorMul : x3::position_tagged +{ +}; + +struct MultiOperatorPlus : x3::position_tagged +{ +}; + +struct MultiOperator : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct BinaryOperatorMinus : x3::position_tagged +{ +}; + +struct BinaryOperatorDiv : x3::position_tagged +{ +}; + +struct BinaryOperator : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct BinaryComparatorGreater : x3::position_tagged +{ +}; + +struct BinaryComparatorLess : x3::position_tagged +{ +}; + +struct BinaryComparatorEqual : x3::position_tagged +{ +}; + +struct BinaryComparatorGreaterEqual : x3::position_tagged +{ +}; + +struct BinaryComparatorLessEqual : x3::position_tagged +{ +}; + +struct BinaryComparator : + x3::position_tagged, + x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct FunctionHead : x3::position_tagged +{ + FunctionSymbol function_symbol; + std::vector terms; +}; + +struct FunctionExpression : + x3::position_tagged, + x3::variant, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast> +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct FunctionExpressionNumber : x3::position_tagged +{ + Number number; +}; + +struct FunctionExpressionBinaryOp : x3::position_tagged +{ + BinaryOperator binary_operator; + FunctionExpression function_expression_left; + FunctionExpression function_expression_right; +}; + +struct FunctionExpressionMinus : x3::position_tagged +{ + FunctionExpression function_expression; +}; + +struct FunctionExpressionHead : x3::position_tagged +{ + FunctionHead function_head; +}; + +/* Goal Descriptors */ +struct GoalDescriptor : + x3::position_tagged, + x3::variant, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast> +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct GoalDescriptorAtom : x3::position_tagged +{ + Atom atom; +}; + +struct GoalDescriptorLiteral : x3::position_tagged +{ + Literal literal; +}; + +struct GoalDescriptorAnd : x3::position_tagged +{ + std::vector goal_descriptors; +}; + +struct GoalDescriptorOr : x3::position_tagged +{ + std::vector goal_descriptors; +}; + +struct GoalDescriptorNot : x3::position_tagged +{ + GoalDescriptor goal_descriptor; +}; + +struct GoalDescriptorImply : x3::position_tagged +{ + GoalDescriptor goal_descriptor_left; + GoalDescriptor goal_descriptor_right; +}; + +struct GoalDescriptorExists : x3::position_tagged +{ + TypedListOfVariables typed_list_of_variables; + GoalDescriptor goal_descriptor; +}; + +struct GoalDescriptorForall : x3::position_tagged +{ + TypedListOfVariables typed_list_of_variables; + GoalDescriptor goal_descriptor; +}; + +struct GoalDescriptorFunctionComparison : x3::position_tagged +{ + BinaryComparator binary_comparator; + FunctionExpression function_expression_left; + FunctionExpression function_expression_right; +}; + +/* */ +struct ConstraintGoalDescriptor : + x3::position_tagged, + x3::variant, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast> +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct ConstraintGoalDescriptorAnd : x3::position_tagged +{ + std::vector constraint_goal_descriptors; +}; + +struct ConstraintGoalDescriptorForall : x3::position_tagged +{ + TypedListOfVariables typed_list_of_variables; + ConstraintGoalDescriptor constraint_goal_descriptor; +}; + +struct ConstraintGoalDescriptorAtEnd : x3::position_tagged +{ + GoalDescriptor goal_descriptor; +}; + +struct ConstraintGoalDescriptorAlways : x3::position_tagged +{ + GoalDescriptor goal_descriptor; +}; + +struct ConstraintGoalDescriptorSometime : x3::position_tagged +{ + GoalDescriptor goal_descriptor; +}; + +struct ConstraintGoalDescriptorWithin : x3::position_tagged +{ + Number number; + GoalDescriptor goal_descriptor; +}; + +struct ConstraintGoalDescriptorAtMostOnce : x3::position_tagged +{ + GoalDescriptor goal_descriptor; +}; + +struct ConstraintGoalDescriptorSometimeAfter : x3::position_tagged +{ + GoalDescriptor goal_descriptor_left; + GoalDescriptor goal_descriptor_right; +}; + +struct ConstraintGoalDescriptorSometimeBefore : x3::position_tagged +{ + GoalDescriptor goal_descriptor_left; + GoalDescriptor goal_descriptor_right; +}; + +struct ConstraintGoalDescriptorAlwaysWithin : x3::position_tagged +{ + Number number; + GoalDescriptor goal_descriptor_left; + GoalDescriptor goal_descriptor_right; +}; + +struct ConstraintGoalDescriptorHoldDuring : x3::position_tagged +{ + Number number_left; + Number number_right; + GoalDescriptor goal_descriptor; +}; + +struct ConstraintGoalDescriptorHoldAfter : x3::position_tagged +{ + Number number; + GoalDescriptor goal_descriptor; +}; + +/* */ +struct PreferenceName : x3::position_tagged +{ + Name name; +}; + +struct PreconditionGoalDescriptor : + x3::position_tagged, + x3::variant, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast> +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct PreconditionGoalDescriptorSimple : x3::position_tagged +{ + GoalDescriptor goal_descriptor; +}; + +struct PreconditionGoalDescriptorAnd : x3::position_tagged +{ + std::vector precondition_goal_descriptors; +}; + +struct PreconditionGoalDescriptorPreference : x3::position_tagged +{ + PreferenceName preference_name; + GoalDescriptor goal_descriptor; +}; + +struct PreconditionGoalDescriptorForall : x3::position_tagged +{ + TypedListOfVariables typed_list_of_variables; + PreconditionGoalDescriptor precondition_goal_descriptor; +}; + +/* */ +struct AssignOperatorAssign : x3::position_tagged +{ +}; + +struct AssignOperatorScaleUp : x3::position_tagged +{ +}; + +struct AssignOperatorScaleDown : x3::position_tagged +{ +}; + +struct AssignOperatorIncrease : x3::position_tagged +{ +}; + +struct AssignOperatorDecrease : x3::position_tagged +{ +}; + +struct AssignOperator : + x3::position_tagged, + x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* */ +// +struct Effect : x3::position_tagged, x3::variant, x3::forward_ast, std::vector> +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct EffectProductionLiteral : x3::position_tagged +{ + Literal literal; +}; + +struct EffectProductionNumericFluentTotalCost : x3::position_tagged +{ + AssignOperatorIncrease assign_operator_increase; + FunctionSymbol function_symbol_total_cost; + FunctionExpression numeric_term; +}; + +struct EffectProductionNumericFluentGeneral : x3::position_tagged +{ + AssignOperator assign_operator; + FunctionHead function_head; + FunctionExpression function_expression; +}; + +struct EffectProduction : + x3::position_tagged, + x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct EffectConditionalForall : x3::position_tagged +{ + TypedListOfVariables typed_list_of_variables; + Effect effect; +}; + +struct EffectConditionalWhen : x3::position_tagged +{ + GoalDescriptor goal_descriptor; + Effect effect; +}; + +struct EffectConditional : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* */ +struct ActionSymbol : x3::position_tagged +{ + Name name; +}; + +struct ActionBody : x3::position_tagged +{ + boost::optional precondition_goal_descriptor; + boost::optional effect; +}; + +struct Action : x3::position_tagged +{ + ActionSymbol action_symbol; + TypedListOfVariables typed_list_of_variables; + ActionBody action_body; +}; + +/* */ +struct DerivedPredicate : x3::position_tagged +{ + TypedListOfVariables typed_list_of_variables; + GoalDescriptor goal_descriptor; +}; + +/* */ +struct Types : x3::position_tagged +{ + TypedListOfNames typed_list_of_names; +}; + +/* */ +struct Constants : x3::position_tagged +{ + TypedListOfNames typed_list_of_names; +}; + +/* */ +struct Predicates : x3::position_tagged +{ + std::vector atomic_formula_skeletons; +}; + +/* */ +struct Functions : x3::position_tagged +{ + FunctionTypedListOfAtomicFunctionSkeletons function_types_list_of_atomic_function_skeletons; +}; + +/* */ +struct Constraints : x3::position_tagged +{ + ConstraintGoalDescriptor constraint_goal_descriptor; +}; + +/* */ +struct Structure : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* */ +struct DomainName : x3::position_tagged +{ + Name name; +}; + +struct Domain : x3::position_tagged +{ + DomainName domain_name; + boost::optional requirements; + boost::optional types; + boost::optional constants; + boost::optional predicates; + boost::optional functions; + boost::optional constraints; + std::vector structures; +}; } #endif \ No newline at end of file diff --git a/include/loki/domain/ast/error_handler.hpp b/include/loki/domain/ast/error_handler.hpp index c31d8d02..cdf9d79a 100644 --- a/include/loki/domain/ast/error_handler.hpp +++ b/include/loki/domain/ast/error_handler.hpp @@ -18,21 +18,19 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_AST_ERROR_HANDLER_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_AST_ERROR_HANDLER_HPP_ -#include "../../common/ast/error_handler.hpp" +#include "loki/common/ast/error_handler.hpp" -#include #include - +#include namespace loki::domain { - namespace x3 = boost::spirit::x3; +namespace x3 = boost::spirit::x3; - struct error_handler_domain : error_handler_base { - error_handler_domain() : error_handler_base() { - id_map["name"] = "Name"; - } - }; +struct error_handler_domain : error_handler_base +{ + error_handler_domain() : error_handler_base() { id_map["name"] = "Name"; } +}; } #endif diff --git a/include/loki/domain/ast/parser.hpp b/include/loki/domain/ast/parser.hpp index 6e326d49..80169422 100644 --- a/include/loki/domain/ast/parser.hpp +++ b/include/loki/domain/ast/parser.hpp @@ -18,27 +18,27 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_SYNTACTIC_PARSER_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_SYNTACTIC_PARSER_HPP_ -#include "ast.hpp" +#include "loki/domain/ast/ast.hpp" #include - namespace loki::domain { - namespace x3 = boost::spirit::x3; +namespace x3 = boost::spirit::x3; - /////////////////////////////////////////////////////////////////////////// - // parser public interface - /////////////////////////////////////////////////////////////////////////// - namespace parser { - struct DomainClass; +/////////////////////////////////////////////////////////////////////////// +// parser public interface +/////////////////////////////////////////////////////////////////////////// +namespace parser +{ +struct DomainClass; - typedef x3::rule domain_type; +typedef x3::rule domain_type; - BOOST_SPIRIT_DECLARE(domain_type) - } +BOOST_SPIRIT_DECLARE(domain_type) +} - parser::domain_type const& domain(); +parser::domain_type const& domain(); } #endif \ No newline at end of file diff --git a/include/loki/domain/ast/printer.hpp b/include/loki/domain/ast/printer.hpp index ecdec6f0..826cee19 100644 --- a/include/loki/domain/ast/printer.hpp +++ b/include/loki/domain/ast/printer.hpp @@ -18,149 +18,149 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_AST_PRINTER_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_AST_PRINTER_HPP_ -#include "ast.hpp" -#include "../../common/printer.hpp" +#include "loki/common/printer.hpp" +#include "loki/domain/ast/ast.hpp" - -namespace loki { +namespace loki +{ // create string representations from ast nodes. -extern std::string parse_text(const domain::ast::Name& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Variable& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Number& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::FunctionSymbol& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Term& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Predicate& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::RequirementStrips& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementTyping& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementNegativePreconditions& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementDisjunctivePreconditions& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementEquality& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementExistentialPreconditions& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementUniversalPreconditions& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementQuantifiedPreconditions& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementConditionalEffects& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementFluents& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementObjectFluents& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementNumericFluents& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementAdl& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementDurativeActions& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementDerivedPredicates& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementTimedInitialLiterals& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementPreferences& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementConstraints& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::RequirementActionCosts& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Requirement& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::Type& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::TypeObject& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::TypeNumber& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::TypeEither& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::TypedListOfNamesRecursively& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::TypedListOfNames& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::TypedListOfVariablesRecursively& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::TypedListOfVariables& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::AtomicFormulaSkeleton& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::AtomicFunctionSkeletonTotalCost& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AtomicFunctionSkeletonGeneral& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AtomicFunctionSkeleton& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::FunctionTypedListOfAtomicFunctionSkeletonsRecursively& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::FunctionTypedListOfAtomicFunctionSkeletons& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::AtomicFormulaOfTermsPredicate& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AtomicFormulaOfTermsEquality& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AtomicFormulaOfTerms& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Atom& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::NegatedAtom& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Literal& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::MultiOperatorMul& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::MultiOperatorPlus& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::MultiOperator& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::BinaryOperatorMinus& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::BinaryOperatorDiv& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::BinaryOperator& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::BinaryComparatorGreater& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::BinaryComparatorLess& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::BinaryComparatorEqual& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::BinaryComparatorGreaterEqual& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::BinaryComparatorLessEqual& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::BinaryComparator& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::FunctionHead& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::FunctionExpression& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::FunctionExpressionNumber& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::FunctionExpressionBinaryOp& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::FunctionExpressionMinus& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::FunctionExpressionHead& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::GoalDescriptor& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorAtom& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorLiteral& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorAnd& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorOr& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorNot& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorImply& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorExists& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorForall& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::GoalDescriptorFunctionComparison& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptor& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAnd& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorForall& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAtEnd& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAlways& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometime& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorWithin& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAtMostOnce& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometimeAfter& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometimeBefore& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAlwaysWithin& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorHoldDuring& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorHoldAfter& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::PreferenceName& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::PreconditionGoalDescriptor& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::PreconditionGoalDescriptorSimple& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::PreconditionGoalDescriptorAnd& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::PreconditionGoalDescriptorPreference& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::PreconditionGoalDescriptorForall& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::AssignOperatorAssign& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AssignOperatorScaleUp& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AssignOperatorScaleDown& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AssignOperatorIncrease& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AssignOperatorDecrease& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::AssignOperator& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::Effect& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::EffectProductionLiteral& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::EffectProductionNumericFluentTotalCost& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::EffectProductionNumericFluentGeneral& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::EffectProduction& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::EffectConditionalForall& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::EffectConditionalWhen& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::EffectConditional& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::ActionSymbol& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::ActionBody& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::Action& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::DerivedPredicate& node, const FormattingOptions& options={}); - -extern std::string parse_text(const domain::ast::DomainName& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Requirements& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Types& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Constants& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Predicates& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Functions& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Constraints& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Structure& node, const FormattingOptions& options={}); -extern std::string parse_text(const domain::ast::Domain& node, const FormattingOptions& options={}); +extern std::string parse_text(const domain::ast::Name& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Variable& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Number& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::FunctionSymbol& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Term& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Predicate& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::RequirementStrips& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementTyping& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementNegativePreconditions& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementDisjunctivePreconditions& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementEquality& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementExistentialPreconditions& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementUniversalPreconditions& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementQuantifiedPreconditions& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementConditionalEffects& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementFluents& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementObjectFluents& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementNumericFluents& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementAdl& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementDurativeActions& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementDerivedPredicates& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementTimedInitialLiterals& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementPreferences& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementConstraints& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::RequirementActionCosts& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Requirement& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::Type& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::TypeObject& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::TypeNumber& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::TypeEither& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::TypedListOfNamesRecursively& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::TypedListOfNames& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::TypedListOfVariablesRecursively& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::TypedListOfVariables& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::AtomicFormulaSkeleton& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::AtomicFunctionSkeletonTotalCost& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AtomicFunctionSkeletonGeneral& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AtomicFunctionSkeleton& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::FunctionTypedListOfAtomicFunctionSkeletonsRecursively& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::FunctionTypedListOfAtomicFunctionSkeletons& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::AtomicFormulaOfTermsPredicate& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AtomicFormulaOfTermsEquality& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AtomicFormulaOfTerms& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Atom& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::NegatedAtom& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Literal& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::MultiOperatorMul& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::MultiOperatorPlus& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::MultiOperator& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::BinaryOperatorMinus& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::BinaryOperatorDiv& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::BinaryOperator& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::BinaryComparatorGreater& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::BinaryComparatorLess& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::BinaryComparatorEqual& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::BinaryComparatorGreaterEqual& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::BinaryComparatorLessEqual& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::BinaryComparator& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::FunctionHead& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::FunctionExpression& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::FunctionExpressionNumber& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::FunctionExpressionBinaryOp& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::FunctionExpressionMinus& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::FunctionExpressionHead& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::GoalDescriptor& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorAtom& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorLiteral& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorAnd& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorOr& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorNot& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorImply& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorExists& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorForall& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::GoalDescriptorFunctionComparison& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptor& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAnd& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorForall& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAtEnd& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAlways& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometime& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorWithin& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAtMostOnce& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometimeAfter& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometimeBefore& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorAlwaysWithin& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorHoldDuring& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ConstraintGoalDescriptorHoldAfter& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::PreferenceName& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::PreconditionGoalDescriptor& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::PreconditionGoalDescriptorSimple& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::PreconditionGoalDescriptorAnd& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::PreconditionGoalDescriptorPreference& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::PreconditionGoalDescriptorForall& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::AssignOperatorAssign& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AssignOperatorScaleUp& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AssignOperatorScaleDown& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AssignOperatorIncrease& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AssignOperatorDecrease& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::AssignOperator& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::Effect& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::EffectProductionLiteral& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::EffectProductionNumericFluentTotalCost& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::EffectProductionNumericFluentGeneral& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::EffectProduction& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::EffectConditionalForall& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::EffectConditionalWhen& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::EffectConditional& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::ActionSymbol& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::ActionBody& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::Action& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::DerivedPredicate& node, const FormattingOptions& options = {}); + +extern std::string parse_text(const domain::ast::DomainName& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Requirements& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Types& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Constants& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Predicates& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Functions& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Constraints& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Structure& node, const FormattingOptions& options = {}); +extern std::string parse_text(const domain::ast::Domain& node, const FormattingOptions& options = {}); } diff --git a/include/loki/domain/parser.hpp b/include/loki/domain/parser.hpp index 5fc0fe64..9d144a9f 100644 --- a/include/loki/domain/parser.hpp +++ b/include/loki/domain/parser.hpp @@ -18,15 +18,15 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PARSER_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PARSER_HPP_ -#include "pddl/declarations.hpp" +#include "loki/common/filesystem.hpp" +#include "loki/common/pddl/context.hpp" +#include "loki/domain/pddl/declarations.hpp" -#include "../common/pddl/context.hpp" -#include "../common/filesystem.hpp" +namespace loki +{ - -namespace loki { - -class DomainParser { +class DomainParser +{ private: fs::path m_file_path; // We need to keep the source in memory for error reporting. diff --git a/include/loki/domain/pddl/action.hpp b/include/loki/domain/pddl/action.hpp index 3365a2e1..5ee0d882 100644 --- a/include/loki/domain/pddl/action.hpp +++ b/include/loki/domain/pddl/action.hpp @@ -18,22 +18,22 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_ACTION_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_ACTION_HPP_ -#include "declarations.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" -#include "../../common/pddl/base.hpp" - -#include #include +#include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class ActionImpl : public Base { +namespace loki::pddl +{ +class ActionImpl : public Base +{ private: std::string m_name; ParameterList m_parameters; @@ -63,21 +63,20 @@ class ActionImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Action& left_action, const loki::pddl::Action& right_action) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Action& left_action, const loki::pddl::Action& right_action) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ActionImpl& action) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ActionImpl& action) const; +}; } - #endif diff --git a/include/loki/domain/pddl/atom.hpp b/include/loki/domain/pddl/atom.hpp index c699c540..c877fe80 100644 --- a/include/loki/domain/pddl/atom.hpp +++ b/include/loki/domain/pddl/atom.hpp @@ -15,25 +15,24 @@ * along with this program. If not, see . */ - #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_ATOM_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_ATOM_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class AtomImpl : public Base { +namespace loki::pddl +{ +class AtomImpl : public Base +{ private: Predicate m_predicate; TermList m_terms; @@ -59,20 +58,20 @@ class AtomImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Atom& left_atom, const loki::pddl::Atom& right_atom) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Atom& left_atom, const loki::pddl::Atom& right_atom) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::AtomImpl& atom) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::AtomImpl& atom) const; +}; } #endif diff --git a/include/loki/domain/pddl/conditions.hpp b/include/loki/domain/pddl/conditions.hpp index 8e67cc78..03176500 100644 --- a/include/loki/domain/pddl/conditions.hpp +++ b/include/loki/domain/pddl/conditions.hpp @@ -15,27 +15,26 @@ * along with this program. If not, see . */ - #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_CONDITIONS_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_CONDITIONS_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { +namespace loki::pddl +{ /* Literal */ -class ConditionLiteralImpl : public Base { +class ConditionLiteralImpl : public Base +{ private: Literal m_literal; @@ -56,9 +55,9 @@ class ConditionLiteralImpl : public Base { const Literal& get_literal() const; }; - /* And */ -class ConditionAndImpl : public Base { +class ConditionAndImpl : public Base +{ private: ConditionList m_conditions; @@ -79,9 +78,9 @@ class ConditionAndImpl : public Base { const ConditionList& get_conditions() const; }; - /* Or */ -class ConditionOrImpl : public Base { +class ConditionOrImpl : public Base +{ private: ConditionList m_conditions; @@ -102,9 +101,9 @@ class ConditionOrImpl : public Base { const ConditionList& get_conditions() const; }; - /* Not */ -class ConditionNotImpl : public Base { +class ConditionNotImpl : public Base +{ private: Condition m_condition; @@ -125,9 +124,9 @@ class ConditionNotImpl : public Base { const Condition& get_condition() const; }; - /* Imply */ -class ConditionImplyImpl : public Base { +class ConditionImplyImpl : public Base +{ private: Condition m_condition_left; Condition m_condition_right; @@ -150,9 +149,9 @@ class ConditionImplyImpl : public Base { const Condition& get_condition_right() const; }; - /* Exists */ -class ConditionExistsImpl : public Base { +class ConditionExistsImpl : public Base +{ private: ParameterList m_parameters; Condition m_condition; @@ -175,9 +174,9 @@ class ConditionExistsImpl : public Base { const Condition& get_condition() const; }; - /* Forall */ -class ConditionForallImpl : public Base { +class ConditionForallImpl : public Base +{ private: ParameterList m_parameters; Condition m_condition; @@ -202,57 +201,56 @@ class ConditionForallImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Condition& left_condition, const loki::pddl::Condition& right_condition) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Condition& left_condition, const loki::pddl::Condition& right_condition) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ConditionLiteralImpl& condition) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ConditionAndImpl& condition) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ConditionOrImpl& condition) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ConditionNotImpl& condition) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ConditionImplyImpl& condition) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ConditionExistsImpl& condition) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ConditionForallImpl& condition) const; - }; -} +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ConditionLiteralImpl& condition) const; +}; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ConditionAndImpl& condition) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ConditionOrImpl& condition) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ConditionNotImpl& condition) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ConditionImplyImpl& condition) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ConditionExistsImpl& condition) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ConditionForallImpl& condition) const; +}; +} #endif diff --git a/include/loki/domain/pddl/declarations.hpp b/include/loki/domain/pddl/declarations.hpp index 1ac23faa..1f03c13e 100644 --- a/include/loki/domain/pddl/declarations.hpp +++ b/include/loki/domain/pddl/declarations.hpp @@ -18,124 +18,114 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_DECLARATIONS_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_DECLARATIONS_HPP_ -#include "../../common/pddl/declarations.hpp" +#include "loki/common/pddl/declarations.hpp" #include - #include -#include #include +#include - -namespace loki::pddl { - class RequirementsImpl; - using Requirements = const RequirementsImpl*; - - class TypeImpl; - using Type = const TypeImpl*; - using TypeList = boost::container::small_vector; // often single type - //using TypeList = std::vector; - - class ObjectImpl; - using Object = const ObjectImpl*; - using ObjectList = std::vector; - - class VariableImpl; - using Variable = const VariableImpl*; - using VariableList = std::vector; // not used - using VariableAssignment = std::unordered_map; - - class TermObjectImpl; - class TermVariableImpl; - using TermImpl = std::variant; - using Term = const TermImpl*; - using TermList = boost::container::small_vector; // often unary and binary predicates - //using TermList = std::vector; - - class AtomImpl; - using Atom = const AtomImpl*; - using AtomList = std::vector; - - class ParameterImpl; - using Parameter = const ParameterImpl*; - using ParameterList = boost::container::small_vector; // often actions, quantifiers with few parameters - //using ParameterList = std::vector; - using ParameterAssignment = std::unordered_map; - - class PredicateImpl; - using Predicate = const PredicateImpl*; - using PredicateList = std::vector; - - class LiteralImpl; - using Literal = const LiteralImpl*; - using LiteralList = std::vector; - - class ConditionLiteralImpl; - class ConditionAndImpl; - class ConditionOrImpl; - class ConditionNotImpl; - class ConditionImplyImpl; - class ConditionExistsImpl; - class ConditionForallImpl; - using ConditionImpl = std::variant; - using Condition = const ConditionImpl*; - using ConditionList = std::vector; - - class EffectLiteralImpl; - class EffectAndImpl; - class EffectNumericImpl; - class EffectConditionalForallImpl; - class EffectConditionalWhenImpl; - using EffectImpl = std::variant; - using Effect = const EffectImpl*; - using EffectList = std::vector; - - class FunctionExpressionNumberImpl; - class FunctionExpressionBinaryOperatorImpl; - class FunctionExpressionMultiOperatorImpl; - class FunctionExpressionMinusImpl; - class FunctionExpressionFunctionImpl; - using FunctionExpressionImpl = std::variant; - using FunctionExpression = const FunctionExpressionImpl*; - using FunctionExpressionList = std::vector; - - class FunctionSkeletonImpl; - using FunctionSkeleton = const FunctionSkeletonImpl*; - using FunctionSkeletonList = std::vector; - - class FunctionImpl; - using Function = const FunctionImpl*; - using FunctionList = std::vector; - - class ConstraintImpl; - using Constraint = const ConstraintImpl*; - using ConstraintList = std::vector; - - class ActionImpl; - using Action = const ActionImpl*; - using ActionList = std::vector; - - class DerivedPredicateImpl; - using DerivedPredicate = const DerivedPredicateImpl*; - using DerivedPredicateList = std::vector; - - class DomainImpl; - using Domain = const DomainImpl*; - using DomainList = std::vector; +namespace loki::pddl +{ +class RequirementsImpl; +using Requirements = const RequirementsImpl*; + +class TypeImpl; +using Type = const TypeImpl*; +using TypeList = boost::container::small_vector; // often single type +// using TypeList = std::vector; + +class ObjectImpl; +using Object = const ObjectImpl*; +using ObjectList = std::vector; + +class VariableImpl; +using Variable = const VariableImpl*; +using VariableList = std::vector; // not used +using VariableAssignment = std::unordered_map; + +class TermObjectImpl; +class TermVariableImpl; +using TermImpl = std::variant; +using Term = const TermImpl*; +using TermList = boost::container::small_vector; // often unary and binary predicates +// using TermList = std::vector; + +class AtomImpl; +using Atom = const AtomImpl*; +using AtomList = std::vector; + +class ParameterImpl; +using Parameter = const ParameterImpl*; +using ParameterList = boost::container::small_vector; // often actions, quantifiers with few parameters +// using ParameterList = std::vector; +using ParameterAssignment = std::unordered_map; + +class PredicateImpl; +using Predicate = const PredicateImpl*; +using PredicateList = std::vector; + +class LiteralImpl; +using Literal = const LiteralImpl*; +using LiteralList = std::vector; + +class ConditionLiteralImpl; +class ConditionAndImpl; +class ConditionOrImpl; +class ConditionNotImpl; +class ConditionImplyImpl; +class ConditionExistsImpl; +class ConditionForallImpl; +using ConditionImpl = + std::variant; +using Condition = const ConditionImpl*; +using ConditionList = std::vector; + +class EffectLiteralImpl; +class EffectAndImpl; +class EffectNumericImpl; +class EffectConditionalForallImpl; +class EffectConditionalWhenImpl; +using EffectImpl = std::variant; +using Effect = const EffectImpl*; +using EffectList = std::vector; + +class FunctionExpressionNumberImpl; +class FunctionExpressionBinaryOperatorImpl; +class FunctionExpressionMultiOperatorImpl; +class FunctionExpressionMinusImpl; +class FunctionExpressionFunctionImpl; +using FunctionExpressionImpl = std::variant; +using FunctionExpression = const FunctionExpressionImpl*; +using FunctionExpressionList = std::vector; + +class FunctionSkeletonImpl; +using FunctionSkeleton = const FunctionSkeletonImpl*; +using FunctionSkeletonList = std::vector; + +class FunctionImpl; +using Function = const FunctionImpl*; +using FunctionList = std::vector; + +class ConstraintImpl; +using Constraint = const ConstraintImpl*; +using ConstraintList = std::vector; + +class ActionImpl; +using Action = const ActionImpl*; +using ActionList = std::vector; + +class DerivedPredicateImpl; +using DerivedPredicate = const DerivedPredicateImpl*; +using DerivedPredicateList = std::vector; + +class DomainImpl; +using Domain = const DomainImpl*; +using DomainList = std::vector; } #endif diff --git a/include/loki/domain/pddl/derived_predicate.hpp b/include/loki/domain/pddl/derived_predicate.hpp index 5f03fa59..81d56a7c 100644 --- a/include/loki/domain/pddl/derived_predicate.hpp +++ b/include/loki/domain/pddl/derived_predicate.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_DERIVED_PREDICATE_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_DERIVED_PREDICATE_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class DerivedPredicateImpl : public Base { +namespace loki::pddl +{ +class DerivedPredicateImpl : public Base +{ private: ParameterList m_parameters; Condition m_condition; @@ -58,21 +58,20 @@ class DerivedPredicateImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::DerivedPredicate& left_predicate, const loki::pddl::DerivedPredicate& right_predicate) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::DerivedPredicate& left_predicate, const loki::pddl::DerivedPredicate& right_predicate) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::DerivedPredicateImpl& action) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::DerivedPredicateImpl& action) const; +}; } - #endif diff --git a/include/loki/domain/pddl/domain.hpp b/include/loki/domain/pddl/domain.hpp index fa6905aa..6751b60a 100644 --- a/include/loki/domain/pddl/domain.hpp +++ b/include/loki/domain/pddl/domain.hpp @@ -18,23 +18,23 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_DOMAIN_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_DOMAIN_HPP_ -#include "declarations.hpp" -#include "requirements.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" +#include "loki/domain/pddl/requirements.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } +namespace loki::pddl +{ -namespace loki::pddl { - -class DomainImpl : public Base { +class DomainImpl : public Base +{ private: std::string m_name; Requirements m_requirements; @@ -45,13 +45,13 @@ class DomainImpl : public Base { ActionList m_actions; DomainImpl(int identifier, - std::string name, - Requirements requirements, - TypeList types, - ObjectList constants, - PredicateList predicates, - FunctionSkeletonList functions, - ActionList actions); + std::string name, + Requirements requirements, + TypeList types, + ObjectList constants, + PredicateList predicates, + FunctionSkeletonList functions, + ActionList actions); // Give access to the constructor. template @@ -77,20 +77,20 @@ class DomainImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Domain& left_domain, const loki::pddl::Domain& right_domain) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Domain& left_domain, const loki::pddl::Domain& right_domain) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::DomainImpl& domain) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::DomainImpl& domain) const; +}; } #endif diff --git a/include/loki/domain/pddl/effects.hpp b/include/loki/domain/pddl/effects.hpp index c504bc8d..de04c6db 100644 --- a/include/loki/domain/pddl/effects.hpp +++ b/include/loki/domain/pddl/effects.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_EFFECTS_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_EFFECTS_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -enum class AssignOperatorEnum { +namespace loki::pddl +{ +enum class AssignOperatorEnum +{ ASSIGN, SCALE_UP, SCALE_DOWN, @@ -43,9 +43,9 @@ enum class AssignOperatorEnum { extern std::unordered_map assign_operator_enum_to_string; extern const std::string& to_string(pddl::AssignOperatorEnum assign_operator); - /* Literal */ -class EffectLiteralImpl : public Base { +class EffectLiteralImpl : public Base +{ private: Literal m_literal; @@ -66,9 +66,9 @@ class EffectLiteralImpl : public Base { const Literal& get_literal() const; }; - /* And */ -class EffectAndImpl : public Base { +class EffectAndImpl : public Base +{ private: EffectList m_effects; @@ -89,9 +89,9 @@ class EffectAndImpl : public Base { const EffectList& get_effects() const; }; - /* EffectNumeric */ -class EffectNumericImpl : public Base { +class EffectNumericImpl : public Base +{ private: AssignOperatorEnum m_assign_operator; Function m_function; @@ -116,9 +116,9 @@ class EffectNumericImpl : public Base { const FunctionExpression& get_function_expression() const; }; - /* ConditionalForall */ -class EffectConditionalForallImpl : public Base { +class EffectConditionalForallImpl : public Base +{ private: ParameterList m_parameters; Effect m_effect; @@ -141,9 +141,9 @@ class EffectConditionalForallImpl : public Base { const Effect& get_effect() const; }; - /* ConditionalWhen */ -class EffectConditionalWhenImpl : public Base { +class EffectConditionalWhenImpl : public Base +{ private: Condition m_condition; Effect m_effect; @@ -166,48 +166,46 @@ class EffectConditionalWhenImpl : public Base { const Effect& get_effect() const; }; - } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Effect& left_effect, const loki::pddl::Effect& right_effect) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::EffectLiteralImpl& effect) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Effect& left_effect, const loki::pddl::Effect& right_effect) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::EffectLiteralImpl& effect) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::EffectAndImpl& effect) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::EffectNumericImpl& effect) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::EffectConditionalForallImpl& effect) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::EffectConditionalWhenImpl& effect) const; - }; -} +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::EffectAndImpl& effect) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::EffectNumericImpl& effect) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::EffectConditionalForallImpl& effect) const; +}; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::EffectConditionalWhenImpl& effect) const; +}; +} #endif diff --git a/include/loki/domain/pddl/exceptions.hpp b/include/loki/domain/pddl/exceptions.hpp index 20779929..6d956eb4 100644 --- a/include/loki/domain/pddl/exceptions.hpp +++ b/include/loki/domain/pddl/exceptions.hpp @@ -18,132 +18,145 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_EXCEPTIONS_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_EXCEPTIONS_HPP_ -#include "declarations.hpp" -#include "requirements.hpp" - -#include "../../common/exceptions.hpp" +#include "loki/common/exceptions.hpp" +#include "loki/domain/pddl/declarations.hpp" +#include "loki/domain/pddl/requirements.hpp" #include - -namespace loki { +namespace loki +{ /* Type */ -class ReservedTypeError : public SemanticParserError { +class ReservedTypeError : public SemanticParserError +{ public: ReservedTypeError(const std::string& name, const std::string& error_handler_output); }; -class UnusedTypeError : public SemanticParserError { +class UnusedTypeError : public SemanticParserError +{ public: UnusedTypeError(const std::string& name, const std::string& error_handler_output); }; -class UndefinedTypeError : public SemanticParserError { +class UndefinedTypeError : public SemanticParserError +{ public: UndefinedTypeError(const std::string& name, const std::string& error_handler_output); }; -class MultiDefinitionTypeError : public SemanticParserError { +class MultiDefinitionTypeError : public SemanticParserError +{ public: MultiDefinitionTypeError(const std::string& name, const std::string& error_handler_output); }; /* Predicate */ -class UnusedPredicateError : public SemanticParserError { +class UnusedPredicateError : public SemanticParserError +{ public: UnusedPredicateError(const std::string& name, const std::string& error_handler_output); }; -class UndefinedPredicateError : public SemanticParserError { +class UndefinedPredicateError : public SemanticParserError +{ public: UndefinedPredicateError(const std::string& name, const std::string& error_handler_output); }; -class MultiDefinitionPredicateError : public SemanticParserError { +class MultiDefinitionPredicateError : public SemanticParserError +{ public: MultiDefinitionPredicateError(const std::string& name, const std::string& error_handler_output); }; /* Constant */ // UnusedConstantError is not a valid exception because constants are not required to be used in all problems -class UndefinedConstantError : public SemanticParserError { +class UndefinedConstantError : public SemanticParserError +{ public: UndefinedConstantError(const std::string& name, const std::string& error_handler_output); }; -class MultiDefinitionConstantError : public SemanticParserError { +class MultiDefinitionConstantError : public SemanticParserError +{ public: MultiDefinitionConstantError(const std::string& name, const std::string& error_handler_output); }; /* Variable */ -class UnusedVariableError : public SemanticParserError { +class UnusedVariableError : public SemanticParserError +{ public: UnusedVariableError(const std::string& name, const std::string& error_handler_output); }; -class UndefinedVariableError : public SemanticParserError { +class UndefinedVariableError : public SemanticParserError +{ public: UndefinedVariableError(const std::string& name, const std::string& error_handler_output); }; -class MultiDefinitionVariableError : public SemanticParserError { +class MultiDefinitionVariableError : public SemanticParserError +{ public: MultiDefinitionVariableError(const std::string& name, const std::string& error_handler_output); }; /* FunctionSkeleton */ -class UnusedFunctionSkeletonError : public SemanticParserError { +class UnusedFunctionSkeletonError : public SemanticParserError +{ public: UnusedFunctionSkeletonError(const std::string& name, const std::string& error_handler_output); }; -class UndefinedFunctionSkeletonError : public SemanticParserError { +class UndefinedFunctionSkeletonError : public SemanticParserError +{ public: UndefinedFunctionSkeletonError(const std::string& name, const std::string& error_handler_output); }; -class MultiDefinitionFunctionSkeletonError : public SemanticParserError { +class MultiDefinitionFunctionSkeletonError : public SemanticParserError +{ public: MultiDefinitionFunctionSkeletonError(const std::string& name, const std::string& error_handler_output); }; /* Requirement */ -class UnusedRequirementError : public SemanticParserError { +class UnusedRequirementError : public SemanticParserError +{ public: UnusedRequirementError(pddl::RequirementEnum requirement, const std::string& error_handler_output); }; -class UndefinedRequirementError : public SemanticParserError { +class UndefinedRequirementError : public SemanticParserError +{ public: UndefinedRequirementError(pddl::RequirementEnum requirement, const std::string& error_handler_output); }; -class UnsupportedRequirementError : public std::runtime_error { +class UnsupportedRequirementError : public std::runtime_error +{ public: explicit UnsupportedRequirementError(pddl::RequirementEnum requirement, const std::string& error_handler_output); }; - /* Compatibility errors */ -class MismatchedPredicateTermListError : public SemanticParserError { +class MismatchedPredicateTermListError : public SemanticParserError +{ public: - MismatchedPredicateTermListError( - const pddl::Predicate& predicate, - const pddl::TermList& term_list, - const std::string& error_handler_output); + MismatchedPredicateTermListError(const pddl::Predicate& predicate, const pddl::TermList& term_list, const std::string& error_handler_output); }; -class MismatchedFunctionSkeletonTermListError : public SemanticParserError { +class MismatchedFunctionSkeletonTermListError : public SemanticParserError +{ public: - MismatchedFunctionSkeletonTermListError( - const pddl::FunctionSkeleton& function_skeleton, - const pddl::TermList& term_list, - const std::string& error_handler_output); + MismatchedFunctionSkeletonTermListError(const pddl::FunctionSkeleton& function_skeleton, + const pddl::TermList& term_list, + const std::string& error_handler_output); }; - } #endif \ No newline at end of file diff --git a/include/loki/domain/pddl/function.hpp b/include/loki/domain/pddl/function.hpp index cfca451b..8595c808 100644 --- a/include/loki/domain/pddl/function.hpp +++ b/include/loki/domain/pddl/function.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_FUNCTION_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_FUNCTION_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class FunctionImpl : public Base { +namespace loki::pddl +{ +class FunctionImpl : public Base +{ private: FunctionSkeleton m_function_skeleton; TermList m_terms; @@ -58,20 +58,20 @@ class FunctionImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Function& left_function, const loki::pddl::Function& right_function) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Function& left_function, const loki::pddl::Function& right_function) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::FunctionImpl& function) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::FunctionImpl& function) const; +}; } #endif diff --git a/include/loki/domain/pddl/function_expressions.hpp b/include/loki/domain/pddl/function_expressions.hpp index e4c94b24..b27f40eb 100644 --- a/include/loki/domain/pddl/function_expressions.hpp +++ b/include/loki/domain/pddl/function_expressions.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_FUNCTION_EXPRESSIONS_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_FUNCTION_EXPRESSIONS_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -enum class BinaryOperatorEnum { +namespace loki::pddl +{ +enum class BinaryOperatorEnum +{ MUL, PLUS, MINUS, @@ -42,7 +42,8 @@ enum class BinaryOperatorEnum { extern std::unordered_map binary_operator_enum_to_string; extern const std::string& to_string(pddl::BinaryOperatorEnum binary_operator); -enum class MultiOperatorEnum { +enum class MultiOperatorEnum +{ MUL, PLUS, }; @@ -50,9 +51,9 @@ enum class MultiOperatorEnum { extern std::unordered_map multi_operator_enum_to_string; extern const std::string& to_string(pddl::MultiOperatorEnum multi_operator); - /* FunctionExpressionNumber */ -class FunctionExpressionNumberImpl : public Base { +class FunctionExpressionNumberImpl : public Base +{ private: double m_number; @@ -73,18 +74,18 @@ class FunctionExpressionNumberImpl : public Base { double get_number() const; }; - /* FunctionExpressionBinaryOperator */ -class FunctionExpressionBinaryOperatorImpl : public Base { +class FunctionExpressionBinaryOperatorImpl : public Base +{ private: BinaryOperatorEnum m_binary_operator; FunctionExpression m_left_function_expression; FunctionExpression m_right_function_expression; FunctionExpressionBinaryOperatorImpl(int identifier, - BinaryOperatorEnum binary_operator, - FunctionExpression left_function_expression, - FunctionExpression right_function_expression); + BinaryOperatorEnum binary_operator, + FunctionExpression left_function_expression, + FunctionExpression right_function_expression); // Give access to the constructor. template @@ -103,16 +104,14 @@ class FunctionExpressionBinaryOperatorImpl : public Base { +class FunctionExpressionMultiOperatorImpl : public Base +{ private: MultiOperatorEnum m_multi_operator; FunctionExpressionList m_function_expressions; - FunctionExpressionMultiOperatorImpl(int identifier, - MultiOperatorEnum multi_operator, - FunctionExpressionList function_expressions); + FunctionExpressionMultiOperatorImpl(int identifier, MultiOperatorEnum multi_operator, FunctionExpressionList function_expressions); // Give access to the constructor. template @@ -130,9 +129,9 @@ class FunctionExpressionMultiOperatorImpl : public Base { +class FunctionExpressionMinusImpl : public Base +{ private: FunctionExpression m_function_expression; @@ -153,9 +152,9 @@ class FunctionExpressionMinusImpl : public Base { const FunctionExpression& get_function_expression() const; }; - /* FunctionExpressionFunction */ -class FunctionExpressionFunctionImpl : public Base { +class FunctionExpressionFunctionImpl : public Base +{ private: Function m_function; @@ -178,44 +177,44 @@ class FunctionExpressionFunctionImpl : public Base +struct less +{ + bool operator()(const loki::pddl::FunctionExpression& left_function_expression, const loki::pddl::FunctionExpression& right_function_expression) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::FunctionExpressionNumberImpl& function_expressions) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::FunctionExpression& left_function_expression, const loki::pddl::FunctionExpression& right_function_expression) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::FunctionExpressionNumberImpl& function_expressions) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::FunctionExpressionBinaryOperatorImpl& function_expressions) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::FunctionExpressionMultiOperatorImpl& function_expressions) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::FunctionExpressionMinusImpl& function_expressions) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::FunctionExpressionFunctionImpl& function_expressions) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::FunctionExpressionBinaryOperatorImpl& function_expressions) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::FunctionExpressionMultiOperatorImpl& function_expressions) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::FunctionExpressionMinusImpl& function_expressions) const; +}; + +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::FunctionExpressionFunctionImpl& function_expressions) const; +}; } #endif diff --git a/include/loki/domain/pddl/function_skeleton.hpp b/include/loki/domain/pddl/function_skeleton.hpp index eca217f6..afe56815 100644 --- a/include/loki/domain/pddl/function_skeleton.hpp +++ b/include/loki/domain/pddl/function_skeleton.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_FUNCTION_SKELETON_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_FUNCTION_SKELETON_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class FunctionSkeletonImpl : public Base { +namespace loki::pddl +{ +class FunctionSkeletonImpl : public Base +{ private: std::string m_name; ParameterList m_parameters; @@ -63,20 +63,20 @@ class FunctionSkeletonImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::FunctionSkeleton& left_function, const loki::pddl::FunctionSkeleton& right_function) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::FunctionSkeleton& left_function, const loki::pddl::FunctionSkeleton& right_function) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::FunctionSkeletonImpl& function) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::FunctionSkeletonImpl& function) const; +}; } #endif diff --git a/include/loki/domain/pddl/literal.hpp b/include/loki/domain/pddl/literal.hpp index 79ac7fd0..c325bd0d 100644 --- a/include/loki/domain/pddl/literal.hpp +++ b/include/loki/domain/pddl/literal.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_LITERAL_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_LITERAL_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class LiteralImpl : public Base { +namespace loki::pddl +{ +class LiteralImpl : public Base +{ private: bool m_is_negated; Atom m_atom; @@ -58,21 +58,20 @@ class LiteralImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Literal& left_literal, const loki::pddl::Literal& right_literal) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Literal& left_literal, const loki::pddl::Literal& right_literal) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::LiteralImpl& literal) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::LiteralImpl& literal) const; +}; } - #endif diff --git a/include/loki/domain/pddl/object.hpp b/include/loki/domain/pddl/object.hpp index 9db15e17..acde85f2 100644 --- a/include/loki/domain/pddl/object.hpp +++ b/include/loki/domain/pddl/object.hpp @@ -18,26 +18,26 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_OBJECT_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_OBJECT_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class ObjectImpl : public Base { +namespace loki::pddl +{ +class ObjectImpl : public Base +{ private: std::string m_name; TypeList m_types; - ObjectImpl(int identifier, std::string name, TypeList types={}); + ObjectImpl(int identifier, std::string name, TypeList types = {}); // Give access to the constructor. template @@ -58,21 +58,20 @@ class ObjectImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Object& left_object, const loki::pddl::Object& right_object) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Object& left_object, const loki::pddl::Object& right_object) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ObjectImpl& object) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ObjectImpl& object) const; +}; } - #endif diff --git a/include/loki/domain/pddl/parameter.hpp b/include/loki/domain/pddl/parameter.hpp index 665aeb6d..cb66172e 100644 --- a/include/loki/domain/pddl/parameter.hpp +++ b/include/loki/domain/pddl/parameter.hpp @@ -18,22 +18,22 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_PARAMETER_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_PARAMETER_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } +namespace loki::pddl +{ -namespace loki::pddl { - -class ParameterImpl : public Base { +class ParameterImpl : public Base +{ private: Variable m_variable; TypeList m_types; @@ -62,20 +62,20 @@ class ParameterImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Parameter& left_parameter, const loki::pddl::Parameter& right_parameter) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Parameter& left_parameter, const loki::pddl::Parameter& right_parameter) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ParameterImpl& parameter) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ParameterImpl& parameter) const; +}; } #endif diff --git a/include/loki/domain/pddl/parser.hpp b/include/loki/domain/pddl/parser.hpp index 2242c093..f296f63a 100644 --- a/include/loki/domain/pddl/parser.hpp +++ b/include/loki/domain/pddl/parser.hpp @@ -18,13 +18,12 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_PARSER_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_PARSER_HPP_ -#include "../../common/pddl/context.hpp" -#include "declarations.hpp" +#include "loki/common/pddl/context.hpp" +#include "loki/domain/ast/ast.hpp" +#include "loki/domain/pddl/declarations.hpp" -#include "../ast/ast.hpp" - - -namespace loki { +namespace loki +{ extern pddl::Domain parse(const domain::ast::Domain& domain_node, Context& context); diff --git a/include/loki/domain/pddl/predicate.hpp b/include/loki/domain/pddl/predicate.hpp index 2cb72def..eb8292ac 100644 --- a/include/loki/domain/pddl/predicate.hpp +++ b/include/loki/domain/pddl/predicate.hpp @@ -18,23 +18,23 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_PREDICATE_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_PREDICATE_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { +namespace loki::pddl +{ // An alternative name is AtomSkeleton -class PredicateImpl : public Base { +class PredicateImpl : public Base +{ private: std::string m_name; ParameterList m_parameters; @@ -63,20 +63,20 @@ class PredicateImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Predicate& left_predicate, const loki::pddl::Predicate& right_predicate) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Predicate& left_predicate, const loki::pddl::Predicate& right_predicate) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::PredicateImpl& predicate) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::PredicateImpl& predicate) const; +}; } #endif diff --git a/include/loki/domain/pddl/requirements.hpp b/include/loki/domain/pddl/requirements.hpp index 281cb37b..9443a99c 100644 --- a/include/loki/domain/pddl/requirements.hpp +++ b/include/loki/domain/pddl/requirements.hpp @@ -18,23 +18,23 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_REQUIREMENTS_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_REQUIREMENTS_HPP_ -#include "declarations.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" -#include "../../common/pddl/base.hpp" - -#include #include +#include #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -enum class RequirementEnum { +namespace loki::pddl +{ +enum class RequirementEnum +{ STRIPS, TYPING, NEGATIVE_PRECONDITIONS, @@ -62,8 +62,8 @@ using RequirementEnumList = std::vector; extern std::unordered_map requirement_enum_to_string; extern const std::string& to_string(pddl::RequirementEnum requirement); - -class RequirementsImpl : public Base { +class RequirementsImpl : public Base +{ private: RequirementEnumSet m_requirements; @@ -89,20 +89,20 @@ class RequirementsImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Requirements& left_requirements, const loki::pddl::Requirements& right_requirements) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Requirements& left_requirements, const loki::pddl::Requirements& right_requirements) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::RequirementsImpl& requirements) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::RequirementsImpl& requirements) const; +}; } #endif diff --git a/include/loki/domain/pddl/term.hpp b/include/loki/domain/pddl/term.hpp index 5673e02e..5df7a742 100644 --- a/include/loki/domain/pddl/term.hpp +++ b/include/loki/domain/pddl/term.hpp @@ -18,22 +18,22 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_TERM_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_TERM_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } +namespace loki::pddl +{ -namespace loki::pddl { - -class TermObjectImpl : public Base { +class TermObjectImpl : public Base +{ private: Object m_object; @@ -54,8 +54,8 @@ class TermObjectImpl : public Base { const Object& get_object() const; }; - -class TermVariableImpl : public Base { +class TermVariableImpl : public Base +{ private: Variable m_variable; @@ -78,27 +78,26 @@ class TermVariableImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Term& left_term, const loki::pddl::Term& right_term) const; +}; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::TermObjectImpl& term) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Term& left_term, const loki::pddl::Term& right_term) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::TermObjectImpl& term) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::TermVariableImpl& term) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::TermVariableImpl& term) const; +}; } #endif diff --git a/include/loki/domain/pddl/type.hpp b/include/loki/domain/pddl/type.hpp index b4eda99b..790bce19 100644 --- a/include/loki/domain/pddl/type.hpp +++ b/include/loki/domain/pddl/type.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_TYPE_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_TYPE_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class TypeImpl : public Base { +namespace loki::pddl +{ +class TypeImpl : public Base +{ private: std::string m_name; TypeList m_bases; @@ -57,20 +57,20 @@ class TypeImpl : public Base { }; } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Type& left_type, const loki::pddl::Type& right_type) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Type& left_type, const loki::pddl::Type& right_type) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::TypeImpl& type) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::TypeImpl& type) const; +}; } #endif diff --git a/include/loki/domain/pddl/variable.hpp b/include/loki/domain/pddl/variable.hpp index d9ec8599..6ebed79b 100644 --- a/include/loki/domain/pddl/variable.hpp +++ b/include/loki/domain/pddl/variable.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_DOMAIN_PDDL_VARIABLE_HPP_ #define LOKI_INCLUDE_LOKI_DOMAIN_PDDL_VARIABLE_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/domain/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class VariableImpl : public Base { +namespace loki::pddl +{ +class VariableImpl : public Base +{ private: std::string m_name; @@ -56,21 +56,20 @@ class VariableImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Variable& left_variable, const loki::pddl::Variable& right_variable) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Variable& left_variable, const loki::pddl::Variable& right_variable) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::VariableImpl& variable) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::VariableImpl& variable) const; +}; } - #endif diff --git a/include/loki/problem/ast/ast.hpp b/include/loki/problem/ast/ast.hpp index 2e61c821..061cf5ba 100644 --- a/include/loki/problem/ast/ast.hpp +++ b/include/loki/problem/ast/ast.hpp @@ -18,290 +18,303 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_AST_AST_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_AST_AST_HPP_ -#include "../../domain/ast/ast.hpp" +#include "loki/domain/ast/ast.hpp" +#include #include #include -#include - #include #include - namespace loki::problem::ast { - /////////////////////////////////////////////////////////////////////////// - // The AST - /////////////////////////////////////////////////////////////////////////// - namespace x3 = boost::spirit::x3; - - struct BasicFunctionTerm; - - struct AtomicFormulaOfNamesPredicate; - struct AtomicFormulaOfNamesEquality; // :equality - struct AtomicFormulaOfNames; - struct Atom; - struct NegatedAtom; - struct Literal; - - struct InitialElementLiteral; - struct InitialElementTimedLiterals; // :timed-initial-literals - struct InitialElementNumericFluentsTotalCost; // :action-costs - struct InitialElementNumericFluentsGeneral; // :numeric-fluents - struct InitialElement; - - struct MetricFunctionExpression; - struct MetricFunctionExpressionNumber; - struct MetricFunctionExpressionBinaryOperator; - struct MetricFunctionExpressionMultiOperator; - struct MetricFunctionExpressionMinus; - struct MetricFunctionExpressionBasicFunctionTerm; - struct MetricFunctionExpressionTotalTime; - struct MetricFunctionExpressionPreferences; // :preferences - - struct OptimizationMinimize; - struct OptimizationMaximize; - struct Optimization; - struct MetricSpecificationTotalCost; - struct MetricSpecificationGeneral; - - struct PreferenceConstraintGoalDescriptor; - struct PreferenceConstraintGoalDescriptorAnd; - struct PreferenceConstraintGoalDescriptorForall; // :universal-preconditions - struct PreferenceConstraintGoalDescriptorPreference; // :preferences - struct PreferenceConstraintGoalDescriptorSimple; - - struct ProblemName; - struct DomainName; - struct Objects; - struct Initial; - struct Goal; - struct Constraints; // :constraints - struct MetricSpecification; // :numeric-fluents - - struct Problem; - - - /* */ - struct BasicFunctionTerm : x3::position_tagged { - domain::ast::FunctionSymbol function_symbol; - std::vector names; - }; - - - /* Atomic formulas */ - struct AtomicFormulaOfNamesPredicate : x3::position_tagged - { - domain::ast::Predicate predicate; - std::vector names; - }; - - struct AtomicFormulaOfNamesEquality : x3::position_tagged - { - domain::ast::Name name_left; - domain::ast::Name name_right; - }; - - struct AtomicFormulaOfNames : x3::position_tagged, - x3::variant< - AtomicFormulaOfNamesPredicate, - AtomicFormulaOfNamesEquality> - { - using base_type::base_type; - using base_type::operator=; - }; - - struct Atom : x3::position_tagged - { - AtomicFormulaOfNames atomic_formula_of_names; - }; - - struct NegatedAtom : x3::position_tagged - { - AtomicFormulaOfNames atomic_formula_of_names; - }; - - struct Literal : x3::position_tagged, - x3::variant< - Atom, - NegatedAtom> - { - using base_type::base_type; - using base_type::operator=; - }; - - /* */ - struct InitialElementLiteral : x3::position_tagged { - Literal literal; - }; - - struct InitialElementTimedLiterals : x3::position_tagged { - domain::ast::Number number; - Literal literal; - }; - - struct InitialElementNumericFluentsTotalCost : x3::position_tagged { - domain::ast::FunctionSymbol function_symbol_total_cost; - domain::ast::Number number; - }; - - struct InitialElementNumericFluentsGeneral : x3::position_tagged { - BasicFunctionTerm basic_function_term; - domain::ast::Number number; - }; - - struct InitialElement : x3::position_tagged, - x3::variant< - InitialElementLiteral, - InitialElementTimedLiterals, - InitialElementNumericFluentsTotalCost, - InitialElementNumericFluentsGeneral> { - using base_type::base_type; - using base_type::operator=; - }; - - - /* */ - struct MetricFunctionExpression : x3::position_tagged, - x3::variant< - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast> { - using base_type::base_type; - using base_type::operator=; - }; - - struct MetricFunctionExpressionNumber : x3::position_tagged { - domain::ast::Number number; - }; - - struct MetricFunctionExpressionBinaryOperator : x3::position_tagged { - domain::ast::BinaryOperator binary_operator; - MetricFunctionExpression metric_function_expression_left; - MetricFunctionExpression metric_function_expression_right; - }; - - struct MetricFunctionExpressionMultiOperator : x3::position_tagged { - domain::ast::MultiOperator multi_operator; - MetricFunctionExpression metric_function_expression_first; - std::vector metric_function_expression_remaining; - }; - - struct MetricFunctionExpressionMinus : x3::position_tagged { - MetricFunctionExpression metric_function_expression; - }; - - struct MetricFunctionExpressionBasicFunctionTerm : x3::position_tagged { - BasicFunctionTerm basic_function_term; - }; - - struct MetricFunctionExpressionTotalTime : x3::position_tagged { }; - - struct MetricFunctionExpressionPreferences : x3::position_tagged { - domain::ast::PreferenceName preference_name; - }; - - - /* */ - struct OptimizationMinimize : x3::position_tagged { }; - - struct OptimizationMaximize : x3::position_tagged { }; - - struct Optimization : x3::position_tagged, - x3::variant< - OptimizationMinimize, - OptimizationMaximize> { - using base_type::base_type; - using base_type::operator=; - }; - - struct MetricSpecificationTotalCost : x3::position_tagged { - OptimizationMinimize optimization_minimize; - domain::ast::FunctionSymbol function_symbol_total_cost; - }; - - struct MetricSpecificationGeneral : x3::position_tagged { - Optimization optimization; - MetricFunctionExpression metric_function_expression; - }; - - - /* */ - struct PreferenceConstraintGoalDescriptor : x3::position_tagged, - x3::variant< - x3::forward_ast, - x3::forward_ast, - x3::forward_ast, - x3::forward_ast> { - using base_type::base_type; - using base_type::operator=; - }; - - struct PreferenceConstraintGoalDescriptorAnd : x3::position_tagged { - std::vector preference_constraint_goal_descriptors; - }; - - struct PreferenceConstraintGoalDescriptorForall : x3::position_tagged { - domain::ast::TypedListOfVariables typed_list_of_variables; - PreferenceConstraintGoalDescriptor preference_constraint_goal_descriptor; - }; - - struct PreferenceConstraintGoalDescriptorPreference : x3::position_tagged { - boost::optional preference_name; - domain::ast::ConstraintGoalDescriptor constraint_goal_descriptor; - }; - - struct PreferenceConstraintGoalDescriptorSimple : x3::position_tagged { - domain::ast::ConstraintGoalDescriptor constraint_goal_descriptor; - }; - - - /* */ - struct ProblemName : x3::position_tagged { - domain::ast::Name name; - }; - - struct DomainName : x3::position_tagged { - domain::ast::Name name; - }; - - struct Objects : x3::position_tagged { - domain::ast::TypedListOfNames typed_list_of_names; - }; - - struct Initial : x3::position_tagged { - std::vector initial_elements; - }; - - struct Goal : x3::position_tagged { - domain::ast::PreconditionGoalDescriptor precondition_goal_descriptor; - }; - - struct Constraints : x3::position_tagged { - PreferenceConstraintGoalDescriptor preference_constraint_goal_descriptor; - }; - - struct MetricSpecification : x3::position_tagged, - x3::variant { - using base_type::base_type; - using base_type::operator=; - }; - - struct Problem : x3::position_tagged { - ProblemName problem_name; - DomainName domain_name; - boost::optional requirements; - boost::optional objects; - Initial initial; - Goal goal; - boost::optional constraints; - boost::optional metric_specification; - }; +/////////////////////////////////////////////////////////////////////////// +// The AST +/////////////////////////////////////////////////////////////////////////// +namespace x3 = boost::spirit::x3; + +struct BasicFunctionTerm; + +struct AtomicFormulaOfNamesPredicate; +struct AtomicFormulaOfNamesEquality; // :equality +struct AtomicFormulaOfNames; +struct Atom; +struct NegatedAtom; +struct Literal; + +struct InitialElementLiteral; +struct InitialElementTimedLiterals; // :timed-initial-literals +struct InitialElementNumericFluentsTotalCost; // :action-costs +struct InitialElementNumericFluentsGeneral; // :numeric-fluents +struct InitialElement; + +struct MetricFunctionExpression; +struct MetricFunctionExpressionNumber; +struct MetricFunctionExpressionBinaryOperator; +struct MetricFunctionExpressionMultiOperator; +struct MetricFunctionExpressionMinus; +struct MetricFunctionExpressionBasicFunctionTerm; +struct MetricFunctionExpressionTotalTime; +struct MetricFunctionExpressionPreferences; // :preferences + +struct OptimizationMinimize; +struct OptimizationMaximize; +struct Optimization; +struct MetricSpecificationTotalCost; +struct MetricSpecificationGeneral; + +struct PreferenceConstraintGoalDescriptor; +struct PreferenceConstraintGoalDescriptorAnd; +struct PreferenceConstraintGoalDescriptorForall; // :universal-preconditions +struct PreferenceConstraintGoalDescriptorPreference; // :preferences +struct PreferenceConstraintGoalDescriptorSimple; + +struct ProblemName; +struct DomainName; +struct Objects; +struct Initial; +struct Goal; +struct Constraints; // :constraints +struct MetricSpecification; // :numeric-fluents + +struct Problem; + +/* */ +struct BasicFunctionTerm : x3::position_tagged +{ + domain::ast::FunctionSymbol function_symbol; + std::vector names; +}; + +/* Atomic formulas */ +struct AtomicFormulaOfNamesPredicate : x3::position_tagged +{ + domain::ast::Predicate predicate; + std::vector names; +}; + +struct AtomicFormulaOfNamesEquality : x3::position_tagged +{ + domain::ast::Name name_left; + domain::ast::Name name_right; +}; + +struct AtomicFormulaOfNames : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct Atom : x3::position_tagged +{ + AtomicFormulaOfNames atomic_formula_of_names; +}; + +struct NegatedAtom : x3::position_tagged +{ + AtomicFormulaOfNames atomic_formula_of_names; +}; + +struct Literal : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* */ +struct InitialElementLiteral : x3::position_tagged +{ + Literal literal; +}; + +struct InitialElementTimedLiterals : x3::position_tagged +{ + domain::ast::Number number; + Literal literal; +}; + +struct InitialElementNumericFluentsTotalCost : x3::position_tagged +{ + domain::ast::FunctionSymbol function_symbol_total_cost; + domain::ast::Number number; +}; + +struct InitialElementNumericFluentsGeneral : x3::position_tagged +{ + BasicFunctionTerm basic_function_term; + domain::ast::Number number; +}; + +struct InitialElement : + x3::position_tagged, + x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +/* */ +struct MetricFunctionExpression : + x3::position_tagged, + x3::variant, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast> +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct MetricFunctionExpressionNumber : x3::position_tagged +{ + domain::ast::Number number; +}; + +struct MetricFunctionExpressionBinaryOperator : x3::position_tagged +{ + domain::ast::BinaryOperator binary_operator; + MetricFunctionExpression metric_function_expression_left; + MetricFunctionExpression metric_function_expression_right; +}; + +struct MetricFunctionExpressionMultiOperator : x3::position_tagged +{ + domain::ast::MultiOperator multi_operator; + MetricFunctionExpression metric_function_expression_first; + std::vector metric_function_expression_remaining; +}; + +struct MetricFunctionExpressionMinus : x3::position_tagged +{ + MetricFunctionExpression metric_function_expression; +}; + +struct MetricFunctionExpressionBasicFunctionTerm : x3::position_tagged +{ + BasicFunctionTerm basic_function_term; +}; + +struct MetricFunctionExpressionTotalTime : x3::position_tagged +{ +}; + +struct MetricFunctionExpressionPreferences : x3::position_tagged +{ + domain::ast::PreferenceName preference_name; +}; + +/* */ +struct OptimizationMinimize : x3::position_tagged +{ +}; + +struct OptimizationMaximize : x3::position_tagged +{ +}; + +struct Optimization : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct MetricSpecificationTotalCost : x3::position_tagged +{ + OptimizationMinimize optimization_minimize; + domain::ast::FunctionSymbol function_symbol_total_cost; +}; + +struct MetricSpecificationGeneral : x3::position_tagged +{ + Optimization optimization; + MetricFunctionExpression metric_function_expression; +}; + +/* */ +struct PreferenceConstraintGoalDescriptor : + x3::position_tagged, + x3::variant, + x3::forward_ast, + x3::forward_ast, + x3::forward_ast> +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct PreferenceConstraintGoalDescriptorAnd : x3::position_tagged +{ + std::vector preference_constraint_goal_descriptors; +}; + +struct PreferenceConstraintGoalDescriptorForall : x3::position_tagged +{ + domain::ast::TypedListOfVariables typed_list_of_variables; + PreferenceConstraintGoalDescriptor preference_constraint_goal_descriptor; +}; + +struct PreferenceConstraintGoalDescriptorPreference : x3::position_tagged +{ + boost::optional preference_name; + domain::ast::ConstraintGoalDescriptor constraint_goal_descriptor; +}; + +struct PreferenceConstraintGoalDescriptorSimple : x3::position_tagged +{ + domain::ast::ConstraintGoalDescriptor constraint_goal_descriptor; +}; + +/* */ +struct ProblemName : x3::position_tagged +{ + domain::ast::Name name; +}; + +struct DomainName : x3::position_tagged +{ + domain::ast::Name name; +}; + +struct Objects : x3::position_tagged +{ + domain::ast::TypedListOfNames typed_list_of_names; +}; + +struct Initial : x3::position_tagged +{ + std::vector initial_elements; +}; + +struct Goal : x3::position_tagged +{ + domain::ast::PreconditionGoalDescriptor precondition_goal_descriptor; +}; + +struct Constraints : x3::position_tagged +{ + PreferenceConstraintGoalDescriptor preference_constraint_goal_descriptor; +}; + +struct MetricSpecification : x3::position_tagged, x3::variant +{ + using base_type::base_type; + using base_type::operator=; +}; + +struct Problem : x3::position_tagged +{ + ProblemName problem_name; + DomainName domain_name; + boost::optional requirements; + boost::optional objects; + Initial initial; + Goal goal; + boost::optional constraints; + boost::optional metric_specification; +}; } diff --git a/include/loki/problem/ast/error_handler.hpp b/include/loki/problem/ast/error_handler.hpp index 41133f01..d3dfe9cd 100644 --- a/include/loki/problem/ast/error_handler.hpp +++ b/include/loki/problem/ast/error_handler.hpp @@ -18,21 +18,19 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_AST_ERROR_HANDLER_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_AST_ERROR_HANDLER_HPP_ -#include "../../domain/ast/error_handler.hpp" +#include "loki/domain/ast/error_handler.hpp" -#include #include - +#include namespace loki::problem { - namespace x3 = boost::spirit::x3; +namespace x3 = boost::spirit::x3; - struct error_handler_problem : domain::error_handler_domain { - error_handler_problem() : domain::error_handler_domain() { - id_map["name"] = "Name"; - } - }; +struct error_handler_problem : domain::error_handler_domain +{ + error_handler_problem() : domain::error_handler_domain() { id_map["name"] = "Name"; } +}; } #endif diff --git a/include/loki/problem/ast/parser.hpp b/include/loki/problem/ast/parser.hpp index cf69e257..e0709ba2 100644 --- a/include/loki/problem/ast/parser.hpp +++ b/include/loki/problem/ast/parser.hpp @@ -18,27 +18,27 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_AST_PARSER_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_AST_PARSER_HPP_ -#include "ast.hpp" +#include "loki/problem/ast/ast.hpp" #include - namespace loki::problem { - namespace x3 = boost::spirit::x3; +namespace x3 = boost::spirit::x3; - /////////////////////////////////////////////////////////////////////////// - // parser public interface - /////////////////////////////////////////////////////////////////////////// - namespace parser { - struct ProblemClass; +/////////////////////////////////////////////////////////////////////////// +// parser public interface +/////////////////////////////////////////////////////////////////////////// +namespace parser +{ +struct ProblemClass; - typedef x3::rule problem_type; +typedef x3::rule problem_type; - BOOST_SPIRIT_DECLARE(problem_type) - } +BOOST_SPIRIT_DECLARE(problem_type) +} - parser::problem_type const& problem(); +parser::problem_type const& problem(); } #endif \ No newline at end of file diff --git a/include/loki/problem/ast/printer.hpp b/include/loki/problem/ast/printer.hpp index 5aff8779..600b7ec7 100644 --- a/include/loki/problem/ast/printer.hpp +++ b/include/loki/problem/ast/printer.hpp @@ -18,58 +18,58 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_AST_PRINTER_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_AST_PRINTER_HPP_ -#include "ast.hpp" -#include "../../common/printer.hpp" +#include "loki/common/printer.hpp" +#include "loki/problem/ast/ast.hpp" - -namespace loki { +namespace loki +{ // create string representations from ast nodes. -extern std::string parse_text(const problem::ast::BasicFunctionTerm& node, const FormattingOptions& options={}); +extern std::string parse_text(const problem::ast::BasicFunctionTerm& node, const FormattingOptions& options = {}); -extern std::string parse_text(const problem::ast::AtomicFormulaOfNamesPredicate& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::AtomicFormulaOfNamesEquality& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::AtomicFormulaOfNames& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::Atom& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::NegatedAtom& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::Literal& node, const FormattingOptions& options={}); +extern std::string parse_text(const problem::ast::AtomicFormulaOfNamesPredicate& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::AtomicFormulaOfNamesEquality& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::AtomicFormulaOfNames& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::Atom& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::NegatedAtom& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::Literal& node, const FormattingOptions& options = {}); -extern std::string parse_text(const problem::ast::InitialElementLiteral& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::InitialElementTimedLiterals& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::InitialElementNumericFluentsTotalCost& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::InitialElementNumericFluentsGeneral& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::InitialElement& node, const FormattingOptions& options={}); +extern std::string parse_text(const problem::ast::InitialElementLiteral& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::InitialElementTimedLiterals& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::InitialElementNumericFluentsTotalCost& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::InitialElementNumericFluentsGeneral& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::InitialElement& node, const FormattingOptions& options = {}); -extern std::string parse_text(const problem::ast::MetricFunctionExpression& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricFunctionExpressionNumber& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricFunctionExpressionBinaryOperator& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricFunctionExpressionMultiOperator& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricFunctionExpressionMinus& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricFunctionExpressionBasicFunctionTerm& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricFunctionExpressionTotalTime& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricFunctionExpressionPreferences& node, const FormattingOptions& options={}); +extern std::string parse_text(const problem::ast::MetricFunctionExpression& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricFunctionExpressionNumber& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricFunctionExpressionBinaryOperator& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricFunctionExpressionMultiOperator& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricFunctionExpressionMinus& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricFunctionExpressionBasicFunctionTerm& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricFunctionExpressionTotalTime& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricFunctionExpressionPreferences& node, const FormattingOptions& options = {}); -extern std::string parse_text(const problem::ast::OptimizationMinimize& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::OptimizationMaximize& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::Optimization& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricSpecificationTotalCost& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricSpecificationGeneral& node, const FormattingOptions& options={}); +extern std::string parse_text(const problem::ast::OptimizationMinimize& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::OptimizationMaximize& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::Optimization& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricSpecificationTotalCost& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricSpecificationGeneral& node, const FormattingOptions& options = {}); -extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptor& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptorAnd& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptorForall& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptorPreference& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptorSimple& node, const FormattingOptions& options={}); +extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptor& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptorAnd& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptorForall& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptorPreference& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::PreferenceConstraintGoalDescriptorSimple& node, const FormattingOptions& options = {}); -extern std::string parse_text(const problem::ast::ProblemName& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::DomainName& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::Objects& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::Initial& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::Goal& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::Constraints& node, const FormattingOptions& options={}); -extern std::string parse_text(const problem::ast::MetricSpecification& node, const FormattingOptions& options={}); +extern std::string parse_text(const problem::ast::ProblemName& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::DomainName& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::Objects& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::Initial& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::Goal& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::Constraints& node, const FormattingOptions& options = {}); +extern std::string parse_text(const problem::ast::MetricSpecification& node, const FormattingOptions& options = {}); -extern std::string parse_text(const problem::ast::Problem& node, const FormattingOptions& options={}); +extern std::string parse_text(const problem::ast::Problem& node, const FormattingOptions& options = {}); } diff --git a/include/loki/problem/parser.hpp b/include/loki/problem/parser.hpp index 1555a4bf..b3734bc3 100644 --- a/include/loki/problem/parser.hpp +++ b/include/loki/problem/parser.hpp @@ -18,16 +18,16 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PARSER_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PARSER_HPP_ -#include "pddl/declarations.hpp" +#include "loki/common/filesystem.hpp" +#include "loki/common/pddl/context.hpp" +#include "loki/domain/parser.hpp" +#include "loki/problem/pddl/declarations.hpp" -#include "../common/pddl/context.hpp" -#include "../common/filesystem.hpp" -#include "../domain/parser.hpp" +namespace loki +{ - -namespace loki { - -class ProblemParser { +class ProblemParser +{ private: fs::path m_file_path; // We need to keep the source in memory for error reporting. diff --git a/include/loki/problem/pddl/declarations.hpp b/include/loki/problem/pddl/declarations.hpp index 83a83eca..e403a8c8 100644 --- a/include/loki/problem/pddl/declarations.hpp +++ b/include/loki/problem/pddl/declarations.hpp @@ -18,30 +18,30 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PDDL_DECLARATIONS_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PDDL_DECLARATIONS_HPP_ -#include "../../domain/pddl/declarations.hpp" +#include "loki/domain/pddl/declarations.hpp" #include +namespace loki::pddl +{ +class GroundAtomImpl; +using GroundAtom = const GroundAtomImpl*; +using GroundAtomList = std::vector; -namespace loki::pddl { - class GroundAtomImpl; - using GroundAtom = const GroundAtomImpl*; - using GroundAtomList = std::vector; +class GroundLiteralImpl; +using GroundLiteral = const GroundLiteralImpl*; +using GroundLiteralList = std::vector; - class GroundLiteralImpl; - using GroundLiteral = const GroundLiteralImpl*; - using GroundLiteralList = std::vector; +class NumericFluentImpl; +using NumericFluent = const NumericFluentImpl*; +using NumericFluentList = std::vector; - class NumericFluentImpl; - using NumericFluent = const NumericFluentImpl*; - using NumericFluentList = std::vector; +class OptimizationMetricImpl; +using OptimizationMetric = const OptimizationMetricImpl*; - class OptimizationMetricImpl; - using OptimizationMetric = const OptimizationMetricImpl*; - - class ProblemImpl; - using Problem = const ProblemImpl*; - using ProblemList = std::vector; +class ProblemImpl; +using Problem = const ProblemImpl*; +using ProblemList = std::vector; } #endif diff --git a/include/loki/problem/pddl/exceptions.hpp b/include/loki/problem/pddl/exceptions.hpp index 1742f70e..788adbcc 100644 --- a/include/loki/problem/pddl/exceptions.hpp +++ b/include/loki/problem/pddl/exceptions.hpp @@ -18,50 +18,49 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PDDL_EXCEPTIONS_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PDDL_EXCEPTIONS_HPP_ -#include "declarations.hpp" -#include "../../common/exceptions.hpp" +#include "loki/common/exceptions.hpp" +#include "loki/problem/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ /* Object */ -class UnusedObjectError : public SemanticParserError { +class UnusedObjectError : public SemanticParserError +{ public: UnusedObjectError(const std::string& name, const std::string& error_handler_output); }; -class UndefinedObjectError : public SemanticParserError { +class UndefinedObjectError : public SemanticParserError +{ public: UndefinedObjectError(const std::string& name, const std::string& error_handler_output); }; -class MultiDefinitionObjectError : public SemanticParserError { +class MultiDefinitionObjectError : public SemanticParserError +{ public: MultiDefinitionObjectError(const std::string& name, const std::string& error_handler_output); }; /* Compatibility errors */ -class MismatchedDomainError : public SemanticParserError { +class MismatchedDomainError : public SemanticParserError +{ public: - MismatchedDomainError( - const pddl::Domain& domain, - const std::string& domain_name, - const std::string& error_handler_output); + MismatchedDomainError(const pddl::Domain& domain, const std::string& domain_name, const std::string& error_handler_output); }; -class MismatchedPredicateObjectListError : public SemanticParserError { +class MismatchedPredicateObjectListError : public SemanticParserError +{ public: - MismatchedPredicateObjectListError( - const pddl::Predicate& predicate, - const pddl::ObjectList& object_list, - const std::string& error_handler_output); + MismatchedPredicateObjectListError(const pddl::Predicate& predicate, const pddl::ObjectList& object_list, const std::string& error_handler_output); }; -class NegativeCostError : public SemanticParserError { +class NegativeCostError : public SemanticParserError +{ public: - NegativeCostError( - const std::string& error_handler_output); + NegativeCostError(const std::string& error_handler_output); }; } diff --git a/include/loki/problem/pddl/ground_atom.hpp b/include/loki/problem/pddl/ground_atom.hpp index 4decfe77..a5389326 100644 --- a/include/loki/problem/pddl/ground_atom.hpp +++ b/include/loki/problem/pddl/ground_atom.hpp @@ -15,25 +15,24 @@ * along with this program. If not, see . */ - #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PDDL_GROUND_ATOM_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PDDL_GROUND_ATOM_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/problem/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class GroundAtomImpl : public Base { +namespace loki::pddl +{ +class GroundAtomImpl : public Base +{ private: Predicate m_predicate; ObjectList m_objects; @@ -59,20 +58,20 @@ class GroundAtomImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::GroundAtom& left_atom, const loki::pddl::GroundAtom& right_atom) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::GroundAtom& left_atom, const loki::pddl::GroundAtom& right_atom) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::GroundAtomImpl& atom) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::GroundAtomImpl& atom) const; +}; } #endif diff --git a/include/loki/problem/pddl/ground_literal.hpp b/include/loki/problem/pddl/ground_literal.hpp index 69fbae3c..c6e2dbb2 100644 --- a/include/loki/problem/pddl/ground_literal.hpp +++ b/include/loki/problem/pddl/ground_literal.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PDDL_GROUND_LITERAL_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PDDL_GROUND_LITERAL_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/problem/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class GroundLiteralImpl : public Base { +namespace loki::pddl +{ +class GroundLiteralImpl : public Base +{ private: bool m_is_negated; GroundAtom m_atom; @@ -58,21 +58,20 @@ class GroundLiteralImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::GroundLiteral& left_literal, const loki::pddl::GroundLiteral& right_literal) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::GroundLiteral& left_literal, const loki::pddl::GroundLiteral& right_literal) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::GroundLiteralImpl& literal) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::GroundLiteralImpl& literal) const; +}; } - #endif diff --git a/include/loki/problem/pddl/metric.hpp b/include/loki/problem/pddl/metric.hpp index 5780545b..59778c55 100644 --- a/include/loki/problem/pddl/metric.hpp +++ b/include/loki/problem/pddl/metric.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PDDL_METRIC_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PDDL_METRIC_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/problem/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -enum class OptimizationMetricEnum { +namespace loki::pddl +{ +enum class OptimizationMetricEnum +{ MINIMIZE, MAXIMIZE }; @@ -40,8 +40,8 @@ enum class OptimizationMetricEnum { extern std::unordered_map optimization_metric_enum_to_string; extern const std::string& to_string(pddl::OptimizationMetricEnum optimization_metric); - -class OptimizationMetricImpl : public Base { +class OptimizationMetricImpl : public Base +{ private: OptimizationMetricEnum m_optimization_metric; FunctionExpression m_function_expression; @@ -67,20 +67,20 @@ class OptimizationMetricImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::OptimizationMetric& left_metric, const loki::pddl::OptimizationMetric& right_metric) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::OptimizationMetric& left_metric, const loki::pddl::OptimizationMetric& right_metric) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::OptimizationMetricImpl& metric) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::OptimizationMetricImpl& metric) const; +}; } #endif diff --git a/include/loki/problem/pddl/numeric_fluent.hpp b/include/loki/problem/pddl/numeric_fluent.hpp index c99a31ba..054ce85a 100644 --- a/include/loki/problem/pddl/numeric_fluent.hpp +++ b/include/loki/problem/pddl/numeric_fluent.hpp @@ -18,21 +18,21 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PDDL_NUMERIC_FLUENT_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PDDL_NUMERIC_FLUENT_HPP_ -#include "declarations.hpp" - -#include "../../common/pddl/base.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/problem/pddl/declarations.hpp" #include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class NumericFluentImpl : public Base { +namespace loki::pddl +{ +class NumericFluentImpl : public Base +{ private: Function m_function; double m_number; @@ -58,20 +58,20 @@ class NumericFluentImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::NumericFluent& left_numeric_fluent, const loki::pddl::NumericFluent& right_numeric_fluent) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::NumericFluent& left_numeric_fluent, const loki::pddl::NumericFluent& right_numeric_fluent) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::NumericFluentImpl& numeric_fluent) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::NumericFluentImpl& numeric_fluent) const; +}; } #endif diff --git a/include/loki/problem/pddl/parser.hpp b/include/loki/problem/pddl/parser.hpp index 82e7460e..7612c6bf 100644 --- a/include/loki/problem/pddl/parser.hpp +++ b/include/loki/problem/pddl/parser.hpp @@ -18,13 +18,12 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PDDL_PARSER_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PDDL_PARSER_HPP_ -#include "../../common/pddl/context.hpp" -#include "declarations.hpp" +#include "loki/common/pddl/context.hpp" +#include "loki/problem/ast/ast.hpp" +#include "loki/problem/pddl/declarations.hpp" -#include "../ast/ast.hpp" - - -namespace loki { +namespace loki +{ extern pddl::Problem parse(const problem::ast::Problem& problem_node, Context& context, const pddl::Domain& domain); diff --git a/include/loki/problem/pddl/problem.hpp b/include/loki/problem/pddl/problem.hpp index 9c8ac746..4f875a98 100644 --- a/include/loki/problem/pddl/problem.hpp +++ b/include/loki/problem/pddl/problem.hpp @@ -18,22 +18,22 @@ #ifndef LOKI_INCLUDE_LOKI_PROBLEM_PDDL_PROBLEM_HPP_ #define LOKI_INCLUDE_LOKI_PROBLEM_PDDL_PROBLEM_HPP_ -#include "declarations.hpp" +#include "loki/common/pddl/base.hpp" +#include "loki/problem/pddl/declarations.hpp" -#include "../../common/pddl/base.hpp" - -#include #include +#include - -namespace loki { +namespace loki +{ template class PersistentFactory; } - -namespace loki::pddl { -class ProblemImpl : public Base { +namespace loki::pddl +{ +class ProblemImpl : public Base +{ private: Domain m_domain; std::string m_name; @@ -44,7 +44,15 @@ class ProblemImpl : public Base { Condition m_goal_condition; std::optional m_optimization_metric; - ProblemImpl(int identifier, Domain domain, std::string name, Requirements requirements, ObjectList objects, GroundLiteralList initial_literals, NumericFluentList numeric_fluents, Condition goal_condition, std::optional optimization_metric); + ProblemImpl(int identifier, + Domain domain, + std::string name, + Requirements requirements, + ObjectList objects, + GroundLiteralList initial_literals, + NumericFluentList numeric_fluents, + Condition goal_condition, + std::optional optimization_metric); // Give access to the constructor. template @@ -71,20 +79,20 @@ class ProblemImpl : public Base { } +namespace std +{ +// Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures +template<> +struct less +{ + bool operator()(const loki::pddl::Problem& left_problem, const loki::pddl::Problem& right_problem) const; +}; -namespace std { - // Inject comparison and hash function to make pointers behave appropriately with ordered and unordered datastructures - template<> - struct less - { - bool operator()(const loki::pddl::Problem& left_problem, const loki::pddl::Problem& right_problem) const; - }; - - template<> - struct hash - { - std::size_t operator()(const loki::pddl::ProblemImpl& problem) const; - }; +template<> +struct hash +{ + std::size_t operator()(const loki::pddl::ProblemImpl& problem) const; +}; } #endif diff --git a/src/common/exceptions.cpp b/src/common/exceptions.cpp index 5d8be6d1..28087618 100644 --- a/src/common/exceptions.cpp +++ b/src/common/exceptions.cpp @@ -17,18 +17,20 @@ #include +namespace loki +{ +FileNotExistsError::FileNotExistsError(const std::string& path_to_file) : std::runtime_error("File does not exist at " + path_to_file) {} -namespace loki { -FileNotExistsError::FileNotExistsError(const std::string& path_to_file) - : std::runtime_error("File does not exist at " + path_to_file) { } - -SyntaxParserError::SyntaxParserError(const std::string& message, const std::string& error_handler_output) - : std::runtime_error(message + "\n" + error_handler_output) { } +SyntaxParserError::SyntaxParserError(const std::string& message, const std::string& error_handler_output) : + std::runtime_error(message + "\n" + error_handler_output) +{ +} -SemanticParserError::SemanticParserError(const std::string& message, const std::string& error_handler_output) - : std::runtime_error(message + "\n" + error_handler_output) { } +SemanticParserError::SemanticParserError(const std::string& message, const std::string& error_handler_output) : + std::runtime_error(message + "\n" + error_handler_output) +{ +} -NotImplementedError::NotImplementedError(const std::string& message) - : std::runtime_error(message) { } +NotImplementedError::NotImplementedError(const std::string& message) : std::runtime_error(message) {} } diff --git a/src/common/filesystem.cpp b/src/common/filesystem.cpp index b66a51f9..be6de4f3 100644 --- a/src/common/filesystem.cpp +++ b/src/common/filesystem.cpp @@ -15,37 +15,41 @@ * along with this program. If not, see . */ -#include -#include - -#include #include +#include +#include #include +#include +namespace loki +{ -namespace loki { - -std::string read_file(const fs::path& file_path) { +std::string read_file(const fs::path& file_path) +{ std::ifstream file(file_path.c_str()); - if (!file.is_open()) { + if (!file.is_open()) + { throw FileNotExistsError(std::string(file_path.c_str())); } std::stringstream buffer; std::string line; - while (std::getline(file, line)) { + while (std::getline(file, line)) + { // Strip comments size_t commentPos = line.find(';'); - if (commentPos != std::string::npos) { + if (commentPos != std::string::npos) + { line = line.substr(0, commentPos); } // Replace tabs with four spaces size_t tabPos = 0; - while ((tabPos = line.find('\t', tabPos)) != std::string::npos) { + while ((tabPos = line.find('\t', tabPos)) != std::string::npos) + { line.replace(tabPos, 1, " "); - tabPos += 4; // Move past the new spaces + tabPos += 4; // Move past the new spaces } buffer << line << '\n'; diff --git a/src/common/memory.cpp b/src/common/memory.cpp index 996f6465..39fd50b3 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -17,43 +17,41 @@ #include - -namespace loki { +namespace loki +{ std::tuple process_mem_usage() { - using std::ios_base; - using std::ifstream; - using std::string; - - // 'file' stat seems to give the most reliable results - // - ifstream stat_stream("/proc/self/stat",ios_base::in); - - // dummy vars for leading entries in stat that we don't care about - // - string pid, comm, state, ppid, pgrp, session, tty_nr; - string tpgid, flags, minflt, cminflt, majflt, cmajflt; - string utime, stime, cutime, cstime, priority, nice; - string O, itrealvalue, starttime; - - // the two fields we want - // - unsigned long vsize; - long rss; - - stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr - >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt - >> utime >> stime >> cutime >> cstime >> priority >> nice - >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest - - stat_stream.close(); - - long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages - double vm_usage = vsize / 1024.0; - double resident_set = rss * page_size_kb; - - return std::make_tuple(vm_usage, resident_set); + using std::ifstream; + using std::ios_base; + using std::string; + + // 'file' stat seems to give the most reliable results + // + ifstream stat_stream("/proc/self/stat", ios_base::in); + + // dummy vars for leading entries in stat that we don't care about + // + string pid, comm, state, ppid, pgrp, session, tty_nr; + string tpgid, flags, minflt, cminflt, majflt, cmajflt; + string utime, stime, cutime, cstime, priority, nice; + string O, itrealvalue, starttime; + + // the two fields we want + // + unsigned long vsize; + long rss; + + stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt >> utime >> stime + >> cutime >> cstime >> priority >> nice >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest + + stat_stream.close(); + + long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages + double vm_usage = vsize / 1024.0; + double resident_set = rss * page_size_kb; + + return std::make_tuple(vm_usage, resident_set); } } \ No newline at end of file diff --git a/src/common/pddl/scope.cpp b/src/common/pddl/scope.cpp index 25d32e47..a9855ee7 100644 --- a/src/common/pddl/scope.cpp +++ b/src/common/pddl/scope.cpp @@ -17,35 +17,23 @@ #include +namespace loki +{ -namespace loki { +Scope::Scope(const Scope* parent_scope) : m_parent_scope(parent_scope) {} -Scope::Scope(const Scope* parent_scope) : m_parent_scope(parent_scope) { } +ScopeStack::ScopeStack(const PDDLErrorHandler& error_handler, const ScopeStack* parent) : m_error_handler(error_handler), m_parent(parent) {} +void ScopeStack::open_scope() { m_stack.push_back(m_stack.empty() ? std::make_unique() : std::make_unique(m_stack.back().get())); } -ScopeStack::ScopeStack( - const PDDLErrorHandler& error_handler, - const ScopeStack* parent) - : m_error_handler(error_handler) - , m_parent(parent) { } - -void ScopeStack::open_scope() { - m_stack.push_back(m_stack.empty() - ? std::make_unique() - : std::make_unique(m_stack.back().get())); -} - -void ScopeStack::close_scope() { +void ScopeStack::close_scope() +{ assert(!m_stack.empty()); m_stack.pop_back(); } -const PDDLErrorHandler& ScopeStack::get_error_handler() const { - return m_error_handler; -} +const PDDLErrorHandler& ScopeStack::get_error_handler() const { return m_error_handler; } -const std::deque>& ScopeStack::get_stack() const { - return m_stack; -} +const std::deque>& ScopeStack::get_stack() const { return m_stack; } } \ No newline at end of file diff --git a/src/domain/ast/ast_adapted.hpp b/src/domain/ast/ast_adapted.hpp index 17f0652b..0d2d7aef 100644 --- a/src/domain/ast/ast_adapted.hpp +++ b/src/domain/ast/ast_adapted.hpp @@ -18,10 +18,9 @@ #ifndef LOKI_SRC_DOMAIN_AST_AST_ADAPTED_HPP_ #define LOKI_SRC_DOMAIN_AST_AST_ADAPTED_HPP_ -#include - #include #include +#include // We need to tell fusion about our rexpr and rexpr_key_value // to make them a first-class fusion citizens @@ -40,7 +39,10 @@ BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::AtomicFormulaSkeleton, predicate, t BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::AtomicFunctionSkeletonTotalCost, function_symbol) BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::AtomicFunctionSkeletonGeneral, function_symbol, arguments) -BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::FunctionTypedListOfAtomicFunctionSkeletonsRecursively, atomic_function_skeletons, function_type, function_typed_list_of_atomic_function_skeletons) +BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::FunctionTypedListOfAtomicFunctionSkeletonsRecursively, + atomic_function_skeletons, + function_type, + function_typed_list_of_atomic_function_skeletons) BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::AtomicFormulaOfTermsPredicate, predicate, terms) BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::AtomicFormulaOfTermsEquality, term_left, term_right) @@ -103,5 +105,4 @@ BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::Functions, function_types_list_of_a BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::Constraints, constraint_goal_descriptor) BOOST_FUSION_ADAPT_STRUCT(loki::domain::ast::Domain, domain_name, requirements, types, constants, predicates, functions, constraints, structures) - #endif diff --git a/src/domain/ast/parser.hpp b/src/domain/ast/parser.hpp index 78c901ec..50fab3ee 100644 --- a/src/domain/ast/parser.hpp +++ b/src/domain/ast/parser.hpp @@ -18,534 +18,595 @@ #ifndef LOKI_SRC_DOMAIN_AST_PARSER_HPP_ #define LOKI_SRC_DOMAIN_AST_PARSER_HPP_ +#include #include -#include +namespace loki::domain +{ +namespace x3 = boost::spirit::x3; +namespace ascii = boost::spirit::x3::ascii; + +using x3::eoi; +using x3::eol; +using x3::lit; +using x3::no_skip; +using x3::string; + +using ascii::char_; +using ascii::space; + +/////////////////////////////////////////////////////////////////////////// +// parser public interface for testing +/////////////////////////////////////////////////////////////////////////// +namespace parser +{ +struct DefineKeywordClass; +struct DomainKeywordClass; + +struct NameClass; +struct VariableClass; +struct NameTotalCostClass; +struct FunctionSymbolTotalCostClass; +struct FunctionSymbolClass; +struct TermClass; +struct NumberClass; +struct PredicateClass; + +struct RequirementStripsClass; +struct RequirementTypingClass; +struct RequirementNegativePreconditionsClass; +struct RequirementDisjunctivePreconditionsClass; +struct RequirementEqualityClass; +struct RequirementExistentialPreconditionsClass; +struct RequirementUniversalPreconditionsClass; +struct RequirementQuantifiedPreconditionsClass; +struct RequirementConditionalEffectsClass; +struct RequirementFluentsClass; +struct RequirementObjectFluentsClass; +struct RequirementNumericFluentsClass; +struct RequirementAdlClass; +struct RequirementDurativeActionsClass; +struct RequirementDerivedPredicatesClass; +struct RequirementTimedInitialLiteralsClass; +struct RequirementPreferencesClass; +struct RequirementConstraintsClass; +struct RequirementActionCostsClass; +struct RequirementClass; + +struct TypeClass; +struct TypeObjectClass; +struct TypeNumberClass; +struct TypeEitherClass; +struct TypedListOfNamesRecursivelyClass; +struct TypedListOfNamesClass; +struct TypedListOfVariablesRecursivelyClass; +struct TypedListOfVariablesClass; + +struct AtomicFormulaSkeletonClass; + +struct AtomicFunctionSkeletonTotalCostClass; +struct AtomicFunctionSkeletonGeneralClass; +struct AtomicFunctionSkeletonClass; +struct FunctionTypedListOfAtomicFunctionSkeletonsRecursivelyClass; +struct FunctionTypedListOfAtomicFunctionSkeletonsClass; + +struct AtomicFormulaOfTermsPredicateClass; +struct AtomicFormulaOfTermsEqualityClass; +struct AtomicFormulaOfTermsClass; +struct AtomClass; +struct NegatedAtomClass; +struct LiteralClass; + +struct MultiOperatorMulClass; +struct MultiOperatorPlusClass; +struct MultiOperatorClass; +struct BinaryOperatorMinusClass; +struct BinaryOperatorDivClass; +struct BinaryOperatorClass; + +struct BinaryComparatorGreaterClass; +struct BinaryComparatorLessClass; +struct BinaryComparatorEqualClass; +struct BinaryComparatorGreaterEqualClass; +struct BinaryComparatorLessEqualClass; +struct BinaryComparatorClass; + +struct FunctionHeadClass; +struct FunctionExpressionClass; +struct FunctionExpressionNumberClass; +struct FunctionExpressionBinaryOpClass; +struct FunctionExpressionMinusClass; +struct FunctionExpressionHeadClass; + +struct GoalDescriptorClass; +struct GoalDescriptorAtomClass; +struct GoalDescriptorLiteralClass; +struct GoalDescriptorAndClass; +struct GoalDescriptorOrClass; +struct GoalDescriptorNotClass; +struct GoalDescriptorImplyClass; +struct GoalDescriptorExistsClass; +struct GoalDescriptorForallClass; +struct GoalDescriptorFunctionComparisonClass; + +struct ConstraintGoalDescriptorClass; +struct ConstraintGoalDescriptorAndClass; +struct ConstraintGoalDescriptorForallClass; +struct ConstraintGoalDescriptorAtEndClass; +struct ConstraintGoalDescriptorAlwaysClass; +struct ConstraintGoalDescriptorSometimeClass; +struct ConstraintGoalDescriptorWithinClass; +struct ConstraintGoalDescriptorAtMostOnceClass; +struct ConstraintGoalDescriptorSometimeAfterClass; +struct ConstraintGoalDescriptorSometimeBeforeClass; +struct ConstraintGoalDescriptorAlwaysWithinClass; +struct ConstraintGoalDescriptorHoldDuringClass; +struct ConstraintGoalDescriptorHoldAfterClass; + +struct PreferenceNameClass; +struct PreconditionGoalDescriptorClass; +struct PreconditionGoalDescriptorSimpleClass; +struct PreconditionGoalDescriptorAndClass; +struct PreconditionGoalDescriptorPreferenceClass; +struct PreconditionGoalDescriptorForallClass; + +struct AssignOperatorAssignClass; +struct AssignOperatorScaleUpClass; +struct AssignOperatorScaleDownClass; +struct AssignOperatorIncreaseClass; +struct AssignOperatorDecreaseClass; +struct AssignOperatorClass; + +struct NumericTermClass; + +struct EffectClass; +struct EffectProductionLiteralClass; +struct EffectProductionNumericFluentTotalCostClass; +struct EffectProductionNumericFluentGeneralClass; +struct EffectProductionClass; +struct EffectConditionalForallClass; +struct EffectConditionalWhenClass; +struct EffectConditionalClass; +struct ActionSymbolClass; +struct ActionBodyClass; +struct ActionClass; +struct DurativeActionClass; // TODO +struct DerivedPredicateClass; + +struct DomainNameClass; +struct RequirementsClass; +struct TypesClass; +struct ConstantsClass; +struct PredicatesClass; +struct FunctionsClass; +struct ConstraintsClass; +struct StructureClass; + +typedef x3::rule define_keyword_type; +typedef x3::rule domain_keyword_type; + +typedef x3::rule name_type; +typedef x3::rule variable_type; +typedef x3::rule name_total_cost_type; +typedef x3::rule function_symbol_total_cost_type; +typedef x3::rule function_symbol_type; +typedef x3::rule term_type; +typedef x3::rule number_type; +typedef x3::rule predicate_type; + +typedef x3::rule requirement_strips_type; +typedef x3::rule requirement_typing_type; +typedef x3::rule requirement_negative_preconditions_type; +typedef x3::rule requirement_disjunctive_preconditions_type; +typedef x3::rule requirement_equality_type; +typedef x3::rule requirement_existential_preconditions_type; +typedef x3::rule requirement_universal_preconditions_type; +typedef x3::rule requirement_quantified_preconditions_type; +typedef x3::rule requirement_conditional_effects_type; +typedef x3::rule requirement_fluents_type; +typedef x3::rule requirement_object_fluents_type; +typedef x3::rule requirement_numeric_fluents_type; +typedef x3::rule requirement_adl_type; +typedef x3::rule requirement_durative_actions_type; +typedef x3::rule requirement_derived_predicates_type; +typedef x3::rule requirement_timed_initial_literals_type; +typedef x3::rule requirement_preferences_type; +typedef x3::rule requirement_constraints_type; +typedef x3::rule requirement_action_costs_type; +typedef x3::rule requirement_type; + +typedef x3::rule type_type; +typedef x3::rule type_object_type; +typedef x3::rule type_number_type; +typedef x3::rule type_either_type; +typedef x3::rule typed_list_of_names_recursively_type; +typedef x3::rule typed_list_of_names_type; +typedef x3::rule typed_list_of_variables_recursively_type; +typedef x3::rule typed_list_of_variables_type; + +typedef x3::rule atomic_formula_skeleton_type; + +typedef x3::rule atomic_function_skeleton_total_cost_type; +typedef x3::rule atomic_function_skeleton_general_type; +typedef x3::rule atomic_function_skeleton_type; +typedef x3::rule + function_typed_list_of_atomic_function_skeletons_recursively_type; +typedef x3::rule + function_typed_list_of_atomic_function_skeletons_type; + +typedef x3::rule atomic_formula_of_terms_predicate_type; +typedef x3::rule atomic_formula_of_terms_equality_type; +typedef x3::rule atomic_formula_of_terms_type; +typedef x3::rule atom_type; +typedef x3::rule negated_atom_type; +typedef x3::rule literal_type; + +typedef x3::rule multi_operator_mul_type; +typedef x3::rule multi_operator_plus_type; +typedef x3::rule multi_operator_type; +typedef x3::rule binary_operator_minus_type; +typedef x3::rule binary_operator_div_type; +typedef x3::rule binary_operator_type; + +typedef x3::rule binary_comparator_greater_type; +typedef x3::rule binary_comparator_less_type; +typedef x3::rule binary_comparator_equal_type; +typedef x3::rule binary_comparator_greater_equal_type; +typedef x3::rule binary_comparator_less_equal_type; +typedef x3::rule binary_comparator_type; + +typedef x3::rule function_expression_type; +typedef x3::rule function_head_type; +typedef x3::rule function_expression_number_type; +typedef x3::rule function_expression_binary_op_type; +typedef x3::rule function_expression_minus_type; +typedef x3::rule function_expression_head_type; + +typedef x3::rule goal_descriptor_type; +typedef x3::rule goal_descriptor_atom_type; +typedef x3::rule goal_descriptor_literal_type; +typedef x3::rule goal_descriptor_and_type; +typedef x3::rule goal_descriptor_or_type; +typedef x3::rule goal_descriptor_not_type; +typedef x3::rule goal_descriptor_imply_type; +typedef x3::rule goal_descriptor_exists_type; +typedef x3::rule goal_descriptor_forall_type; +typedef x3::rule goal_descriptor_function_comparison_type; + +typedef x3::rule constraint_goal_descriptor_type; +typedef x3::rule constraint_goal_descriptor_and_type; +typedef x3::rule constraint_goal_descriptor_forall_type; +typedef x3::rule constraint_goal_descriptor_at_end_type; +typedef x3::rule constraint_goal_descriptor_always_type; +typedef x3::rule constraint_goal_descriptor_sometime_type; +typedef x3::rule constraint_goal_descriptor_within_type; +typedef x3::rule constraint_goal_descriptor_at_most_once_type; +typedef x3::rule constraint_goal_descriptor_sometime_after_type; +typedef x3::rule constraint_goal_descriptor_sometime_before_type; +typedef x3::rule constraint_goal_descriptor_always_within_type; +typedef x3::rule constraint_goal_descriptor_hold_during_type; +typedef x3::rule constraint_goal_descriptor_hold_after_type; + +typedef x3::rule precondition_goal_descriptor_type; +typedef x3::rule preference_name_type; +typedef x3::rule precondition_goal_descriptor_simple_type; +typedef x3::rule precondition_goal_descriptor_and_type; +typedef x3::rule precondition_goal_descriptor_preference_type; +typedef x3::rule precondition_goal_descriptor_forall_type; + +typedef x3::rule assign_operator_assign_type; +typedef x3::rule assign_operator_scale_up_type; +typedef x3::rule assign_operator_scale_down_type; +typedef x3::rule assign_operator_increase_type; +typedef x3::rule assign_operator_decrease_type; +typedef x3::rule assign_operator_type; + +typedef x3::rule numeric_term_type; + +typedef x3::rule effect_type; +typedef x3::rule effect_production_literal_type; +typedef x3::rule effect_production_numeric_fluent_total_cost_type; +typedef x3::rule effect_production_numeric_fluent_general_type; +typedef x3::rule effect_production_type; +typedef x3::rule effect_conditional_forall_type; +typedef x3::rule effect_conditional_when_type; +typedef x3::rule effect_conditional_type; +typedef x3::rule action_symbol_type; +typedef x3::rule action_body_type; +typedef x3::rule action_type; + +typedef x3::rule derived_predicate_type; + +typedef x3::rule domain_name_type; +typedef x3::rule requirements_type; +typedef x3::rule types_type; +typedef x3::rule constants_type; +typedef x3::rule predicates_type; +typedef x3::rule functions_type; +typedef x3::rule constraints_type; +typedef x3::rule structure_type; + +BOOST_SPIRIT_DECLARE(define_keyword_type, domain_keyword_type) + +BOOST_SPIRIT_DECLARE(name_type, + variable_type, + name_total_cost_type, + function_symbol_total_cost_type, + function_symbol_type, + term_type, + number_type, + predicate_type) + +BOOST_SPIRIT_DECLARE(requirement_strips_type, + requirement_typing_type, + requirement_negative_preconditions_type, + requirement_disjunctive_preconditions_type, + requirement_equality_type, + requirement_existential_preconditions_type, + requirement_universal_preconditions_type, + requirement_quantified_preconditions_type, + requirement_conditional_effects_type, + requirement_fluents_type, + requirement_object_fluents_type, + requirement_numeric_fluents_type, + requirement_adl_type, + requirement_durative_actions_type, + requirement_derived_predicates_type, + requirement_timed_initial_literals_type, + requirement_preferences_type, + requirement_constraints_type, + requirement_action_costs_type, + requirement_type) + +BOOST_SPIRIT_DECLARE(type_type, + type_object_type, + type_number_type, + type_either_type, + typed_list_of_names_recursively_type, + typed_list_of_names_type, + typed_list_of_variables_recursively_type, + typed_list_of_variables_type) + +BOOST_SPIRIT_DECLARE(atomic_formula_skeleton_type) + +BOOST_SPIRIT_DECLARE(atomic_function_skeleton_total_cost_type, + atomic_function_skeleton_general_type, + atomic_function_skeleton_type, + function_typed_list_of_atomic_function_skeletons_recursively_type, + function_typed_list_of_atomic_function_skeletons_type) + +BOOST_SPIRIT_DECLARE(atomic_formula_of_terms_type, atom_type, negated_atom_type, literal_type) + +BOOST_SPIRIT_DECLARE(multi_operator_mul_type, + multi_operator_plus_type, + multi_operator_type, + binary_operator_minus_type, + binary_operator_div_type, + binary_operator_type) + +BOOST_SPIRIT_DECLARE(binary_comparator_greater_type, + binary_comparator_less_type, + binary_comparator_equal_type, + binary_comparator_greater_equal_type, + binary_comparator_less_equal_type, + binary_comparator_type) + +BOOST_SPIRIT_DECLARE(function_expression_type, + function_head_type, + function_expression_number_type, + function_expression_number_type, + function_expression_binary_op_type, + function_expression_minus_type, + function_expression_head_type) + +BOOST_SPIRIT_DECLARE(goal_descriptor_type, + goal_descriptor_atom_type, + goal_descriptor_literal_type, + goal_descriptor_and_type, + goal_descriptor_or_type, + goal_descriptor_not_type, + goal_descriptor_imply_type, + goal_descriptor_exists_type, + goal_descriptor_forall_type, + goal_descriptor_function_comparison_type) + +BOOST_SPIRIT_DECLARE(constraint_goal_descriptor_type, + constraint_goal_descriptor_and_type, + constraint_goal_descriptor_forall_type, + constraint_goal_descriptor_at_end_type, + constraint_goal_descriptor_always_type, + constraint_goal_descriptor_sometime_type, + constraint_goal_descriptor_within_type, + constraint_goal_descriptor_at_most_once_type, + constraint_goal_descriptor_sometime_after_type, + constraint_goal_descriptor_sometime_before_type, + constraint_goal_descriptor_always_within_type, + constraint_goal_descriptor_hold_during_type, + constraint_goal_descriptor_hold_after_type) + +BOOST_SPIRIT_DECLARE(precondition_goal_descriptor_type, + preference_name_type, + precondition_goal_descriptor_simple_type, + precondition_goal_descriptor_and_type, + precondition_goal_descriptor_preference_type, + precondition_goal_descriptor_forall_type) + +BOOST_SPIRIT_DECLARE(assign_operator_assign_type, + assign_operator_scale_up_type, + assign_operator_scale_down_type, + assign_operator_increase_type, + assign_operator_decrease_type, + assign_operator_type) + +BOOST_SPIRIT_DECLARE(numeric_term_type) + +BOOST_SPIRIT_DECLARE(effect_type, + effect_production_literal_type, + effect_production_numeric_fluent_total_cost_type, + effect_production_numeric_fluent_general_type, + effect_production_type, + effect_conditional_forall_type, + effect_conditional_when_type, + effect_conditional_type, + action_symbol_type, + action_body_type, + action_type, + derived_predicate_type) + +BOOST_SPIRIT_DECLARE(domain_name_type, requirements_type, types_type, constants_type, predicates_type, functions_type, constraints_type, structure_type) +} +inline auto separator() +{ + return (ascii::space | x3::eol | x3::eoi | lit('(') | lit(')')); // TODO: is ) correct? +} -namespace loki::domain { - namespace x3 = boost::spirit::x3; - namespace ascii = boost::spirit::x3::ascii; - - using x3::lit; - using x3::string; - using x3::no_skip; - using x3::eol; - using x3::eoi; - - using ascii::char_; - using ascii::space; - - /////////////////////////////////////////////////////////////////////////// - // parser public interface for testing - /////////////////////////////////////////////////////////////////////////// - namespace parser { - struct DefineKeywordClass; - struct DomainKeywordClass; - - struct NameClass; - struct VariableClass; - struct NameTotalCostClass; - struct FunctionSymbolTotalCostClass; - struct FunctionSymbolClass; - struct TermClass; - struct NumberClass; - struct PredicateClass; - - struct RequirementStripsClass; - struct RequirementTypingClass; - struct RequirementNegativePreconditionsClass; - struct RequirementDisjunctivePreconditionsClass; - struct RequirementEqualityClass; - struct RequirementExistentialPreconditionsClass; - struct RequirementUniversalPreconditionsClass; - struct RequirementQuantifiedPreconditionsClass; - struct RequirementConditionalEffectsClass; - struct RequirementFluentsClass; - struct RequirementObjectFluentsClass; - struct RequirementNumericFluentsClass; - struct RequirementAdlClass; - struct RequirementDurativeActionsClass; - struct RequirementDerivedPredicatesClass; - struct RequirementTimedInitialLiteralsClass; - struct RequirementPreferencesClass; - struct RequirementConstraintsClass; - struct RequirementActionCostsClass; - struct RequirementClass; - - struct TypeClass; - struct TypeObjectClass; - struct TypeNumberClass; - struct TypeEitherClass; - struct TypedListOfNamesRecursivelyClass; - struct TypedListOfNamesClass; - struct TypedListOfVariablesRecursivelyClass; - struct TypedListOfVariablesClass; - - struct AtomicFormulaSkeletonClass; - - struct AtomicFunctionSkeletonTotalCostClass; - struct AtomicFunctionSkeletonGeneralClass; - struct AtomicFunctionSkeletonClass; - struct FunctionTypedListOfAtomicFunctionSkeletonsRecursivelyClass; - struct FunctionTypedListOfAtomicFunctionSkeletonsClass; - - struct AtomicFormulaOfTermsPredicateClass; - struct AtomicFormulaOfTermsEqualityClass; - struct AtomicFormulaOfTermsClass; - struct AtomClass; - struct NegatedAtomClass; - struct LiteralClass; - - struct MultiOperatorMulClass; - struct MultiOperatorPlusClass; - struct MultiOperatorClass; - struct BinaryOperatorMinusClass; - struct BinaryOperatorDivClass; - struct BinaryOperatorClass; - - struct BinaryComparatorGreaterClass; - struct BinaryComparatorLessClass; - struct BinaryComparatorEqualClass; - struct BinaryComparatorGreaterEqualClass; - struct BinaryComparatorLessEqualClass; - struct BinaryComparatorClass; - - struct FunctionHeadClass; - struct FunctionExpressionClass; - struct FunctionExpressionNumberClass; - struct FunctionExpressionBinaryOpClass; - struct FunctionExpressionMinusClass; - struct FunctionExpressionHeadClass; - - struct GoalDescriptorClass; - struct GoalDescriptorAtomClass; - struct GoalDescriptorLiteralClass; - struct GoalDescriptorAndClass; - struct GoalDescriptorOrClass; - struct GoalDescriptorNotClass; - struct GoalDescriptorImplyClass; - struct GoalDescriptorExistsClass; - struct GoalDescriptorForallClass; - struct GoalDescriptorFunctionComparisonClass; - - struct ConstraintGoalDescriptorClass; - struct ConstraintGoalDescriptorAndClass; - struct ConstraintGoalDescriptorForallClass; - struct ConstraintGoalDescriptorAtEndClass; - struct ConstraintGoalDescriptorAlwaysClass; - struct ConstraintGoalDescriptorSometimeClass; - struct ConstraintGoalDescriptorWithinClass; - struct ConstraintGoalDescriptorAtMostOnceClass; - struct ConstraintGoalDescriptorSometimeAfterClass; - struct ConstraintGoalDescriptorSometimeBeforeClass; - struct ConstraintGoalDescriptorAlwaysWithinClass; - struct ConstraintGoalDescriptorHoldDuringClass; - struct ConstraintGoalDescriptorHoldAfterClass; - - struct PreferenceNameClass; - struct PreconditionGoalDescriptorClass; - struct PreconditionGoalDescriptorSimpleClass; - struct PreconditionGoalDescriptorAndClass; - struct PreconditionGoalDescriptorPreferenceClass; - struct PreconditionGoalDescriptorForallClass; - - struct AssignOperatorAssignClass; - struct AssignOperatorScaleUpClass; - struct AssignOperatorScaleDownClass; - struct AssignOperatorIncreaseClass; - struct AssignOperatorDecreaseClass; - struct AssignOperatorClass; - - struct NumericTermClass; - - struct EffectClass; - struct EffectProductionLiteralClass; - struct EffectProductionNumericFluentTotalCostClass; - struct EffectProductionNumericFluentGeneralClass; - struct EffectProductionClass; - struct EffectConditionalForallClass; - struct EffectConditionalWhenClass; - struct EffectConditionalClass; - struct ActionSymbolClass; - struct ActionBodyClass; - struct ActionClass; - struct DurativeActionClass; // TODO - struct DerivedPredicateClass; - - struct DomainNameClass; - struct RequirementsClass; - struct TypesClass; - struct ConstantsClass; - struct PredicatesClass; - struct FunctionsClass; - struct ConstraintsClass; - struct StructureClass; - - typedef x3::rule define_keyword_type; - typedef x3::rule domain_keyword_type; - - typedef x3::rule name_type; - typedef x3::rule variable_type; - typedef x3::rule name_total_cost_type; - typedef x3::rule function_symbol_total_cost_type; - typedef x3::rule function_symbol_type; - typedef x3::rule term_type; - typedef x3::rule number_type; - typedef x3::rule predicate_type; - - typedef x3::rule requirement_strips_type; - typedef x3::rule requirement_typing_type; - typedef x3::rule requirement_negative_preconditions_type; - typedef x3::rule requirement_disjunctive_preconditions_type; - typedef x3::rule requirement_equality_type; - typedef x3::rule requirement_existential_preconditions_type; - typedef x3::rule requirement_universal_preconditions_type; - typedef x3::rule requirement_quantified_preconditions_type; - typedef x3::rule requirement_conditional_effects_type; - typedef x3::rule requirement_fluents_type; - typedef x3::rule requirement_object_fluents_type; - typedef x3::rule requirement_numeric_fluents_type; - typedef x3::rule requirement_adl_type; - typedef x3::rule requirement_durative_actions_type; - typedef x3::rule requirement_derived_predicates_type; - typedef x3::rule requirement_timed_initial_literals_type; - typedef x3::rule requirement_preferences_type; - typedef x3::rule requirement_constraints_type; - typedef x3::rule requirement_action_costs_type; - typedef x3::rule requirement_type; - - typedef x3::rule type_type; - typedef x3::rule type_object_type; - typedef x3::rule type_number_type; - typedef x3::rule type_either_type; - typedef x3::rule typed_list_of_names_recursively_type; - typedef x3::rule typed_list_of_names_type; - typedef x3::rule typed_list_of_variables_recursively_type; - typedef x3::rule typed_list_of_variables_type; - - typedef x3::rule atomic_formula_skeleton_type; - - typedef x3::rule atomic_function_skeleton_total_cost_type; - typedef x3::rule atomic_function_skeleton_general_type; - typedef x3::rule atomic_function_skeleton_type; - typedef x3::rule function_typed_list_of_atomic_function_skeletons_recursively_type; - typedef x3::rule function_typed_list_of_atomic_function_skeletons_type; - - typedef x3::rule atomic_formula_of_terms_predicate_type; - typedef x3::rule atomic_formula_of_terms_equality_type; - typedef x3::rule atomic_formula_of_terms_type; - typedef x3::rule atom_type; - typedef x3::rule negated_atom_type; - typedef x3::rule literal_type; - - typedef x3::rule multi_operator_mul_type; - typedef x3::rule multi_operator_plus_type; - typedef x3::rule multi_operator_type; - typedef x3::rule binary_operator_minus_type; - typedef x3::rule binary_operator_div_type; - typedef x3::rule binary_operator_type; - - typedef x3::rule binary_comparator_greater_type; - typedef x3::rule binary_comparator_less_type; - typedef x3::rule binary_comparator_equal_type; - typedef x3::rule binary_comparator_greater_equal_type; - typedef x3::rule binary_comparator_less_equal_type; - typedef x3::rule binary_comparator_type; - - typedef x3::rule function_expression_type; - typedef x3::rule function_head_type; - typedef x3::rule function_expression_number_type; - typedef x3::rule function_expression_binary_op_type; - typedef x3::rule function_expression_minus_type; - typedef x3::rule function_expression_head_type; - - typedef x3::rule goal_descriptor_type; - typedef x3::rule goal_descriptor_atom_type; - typedef x3::rule goal_descriptor_literal_type; - typedef x3::rule goal_descriptor_and_type; - typedef x3::rule goal_descriptor_or_type; - typedef x3::rule goal_descriptor_not_type; - typedef x3::rule goal_descriptor_imply_type; - typedef x3::rule goal_descriptor_exists_type; - typedef x3::rule goal_descriptor_forall_type; - typedef x3::rule goal_descriptor_function_comparison_type; - - typedef x3::rule constraint_goal_descriptor_type; - typedef x3::rule constraint_goal_descriptor_and_type; - typedef x3::rule constraint_goal_descriptor_forall_type; - typedef x3::rule constraint_goal_descriptor_at_end_type; - typedef x3::rule constraint_goal_descriptor_always_type; - typedef x3::rule constraint_goal_descriptor_sometime_type; - typedef x3::rule constraint_goal_descriptor_within_type; - typedef x3::rule constraint_goal_descriptor_at_most_once_type; - typedef x3::rule constraint_goal_descriptor_sometime_after_type; - typedef x3::rule constraint_goal_descriptor_sometime_before_type; - typedef x3::rule constraint_goal_descriptor_always_within_type; - typedef x3::rule constraint_goal_descriptor_hold_during_type; - typedef x3::rule constraint_goal_descriptor_hold_after_type; - - typedef x3::rule precondition_goal_descriptor_type; - typedef x3::rule preference_name_type; - typedef x3::rule precondition_goal_descriptor_simple_type; - typedef x3::rule precondition_goal_descriptor_and_type; - typedef x3::rule precondition_goal_descriptor_preference_type; - typedef x3::rule precondition_goal_descriptor_forall_type; - - typedef x3::rule assign_operator_assign_type; - typedef x3::rule assign_operator_scale_up_type; - typedef x3::rule assign_operator_scale_down_type; - typedef x3::rule assign_operator_increase_type; - typedef x3::rule assign_operator_decrease_type; - typedef x3::rule assign_operator_type; - - typedef x3::rule numeric_term_type; - - typedef x3::rule effect_type; - typedef x3::rule effect_production_literal_type; - typedef x3::rule effect_production_numeric_fluent_total_cost_type; - typedef x3::rule effect_production_numeric_fluent_general_type; - typedef x3::rule effect_production_type; - typedef x3::rule effect_conditional_forall_type; - typedef x3::rule effect_conditional_when_type; - typedef x3::rule effect_conditional_type; - typedef x3::rule action_symbol_type; - typedef x3::rule action_body_type; - typedef x3::rule action_type; - - typedef x3::rule derived_predicate_type; - - typedef x3::rule domain_name_type; - typedef x3::rule requirements_type; - typedef x3::rule types_type; - typedef x3::rule constants_type; - typedef x3::rule predicates_type; - typedef x3::rule functions_type; - typedef x3::rule constraints_type; - typedef x3::rule structure_type; - - BOOST_SPIRIT_DECLARE(define_keyword_type, domain_keyword_type) - - BOOST_SPIRIT_DECLARE(name_type, variable_type, name_total_cost_type, function_symbol_total_cost_type, function_symbol_type, term_type, number_type, predicate_type) - - BOOST_SPIRIT_DECLARE( - requirement_strips_type, requirement_typing_type, requirement_negative_preconditions_type, requirement_disjunctive_preconditions_type, - requirement_equality_type, requirement_existential_preconditions_type, requirement_universal_preconditions_type, - requirement_quantified_preconditions_type, requirement_conditional_effects_type, requirement_fluents_type, - requirement_object_fluents_type, requirement_numeric_fluents_type, requirement_adl_type, requirement_durative_actions_type, - requirement_derived_predicates_type, requirement_timed_initial_literals_type, requirement_preferences_type, - requirement_constraints_type, requirement_action_costs_type, requirement_type) - - BOOST_SPIRIT_DECLARE( - type_type, type_object_type, type_number_type, type_either_type, - typed_list_of_names_recursively_type, typed_list_of_names_type, - typed_list_of_variables_recursively_type, typed_list_of_variables_type) - - BOOST_SPIRIT_DECLARE(atomic_formula_skeleton_type) - - BOOST_SPIRIT_DECLARE(atomic_function_skeleton_total_cost_type, atomic_function_skeleton_general_type, atomic_function_skeleton_type, - function_typed_list_of_atomic_function_skeletons_recursively_type, function_typed_list_of_atomic_function_skeletons_type) - - BOOST_SPIRIT_DECLARE(atomic_formula_of_terms_type, atom_type, negated_atom_type, literal_type) - - BOOST_SPIRIT_DECLARE(multi_operator_mul_type, multi_operator_plus_type, multi_operator_type, - binary_operator_minus_type, binary_operator_div_type, binary_operator_type) - - BOOST_SPIRIT_DECLARE(binary_comparator_greater_type, binary_comparator_less_type, - binary_comparator_equal_type, binary_comparator_greater_equal_type, - binary_comparator_less_equal_type, binary_comparator_type) - - BOOST_SPIRIT_DECLARE(function_expression_type, function_head_type, function_expression_number_type, - function_expression_number_type, function_expression_binary_op_type, - function_expression_minus_type, function_expression_head_type) - - BOOST_SPIRIT_DECLARE(goal_descriptor_type, goal_descriptor_atom_type, goal_descriptor_literal_type, - goal_descriptor_and_type, goal_descriptor_or_type, goal_descriptor_not_type, - goal_descriptor_imply_type, goal_descriptor_exists_type, goal_descriptor_forall_type, - goal_descriptor_function_comparison_type) - - BOOST_SPIRIT_DECLARE(constraint_goal_descriptor_type, constraint_goal_descriptor_and_type, - constraint_goal_descriptor_forall_type, constraint_goal_descriptor_at_end_type, - constraint_goal_descriptor_always_type, constraint_goal_descriptor_sometime_type, - constraint_goal_descriptor_within_type, constraint_goal_descriptor_at_most_once_type, - constraint_goal_descriptor_sometime_after_type, constraint_goal_descriptor_sometime_before_type, - constraint_goal_descriptor_always_within_type, constraint_goal_descriptor_hold_during_type, - constraint_goal_descriptor_hold_after_type) - - BOOST_SPIRIT_DECLARE(precondition_goal_descriptor_type, preference_name_type, - precondition_goal_descriptor_simple_type, precondition_goal_descriptor_and_type, - precondition_goal_descriptor_preference_type, precondition_goal_descriptor_forall_type) - - BOOST_SPIRIT_DECLARE(assign_operator_assign_type, assign_operator_scale_up_type, assign_operator_scale_down_type, - assign_operator_increase_type, assign_operator_decrease_type, assign_operator_type) - - BOOST_SPIRIT_DECLARE(numeric_term_type) - - BOOST_SPIRIT_DECLARE(effect_type, effect_production_literal_type, - effect_production_numeric_fluent_total_cost_type, effect_production_numeric_fluent_general_type, - effect_production_type, effect_conditional_forall_type, - effect_conditional_when_type, effect_conditional_type, action_symbol_type, action_body_type, action_type, - derived_predicate_type) - - - BOOST_SPIRIT_DECLARE(domain_name_type, requirements_type, - types_type, constants_type, predicates_type, functions_type, constraints_type, structure_type) - } - - inline auto separator() { - return (ascii::space | x3::eol | x3::eoi | lit('(') | lit(')')); // TODO: is ) correct? - } - - /// @brief Matches a keyword - inline auto keyword_lit(const std::string& keyword) { - return lit(keyword) >> no_skip[&separator()]; - } - - /// @brief Synthesizes a keyword string - inline auto keyword_string(const std::string& keyword) { - return string(keyword) >> no_skip[&separator()]; - } - - parser::define_keyword_type const& define_keyword(); - parser::domain_keyword_type const& domain_keyword(); - - parser::name_type const& name(); - parser::variable_type const& variable(); - parser::number_type const& number(); - parser::name_total_cost_type const& name_total_cost(); - parser::function_symbol_total_cost_type const& function_symbol_total_cost(); - parser::function_symbol_type const& function_symbol(); - parser::term_type const& term(); - parser::predicate_type const& predicate(); - - parser::requirement_strips_type const& requirement_strips(); - parser::requirement_typing_type const& requirement_typing(); - parser::requirement_negative_preconditions_type const& requirement_negative_preconditions(); - parser::requirement_disjunctive_preconditions_type const& requirement_disjunctive_preconditions(); - parser::requirement_equality_type const& requirement_equality(); - parser::requirement_existential_preconditions_type const& requirement_existential_preconditions(); - parser::requirement_universal_preconditions_type const& requirement_universal_preconditions(); - parser::requirement_quantified_preconditions_type const& requirement_quantified_preconditions(); - parser::requirement_conditional_effects_type const& requirement_conditional_effects(); - parser::requirement_fluents_type const& requirement_fluents(); - parser::requirement_object_fluents_type const& requirement_object_fluents(); - parser::requirement_numeric_fluents_type const& requirement_numeric_fluents(); - parser::requirement_adl_type const& requirement_adl(); - parser::requirement_durative_actions_type const& requirement_durative_actions(); - parser::requirement_derived_predicates_type const& requirement_derived_predicates(); - parser::requirement_timed_initial_literals_type const& requirement_timed_initial_literals(); - parser::requirement_preferences_type const& requirement_preferences(); - parser::requirement_constraints_type const& requirement_constraints(); - parser::requirement_action_costs_type const& requirement_action_costs(); - parser::requirement_type const& requirement(); - - parser::type_type const& type(); - parser::type_object_type const& type_object(); - parser::type_number_type const& type_number(); - parser::type_either_type const& type_either(); - parser::typed_list_of_names_recursively_type const& typed_list_of_names_recursively(); - parser::typed_list_of_names_type const& typed_list_of_names(); - parser::typed_list_of_variables_recursively_type const& typed_list_of_variables_recursively(); - parser::typed_list_of_variables_type const& typed_list_of_variables(); - - parser::atomic_formula_skeleton_type const& atomic_formula_skeleton(); - - parser::multi_operator_mul_type const& multi_operator_mul(); - parser::multi_operator_plus_type const& multi_operator_plus(); - parser::multi_operator_type const& multi_operator(); - parser::binary_operator_minus_type const& binary_operator_minus(); - parser::binary_operator_div_type const& binary_operator_div(); - parser::binary_operator_type const& binary_operator(); - - parser::binary_comparator_greater_type const& binary_comparator_greater(); - parser::binary_comparator_less_type const& binary_comparator_less(); - parser::binary_comparator_equal_type const& binary_comparator_equal(); - parser::binary_comparator_greater_equal_type const& binary_comparator_greater_equal(); - parser::binary_comparator_less_equal_type const& binary_comparator_less_equal(); - parser::binary_comparator_type const& binary_comparator(); - - parser::atomic_function_skeleton_total_cost_type const& atomic_function_skeleton_total_cost(); - parser::atomic_function_skeleton_general_type const& atomic_function_skeleton_general(); - parser::atomic_function_skeleton_type const& atomic_function_skeleton(); - parser::function_typed_list_of_atomic_function_skeletons_recursively_type const& function_typed_list_of_atomic_function_skeletons_recursively(); - parser::function_typed_list_of_atomic_function_skeletons_type const& function_typed_list_of_atomic_function_skeletons(); - - parser::atomic_formula_of_terms_predicate_type const& atomic_formula_of_terms_predicate(); - parser::atomic_formula_of_terms_equality_type const& atomic_formula_of_terms_equality(); - parser::atomic_formula_of_terms_type const& atomic_formula_of_terms(); - parser::atom_type const& atom(); - parser::negated_atom_type const& negated_atom(); - parser::literal_type const& literal(); - - parser::function_expression_type const& function_expression(); - parser::function_head_type const& function_head(); - parser::function_expression_number_type const& function_expression_number(); - parser::function_expression_binary_op_type const& function_expression_binary_op(); - parser::function_expression_minus_type const& function_expression_minus(); - parser::function_expression_head_type const& function_expression_head(); - - parser::goal_descriptor_type const& goal_descriptor(); - parser::goal_descriptor_atom_type const& goal_descriptor_atom(); - parser::goal_descriptor_literal_type const& goal_descriptor_literal(); - parser::goal_descriptor_and_type const& goal_descriptor_and(); - parser::goal_descriptor_or_type const& goal_descriptor_or(); - parser::goal_descriptor_not_type const& goal_descriptor_not(); - parser::goal_descriptor_imply_type const& goal_descriptor_imply(); - parser::goal_descriptor_exists_type const& goal_descriptor_exists(); - parser::goal_descriptor_forall_type const& goal_descriptor_forall(); - parser::goal_descriptor_function_comparison_type const& goal_descriptor_function_comparison(); - - parser::constraint_goal_descriptor_type const& constraint_goal_descriptor(); - parser::constraint_goal_descriptor_and_type const& constraint_goal_descriptor_and(); - parser::constraint_goal_descriptor_forall_type const& constraint_goal_descriptor_forall(); - parser::constraint_goal_descriptor_at_end_type const& constraint_goal_descriptor_at_end(); - parser::constraint_goal_descriptor_always_type const& constraint_goal_descriptor_always(); - parser::constraint_goal_descriptor_sometime_type const& constraint_goal_descriptor_sometime(); - parser::constraint_goal_descriptor_within_type const& constraint_goal_descriptor_within(); - parser::constraint_goal_descriptor_at_most_once_type const& constraint_goal_descriptor_at_most_once(); - parser::constraint_goal_descriptor_sometime_after_type const& constraint_goal_descriptor_sometime_after(); - parser::constraint_goal_descriptor_sometime_before_type const& constraint_goal_descriptor_sometime_before(); - parser::constraint_goal_descriptor_always_within_type const& constraint_goal_descriptor_always_within(); - parser::constraint_goal_descriptor_hold_during_type const& constraint_goal_descriptor_hold_during(); - parser::constraint_goal_descriptor_hold_after_type const& constraint_goal_descriptor_hold_after(); - - parser::precondition_goal_descriptor_type const& precondition_goal_descriptor(); - parser::preference_name_type const& preference_name(); - parser::precondition_goal_descriptor_simple_type const& precondition_goal_descriptor_simple(); - parser::precondition_goal_descriptor_and_type const& precondition_goal_descriptor_and(); - parser::precondition_goal_descriptor_preference_type const& precondition_goal_descriptor_preference(); - parser::precondition_goal_descriptor_forall_type const& precondition_goal_descriptor_forall(); - - parser::assign_operator_assign_type const& assign_operator_assign(); - parser::assign_operator_scale_up_type const& assign_operator_scale_up(); - parser::assign_operator_scale_down_type const& assign_operator_scale_down(); - parser::assign_operator_increase_type const& assign_operator_increase(); - parser::assign_operator_decrease_type const& assign_operator_decrease(); - parser::assign_operator_type const& assign_operator(); - - parser::numeric_term_type const& numeric_term(); - - parser::effect_type const& effect(); - parser::effect_production_literal_type const& effect_production_literal(); - parser::effect_production_numeric_fluent_total_cost_type const& effect_production_numeric_fluent_total_cost(); - parser::effect_production_numeric_fluent_general_type const& effect_production_numeric_fluent_general(); - parser::effect_production_type const& effect_production(); - parser::effect_conditional_forall_type const& effect_conditional_forall(); - parser::effect_conditional_when_type const& effect_conditional_when(); - parser::effect_conditional_type const& effect_conditional(); - parser::action_symbol_type const& action_symbol(); - parser::action_body_type const& action_body(); - parser::action_type const& action(); - parser::derived_predicate_type const& derived_predicate(); - - parser::domain_name_type const& domain_name(); - parser::requirements_type const& requirements(); - parser::types_type const& types(); - parser::constants_type const& constants(); - parser::predicates_type const& predicates(); - parser::functions_type const& functions(); - parser::constraints_type const& constraints(); - parser::structure_type const& structure(); +/// @brief Matches a keyword +inline auto keyword_lit(const std::string& keyword) { return lit(keyword) >> no_skip[&separator()]; } + +/// @brief Synthesizes a keyword string +inline auto keyword_string(const std::string& keyword) { return string(keyword) >> no_skip[&separator()]; } + +parser::define_keyword_type const& define_keyword(); +parser::domain_keyword_type const& domain_keyword(); + +parser::name_type const& name(); +parser::variable_type const& variable(); +parser::number_type const& number(); +parser::name_total_cost_type const& name_total_cost(); +parser::function_symbol_total_cost_type const& function_symbol_total_cost(); +parser::function_symbol_type const& function_symbol(); +parser::term_type const& term(); +parser::predicate_type const& predicate(); + +parser::requirement_strips_type const& requirement_strips(); +parser::requirement_typing_type const& requirement_typing(); +parser::requirement_negative_preconditions_type const& requirement_negative_preconditions(); +parser::requirement_disjunctive_preconditions_type const& requirement_disjunctive_preconditions(); +parser::requirement_equality_type const& requirement_equality(); +parser::requirement_existential_preconditions_type const& requirement_existential_preconditions(); +parser::requirement_universal_preconditions_type const& requirement_universal_preconditions(); +parser::requirement_quantified_preconditions_type const& requirement_quantified_preconditions(); +parser::requirement_conditional_effects_type const& requirement_conditional_effects(); +parser::requirement_fluents_type const& requirement_fluents(); +parser::requirement_object_fluents_type const& requirement_object_fluents(); +parser::requirement_numeric_fluents_type const& requirement_numeric_fluents(); +parser::requirement_adl_type const& requirement_adl(); +parser::requirement_durative_actions_type const& requirement_durative_actions(); +parser::requirement_derived_predicates_type const& requirement_derived_predicates(); +parser::requirement_timed_initial_literals_type const& requirement_timed_initial_literals(); +parser::requirement_preferences_type const& requirement_preferences(); +parser::requirement_constraints_type const& requirement_constraints(); +parser::requirement_action_costs_type const& requirement_action_costs(); +parser::requirement_type const& requirement(); + +parser::type_type const& type(); +parser::type_object_type const& type_object(); +parser::type_number_type const& type_number(); +parser::type_either_type const& type_either(); +parser::typed_list_of_names_recursively_type const& typed_list_of_names_recursively(); +parser::typed_list_of_names_type const& typed_list_of_names(); +parser::typed_list_of_variables_recursively_type const& typed_list_of_variables_recursively(); +parser::typed_list_of_variables_type const& typed_list_of_variables(); + +parser::atomic_formula_skeleton_type const& atomic_formula_skeleton(); + +parser::multi_operator_mul_type const& multi_operator_mul(); +parser::multi_operator_plus_type const& multi_operator_plus(); +parser::multi_operator_type const& multi_operator(); +parser::binary_operator_minus_type const& binary_operator_minus(); +parser::binary_operator_div_type const& binary_operator_div(); +parser::binary_operator_type const& binary_operator(); + +parser::binary_comparator_greater_type const& binary_comparator_greater(); +parser::binary_comparator_less_type const& binary_comparator_less(); +parser::binary_comparator_equal_type const& binary_comparator_equal(); +parser::binary_comparator_greater_equal_type const& binary_comparator_greater_equal(); +parser::binary_comparator_less_equal_type const& binary_comparator_less_equal(); +parser::binary_comparator_type const& binary_comparator(); + +parser::atomic_function_skeleton_total_cost_type const& atomic_function_skeleton_total_cost(); +parser::atomic_function_skeleton_general_type const& atomic_function_skeleton_general(); +parser::atomic_function_skeleton_type const& atomic_function_skeleton(); +parser::function_typed_list_of_atomic_function_skeletons_recursively_type const& function_typed_list_of_atomic_function_skeletons_recursively(); +parser::function_typed_list_of_atomic_function_skeletons_type const& function_typed_list_of_atomic_function_skeletons(); + +parser::atomic_formula_of_terms_predicate_type const& atomic_formula_of_terms_predicate(); +parser::atomic_formula_of_terms_equality_type const& atomic_formula_of_terms_equality(); +parser::atomic_formula_of_terms_type const& atomic_formula_of_terms(); +parser::atom_type const& atom(); +parser::negated_atom_type const& negated_atom(); +parser::literal_type const& literal(); + +parser::function_expression_type const& function_expression(); +parser::function_head_type const& function_head(); +parser::function_expression_number_type const& function_expression_number(); +parser::function_expression_binary_op_type const& function_expression_binary_op(); +parser::function_expression_minus_type const& function_expression_minus(); +parser::function_expression_head_type const& function_expression_head(); + +parser::goal_descriptor_type const& goal_descriptor(); +parser::goal_descriptor_atom_type const& goal_descriptor_atom(); +parser::goal_descriptor_literal_type const& goal_descriptor_literal(); +parser::goal_descriptor_and_type const& goal_descriptor_and(); +parser::goal_descriptor_or_type const& goal_descriptor_or(); +parser::goal_descriptor_not_type const& goal_descriptor_not(); +parser::goal_descriptor_imply_type const& goal_descriptor_imply(); +parser::goal_descriptor_exists_type const& goal_descriptor_exists(); +parser::goal_descriptor_forall_type const& goal_descriptor_forall(); +parser::goal_descriptor_function_comparison_type const& goal_descriptor_function_comparison(); + +parser::constraint_goal_descriptor_type const& constraint_goal_descriptor(); +parser::constraint_goal_descriptor_and_type const& constraint_goal_descriptor_and(); +parser::constraint_goal_descriptor_forall_type const& constraint_goal_descriptor_forall(); +parser::constraint_goal_descriptor_at_end_type const& constraint_goal_descriptor_at_end(); +parser::constraint_goal_descriptor_always_type const& constraint_goal_descriptor_always(); +parser::constraint_goal_descriptor_sometime_type const& constraint_goal_descriptor_sometime(); +parser::constraint_goal_descriptor_within_type const& constraint_goal_descriptor_within(); +parser::constraint_goal_descriptor_at_most_once_type const& constraint_goal_descriptor_at_most_once(); +parser::constraint_goal_descriptor_sometime_after_type const& constraint_goal_descriptor_sometime_after(); +parser::constraint_goal_descriptor_sometime_before_type const& constraint_goal_descriptor_sometime_before(); +parser::constraint_goal_descriptor_always_within_type const& constraint_goal_descriptor_always_within(); +parser::constraint_goal_descriptor_hold_during_type const& constraint_goal_descriptor_hold_during(); +parser::constraint_goal_descriptor_hold_after_type const& constraint_goal_descriptor_hold_after(); + +parser::precondition_goal_descriptor_type const& precondition_goal_descriptor(); +parser::preference_name_type const& preference_name(); +parser::precondition_goal_descriptor_simple_type const& precondition_goal_descriptor_simple(); +parser::precondition_goal_descriptor_and_type const& precondition_goal_descriptor_and(); +parser::precondition_goal_descriptor_preference_type const& precondition_goal_descriptor_preference(); +parser::precondition_goal_descriptor_forall_type const& precondition_goal_descriptor_forall(); + +parser::assign_operator_assign_type const& assign_operator_assign(); +parser::assign_operator_scale_up_type const& assign_operator_scale_up(); +parser::assign_operator_scale_down_type const& assign_operator_scale_down(); +parser::assign_operator_increase_type const& assign_operator_increase(); +parser::assign_operator_decrease_type const& assign_operator_decrease(); +parser::assign_operator_type const& assign_operator(); + +parser::numeric_term_type const& numeric_term(); + +parser::effect_type const& effect(); +parser::effect_production_literal_type const& effect_production_literal(); +parser::effect_production_numeric_fluent_total_cost_type const& effect_production_numeric_fluent_total_cost(); +parser::effect_production_numeric_fluent_general_type const& effect_production_numeric_fluent_general(); +parser::effect_production_type const& effect_production(); +parser::effect_conditional_forall_type const& effect_conditional_forall(); +parser::effect_conditional_when_type const& effect_conditional_when(); +parser::effect_conditional_type const& effect_conditional(); +parser::action_symbol_type const& action_symbol(); +parser::action_body_type const& action_body(); +parser::action_type const& action(); +parser::derived_predicate_type const& derived_predicate(); + +parser::domain_name_type const& domain_name(); +parser::requirements_type const& requirements(); +parser::types_type const& types(); +parser::constants_type const& constants(); +parser::predicates_type const& predicates(); +parser::functions_type const& functions(); +parser::constraints_type const& constraints(); +parser::structure_type const& structure(); } diff --git a/src/domain/ast/parser_def.hpp b/src/domain/ast/parser_def.hpp index c4c0fcb2..d99b1e6e 100644 --- a/src/domain/ast/parser_def.hpp +++ b/src/domain/ast/parser_def.hpp @@ -21,956 +21,1030 @@ #include "ast_adapted.hpp" #include "parser.hpp" +#include +#include #include #include #include #include -#include -#include +namespace loki::domain::parser +{ +namespace x3 = boost::spirit::x3; +namespace ascii = boost::spirit::x3::ascii; + +using x3::double_; +using x3::eps; +using x3::int_; +using x3::lexeme; +using x3::lit; +using x3::no_skip; +using x3::raw; +using x3::string; + +using ascii::alnum; +using ascii::alpha; +using ascii::char_; +using ascii::space; + +/////////////////////////////////////////////////////////////////////////// +// Rule IDs +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// Rules +/////////////////////////////////////////////////////////////////////////// + +define_keyword_type const define_keyword = "define"; +domain_keyword_type const domain_keyword = "domain"; + +name_type const name = "name"; +variable_type const variable = "variable"; +name_total_cost_type const name_total_cost = "name_total_cost"; +function_symbol_total_cost_type const function_symbol_total_cost = "function_symbol_total_cost"; +function_symbol_type const function_symbol = "function_symbol"; +term_type const term = "term"; +number_type const number = "number"; +predicate_type const predicate = "predicate"; + +requirement_strips_type const requirement_strips = "requirement_strips"; +requirement_typing_type const requirement_typing = "requirement_typing"; +requirement_negative_preconditions_type const requirement_negative_preconditions = "requirement_negative_preconditions"; +requirement_disjunctive_preconditions_type const requirement_disjunctive_preconditions = "requirement_disjunctive_preconditions"; +requirement_equality_type const requirement_equality = "requirement_equality"; +requirement_existential_preconditions_type const requirement_existential_preconditions = "requirement_existential_preconditions"; +requirement_universal_preconditions_type const requirement_universal_preconditions = "requirement_universal_preconditions"; +requirement_quantified_preconditions_type const requirement_quantified_preconditions = "requirement_quantified_preconditions"; +requirement_conditional_effects_type const requirement_conditional_effects = "requirement_conditional_effects"; +requirement_fluents_type const requirement_fluents = "requirement_fluents"; +requirement_object_fluents_type const requirement_object_fluents = "requirement_object_fluents"; +requirement_numeric_fluents_type const requirement_numeric_fluents = "requirement_numeric_fluents"; +requirement_adl_type const requirement_adl = "requirement_adl"; +requirement_durative_actions_type const requirement_durative_actions = "requirement_durative_actions"; +requirement_derived_predicates_type const requirement_derived_predicates = "requirement_derived_predicates"; +requirement_timed_initial_literals_type const requirement_timed_initial_literals = "requirement_timed_initial_literals"; +requirement_preferences_type const requirement_preferences = "requirement_preferences"; +requirement_constraints_type const requirement_constraints = "requirement_constraints"; +requirement_action_costs_type const requirement_action_costs = "requirement_action_costs"; +requirement_type const requirement = "requirement"; + +type_type const type = "type"; +type_object_type const type_object = "type_object"; +type_number_type const type_number = "type_number"; +type_either_type const type_either = "type_either"; +typed_list_of_names_recursively_type const typed_list_of_names_recursively = "typed_list_of_names_recursively"; +typed_list_of_names_type const typed_list_of_names = "typed_list_of_names"; +typed_list_of_variables_recursively_type const typed_list_of_variables_recursively = "typed_list_of_variables_recursively"; +typed_list_of_variables_type const typed_list_of_variables = "typed_list_of_variables"; + +atomic_formula_skeleton_type const atomic_formula_skeleton = "atomic_formula_skeleton"; + +atomic_function_skeleton_total_cost_type const atomic_function_skeleton_total_cost = "atomic_function_skeleton_total_cost"; +atomic_function_skeleton_general_type const atomic_function_skeleton_general = "atomic_function_skeleton_general"; +atomic_function_skeleton_type const atomic_function_skeleton = "atomic_function_skeleton"; +function_typed_list_of_atomic_function_skeletons_recursively_type const function_typed_list_of_atomic_function_skeletons_recursively = + "function_typed_list_of_atomic_function_skeletons_recursively"; +function_typed_list_of_atomic_function_skeletons_type const function_typed_list_of_atomic_function_skeletons = + "function_typed_list_of_atomic_function_skeletons"; + +atomic_formula_of_terms_predicate_type const atomic_formula_of_terms_predicate = "atomic_formula_of_terms_predicate"; +atomic_formula_of_terms_equality_type const atomic_formula_of_terms_equality = "atomic_formula_of_terms_equality"; +atomic_formula_of_terms_type const atomic_formula_of_terms = "atomic_formula_of_terms"; +atom_type const atom = "atom"; +negated_atom_type const negated_atom = "negated_atom"; +literal_type const literal = "literal"; + +multi_operator_mul_type const multi_operator_mul = "multi_operator_mul"; +multi_operator_plus_type const multi_operator_plus = "multi_operator_plus"; +multi_operator_type const multi_operator = "multi_operator"; +binary_operator_minus_type const binary_operator_minus = "binary_operator_minus"; +binary_operator_div_type const binary_operator_div = "binary_operator_div"; +binary_operator_type const binary_operator = "binary_operator"; + +binary_comparator_greater_type const binary_comparator_greater = "binary_comparator_greater"; +binary_comparator_less_type const binary_comparator_less = "binary_comparator_less"; +binary_comparator_equal_type const binary_comparator_equal = "binary_comparator_equal"; +binary_comparator_greater_equal_type const binary_comparator_greater_equal = "binary_comparator_greater_equal"; +binary_comparator_less_equal_type const binary_comparator_less_equal = "binary_comparator_less_equal"; +binary_comparator_type const binary_comparator = "binary_comparator"; + +function_expression_type const function_expression = "function_expression"; +function_head_type const function_head = "function_head"; +function_expression_number_type const function_expression_number = "function_expression_number"; +function_expression_binary_op_type const function_expression_binary_op = "function_expression_binary_op"; +function_expression_minus_type const function_expression_minus = "function_expression_minus"; +function_expression_head_type const function_expression_head = "function_expression_head"; + +goal_descriptor_type const goal_descriptor = "goal_descriptor"; +goal_descriptor_atom_type const goal_descriptor_atom = "goal_descriptor_atom"; +goal_descriptor_literal_type const goal_descriptor_literal = "goal_descriptor_literal"; +goal_descriptor_and_type const goal_descriptor_and = "goal_descriptor_and"; +goal_descriptor_or_type const goal_descriptor_or = "goal_descriptor_or"; +goal_descriptor_not_type const goal_descriptor_not = "goal_descriptor_not"; +goal_descriptor_imply_type const goal_descriptor_imply = "goal_descriptor_imply"; +goal_descriptor_exists_type const goal_descriptor_exists = "goal_descriptor_exists"; +goal_descriptor_forall_type const goal_descriptor_forall = "goal_descriptor_forall"; +goal_descriptor_function_comparison_type const goal_descriptor_function_comparison = "goal_descriptor_function_comparison"; + +constraint_goal_descriptor_type const constraint_goal_descriptor = "constraint_goal_descriptor"; +constraint_goal_descriptor_and_type const constraint_goal_descriptor_and = "constraint_goal_descriptor_and"; +constraint_goal_descriptor_forall_type const constraint_goal_descriptor_forall = "constraint_goal_descriptor_forall"; +constraint_goal_descriptor_at_end_type const constraint_goal_descriptor_at_end = "constraint_goal_descriptor_at_end"; +constraint_goal_descriptor_always_type const constraint_goal_descriptor_always = "constraint_goal_descriptor_always"; +constraint_goal_descriptor_sometime_type const constraint_goal_descriptor_sometime = "constraint_goal_descriptor_sometime"; +constraint_goal_descriptor_within_type const constraint_goal_descriptor_within = "constraint_goal_descriptor_within"; +constraint_goal_descriptor_at_most_once_type const constraint_goal_descriptor_at_most_once = "constraint_goal_descriptor_at_most_once"; +constraint_goal_descriptor_sometime_after_type const constraint_goal_descriptor_sometime_after = "constraint_goal_descriptor_sometime_after"; +constraint_goal_descriptor_sometime_before_type const constraint_goal_descriptor_sometime_before = "constraint_goal_descriptor_sometime_before"; +constraint_goal_descriptor_always_within_type const constraint_goal_descriptor_always_within = "constraint_goal_descriptor_always_within"; +constraint_goal_descriptor_hold_during_type const constraint_goal_descriptor_hold_during = "constraint_goal_descriptor_hold_during"; +constraint_goal_descriptor_hold_after_type const constraint_goal_descriptor_hold_after = "constraint_goal_descriptor_hold_after"; + +precondition_goal_descriptor_type const precondition_goal_descriptor = "precondition_goal_descriptor"; +preference_name_type const preference_name = "preference_name"; +precondition_goal_descriptor_simple_type const precondition_goal_descriptor_simple = "precondition_goal_descriptor_simple"; +precondition_goal_descriptor_and_type const precondition_goal_descriptor_and = "precondition_goal_descriptor_and"; +precondition_goal_descriptor_preference_type const precondition_goal_descriptor_preference = "precondition_goal_descriptor_preference"; +precondition_goal_descriptor_forall_type const precondition_goal_descriptor_forall = "precondition_goal_descriptor_forall"; + +assign_operator_assign_type const assign_operator_assign = "assign_operator_assign"; +assign_operator_scale_up_type const assign_operator_scale_up = "assign_operator_scale_up"; +assign_operator_scale_down_type const assign_operator_scale_down = "assign_operator_scale_down"; +assign_operator_increase_type const assign_operator_increase = "assign_operator_increase"; +assign_operator_decrease_type const assign_operator_decrease = "assign_operator_decrease"; +assign_operator_type const assign_operator = "assign_operator"; + +numeric_term_type const numeric_term = "numeric_term"; + +effect_type const effect = "effect"; +effect_production_literal_type const effect_production_literal = "effect_production_literal"; +effect_production_numeric_fluent_total_cost_type const effect_production_numeric_fluent_total_cost = "effect_production_numeric_fluent_total_cost"; +effect_production_numeric_fluent_general_type const effect_production_numeric_fluent_general = "effect_production_numeric_fluent_general"; +effect_production_type const effect_production = "effect_production"; +effect_conditional_forall_type const effect_conditional_forall = "effect_conditional_forall"; +effect_conditional_when_type const effect_conditional_when = "effect_conditional_when"; +effect_conditional_type const effect_conditional = "effect_conditional"; +action_symbol_type const action_symbol = "action_symbol"; +action_body_type const action_body = "action_body"; +action_type const action = "action"; +derived_predicate_type const derived_predicate = "derived_predicate"; + +domain_name_type const domain_name = "domain_name"; +requirements_type const requirements = "requirements"; +types_type const types = "types"; +constants_type const constants = "constants"; +predicates_type const predicates = "predicates"; +functions_type const functions = "functions"; +constraints_type const constraints = "constraints"; +structure_type const structure = "structure"; +domain_type const domain = "domain"; + +/////////////////////////////////////////////////////////////////////////// +// Grammar +/////////////////////////////////////////////////////////////////////////// + +const auto name_def = raw[lexeme[alpha >> *(alnum | char_('-') | char_('_'))]]; +const auto variable_def = raw[lexeme[char_('?') > name]]; +const auto name_total_cost_def = keyword_string("total-cost"); +const auto function_symbol_total_cost_def = name_total_cost; +const auto function_symbol_def = name; +const auto term_def = name | variable; +const auto number_def = double_; +const auto predicate_def = name; + +const auto requirement_strips_def = keyword_lit(":strips") > x3::attr(ast::RequirementStrips {}); +const auto requirement_typing_def = keyword_lit(":typing") > x3::attr(ast::RequirementTyping {}); +const auto requirement_negative_preconditions_def = keyword_lit(":negative-preconditions") > x3::attr(ast::RequirementNegativePreconditions {}); +const auto requirement_disjunctive_preconditions_def = keyword_lit(":disjunctive-preconditions") > x3::attr(ast::RequirementDisjunctivePreconditions {}); +const auto requirement_equality_def = keyword_lit(":equality") > x3::attr(ast::RequirementEquality {}); +const auto requirement_existential_preconditions_def = keyword_lit(":existential-preconditions") > x3::attr(ast::RequirementExistentialPreconditions {}); +const auto requirement_universal_preconditions_def = keyword_lit(":universal-preconditions") > x3::attr(ast::RequirementUniversalPreconditions {}); +const auto requirement_quantified_preconditions_def = keyword_lit(":quantified-preconditions") > x3::attr(ast::RequirementQuantifiedPreconditions {}); +const auto requirement_conditional_effects_def = keyword_lit(":conditional-effects") > x3::attr(ast::RequirementConditionalEffects {}); +const auto requirement_fluents_def = keyword_lit(":fluents") >> x3::attr(ast::RequirementFluents {}); +const auto requirement_object_fluents_def = keyword_lit(":object-fluents") > x3::attr(ast::RequirementObjectFluents {}); +const auto requirement_numeric_fluents_def = keyword_lit(":numeric-fluents") > x3::attr(ast::RequirementNumericFluents {}); +const auto requirement_adl_def = keyword_lit(":adl") >> x3::attr(ast::RequirementAdl {}); +const auto requirement_durative_actions_def = keyword_lit(":durative-actions") > x3::attr(ast::RequirementDurativeActions {}); +const auto requirement_derived_predicates_def = keyword_lit(":derived-predicates") > x3::attr(ast::RequirementDerivedPredicates {}); +const auto requirement_timed_initial_literals_def = keyword_lit(":timed-initial-literals") > x3::attr(ast::RequirementTimedInitialLiterals {}); +const auto requirement_preferences_def = keyword_lit(":preferences") > x3::attr(ast::RequirementPreferences {}); +const auto requirement_constraints_def = keyword_lit(":constraints") > x3::attr(ast::RequirementConstraints {}); +const auto requirement_action_costs_def = keyword_lit(":action-costs") > x3::attr(ast::RequirementActionCosts {}); +const auto requirement_def = requirement_strips | requirement_typing | requirement_negative_preconditions | requirement_disjunctive_preconditions + | requirement_equality | requirement_existential_preconditions | requirement_universal_preconditions + | requirement_quantified_preconditions | requirement_conditional_effects | requirement_fluents | requirement_object_fluents + | requirement_numeric_fluents | requirement_adl | requirement_durative_actions | requirement_derived_predicates + | requirement_timed_initial_literals | requirement_preferences | requirement_constraints | requirement_action_costs; + +const auto type_def = type_object | type_number | type_either | name; +const auto type_object_def = keyword_lit("object") > x3::attr(ast::TypeObject {}); +const auto type_number_def = keyword_lit("number") > x3::attr(ast::TypeNumber {}); +const auto type_either_def = (lit('(') >> keyword_lit("either") > +type) > lit(')'); +const auto typed_list_of_names_recursively_def = (+name >> lit('-')) > type > typed_list_of_names; +const auto typed_list_of_names_def = typed_list_of_names_recursively | *name; +const auto typed_list_of_variables_recursively_def = (+variable >> lit('-')) > type > typed_list_of_variables; +const auto typed_list_of_variables_def = typed_list_of_variables_recursively | *variable; + +const auto atomic_formula_skeleton_def = lit('(') > predicate > typed_list_of_variables > lit(')'); + +const auto atomic_function_skeleton_total_cost_def = lit('(') >> function_symbol_total_cost > lit(')'); +const auto atomic_function_skeleton_general_def = lit('(') > function_symbol > typed_list_of_variables > lit(')'); +const auto atomic_function_skeleton_def = atomic_function_skeleton_total_cost | atomic_function_skeleton_general; +const auto function_typed_list_of_atomic_function_skeletons_recursively_def = + (+atomic_function_skeleton >> lit('-')) > type_number > -function_typed_list_of_atomic_function_skeletons; +const auto function_typed_list_of_atomic_function_skeletons_def = function_typed_list_of_atomic_function_skeletons_recursively | *atomic_function_skeleton; + +const auto atomic_formula_of_terms_predicate_def = (lit('(') >> predicate) > *term > lit(')'); +const auto atomic_formula_of_terms_equality_def = (lit('(') >> lit('=')) >> term > term > lit(')'); +const auto atomic_formula_of_terms_def = atomic_formula_of_terms_equality | atomic_formula_of_terms_predicate; +const auto atom_def = atomic_formula_of_terms; +const auto negated_atom_def = (lit('(') >> keyword_lit("not")) > atomic_formula_of_terms > lit(')'); +const auto literal_def = negated_atom | atom; + +const auto multi_operator_mul_def = lit('*') > x3::attr(ast::MultiOperatorMul {}); +const auto multi_operator_plus_def = lit('+') > x3::attr(ast::MultiOperatorPlus {}); +const auto multi_operator_def = multi_operator_mul | multi_operator_plus; +const auto binary_operator_minus_def = lit('-') > x3::attr(ast::BinaryOperatorMinus {}); +const auto binary_operator_div_def = lit('/') > x3::attr(ast::BinaryOperatorDiv {}); +const auto binary_operator_def = binary_operator_minus | binary_operator_div | multi_operator; + +const auto binary_comparator_greater_def = lit('>') > x3::attr(ast::BinaryComparatorGreater {}); +const auto binary_comparator_less_def = lit('<') > x3::attr(ast::BinaryComparatorLess {}); +const auto binary_comparator_equal_def = lit('=') > x3::attr(ast::BinaryComparatorEqual {}); +const auto binary_comparator_greater_equal_def = lit(">=") > x3::attr(ast::BinaryComparatorGreaterEqual {}); +const auto binary_comparator_less_equal_def = lit("<=") > x3::attr(ast::BinaryComparatorLessEqual {}); +const auto binary_comparator_def = + binary_comparator_greater | binary_comparator_less | binary_comparator_equal | binary_comparator_greater_equal | binary_comparator_less_equal; + +const auto function_head_def = ((lit('(') >> function_symbol > *term) > lit(')')) | (function_symbol > x3::attr(std::vector {})); +const auto function_expression_def = function_expression_binary_op | function_expression_minus | function_expression_head | function_expression_number; +const auto function_expression_number_def = number; +// distinguishing unary from binary minus requires some more backtracking +const auto function_expression_binary_op_def = (lit('(') >> binary_operator >> function_expression >> function_expression) > lit(')'); +const auto function_expression_minus_def = (lit('(') >> lit('-')) >> function_expression > lit(')'); +const auto function_expression_head_def = function_head; + +const auto goal_descriptor_def = goal_descriptor_not | goal_descriptor_and | goal_descriptor_or | goal_descriptor_imply | goal_descriptor_exists + | goal_descriptor_forall | goal_descriptor_function_comparison | goal_descriptor_atom | goal_descriptor_literal; +const auto goal_descriptor_atom_def = atom; +const auto goal_descriptor_literal_def = literal; +const auto goal_descriptor_and_def = (lit('(') >> keyword_lit("and")) > *goal_descriptor > lit(')'); +const auto goal_descriptor_or_def = (lit('(') >> keyword_lit("or") > *goal_descriptor) > lit(')'); +const auto goal_descriptor_not_def = (lit('(') >> keyword_lit("not")) > goal_descriptor > lit(')'); +const auto goal_descriptor_imply_def = (lit('(') >> keyword_lit("imply")) > goal_descriptor > goal_descriptor > lit(')'); +const auto goal_descriptor_exists_def = (lit('(') >> keyword_lit("exists")) > lit('(') > typed_list_of_variables > lit(')') > goal_descriptor > lit(')'); +const auto goal_descriptor_forall_def = (lit('(') >> keyword_lit("forall")) > lit('(') > typed_list_of_variables > lit(')') > goal_descriptor > lit(')'); +const auto goal_descriptor_function_comparison_def = (lit('(') >> binary_comparator) >> function_expression > function_expression > lit(')'); + +const auto constraint_goal_descriptor_def = constraint_goal_descriptor_and | constraint_goal_descriptor_forall | constraint_goal_descriptor_at_end + | constraint_goal_descriptor_always | constraint_goal_descriptor_sometime | constraint_goal_descriptor_within + | constraint_goal_descriptor_at_most_once | constraint_goal_descriptor_sometime_after + | constraint_goal_descriptor_sometime_before | constraint_goal_descriptor_always_within + | constraint_goal_descriptor_hold_during | constraint_goal_descriptor_hold_after; +const auto constraint_goal_descriptor_and_def = (lit('(') >> keyword_lit("and")) > *constraint_goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_forall_def = (lit('(') >> keyword_lit("forall")) > lit('(') > typed_list_of_variables > lit(')') + > constraint_goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_at_end_def = (lit('(') >> keyword_lit("at") >> keyword_lit("end")) > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_always_def = (lit('(') >> keyword_lit("always")) > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_sometime_def = (lit('(') >> keyword_lit("sometime")) > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_within_def = (lit('(') >> keyword_lit("within")) > number > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_at_most_once_def = (lit('(') >> keyword_lit("at-most-once")) > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_sometime_after_def = (lit('(') >> keyword_lit("sometime-after")) > goal_descriptor > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_sometime_before_def = (lit('(') >> keyword_lit("sometime-before")) > goal_descriptor > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_always_within_def = (lit('(') >> keyword_lit("always-within")) > number > goal_descriptor > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_hold_during_def = (lit('(') >> keyword_lit("hold-during")) > number > number > goal_descriptor > lit(')'); +const auto constraint_goal_descriptor_hold_after_def = (lit('(') >> keyword_lit("hold-after")) > number > goal_descriptor > lit(')'); + +const auto precondition_goal_descriptor_def = + precondition_goal_descriptor_and | precondition_goal_descriptor_preference | precondition_goal_descriptor_forall | precondition_goal_descriptor_simple; +const auto preference_name_def = name; +const auto precondition_goal_descriptor_simple_def = goal_descriptor; +const auto precondition_goal_descriptor_and_def = (lit('(') >> keyword_lit("and") > *precondition_goal_descriptor) > lit(')'); +const auto precondition_goal_descriptor_preference_def = (lit('(') >> keyword_lit("preference")) > preference_name > goal_descriptor > lit(')'); +const auto precondition_goal_descriptor_forall_def = (lit('(') >> keyword_lit("forall")) > lit('(') > typed_list_of_variables > lit(')') + > precondition_goal_descriptor > lit(')'); + +const auto assign_operator_assign_def = keyword_lit("assign") > x3::attr(ast::AssignOperatorAssign {}); +const auto assign_operator_scale_up_def = keyword_lit("scale-up") > x3::attr(ast::AssignOperatorScaleUp {}); +const auto assign_operator_scale_down_def = keyword_lit("scale-down") > x3::attr(ast::AssignOperatorScaleDown {}); +const auto assign_operator_increase_def = keyword_lit("increase") > x3::attr(ast::AssignOperatorIncrease {}); +const auto assign_operator_decrease_def = keyword_lit("decrease") > x3::attr(ast::AssignOperatorDecrease {}); +const auto assign_operator_def = + assign_operator_assign | assign_operator_scale_up | assign_operator_scale_down | assign_operator_increase | assign_operator_decrease; + +// For action cost effects only +const auto numeric_term_def = function_expression_number | function_expression_head; + +const auto effect_def = ((lit('(') >> keyword_lit("and")) > *effect > lit(')')) | effect_conditional | effect_production; +const auto effect_production_literal_def = literal; +const auto effect_production_numeric_fluent_total_cost_def = (lit('(') >> assign_operator_increase >> lit('(') >> function_symbol_total_cost) > lit(')') + > numeric_term > lit(')'); +const auto effect_production_numeric_fluent_general_def = (lit('(') >> assign_operator >> function_head >> function_expression) > lit(')'); +const auto effect_production_def = effect_production_numeric_fluent_total_cost | effect_production_numeric_fluent_general | effect_production_literal; +const auto effect_conditional_forall_def = (lit('(') >> keyword_lit("forall")) > lit("(") > typed_list_of_variables > lit(')') > effect > lit(')'); +const auto effect_conditional_when_def = (lit('(') >> keyword_lit("when")) > goal_descriptor > effect > lit(')'); +const auto effect_conditional_def = effect_conditional_forall | effect_conditional_when; + +const auto action_symbol_def = name; +const auto action_body_def = -(keyword_lit(":precondition") > ((lit('(') >> lit(')')) | precondition_goal_descriptor)) + > -(keyword_lit(":effect") > ((lit('(') >> lit(')')) | effect)); +const auto action_def = (lit('(') >> keyword_lit(":action")) > action_symbol > keyword_lit(":parameters") > lit('(') > typed_list_of_variables > lit(')') + > action_body >> lit(')'); + +const auto derived_predicate_def = (lit('(') >> typed_list_of_variables >> goal_descriptor) > lit(')'); + +const auto define_keyword_def = keyword_lit("define"); +const auto domain_keyword_def = keyword_lit("domain"); +const auto domain_name_def = (lit('(') > domain_keyword) > name > lit(')'); +const auto requirements_def = lit('(') >> keyword_lit(":requirements") > *requirement >> lit(')'); +const auto types_def = (lit('(') >> keyword_lit(":types") > typed_list_of_names) > lit(')'); +const auto constants_def = (lit('(') >> keyword_lit(":constants") > typed_list_of_names) > lit(')'); +const auto predicates_def = (lit('(') >> keyword_lit(":predicates") > *atomic_formula_skeleton) > lit(')'); +const auto functions_def = (lit('(') >> keyword_lit(":functions") > *function_typed_list_of_atomic_function_skeletons) > lit(')'); +const auto constraints_def = (lit('(') >> keyword_lit(":constraints")) > constraint_goal_descriptor > lit(')'); +const auto structure_def = action | derived_predicate; + +const auto domain_def = lit('(') > define_keyword > domain_name > -requirements > -types > -constants > -predicates > -functions > -constraints > *structure + > lit(')'); + +BOOST_SPIRIT_DEFINE(name, variable, name_total_cost, function_symbol_total_cost, function_symbol, term, number, predicate) + +BOOST_SPIRIT_DEFINE(requirement_strips, + requirement_typing, + requirement_negative_preconditions, + requirement_disjunctive_preconditions, + requirement_equality, + requirement_existential_preconditions, + requirement_universal_preconditions, + requirement_quantified_preconditions, + requirement_conditional_effects, + requirement_fluents, + requirement_object_fluents, + requirement_numeric_fluents, + requirement_adl, + requirement_durative_actions, + requirement_derived_predicates, + requirement_timed_initial_literals, + requirement_preferences, + requirement_constraints, + requirement_action_costs, + requirement) + +BOOST_SPIRIT_DEFINE(type, + type_object, + type_number, + type_either, + typed_list_of_names_recursively, + typed_list_of_names, + typed_list_of_variables_recursively, + typed_list_of_variables) + +BOOST_SPIRIT_DEFINE(atomic_formula_skeleton) + +BOOST_SPIRIT_DEFINE(atomic_function_skeleton_total_cost, + atomic_function_skeleton_general, + atomic_function_skeleton, + function_typed_list_of_atomic_function_skeletons_recursively, + function_typed_list_of_atomic_function_skeletons) + +BOOST_SPIRIT_DEFINE(atomic_formula_of_terms_predicate, atomic_formula_of_terms_equality, atomic_formula_of_terms, atom, negated_atom, literal) + +BOOST_SPIRIT_DEFINE(multi_operator_mul, multi_operator_plus, multi_operator, binary_operator_minus, binary_operator_div, binary_operator) + +BOOST_SPIRIT_DEFINE(binary_comparator_greater, + binary_comparator_less, + binary_comparator_equal, + binary_comparator_greater_equal, + binary_comparator_less_equal, + binary_comparator) + +BOOST_SPIRIT_DEFINE(function_head, + function_expression, + function_expression_number, + function_expression_binary_op, + function_expression_minus, + function_expression_head) + +BOOST_SPIRIT_DEFINE(goal_descriptor, + goal_descriptor_atom, + goal_descriptor_literal, + goal_descriptor_and, + goal_descriptor_or, + goal_descriptor_not, + goal_descriptor_imply, + goal_descriptor_exists, + goal_descriptor_forall, + goal_descriptor_function_comparison) + +BOOST_SPIRIT_DEFINE(constraint_goal_descriptor, + constraint_goal_descriptor_and, + constraint_goal_descriptor_forall, + constraint_goal_descriptor_at_end, + constraint_goal_descriptor_always, + constraint_goal_descriptor_sometime, + constraint_goal_descriptor_within, + constraint_goal_descriptor_at_most_once, + constraint_goal_descriptor_sometime_after, + constraint_goal_descriptor_sometime_before, + constraint_goal_descriptor_always_within, + constraint_goal_descriptor_hold_during, + constraint_goal_descriptor_hold_after) + +BOOST_SPIRIT_DEFINE(preference_name, + precondition_goal_descriptor, + precondition_goal_descriptor_simple, + precondition_goal_descriptor_and, + precondition_goal_descriptor_preference, + precondition_goal_descriptor_forall) + +BOOST_SPIRIT_DEFINE(assign_operator_assign, + assign_operator_scale_up, + assign_operator_scale_down, + assign_operator_increase, + assign_operator_decrease, + assign_operator) + +BOOST_SPIRIT_DEFINE(numeric_term) + +BOOST_SPIRIT_DEFINE(effect, + effect_production_literal, + effect_production_numeric_fluent_total_cost, + effect_production_numeric_fluent_general, + effect_production, + effect_conditional_forall, + effect_conditional_when, + effect_conditional, + action_symbol, + action_body, + action, + derived_predicate) + +BOOST_SPIRIT_DEFINE(define_keyword, domain_keyword, domain_name, requirements, types, constants, predicates, functions, constraints, structure, domain) + +/////////////////////////////////////////////////////////////////////////// +// Annotation and Error handling +/////////////////////////////////////////////////////////////////////////// + +struct NameClass : x3::annotate_on_success +{ +}; +struct VariableClass : x3::annotate_on_success +{ +}; +struct NameTotalCostClass : x3::annotate_on_success +{ +}; +struct FunctionSymbolTotalCostClass : x3::annotate_on_success +{ +}; +struct FunctionSymbolClass : x3::annotate_on_success +{ +}; +struct TermClass : x3::annotate_on_success +{ +}; +struct NumberClass : x3::annotate_on_success +{ +}; +struct PredicateClass : x3::annotate_on_success +{ +}; + +struct RequirementStripsClass : x3::annotate_on_success +{ +}; +struct RequirementTypingClass : x3::annotate_on_success +{ +}; +struct RequirementNegativePreconditionsClass : x3::annotate_on_success +{ +}; +struct RequirementDisjunctivePreconditionsClass : x3::annotate_on_success +{ +}; +struct RequirementEqualityClass : x3::annotate_on_success +{ +}; +struct RequirementExistentialPreconditionsClass : x3::annotate_on_success +{ +}; +struct RequirementUniversalPreconditionsClass : x3::annotate_on_success +{ +}; +struct RequirementQuantifiedPreconditionsClass : x3::annotate_on_success +{ +}; +struct RequirementConditionalEffectsClass : x3::annotate_on_success +{ +}; +struct RequirementFluentsClass : x3::annotate_on_success +{ +}; +struct RequirementObjectFluentsClass : x3::annotate_on_success +{ +}; +struct RequirementNumericalFluentsClass : x3::annotate_on_success +{ +}; +struct RequirementAdlClass : x3::annotate_on_success +{ +}; +struct RequirementDurativeActionsClass : x3::annotate_on_success +{ +}; +struct RequirementDerivedPredicatesClass : x3::annotate_on_success +{ +}; +struct RequirementTimedInitialLiteralsClass : x3::annotate_on_success +{ +}; +struct RequirementPreferencesClass : x3::annotate_on_success +{ +}; +struct RequirementConstraintsClass : x3::annotate_on_success +{ +}; +struct RequirementActionCostsClass : x3::annotate_on_success +{ +}; +struct RequirementClass : x3::annotate_on_success +{ +}; + +struct TypeClass : x3::annotate_on_success +{ +}; +struct TypeObjectClass : x3::annotate_on_success +{ +}; +struct TypeNumberClass : x3::annotate_on_success +{ +}; +struct TypeEitherClass : x3::annotate_on_success +{ +}; +struct TypedListOfNamesRecursivelyClass : x3::annotate_on_success +{ +}; +struct TypedListOfNamesClass : x3::annotate_on_success +{ +}; +struct TypedListOfVariablesRecursivelyClass : x3::annotate_on_success +{ +}; +struct TypedListOfVariablesClass : x3::annotate_on_success +{ +}; + +struct AtomicFormulaSkeletonClass : x3::annotate_on_success +{ +}; + +struct AtomicFunctionSkeletonTotalCostClass : x3::annotate_on_success +{ +}; +struct AtomicFunctionSkeletonGeneralClass : x3::annotate_on_success +{ +}; +struct AtomicFunctionSkeletonClass : x3::annotate_on_success +{ +}; +struct FunctionTypedListOfAtomicFunctionSkeletonsRecursivelyClass : x3::annotate_on_success +{ +}; +struct FunctionTypedListOfAtomicFunctionSkeletonsClass : x3::annotate_on_success +{ +}; + +struct AtomicFormulaOfTermsPredicateClass : x3::annotate_on_success +{ +}; +struct AtomicFormulaOfTermsEqualityClass : x3::annotate_on_success +{ +}; +struct AtomicFormulaOfTermsClass : x3::annotate_on_success +{ +}; +struct AtomClass : x3::annotate_on_success +{ +}; +struct NegatedAtomClass : x3::annotate_on_success +{ +}; +struct LiteralClass : x3::annotate_on_success +{ +}; + +struct MultiOperatorMulClass : x3::annotate_on_success +{ +}; +struct MultiOperatorPlusClass : x3::annotate_on_success +{ +}; +struct MultiOperatorClass : x3::annotate_on_success +{ +}; +struct BinaryOperatorMinusClass : x3::annotate_on_success +{ +}; +struct BinaryOperatorDivClass : x3::annotate_on_success +{ +}; +struct BinaryOperatorClass : x3::annotate_on_success +{ +}; + +struct BinaryComparatorGreaterClass : x3::annotate_on_success +{ +}; +struct BinaryComparatorLessClass : x3::annotate_on_success +{ +}; +struct BinaryComparatorEqualClass : x3::annotate_on_success +{ +}; +struct BinaryComparatorGreaterEqualClass : x3::annotate_on_success +{ +}; +struct BinaryComparatorLessEqualClass : x3::annotate_on_success +{ +}; +struct BinaryComparatorClass : x3::annotate_on_success +{ +}; + +struct FunctionExpressionClass : x3::annotate_on_success +{ +}; +struct FunctionHeadClass : x3::annotate_on_success +{ +}; +struct FunctionExpressionNumberClass : x3::annotate_on_success +{ +}; +struct FunctionExpressionBinaryOpClass : x3::annotate_on_success +{ +}; +struct FunctionExpressionMinusClass : x3::annotate_on_success +{ +}; +struct FunctionExpressionHeadClass : x3::annotate_on_success +{ +}; + +struct GoalDescriptorClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorAtomClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorLiteralClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorAndClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorOrClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorNotClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorImplyClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorExistsClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorForallClass : x3::annotate_on_success +{ +}; +struct GoalDescriptorFunctionComparisonClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorAndClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorForallClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorAtEndClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorAlwaysClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorSometimeClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorWithinClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorAtMostOnceClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorSometimeAfterClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorSometimeBeforeClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorAlwaysWithinClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorHoldDuringClass : x3::annotate_on_success +{ +}; +struct ConstraintGoalDescriptorHoldAfterClass : x3::annotate_on_success +{ +}; + +struct PreferenceNameClass : x3::annotate_on_success +{ +}; +struct PreconditionGoalDescriptorClass : x3::annotate_on_success +{ +}; +struct PreconditionGoalDescriptorSimpleClass : x3::annotate_on_success +{ +}; +struct PreconditionGoalDescriptorAndClass : x3::annotate_on_success +{ +}; +struct PreconditionGoalDescriptorPreferenceClass : x3::annotate_on_success +{ +}; +struct PreconditionGoalDescriptorForallClass : x3::annotate_on_success +{ +}; + +struct AssignOperatorAssignClass : x3::annotate_on_success +{ +}; +struct AssignOperatorScaleUpClass : x3::annotate_on_success +{ +}; +struct AssignOperatorScaleDownClass : x3::annotate_on_success +{ +}; +struct AssignOperatorIncreaseClass : x3::annotate_on_success +{ +}; +struct AssignOperatorDecreaseClass : x3::annotate_on_success +{ +}; +struct AssignOperatorClass : x3::annotate_on_success +{ +}; + +struct NumericTermClass : x3::annotate_on_success +{ +}; + +struct EffectClass : x3::annotate_on_success +{ +}; +struct EffectProductionLiteralClass : x3::annotate_on_success +{ +}; +struct EffectProductionNumericFluentTotalCostClass : x3::annotate_on_success +{ +}; +struct EffectProductionNumericFluentGeneralClass : x3::annotate_on_success +{ +}; +struct EffectProductionClass : x3::annotate_on_success +{ +}; +struct EffectConditionalForallClass : x3::annotate_on_success +{ +}; +struct EffectConditionalWhenClass : x3::annotate_on_success +{ +}; +struct EffectConditionalClass : x3::annotate_on_success +{ +}; +struct ActionSymbolClass : x3::annotate_on_success +{ +}; +struct ActionBodyClass : x3::annotate_on_success +{ +}; +struct ActionClass : x3::annotate_on_success +{ +}; +struct DurativeActionClass : x3::annotate_on_success +{ +}; +struct DerivedPredicateClass : x3::annotate_on_success +{ +}; -namespace loki::domain::parser { - namespace x3 = boost::spirit::x3; - namespace ascii = boost::spirit::x3::ascii; - - using x3::lit; - using x3::string; - using x3::lexeme; - using x3::eps; - using x3::int_; - using x3::double_; - using x3::no_skip; - using x3::raw; - - using ascii::alpha; - using ascii::alnum; - using ascii::char_; - using ascii::space; - - /////////////////////////////////////////////////////////////////////////// - // Rule IDs - /////////////////////////////////////////////////////////////////////////// - - - /////////////////////////////////////////////////////////////////////////// - // Rules - /////////////////////////////////////////////////////////////////////////// - - define_keyword_type const define_keyword = "define"; - domain_keyword_type const domain_keyword = "domain"; - - name_type const name = "name"; - variable_type const variable = "variable"; - name_total_cost_type const name_total_cost = "name_total_cost"; - function_symbol_total_cost_type const function_symbol_total_cost = "function_symbol_total_cost"; - function_symbol_type const function_symbol = "function_symbol"; - term_type const term = "term"; - number_type const number = "number"; - predicate_type const predicate = "predicate"; - - requirement_strips_type const requirement_strips = "requirement_strips"; - requirement_typing_type const requirement_typing = "requirement_typing"; - requirement_negative_preconditions_type const requirement_negative_preconditions = "requirement_negative_preconditions"; - requirement_disjunctive_preconditions_type const requirement_disjunctive_preconditions = "requirement_disjunctive_preconditions"; - requirement_equality_type const requirement_equality = "requirement_equality"; - requirement_existential_preconditions_type const requirement_existential_preconditions = "requirement_existential_preconditions"; - requirement_universal_preconditions_type const requirement_universal_preconditions = "requirement_universal_preconditions"; - requirement_quantified_preconditions_type const requirement_quantified_preconditions = "requirement_quantified_preconditions"; - requirement_conditional_effects_type const requirement_conditional_effects = "requirement_conditional_effects"; - requirement_fluents_type const requirement_fluents = "requirement_fluents"; - requirement_object_fluents_type const requirement_object_fluents = "requirement_object_fluents"; - requirement_numeric_fluents_type const requirement_numeric_fluents = "requirement_numeric_fluents"; - requirement_adl_type const requirement_adl = "requirement_adl"; - requirement_durative_actions_type const requirement_durative_actions = "requirement_durative_actions"; - requirement_derived_predicates_type const requirement_derived_predicates = "requirement_derived_predicates"; - requirement_timed_initial_literals_type const requirement_timed_initial_literals = "requirement_timed_initial_literals"; - requirement_preferences_type const requirement_preferences = "requirement_preferences"; - requirement_constraints_type const requirement_constraints = "requirement_constraints"; - requirement_action_costs_type const requirement_action_costs = "requirement_action_costs"; - requirement_type const requirement = "requirement"; - - type_type const type = "type"; - type_object_type const type_object = "type_object"; - type_number_type const type_number = "type_number"; - type_either_type const type_either = "type_either"; - typed_list_of_names_recursively_type const typed_list_of_names_recursively = "typed_list_of_names_recursively"; - typed_list_of_names_type const typed_list_of_names = "typed_list_of_names"; - typed_list_of_variables_recursively_type const typed_list_of_variables_recursively = "typed_list_of_variables_recursively"; - typed_list_of_variables_type const typed_list_of_variables = "typed_list_of_variables"; - - atomic_formula_skeleton_type const atomic_formula_skeleton = "atomic_formula_skeleton"; - - atomic_function_skeleton_total_cost_type const atomic_function_skeleton_total_cost = "atomic_function_skeleton_total_cost"; - atomic_function_skeleton_general_type const atomic_function_skeleton_general = "atomic_function_skeleton_general"; - atomic_function_skeleton_type const atomic_function_skeleton = "atomic_function_skeleton"; - function_typed_list_of_atomic_function_skeletons_recursively_type const function_typed_list_of_atomic_function_skeletons_recursively = "function_typed_list_of_atomic_function_skeletons_recursively"; - function_typed_list_of_atomic_function_skeletons_type const function_typed_list_of_atomic_function_skeletons = "function_typed_list_of_atomic_function_skeletons"; - - atomic_formula_of_terms_predicate_type const atomic_formula_of_terms_predicate = "atomic_formula_of_terms_predicate"; - atomic_formula_of_terms_equality_type const atomic_formula_of_terms_equality = "atomic_formula_of_terms_equality"; - atomic_formula_of_terms_type const atomic_formula_of_terms = "atomic_formula_of_terms"; - atom_type const atom = "atom"; - negated_atom_type const negated_atom = "negated_atom"; - literal_type const literal = "literal"; - - multi_operator_mul_type const multi_operator_mul = "multi_operator_mul"; - multi_operator_plus_type const multi_operator_plus = "multi_operator_plus"; - multi_operator_type const multi_operator = "multi_operator"; - binary_operator_minus_type const binary_operator_minus = "binary_operator_minus"; - binary_operator_div_type const binary_operator_div = "binary_operator_div"; - binary_operator_type const binary_operator = "binary_operator"; - - binary_comparator_greater_type const binary_comparator_greater = "binary_comparator_greater"; - binary_comparator_less_type const binary_comparator_less = "binary_comparator_less"; - binary_comparator_equal_type const binary_comparator_equal = "binary_comparator_equal"; - binary_comparator_greater_equal_type const binary_comparator_greater_equal = "binary_comparator_greater_equal"; - binary_comparator_less_equal_type const binary_comparator_less_equal = "binary_comparator_less_equal"; - binary_comparator_type const binary_comparator = "binary_comparator"; - - function_expression_type const function_expression = "function_expression"; - function_head_type const function_head = "function_head"; - function_expression_number_type const function_expression_number = "function_expression_number"; - function_expression_binary_op_type const function_expression_binary_op = "function_expression_binary_op"; - function_expression_minus_type const function_expression_minus = "function_expression_minus"; - function_expression_head_type const function_expression_head = "function_expression_head"; - - goal_descriptor_type const goal_descriptor = "goal_descriptor"; - goal_descriptor_atom_type const goal_descriptor_atom = "goal_descriptor_atom"; - goal_descriptor_literal_type const goal_descriptor_literal = "goal_descriptor_literal"; - goal_descriptor_and_type const goal_descriptor_and = "goal_descriptor_and"; - goal_descriptor_or_type const goal_descriptor_or = "goal_descriptor_or"; - goal_descriptor_not_type const goal_descriptor_not = "goal_descriptor_not"; - goal_descriptor_imply_type const goal_descriptor_imply = "goal_descriptor_imply"; - goal_descriptor_exists_type const goal_descriptor_exists = "goal_descriptor_exists"; - goal_descriptor_forall_type const goal_descriptor_forall = "goal_descriptor_forall"; - goal_descriptor_function_comparison_type const goal_descriptor_function_comparison = "goal_descriptor_function_comparison"; - - constraint_goal_descriptor_type const constraint_goal_descriptor = "constraint_goal_descriptor"; - constraint_goal_descriptor_and_type const constraint_goal_descriptor_and = "constraint_goal_descriptor_and"; - constraint_goal_descriptor_forall_type const constraint_goal_descriptor_forall = "constraint_goal_descriptor_forall"; - constraint_goal_descriptor_at_end_type const constraint_goal_descriptor_at_end = "constraint_goal_descriptor_at_end"; - constraint_goal_descriptor_always_type const constraint_goal_descriptor_always = "constraint_goal_descriptor_always"; - constraint_goal_descriptor_sometime_type const constraint_goal_descriptor_sometime = "constraint_goal_descriptor_sometime"; - constraint_goal_descriptor_within_type const constraint_goal_descriptor_within = "constraint_goal_descriptor_within"; - constraint_goal_descriptor_at_most_once_type const constraint_goal_descriptor_at_most_once = "constraint_goal_descriptor_at_most_once"; - constraint_goal_descriptor_sometime_after_type const constraint_goal_descriptor_sometime_after = "constraint_goal_descriptor_sometime_after"; - constraint_goal_descriptor_sometime_before_type const constraint_goal_descriptor_sometime_before = "constraint_goal_descriptor_sometime_before"; - constraint_goal_descriptor_always_within_type const constraint_goal_descriptor_always_within = "constraint_goal_descriptor_always_within"; - constraint_goal_descriptor_hold_during_type const constraint_goal_descriptor_hold_during = "constraint_goal_descriptor_hold_during"; - constraint_goal_descriptor_hold_after_type const constraint_goal_descriptor_hold_after = "constraint_goal_descriptor_hold_after"; - - precondition_goal_descriptor_type const precondition_goal_descriptor = "precondition_goal_descriptor"; - preference_name_type const preference_name = "preference_name"; - precondition_goal_descriptor_simple_type const precondition_goal_descriptor_simple = "precondition_goal_descriptor_simple"; - precondition_goal_descriptor_and_type const precondition_goal_descriptor_and = "precondition_goal_descriptor_and"; - precondition_goal_descriptor_preference_type const precondition_goal_descriptor_preference = "precondition_goal_descriptor_preference"; - precondition_goal_descriptor_forall_type const precondition_goal_descriptor_forall = "precondition_goal_descriptor_forall"; - - assign_operator_assign_type const assign_operator_assign = "assign_operator_assign"; - assign_operator_scale_up_type const assign_operator_scale_up = "assign_operator_scale_up"; - assign_operator_scale_down_type const assign_operator_scale_down = "assign_operator_scale_down"; - assign_operator_increase_type const assign_operator_increase = "assign_operator_increase"; - assign_operator_decrease_type const assign_operator_decrease = "assign_operator_decrease"; - assign_operator_type const assign_operator = "assign_operator"; - - numeric_term_type const numeric_term = "numeric_term"; - - effect_type const effect = "effect"; - effect_production_literal_type const effect_production_literal = "effect_production_literal"; - effect_production_numeric_fluent_total_cost_type const effect_production_numeric_fluent_total_cost = "effect_production_numeric_fluent_total_cost"; - effect_production_numeric_fluent_general_type const effect_production_numeric_fluent_general = "effect_production_numeric_fluent_general"; - effect_production_type const effect_production = "effect_production"; - effect_conditional_forall_type const effect_conditional_forall = "effect_conditional_forall"; - effect_conditional_when_type const effect_conditional_when = "effect_conditional_when"; - effect_conditional_type const effect_conditional = "effect_conditional"; - action_symbol_type const action_symbol = "action_symbol"; - action_body_type const action_body = "action_body"; - action_type const action = "action"; - derived_predicate_type const derived_predicate = "derived_predicate"; - - domain_name_type const domain_name = "domain_name"; - requirements_type const requirements = "requirements"; - types_type const types = "types"; - constants_type const constants = "constants"; - predicates_type const predicates = "predicates"; - functions_type const functions = "functions"; - constraints_type const constraints = "constraints"; - structure_type const structure = "structure"; - domain_type const domain = "domain"; - - /////////////////////////////////////////////////////////////////////////// - // Grammar - /////////////////////////////////////////////////////////////////////////// - - const auto name_def = raw[lexeme[alpha >> *(alnum | char_('-') | char_('_'))]]; - const auto variable_def = raw[lexeme[char_('?') > name]]; - const auto name_total_cost_def = keyword_string("total-cost"); - const auto function_symbol_total_cost_def = name_total_cost; - const auto function_symbol_def = name; - const auto term_def = name | variable; - const auto number_def = double_; - const auto predicate_def = name; - - const auto requirement_strips_def = keyword_lit(":strips") > x3::attr(ast::RequirementStrips{}); - const auto requirement_typing_def = keyword_lit(":typing") > x3::attr(ast::RequirementTyping{}); - const auto requirement_negative_preconditions_def = keyword_lit(":negative-preconditions") > x3::attr(ast::RequirementNegativePreconditions{}); - const auto requirement_disjunctive_preconditions_def = keyword_lit(":disjunctive-preconditions") > x3::attr(ast::RequirementDisjunctivePreconditions{}); - const auto requirement_equality_def = keyword_lit(":equality") > x3::attr(ast::RequirementEquality{}); - const auto requirement_existential_preconditions_def = keyword_lit(":existential-preconditions") > x3::attr(ast::RequirementExistentialPreconditions{}); - const auto requirement_universal_preconditions_def = keyword_lit(":universal-preconditions") > x3::attr(ast::RequirementUniversalPreconditions{}); - const auto requirement_quantified_preconditions_def = keyword_lit(":quantified-preconditions") > x3::attr(ast::RequirementQuantifiedPreconditions{}); - const auto requirement_conditional_effects_def = keyword_lit(":conditional-effects") > x3::attr(ast::RequirementConditionalEffects{}); - const auto requirement_fluents_def = keyword_lit(":fluents") >> x3::attr(ast::RequirementFluents{}); - const auto requirement_object_fluents_def = keyword_lit(":object-fluents") > x3::attr(ast::RequirementObjectFluents{}); - const auto requirement_numeric_fluents_def = keyword_lit(":numeric-fluents") > x3::attr(ast::RequirementNumericFluents{}); - const auto requirement_adl_def = keyword_lit(":adl") >> x3::attr(ast::RequirementAdl{}); - const auto requirement_durative_actions_def = keyword_lit(":durative-actions") > x3::attr(ast::RequirementDurativeActions{}); - const auto requirement_derived_predicates_def = keyword_lit(":derived-predicates") > x3::attr(ast::RequirementDerivedPredicates{}); - const auto requirement_timed_initial_literals_def = keyword_lit(":timed-initial-literals") > x3::attr(ast::RequirementTimedInitialLiterals{}); - const auto requirement_preferences_def = keyword_lit(":preferences") > x3::attr(ast::RequirementPreferences{}); - const auto requirement_constraints_def = keyword_lit(":constraints") > x3::attr(ast::RequirementConstraints{}); - const auto requirement_action_costs_def = keyword_lit(":action-costs") > x3::attr(ast::RequirementActionCosts{}); - const auto requirement_def = requirement_strips | requirement_typing | requirement_negative_preconditions - | requirement_disjunctive_preconditions | requirement_equality | requirement_existential_preconditions - | requirement_universal_preconditions | requirement_quantified_preconditions | requirement_conditional_effects - | requirement_fluents | requirement_object_fluents | requirement_numeric_fluents | requirement_adl - | requirement_durative_actions | requirement_derived_predicates | requirement_timed_initial_literals - | requirement_preferences | requirement_constraints | requirement_action_costs; - - const auto type_def = type_object | type_number | type_either | name; - const auto type_object_def = keyword_lit("object") > x3::attr(ast::TypeObject{}); - const auto type_number_def = keyword_lit("number") > x3::attr(ast::TypeNumber{}); - const auto type_either_def = (lit('(') >> keyword_lit("either") > +type) > lit(')'); - const auto typed_list_of_names_recursively_def = (+name >> lit('-')) > type > typed_list_of_names; - const auto typed_list_of_names_def = typed_list_of_names_recursively | *name; - const auto typed_list_of_variables_recursively_def = (+variable >> lit('-')) > type > typed_list_of_variables; - const auto typed_list_of_variables_def = typed_list_of_variables_recursively | *variable; - - const auto atomic_formula_skeleton_def = lit('(') > predicate > typed_list_of_variables > lit(')'); - - const auto atomic_function_skeleton_total_cost_def = lit('(') >> function_symbol_total_cost > lit(')'); - const auto atomic_function_skeleton_general_def = lit('(') > function_symbol > typed_list_of_variables > lit(')'); - const auto atomic_function_skeleton_def = atomic_function_skeleton_total_cost | atomic_function_skeleton_general; - const auto function_typed_list_of_atomic_function_skeletons_recursively_def = (+atomic_function_skeleton >> lit('-')) > type_number > -function_typed_list_of_atomic_function_skeletons; - const auto function_typed_list_of_atomic_function_skeletons_def = function_typed_list_of_atomic_function_skeletons_recursively | *atomic_function_skeleton; - - const auto atomic_formula_of_terms_predicate_def = (lit('(') >> predicate) > *term > lit(')'); - const auto atomic_formula_of_terms_equality_def = (lit('(') >> lit('=')) >> term > term > lit(')'); - const auto atomic_formula_of_terms_def = atomic_formula_of_terms_equality | atomic_formula_of_terms_predicate; - const auto atom_def = atomic_formula_of_terms; - const auto negated_atom_def = (lit('(') >> keyword_lit("not")) > atomic_formula_of_terms > lit(')'); - const auto literal_def = negated_atom | atom; - - const auto multi_operator_mul_def = lit('*') > x3::attr(ast::MultiOperatorMul{}); - const auto multi_operator_plus_def = lit('+') > x3::attr(ast::MultiOperatorPlus{}); - const auto multi_operator_def = multi_operator_mul | multi_operator_plus; - const auto binary_operator_minus_def = lit('-') > x3::attr(ast::BinaryOperatorMinus{}); - const auto binary_operator_div_def = lit('/') > x3::attr(ast::BinaryOperatorDiv{}); - const auto binary_operator_def = binary_operator_minus | binary_operator_div | multi_operator; - - const auto binary_comparator_greater_def = lit('>') > x3::attr(ast::BinaryComparatorGreater{}); - const auto binary_comparator_less_def = lit('<') > x3::attr(ast::BinaryComparatorLess{}); - const auto binary_comparator_equal_def = lit('=') > x3::attr(ast::BinaryComparatorEqual{}); - const auto binary_comparator_greater_equal_def = lit(">=") > x3::attr(ast::BinaryComparatorGreaterEqual{}); - const auto binary_comparator_less_equal_def = lit("<=") > x3::attr(ast::BinaryComparatorLessEqual{}); - const auto binary_comparator_def = binary_comparator_greater | binary_comparator_less | binary_comparator_equal | binary_comparator_greater_equal | binary_comparator_less_equal; - - const auto function_head_def = ((lit('(') >> function_symbol > *term) > lit(')')) | (function_symbol > x3::attr(std::vector{})); - const auto function_expression_def = function_expression_binary_op | function_expression_minus | function_expression_head | function_expression_number; - const auto function_expression_number_def = number; - // distinguishing unary from binary minus requires some more backtracking - const auto function_expression_binary_op_def = (lit('(') >> binary_operator >> function_expression >> function_expression) > lit(')'); - const auto function_expression_minus_def = (lit('(') >> lit('-')) >> function_expression > lit(')'); - const auto function_expression_head_def = function_head; - - const auto goal_descriptor_def = goal_descriptor_not | goal_descriptor_and | goal_descriptor_or | goal_descriptor_imply - | goal_descriptor_exists | goal_descriptor_forall | goal_descriptor_function_comparison | goal_descriptor_atom | goal_descriptor_literal; - const auto goal_descriptor_atom_def = atom; - const auto goal_descriptor_literal_def = literal; - const auto goal_descriptor_and_def = (lit('(') >> keyword_lit("and")) > *goal_descriptor > lit(')'); - const auto goal_descriptor_or_def = (lit('(') >> keyword_lit("or") > *goal_descriptor) > lit(')'); - const auto goal_descriptor_not_def = (lit('(') >> keyword_lit("not")) > goal_descriptor > lit(')'); - const auto goal_descriptor_imply_def = (lit('(') >> keyword_lit("imply")) > goal_descriptor > goal_descriptor > lit(')'); - const auto goal_descriptor_exists_def = (lit('(') >> keyword_lit("exists")) > lit('(') > typed_list_of_variables > lit(')') > goal_descriptor > lit(')'); - const auto goal_descriptor_forall_def = (lit('(') >> keyword_lit("forall")) > lit('(') > typed_list_of_variables > lit(')') > goal_descriptor > lit(')'); - const auto goal_descriptor_function_comparison_def = (lit('(') >> binary_comparator) >> function_expression > function_expression > lit(')'); - - const auto constraint_goal_descriptor_def = constraint_goal_descriptor_and | constraint_goal_descriptor_forall | constraint_goal_descriptor_at_end - | constraint_goal_descriptor_always | constraint_goal_descriptor_sometime | constraint_goal_descriptor_within - | constraint_goal_descriptor_at_most_once | constraint_goal_descriptor_sometime_after | constraint_goal_descriptor_sometime_before - | constraint_goal_descriptor_always_within | constraint_goal_descriptor_hold_during | constraint_goal_descriptor_hold_after; - const auto constraint_goal_descriptor_and_def = (lit('(') >> keyword_lit("and")) > *constraint_goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_forall_def = (lit('(') >> keyword_lit("forall")) > lit('(') > typed_list_of_variables > lit(')') > constraint_goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_at_end_def = (lit('(') >> keyword_lit("at") >> keyword_lit("end")) > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_always_def = (lit('(') >> keyword_lit("always")) > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_sometime_def = (lit('(') >> keyword_lit("sometime")) > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_within_def = (lit('(') >> keyword_lit("within")) > number > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_at_most_once_def = (lit('(') >> keyword_lit("at-most-once")) > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_sometime_after_def = (lit('(') >> keyword_lit("sometime-after")) > goal_descriptor > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_sometime_before_def = (lit('(') >> keyword_lit("sometime-before")) > goal_descriptor > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_always_within_def = (lit('(') >> keyword_lit("always-within")) > number > goal_descriptor > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_hold_during_def = (lit('(') >> keyword_lit("hold-during")) > number > number > goal_descriptor > lit(')'); - const auto constraint_goal_descriptor_hold_after_def = (lit('(') >> keyword_lit("hold-after")) > number > goal_descriptor > lit(')'); - - const auto precondition_goal_descriptor_def = precondition_goal_descriptor_and | precondition_goal_descriptor_preference | precondition_goal_descriptor_forall | precondition_goal_descriptor_simple; - const auto preference_name_def = name; - const auto precondition_goal_descriptor_simple_def = goal_descriptor; - const auto precondition_goal_descriptor_and_def = (lit('(') >> keyword_lit("and") > *precondition_goal_descriptor) > lit(')'); - const auto precondition_goal_descriptor_preference_def = (lit('(') >> keyword_lit("preference")) > preference_name > goal_descriptor > lit(')'); - const auto precondition_goal_descriptor_forall_def = (lit('(') >> keyword_lit("forall")) > lit('(') > typed_list_of_variables > lit(')') > precondition_goal_descriptor > lit(')'); - - const auto assign_operator_assign_def = keyword_lit("assign") > x3::attr(ast::AssignOperatorAssign{}); - const auto assign_operator_scale_up_def = keyword_lit("scale-up") > x3::attr(ast::AssignOperatorScaleUp{}); - const auto assign_operator_scale_down_def = keyword_lit("scale-down") > x3::attr(ast::AssignOperatorScaleDown{}); - const auto assign_operator_increase_def = keyword_lit("increase") > x3::attr(ast::AssignOperatorIncrease{}); - const auto assign_operator_decrease_def = keyword_lit("decrease") > x3::attr(ast::AssignOperatorDecrease{}); - const auto assign_operator_def = assign_operator_assign | assign_operator_scale_up | assign_operator_scale_down | assign_operator_increase | assign_operator_decrease; - - // For action cost effects only - const auto numeric_term_def = function_expression_number | function_expression_head; - - const auto effect_def = ((lit('(') >> keyword_lit("and")) > *effect > lit(')')) | effect_conditional | effect_production; - const auto effect_production_literal_def = literal; - const auto effect_production_numeric_fluent_total_cost_def = (lit('(') >> assign_operator_increase >> lit('(') >> function_symbol_total_cost) > lit(')') > numeric_term > lit(')'); - const auto effect_production_numeric_fluent_general_def = (lit('(') >> assign_operator >> function_head >> function_expression) > lit(')'); - const auto effect_production_def = effect_production_numeric_fluent_total_cost | effect_production_numeric_fluent_general | effect_production_literal; - const auto effect_conditional_forall_def = (lit('(') >> keyword_lit("forall")) > lit("(") > typed_list_of_variables > lit(')') > effect > lit(')'); - const auto effect_conditional_when_def = (lit('(') >> keyword_lit("when")) > goal_descriptor > effect > lit(')'); - const auto effect_conditional_def = effect_conditional_forall | effect_conditional_when; - - const auto action_symbol_def = name; - const auto action_body_def = -(keyword_lit(":precondition") > ((lit('(') >> lit(')')) | precondition_goal_descriptor)) - > -(keyword_lit(":effect") > ((lit('(') >> lit(')')) | effect)); - const auto action_def = (lit('(') >> keyword_lit(":action")) > action_symbol - > keyword_lit(":parameters") > lit('(') > typed_list_of_variables > lit(')') - > action_body - >> lit(')'); - - const auto derived_predicate_def = (lit('(') >> typed_list_of_variables >> goal_descriptor) > lit(')'); - - const auto define_keyword_def = keyword_lit("define"); - const auto domain_keyword_def = keyword_lit("domain"); - const auto domain_name_def = (lit('(') > domain_keyword) > name > lit(')'); - const auto requirements_def = lit('(') >> keyword_lit(":requirements") > *requirement >> lit(')'); - const auto types_def = (lit('(') >> keyword_lit(":types") > typed_list_of_names) > lit(')'); - const auto constants_def = (lit('(') >> keyword_lit(":constants") > typed_list_of_names) > lit(')'); - const auto predicates_def = (lit('(') >> keyword_lit(":predicates") > *atomic_formula_skeleton) > lit(')'); - const auto functions_def = (lit('(') >> keyword_lit(":functions") > *function_typed_list_of_atomic_function_skeletons) > lit(')'); - const auto constraints_def = (lit('(') >> keyword_lit(":constraints")) > constraint_goal_descriptor > lit(')'); - const auto structure_def = action | derived_predicate; - - const auto domain_def = - lit('(') > define_keyword - > domain_name - > -requirements - > -types - > -constants - > -predicates - > -functions - > -constraints - > *structure - > lit(')'); - - - BOOST_SPIRIT_DEFINE(name, variable, name_total_cost, function_symbol_total_cost, function_symbol, term, number, predicate) - - BOOST_SPIRIT_DEFINE(requirement_strips, requirement_typing, requirement_negative_preconditions, - requirement_disjunctive_preconditions, requirement_equality, requirement_existential_preconditions, - requirement_universal_preconditions, requirement_quantified_preconditions, - requirement_conditional_effects, requirement_fluents, requirement_object_fluents, - requirement_numeric_fluents, requirement_adl, requirement_durative_actions, - requirement_derived_predicates, requirement_timed_initial_literals, requirement_preferences, - requirement_constraints, requirement_action_costs, requirement) - - BOOST_SPIRIT_DEFINE(type, type_object, type_number, type_either, typed_list_of_names_recursively, - typed_list_of_names, typed_list_of_variables_recursively, typed_list_of_variables) - - BOOST_SPIRIT_DEFINE(atomic_formula_skeleton) - - BOOST_SPIRIT_DEFINE(atomic_function_skeleton_total_cost, atomic_function_skeleton_general, atomic_function_skeleton, - function_typed_list_of_atomic_function_skeletons_recursively, function_typed_list_of_atomic_function_skeletons) - - BOOST_SPIRIT_DEFINE(atomic_formula_of_terms_predicate, atomic_formula_of_terms_equality, - atomic_formula_of_terms, atom, negated_atom, literal) - - BOOST_SPIRIT_DEFINE(multi_operator_mul, multi_operator_plus, multi_operator, - binary_operator_minus, binary_operator_div, binary_operator) - - BOOST_SPIRIT_DEFINE(binary_comparator_greater, binary_comparator_less, binary_comparator_equal, - binary_comparator_greater_equal, binary_comparator_less_equal, binary_comparator) - - BOOST_SPIRIT_DEFINE(function_head, function_expression, function_expression_number, - function_expression_binary_op, function_expression_minus, function_expression_head) - - BOOST_SPIRIT_DEFINE(goal_descriptor, goal_descriptor_atom, goal_descriptor_literal, - goal_descriptor_and, goal_descriptor_or, goal_descriptor_not, goal_descriptor_imply, - goal_descriptor_exists, goal_descriptor_forall, goal_descriptor_function_comparison) - - BOOST_SPIRIT_DEFINE(constraint_goal_descriptor, constraint_goal_descriptor_and, - constraint_goal_descriptor_forall, constraint_goal_descriptor_at_end, - constraint_goal_descriptor_always, constraint_goal_descriptor_sometime, - constraint_goal_descriptor_within, constraint_goal_descriptor_at_most_once, - constraint_goal_descriptor_sometime_after, constraint_goal_descriptor_sometime_before, - constraint_goal_descriptor_always_within, constraint_goal_descriptor_hold_during, - constraint_goal_descriptor_hold_after) - - BOOST_SPIRIT_DEFINE(preference_name, precondition_goal_descriptor, precondition_goal_descriptor_simple, - precondition_goal_descriptor_and, precondition_goal_descriptor_preference, precondition_goal_descriptor_forall) - - BOOST_SPIRIT_DEFINE(assign_operator_assign, assign_operator_scale_up, assign_operator_scale_down, - assign_operator_increase, assign_operator_decrease, assign_operator) - - BOOST_SPIRIT_DEFINE(numeric_term) - - BOOST_SPIRIT_DEFINE(effect, effect_production_literal, - effect_production_numeric_fluent_total_cost, effect_production_numeric_fluent_general, - effect_production, effect_conditional_forall, - effect_conditional_when, effect_conditional, action_symbol, - action_body, action, derived_predicate) - - BOOST_SPIRIT_DEFINE(define_keyword, domain_keyword, domain_name, requirements, types, - constants, predicates, functions, constraints, structure, domain) - - - /////////////////////////////////////////////////////////////////////////// - // Annotation and Error handling - /////////////////////////////////////////////////////////////////////////// - - struct NameClass : x3::annotate_on_success {}; - struct VariableClass : x3::annotate_on_success {}; - struct NameTotalCostClass : x3::annotate_on_success {}; - struct FunctionSymbolTotalCostClass : x3::annotate_on_success {}; - struct FunctionSymbolClass : x3::annotate_on_success {}; - struct TermClass : x3::annotate_on_success {}; - struct NumberClass : x3::annotate_on_success {}; - struct PredicateClass : x3::annotate_on_success {}; - - struct RequirementStripsClass : x3::annotate_on_success {}; - struct RequirementTypingClass : x3::annotate_on_success {}; - struct RequirementNegativePreconditionsClass : x3::annotate_on_success {}; - struct RequirementDisjunctivePreconditionsClass : x3::annotate_on_success {}; - struct RequirementEqualityClass : x3::annotate_on_success {}; - struct RequirementExistentialPreconditionsClass : x3::annotate_on_success {}; - struct RequirementUniversalPreconditionsClass : x3::annotate_on_success {}; - struct RequirementQuantifiedPreconditionsClass : x3::annotate_on_success {}; - struct RequirementConditionalEffectsClass : x3::annotate_on_success {}; - struct RequirementFluentsClass : x3::annotate_on_success {}; - struct RequirementObjectFluentsClass : x3::annotate_on_success {}; - struct RequirementNumericalFluentsClass : x3::annotate_on_success {}; - struct RequirementAdlClass : x3::annotate_on_success {}; - struct RequirementDurativeActionsClass : x3::annotate_on_success {}; - struct RequirementDerivedPredicatesClass : x3::annotate_on_success {}; - struct RequirementTimedInitialLiteralsClass : x3::annotate_on_success {}; - struct RequirementPreferencesClass : x3::annotate_on_success {}; - struct RequirementConstraintsClass : x3::annotate_on_success {}; - struct RequirementActionCostsClass : x3::annotate_on_success {}; - struct RequirementClass : x3::annotate_on_success {}; - - struct TypeClass : x3::annotate_on_success {}; - struct TypeObjectClass : x3::annotate_on_success {}; - struct TypeNumberClass : x3::annotate_on_success {}; - struct TypeEitherClass : x3::annotate_on_success {}; - struct TypedListOfNamesRecursivelyClass : x3::annotate_on_success {}; - struct TypedListOfNamesClass : x3::annotate_on_success {}; - struct TypedListOfVariablesRecursivelyClass : x3::annotate_on_success {}; - struct TypedListOfVariablesClass : x3::annotate_on_success {}; - - struct AtomicFormulaSkeletonClass : x3::annotate_on_success {}; - - struct AtomicFunctionSkeletonTotalCostClass : x3::annotate_on_success {}; - struct AtomicFunctionSkeletonGeneralClass : x3::annotate_on_success {}; - struct AtomicFunctionSkeletonClass : x3::annotate_on_success {}; - struct FunctionTypedListOfAtomicFunctionSkeletonsRecursivelyClass : x3::annotate_on_success {}; - struct FunctionTypedListOfAtomicFunctionSkeletonsClass : x3::annotate_on_success {}; - - struct AtomicFormulaOfTermsPredicateClass : x3::annotate_on_success {}; - struct AtomicFormulaOfTermsEqualityClass : x3::annotate_on_success {}; - struct AtomicFormulaOfTermsClass : x3::annotate_on_success {}; - struct AtomClass : x3::annotate_on_success {}; - struct NegatedAtomClass : x3::annotate_on_success {}; - struct LiteralClass : x3::annotate_on_success {}; - - struct MultiOperatorMulClass : x3::annotate_on_success {}; - struct MultiOperatorPlusClass : x3::annotate_on_success {}; - struct MultiOperatorClass : x3::annotate_on_success {}; - struct BinaryOperatorMinusClass : x3::annotate_on_success {}; - struct BinaryOperatorDivClass : x3::annotate_on_success {}; - struct BinaryOperatorClass : x3::annotate_on_success {}; - - struct BinaryComparatorGreaterClass : x3::annotate_on_success {}; - struct BinaryComparatorLessClass : x3::annotate_on_success {}; - struct BinaryComparatorEqualClass : x3::annotate_on_success {}; - struct BinaryComparatorGreaterEqualClass : x3::annotate_on_success {}; - struct BinaryComparatorLessEqualClass : x3::annotate_on_success {}; - struct BinaryComparatorClass : x3::annotate_on_success {}; - - struct FunctionExpressionClass : x3::annotate_on_success {}; - struct FunctionHeadClass : x3::annotate_on_success {}; - struct FunctionExpressionNumberClass : x3::annotate_on_success {}; - struct FunctionExpressionBinaryOpClass : x3::annotate_on_success {}; - struct FunctionExpressionMinusClass : x3::annotate_on_success {}; - struct FunctionExpressionHeadClass : x3::annotate_on_success {}; - - struct GoalDescriptorClass : x3::annotate_on_success {}; - struct GoalDescriptorAtomClass : x3::annotate_on_success {}; - struct GoalDescriptorLiteralClass : x3::annotate_on_success {}; - struct GoalDescriptorAndClass : x3::annotate_on_success {}; - struct GoalDescriptorOrClass : x3::annotate_on_success {}; - struct GoalDescriptorNotClass : x3::annotate_on_success {}; - struct GoalDescriptorImplyClass : x3::annotate_on_success {}; - struct GoalDescriptorExistsClass : x3::annotate_on_success {}; - struct GoalDescriptorForallClass : x3::annotate_on_success {}; - struct GoalDescriptorFunctionComparisonClass : x3::annotate_on_success {}; - - struct ConstraintGoalDescriptorClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorAndClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorForallClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorAtEndClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorAlwaysClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorSometimeClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorWithinClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorAtMostOnceClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorSometimeAfterClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorSometimeBeforeClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorAlwaysWithinClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorHoldDuringClass : x3::annotate_on_success {}; - struct ConstraintGoalDescriptorHoldAfterClass : x3::annotate_on_success {}; - - struct PreferenceNameClass : x3::annotate_on_success {}; - struct PreconditionGoalDescriptorClass : x3::annotate_on_success {}; - struct PreconditionGoalDescriptorSimpleClass : x3::annotate_on_success {}; - struct PreconditionGoalDescriptorAndClass : x3::annotate_on_success {}; - struct PreconditionGoalDescriptorPreferenceClass : x3::annotate_on_success {}; - struct PreconditionGoalDescriptorForallClass : x3::annotate_on_success {}; - - struct AssignOperatorAssignClass : x3::annotate_on_success {}; - struct AssignOperatorScaleUpClass : x3::annotate_on_success {}; - struct AssignOperatorScaleDownClass : x3::annotate_on_success {}; - struct AssignOperatorIncreaseClass : x3::annotate_on_success {}; - struct AssignOperatorDecreaseClass : x3::annotate_on_success {}; - struct AssignOperatorClass : x3::annotate_on_success {}; - - struct NumericTermClass : x3::annotate_on_success {}; - - struct EffectClass : x3::annotate_on_success {}; - struct EffectProductionLiteralClass : x3::annotate_on_success {}; - struct EffectProductionNumericFluentTotalCostClass : x3::annotate_on_success {}; - struct EffectProductionNumericFluentGeneralClass : x3::annotate_on_success {}; - struct EffectProductionClass : x3::annotate_on_success {}; - struct EffectConditionalForallClass : x3::annotate_on_success {}; - struct EffectConditionalWhenClass : x3::annotate_on_success {}; - struct EffectConditionalClass : x3::annotate_on_success {}; - struct ActionSymbolClass : x3::annotate_on_success {}; - struct ActionBodyClass : x3::annotate_on_success {}; - struct ActionClass : x3::annotate_on_success {}; - struct DurativeActionClass : x3::annotate_on_success {}; - struct DerivedPredicateClass : x3::annotate_on_success {}; - - struct DomainNameClass : x3::annotate_on_success {}; - struct RequirementsClass : x3::annotate_on_success {}; - struct TypesClass : x3::annotate_on_success {}; - struct ConstantsClass : x3::annotate_on_success {}; - struct PredicatesClass : x3::annotate_on_success {}; - struct FunctionsClass : x3::annotate_on_success {}; - struct ConstraintsClass : x3::annotate_on_success {}; - struct StructureClass : x3::annotate_on_success {}; - struct DomainClass : x3::annotate_on_success, error_handler_domain {}; +struct DomainNameClass : x3::annotate_on_success +{ +}; +struct RequirementsClass : x3::annotate_on_success +{ +}; +struct TypesClass : x3::annotate_on_success +{ +}; +struct ConstantsClass : x3::annotate_on_success +{ +}; +struct PredicatesClass : x3::annotate_on_success +{ +}; +struct FunctionsClass : x3::annotate_on_success +{ +}; +struct ConstraintsClass : x3::annotate_on_success +{ +}; +struct StructureClass : x3::annotate_on_success +{ +}; +struct DomainClass : x3::annotate_on_success, error_handler_domain +{ +}; } namespace loki::domain { - parser::define_keyword_type const& define_keyword() { - return parser::define_keyword; - } - parser::domain_keyword_type const& domain_keyword() { - return parser::domain_keyword; - } - - parser::name_type const& name() { - return parser::name; - } - parser::variable_type const& variable() { - return parser::variable; - } - parser::name_total_cost_type const& name_total_cost() { - return parser::name_total_cost; - } - parser::function_symbol_total_cost_type const& function_symbol_total_cost() { - return parser::function_symbol_total_cost; - } - parser::function_symbol_type const& function_symbol() { - return parser::function_symbol; - } - parser::term_type const& term() { - return parser::term; - } - parser::number_type const& number() { - return parser::number; - } - parser::predicate_type const& predicate() { - return parser::predicate; - } - - parser::requirement_strips_type const& requirement_strips() { - return parser::requirement_strips; - } - parser::requirement_typing_type const& requirement_typing() { - return parser::requirement_typing; - } - parser::requirement_negative_preconditions_type const& requirement_negative_preconditions() { - return parser::requirement_negative_preconditions; - } - parser::requirement_disjunctive_preconditions_type const& requirement_disjunctive_preconditions() { - return parser::requirement_disjunctive_preconditions; - } - parser::requirement_equality_type const& requirement_equality() { - return parser::requirement_equality; - } - parser::requirement_existential_preconditions_type const& requirement_existential_preconditions() { - return parser::requirement_existential_preconditions; - } - parser::requirement_universal_preconditions_type const& requirement_universal_preconditions() { - return parser::requirement_universal_preconditions; - } - parser::requirement_quantified_preconditions_type const& requirement_quantified_preconditions() { - return parser::requirement_quantified_preconditions; - } - parser::requirement_conditional_effects_type const& requirement_conditional_effects() { - return parser::requirement_conditional_effects; - } - parser::requirement_fluents_type const& requirement_fluents() { - return parser::requirement_fluents; - } - parser::requirement_object_fluents_type const& requirement_object_fluents() { - return parser::requirement_object_fluents; - } - parser::requirement_numeric_fluents_type const& requirement_numeric_fluents() { - return parser::requirement_numeric_fluents; - } - parser::requirement_adl_type const& requirement_adl() { - return parser::requirement_adl; - } - parser::requirement_durative_actions_type const& requirement_durative_actions() { - return parser::requirement_durative_actions; - } - parser::requirement_derived_predicates_type const& requirement_derived_predicates() { - return parser::requirement_derived_predicates; - } - parser::requirement_timed_initial_literals_type const& requirement_timed_initial_literals() { - return parser::requirement_timed_initial_literals; - } - parser::requirement_preferences_type const& requirement_preferences() { - return parser::requirement_preferences; - } - parser::requirement_constraints_type const& requirement_constraints() { - return parser::requirement_constraints; - } - parser::requirement_action_costs_type const& requirement_action_costs() { - return parser::requirement_action_costs; - } - parser::requirement_type const& requirement() { - return parser::requirement; - } - - parser::type_type const& type() { - return parser::type; - } - parser::type_object_type const& type_object() { - return parser::type_object; - } - parser::type_number_type const& type_number() { - return parser::type_number; - } - parser::type_either_type const& type_either() { - return parser::type_either; - } - parser::typed_list_of_names_recursively_type const& typed_list_of_names_recursively() { - return parser::typed_list_of_names_recursively; - } - parser::typed_list_of_names_type const& typed_list_of_names() { - return parser::typed_list_of_names; - } - parser::typed_list_of_variables_recursively_type const& typed_list_of_variables_recursively() { - return parser::typed_list_of_variables_recursively; - } - parser::typed_list_of_variables_type const& typed_list_of_variables() { - return parser::typed_list_of_variables; - } - - parser::atomic_formula_skeleton_type const& atomic_formula_skeleton() { - return parser::atomic_formula_skeleton; - } - - parser::atomic_function_skeleton_total_cost_type const& atomic_function_skeleton_total_cost() { - return parser::atomic_function_skeleton_total_cost; - } - parser::atomic_function_skeleton_general_type const& atomic_function_skeleton_general() { - return parser::atomic_function_skeleton_general; - } - parser::atomic_function_skeleton_type const& atomic_function_skeleton() { - return parser::atomic_function_skeleton; - } - parser::function_typed_list_of_atomic_function_skeletons_recursively_type const& function_typed_list_of_atomic_function_skeletons_recursively() { - return parser::function_typed_list_of_atomic_function_skeletons_recursively; - } - parser::function_typed_list_of_atomic_function_skeletons_type const& function_typed_list_of_atomic_function_skeletons() { - return parser::function_typed_list_of_atomic_function_skeletons; - } - - parser::atomic_formula_of_terms_predicate_type const& atomic_formula_of_terms_predicate() { - return parser::atomic_formula_of_terms_predicate; - } - parser::atomic_formula_of_terms_equality_type const& atomic_formula_of_terms_equality() { - return parser::atomic_formula_of_terms_equality; - } - parser::atomic_formula_of_terms_type const& atomic_formula_of_terms() { - return parser::atomic_formula_of_terms; - } - parser::atom_type const& atom() { - return parser::atom; - } - parser::negated_atom_type const& negated_atom() { - return parser::negated_atom; - } - parser::literal_type const& literal() { - return parser::literal; - } - - parser::multi_operator_mul_type const& multi_operator_mul() { - return parser::multi_operator_mul; - } - parser::multi_operator_plus_type const& multi_operator_plus() { - return parser::multi_operator_plus; - } - parser::multi_operator_type const& multi_operator() { - return parser::multi_operator; - } - parser::binary_operator_minus_type const& binary_operator_minus() { - return parser::binary_operator_minus; - } - parser::binary_operator_div_type const& binary_operator_div() { - return parser::binary_operator_div; - } - parser::binary_operator_type const& binary_operator() { - return parser::binary_operator; - } - - parser::binary_comparator_greater_type const& binary_comparator_greater() { - return parser::binary_comparator_greater; - } - parser::binary_comparator_less_type const& binary_comparator_less() { - return parser::binary_comparator_less; - } - parser::binary_comparator_equal_type const& binary_comparator_equal() { - return parser::binary_comparator_equal; - } - parser::binary_comparator_greater_equal_type const& binary_comparator_greater_equal() { - return parser::binary_comparator_greater_equal; - } - parser::binary_comparator_less_equal_type const& binary_comparator_less_equal() { - return parser::binary_comparator_less_equal; - } - parser::binary_comparator_type const& binary_comparator() { - return parser::binary_comparator; - } - - parser::function_expression_type const& function_expression() { - return parser::function_expression; - } - parser::function_head_type const& function_head() { - return parser::function_head; - } - parser::function_expression_number_type const& function_expression_number() { - return parser::function_expression_number; - } - parser::function_expression_binary_op_type const& function_expression_binary_op() { - return parser::function_expression_binary_op; - } - parser::function_expression_minus_type const& function_expression_minus() { - return parser::function_expression_minus; - } - parser::function_expression_head_type const& function_expression_head() { - return parser::function_expression_head; - } - - parser::goal_descriptor_type const& goal_descriptor() { - return parser::goal_descriptor; - } - parser::goal_descriptor_atom_type const& goal_descriptor_atom() { - return parser::goal_descriptor_atom; - } - parser::goal_descriptor_literal_type const& goal_descriptor_literal() { - return parser::goal_descriptor_literal; - } - parser::goal_descriptor_and_type const& goal_descriptor_and() { - return parser::goal_descriptor_and; - } - parser::goal_descriptor_or_type const& goal_descriptor_or() { - return parser::goal_descriptor_or; - } - parser::goal_descriptor_not_type const& goal_descriptor_not() { - return parser::goal_descriptor_not; - } - parser::goal_descriptor_imply_type const& goal_descriptor_imply() { - return parser::goal_descriptor_imply; - } - parser::goal_descriptor_exists_type const& goal_descriptor_exists() { - return parser::goal_descriptor_exists; - } - parser::goal_descriptor_forall_type const& goal_descriptor_forall() { - return parser::goal_descriptor_forall; - } - parser::goal_descriptor_function_comparison_type const& goal_descriptor_function_comparison() { - return parser::goal_descriptor_function_comparison; - } - - parser::constraint_goal_descriptor_type const& constraint_goal_descriptor() { - return parser::constraint_goal_descriptor; - } - parser::constraint_goal_descriptor_and_type const& constraint_goal_descriptor_and() { - return parser::constraint_goal_descriptor_and; - } - parser::constraint_goal_descriptor_forall_type const& constraint_goal_descriptor_forall() { - return parser::constraint_goal_descriptor_forall; - } - parser::constraint_goal_descriptor_at_end_type const& constraint_goal_descriptor_at_end() { - return parser::constraint_goal_descriptor_at_end; - } - parser::constraint_goal_descriptor_always_type const& constraint_goal_descriptor_always() { - return parser::constraint_goal_descriptor_always; - } - parser::constraint_goal_descriptor_sometime_type const& constraint_goal_descriptor_sometime() { - return parser::constraint_goal_descriptor_sometime; - } - parser::constraint_goal_descriptor_within_type const& constraint_goal_descriptor_within() { - return parser::constraint_goal_descriptor_within; - } - parser::constraint_goal_descriptor_at_most_once_type const& constraint_goal_descriptor_at_most_once() { - return parser::constraint_goal_descriptor_at_most_once; - } - parser::constraint_goal_descriptor_sometime_after_type const& constraint_goal_descriptor_sometime_after() { - return parser::constraint_goal_descriptor_sometime_after; - } - parser::constraint_goal_descriptor_sometime_before_type const& constraint_goal_descriptor_sometime_before() { - return parser::constraint_goal_descriptor_sometime_before; - } - parser::constraint_goal_descriptor_always_within_type const& constraint_goal_descriptor_always_within() { - return parser::constraint_goal_descriptor_always_within; - } - parser::constraint_goal_descriptor_hold_during_type const& constraint_goal_descriptor_hold_during() { - return parser::constraint_goal_descriptor_hold_during; - } - parser::constraint_goal_descriptor_hold_after_type const& constraint_goal_descriptor_hold_after() { - return parser::constraint_goal_descriptor_hold_after; - } - - parser::precondition_goal_descriptor_type const& precondition_goal_descriptor() { - return parser::precondition_goal_descriptor; - } - parser::preference_name_type const& preference_name() { - return parser::preference_name; - } - parser::precondition_goal_descriptor_simple_type const& precondition_goal_descriptor_simple() { - return parser::precondition_goal_descriptor_simple; - } - parser::precondition_goal_descriptor_and_type const& precondition_goal_descriptor_and() { - return parser::precondition_goal_descriptor_and; - } - parser::precondition_goal_descriptor_preference_type const& precondition_goal_descriptor_preference() { - return parser::precondition_goal_descriptor_preference; - } - parser::precondition_goal_descriptor_forall_type const& precondition_goal_descriptor_forall() { - return parser::precondition_goal_descriptor_forall; - } - - parser::assign_operator_assign_type const& assign_operator_assign() { - return parser::assign_operator_assign; - } - parser::assign_operator_scale_up_type const& assign_operator_scale_up() { - return parser::assign_operator_scale_up; - } - parser::assign_operator_scale_down_type const& assign_operator_scale_down() { - return parser::assign_operator_scale_down; - } - parser::assign_operator_increase_type const& assign_operator_increase() { - return parser::assign_operator_increase; - } - parser::assign_operator_decrease_type const& assign_operator_decrease() { - return parser::assign_operator_decrease; - } - parser::assign_operator_type const& assign_operator() { - return parser::assign_operator; - } - - parser::numeric_term_type const& numeric_term() { - return parser::numeric_term; - } - - parser::effect_type const& effect() { - return parser::effect; - } - parser::effect_production_literal_type const& effect_production_literal() { - return parser::effect_production_literal; - } - parser::effect_production_numeric_fluent_total_cost_type const& effect_production_numeric_fluent_total_cost() { - return parser::effect_production_numeric_fluent_total_cost; - } - parser::effect_production_numeric_fluent_general_type const& effect_production_numeric_fluent_general() { - return parser::effect_production_numeric_fluent_general; - } - parser::effect_production_type const& effect_production() { - return parser::effect_production; - } - parser::effect_conditional_forall_type const& effect_conditional_forall() { - return parser::effect_conditional_forall; - } - parser::effect_conditional_when_type const& effect_conditional_when() { - return parser::effect_conditional_when; - } - parser::effect_conditional_type const& effect_conditional() { - return parser::effect_conditional; - } - parser::action_symbol_type const& action_symbol() { - return parser::action_symbol; - } - parser::action_body_type const& action_body() { - return parser::action_body; - } - parser::action_type const& action() { - return parser::action; - } - parser::derived_predicate_type const& derived_predicate() { - return parser::derived_predicate; - } - - parser::domain_name_type const& domain_name() { - return parser::domain_name; - } - parser::requirements_type const& requirements() { - return parser::requirements; - } - parser::types_type const& types() { - return parser::types; - } - parser::constants_type const& constants() { - return parser::constants; - } - parser::predicates_type const& predicates() { - return parser::predicates; - } - parser::functions_type const& functions() { - return parser::functions; - } - parser::constraints_type const& constraints() { - return parser::constraints; - } - parser::structure_type const& structure() { - return parser::structure; - } - parser::domain_type const& domain() { - return parser::domain; - } +parser::define_keyword_type const& define_keyword() { return parser::define_keyword; } +parser::domain_keyword_type const& domain_keyword() { return parser::domain_keyword; } + +parser::name_type const& name() { return parser::name; } +parser::variable_type const& variable() { return parser::variable; } +parser::name_total_cost_type const& name_total_cost() { return parser::name_total_cost; } +parser::function_symbol_total_cost_type const& function_symbol_total_cost() { return parser::function_symbol_total_cost; } +parser::function_symbol_type const& function_symbol() { return parser::function_symbol; } +parser::term_type const& term() { return parser::term; } +parser::number_type const& number() { return parser::number; } +parser::predicate_type const& predicate() { return parser::predicate; } + +parser::requirement_strips_type const& requirement_strips() { return parser::requirement_strips; } +parser::requirement_typing_type const& requirement_typing() { return parser::requirement_typing; } +parser::requirement_negative_preconditions_type const& requirement_negative_preconditions() { return parser::requirement_negative_preconditions; } +parser::requirement_disjunctive_preconditions_type const& requirement_disjunctive_preconditions() { return parser::requirement_disjunctive_preconditions; } +parser::requirement_equality_type const& requirement_equality() { return parser::requirement_equality; } +parser::requirement_existential_preconditions_type const& requirement_existential_preconditions() { return parser::requirement_existential_preconditions; } +parser::requirement_universal_preconditions_type const& requirement_universal_preconditions() { return parser::requirement_universal_preconditions; } +parser::requirement_quantified_preconditions_type const& requirement_quantified_preconditions() { return parser::requirement_quantified_preconditions; } +parser::requirement_conditional_effects_type const& requirement_conditional_effects() { return parser::requirement_conditional_effects; } +parser::requirement_fluents_type const& requirement_fluents() { return parser::requirement_fluents; } +parser::requirement_object_fluents_type const& requirement_object_fluents() { return parser::requirement_object_fluents; } +parser::requirement_numeric_fluents_type const& requirement_numeric_fluents() { return parser::requirement_numeric_fluents; } +parser::requirement_adl_type const& requirement_adl() { return parser::requirement_adl; } +parser::requirement_durative_actions_type const& requirement_durative_actions() { return parser::requirement_durative_actions; } +parser::requirement_derived_predicates_type const& requirement_derived_predicates() { return parser::requirement_derived_predicates; } +parser::requirement_timed_initial_literals_type const& requirement_timed_initial_literals() { return parser::requirement_timed_initial_literals; } +parser::requirement_preferences_type const& requirement_preferences() { return parser::requirement_preferences; } +parser::requirement_constraints_type const& requirement_constraints() { return parser::requirement_constraints; } +parser::requirement_action_costs_type const& requirement_action_costs() { return parser::requirement_action_costs; } +parser::requirement_type const& requirement() { return parser::requirement; } + +parser::type_type const& type() { return parser::type; } +parser::type_object_type const& type_object() { return parser::type_object; } +parser::type_number_type const& type_number() { return parser::type_number; } +parser::type_either_type const& type_either() { return parser::type_either; } +parser::typed_list_of_names_recursively_type const& typed_list_of_names_recursively() { return parser::typed_list_of_names_recursively; } +parser::typed_list_of_names_type const& typed_list_of_names() { return parser::typed_list_of_names; } +parser::typed_list_of_variables_recursively_type const& typed_list_of_variables_recursively() { return parser::typed_list_of_variables_recursively; } +parser::typed_list_of_variables_type const& typed_list_of_variables() { return parser::typed_list_of_variables; } + +parser::atomic_formula_skeleton_type const& atomic_formula_skeleton() { return parser::atomic_formula_skeleton; } + +parser::atomic_function_skeleton_total_cost_type const& atomic_function_skeleton_total_cost() { return parser::atomic_function_skeleton_total_cost; } +parser::atomic_function_skeleton_general_type const& atomic_function_skeleton_general() { return parser::atomic_function_skeleton_general; } +parser::atomic_function_skeleton_type const& atomic_function_skeleton() { return parser::atomic_function_skeleton; } +parser::function_typed_list_of_atomic_function_skeletons_recursively_type const& function_typed_list_of_atomic_function_skeletons_recursively() +{ + return parser::function_typed_list_of_atomic_function_skeletons_recursively; +} +parser::function_typed_list_of_atomic_function_skeletons_type const& function_typed_list_of_atomic_function_skeletons() +{ + return parser::function_typed_list_of_atomic_function_skeletons; +} + +parser::atomic_formula_of_terms_predicate_type const& atomic_formula_of_terms_predicate() { return parser::atomic_formula_of_terms_predicate; } +parser::atomic_formula_of_terms_equality_type const& atomic_formula_of_terms_equality() { return parser::atomic_formula_of_terms_equality; } +parser::atomic_formula_of_terms_type const& atomic_formula_of_terms() { return parser::atomic_formula_of_terms; } +parser::atom_type const& atom() { return parser::atom; } +parser::negated_atom_type const& negated_atom() { return parser::negated_atom; } +parser::literal_type const& literal() { return parser::literal; } + +parser::multi_operator_mul_type const& multi_operator_mul() { return parser::multi_operator_mul; } +parser::multi_operator_plus_type const& multi_operator_plus() { return parser::multi_operator_plus; } +parser::multi_operator_type const& multi_operator() { return parser::multi_operator; } +parser::binary_operator_minus_type const& binary_operator_minus() { return parser::binary_operator_minus; } +parser::binary_operator_div_type const& binary_operator_div() { return parser::binary_operator_div; } +parser::binary_operator_type const& binary_operator() { return parser::binary_operator; } + +parser::binary_comparator_greater_type const& binary_comparator_greater() { return parser::binary_comparator_greater; } +parser::binary_comparator_less_type const& binary_comparator_less() { return parser::binary_comparator_less; } +parser::binary_comparator_equal_type const& binary_comparator_equal() { return parser::binary_comparator_equal; } +parser::binary_comparator_greater_equal_type const& binary_comparator_greater_equal() { return parser::binary_comparator_greater_equal; } +parser::binary_comparator_less_equal_type const& binary_comparator_less_equal() { return parser::binary_comparator_less_equal; } +parser::binary_comparator_type const& binary_comparator() { return parser::binary_comparator; } + +parser::function_expression_type const& function_expression() { return parser::function_expression; } +parser::function_head_type const& function_head() { return parser::function_head; } +parser::function_expression_number_type const& function_expression_number() { return parser::function_expression_number; } +parser::function_expression_binary_op_type const& function_expression_binary_op() { return parser::function_expression_binary_op; } +parser::function_expression_minus_type const& function_expression_minus() { return parser::function_expression_minus; } +parser::function_expression_head_type const& function_expression_head() { return parser::function_expression_head; } + +parser::goal_descriptor_type const& goal_descriptor() { return parser::goal_descriptor; } +parser::goal_descriptor_atom_type const& goal_descriptor_atom() { return parser::goal_descriptor_atom; } +parser::goal_descriptor_literal_type const& goal_descriptor_literal() { return parser::goal_descriptor_literal; } +parser::goal_descriptor_and_type const& goal_descriptor_and() { return parser::goal_descriptor_and; } +parser::goal_descriptor_or_type const& goal_descriptor_or() { return parser::goal_descriptor_or; } +parser::goal_descriptor_not_type const& goal_descriptor_not() { return parser::goal_descriptor_not; } +parser::goal_descriptor_imply_type const& goal_descriptor_imply() { return parser::goal_descriptor_imply; } +parser::goal_descriptor_exists_type const& goal_descriptor_exists() { return parser::goal_descriptor_exists; } +parser::goal_descriptor_forall_type const& goal_descriptor_forall() { return parser::goal_descriptor_forall; } +parser::goal_descriptor_function_comparison_type const& goal_descriptor_function_comparison() { return parser::goal_descriptor_function_comparison; } + +parser::constraint_goal_descriptor_type const& constraint_goal_descriptor() { return parser::constraint_goal_descriptor; } +parser::constraint_goal_descriptor_and_type const& constraint_goal_descriptor_and() { return parser::constraint_goal_descriptor_and; } +parser::constraint_goal_descriptor_forall_type const& constraint_goal_descriptor_forall() { return parser::constraint_goal_descriptor_forall; } +parser::constraint_goal_descriptor_at_end_type const& constraint_goal_descriptor_at_end() { return parser::constraint_goal_descriptor_at_end; } +parser::constraint_goal_descriptor_always_type const& constraint_goal_descriptor_always() { return parser::constraint_goal_descriptor_always; } +parser::constraint_goal_descriptor_sometime_type const& constraint_goal_descriptor_sometime() { return parser::constraint_goal_descriptor_sometime; } +parser::constraint_goal_descriptor_within_type const& constraint_goal_descriptor_within() { return parser::constraint_goal_descriptor_within; } +parser::constraint_goal_descriptor_at_most_once_type const& constraint_goal_descriptor_at_most_once() +{ + return parser::constraint_goal_descriptor_at_most_once; +} +parser::constraint_goal_descriptor_sometime_after_type const& constraint_goal_descriptor_sometime_after() +{ + return parser::constraint_goal_descriptor_sometime_after; +} +parser::constraint_goal_descriptor_sometime_before_type const& constraint_goal_descriptor_sometime_before() +{ + return parser::constraint_goal_descriptor_sometime_before; +} +parser::constraint_goal_descriptor_always_within_type const& constraint_goal_descriptor_always_within() +{ + return parser::constraint_goal_descriptor_always_within; +} +parser::constraint_goal_descriptor_hold_during_type const& constraint_goal_descriptor_hold_during() { return parser::constraint_goal_descriptor_hold_during; } +parser::constraint_goal_descriptor_hold_after_type const& constraint_goal_descriptor_hold_after() { return parser::constraint_goal_descriptor_hold_after; } + +parser::precondition_goal_descriptor_type const& precondition_goal_descriptor() { return parser::precondition_goal_descriptor; } +parser::preference_name_type const& preference_name() { return parser::preference_name; } +parser::precondition_goal_descriptor_simple_type const& precondition_goal_descriptor_simple() { return parser::precondition_goal_descriptor_simple; } +parser::precondition_goal_descriptor_and_type const& precondition_goal_descriptor_and() { return parser::precondition_goal_descriptor_and; } +parser::precondition_goal_descriptor_preference_type const& precondition_goal_descriptor_preference() +{ + return parser::precondition_goal_descriptor_preference; +} +parser::precondition_goal_descriptor_forall_type const& precondition_goal_descriptor_forall() { return parser::precondition_goal_descriptor_forall; } + +parser::assign_operator_assign_type const& assign_operator_assign() { return parser::assign_operator_assign; } +parser::assign_operator_scale_up_type const& assign_operator_scale_up() { return parser::assign_operator_scale_up; } +parser::assign_operator_scale_down_type const& assign_operator_scale_down() { return parser::assign_operator_scale_down; } +parser::assign_operator_increase_type const& assign_operator_increase() { return parser::assign_operator_increase; } +parser::assign_operator_decrease_type const& assign_operator_decrease() { return parser::assign_operator_decrease; } +parser::assign_operator_type const& assign_operator() { return parser::assign_operator; } + +parser::numeric_term_type const& numeric_term() { return parser::numeric_term; } + +parser::effect_type const& effect() { return parser::effect; } +parser::effect_production_literal_type const& effect_production_literal() { return parser::effect_production_literal; } +parser::effect_production_numeric_fluent_total_cost_type const& effect_production_numeric_fluent_total_cost() +{ + return parser::effect_production_numeric_fluent_total_cost; +} +parser::effect_production_numeric_fluent_general_type const& effect_production_numeric_fluent_general() +{ + return parser::effect_production_numeric_fluent_general; +} +parser::effect_production_type const& effect_production() { return parser::effect_production; } +parser::effect_conditional_forall_type const& effect_conditional_forall() { return parser::effect_conditional_forall; } +parser::effect_conditional_when_type const& effect_conditional_when() { return parser::effect_conditional_when; } +parser::effect_conditional_type const& effect_conditional() { return parser::effect_conditional; } +parser::action_symbol_type const& action_symbol() { return parser::action_symbol; } +parser::action_body_type const& action_body() { return parser::action_body; } +parser::action_type const& action() { return parser::action; } +parser::derived_predicate_type const& derived_predicate() { return parser::derived_predicate; } + +parser::domain_name_type const& domain_name() { return parser::domain_name; } +parser::requirements_type const& requirements() { return parser::requirements; } +parser::types_type const& types() { return parser::types; } +parser::constants_type const& constants() { return parser::constants; } +parser::predicates_type const& predicates() { return parser::predicates; } +parser::functions_type const& functions() { return parser::functions; } +parser::constraints_type const& constraints() { return parser::constraints; } +parser::structure_type const& structure() { return parser::structure; } +parser::domain_type const& domain() { return parser::domain; } } #endif diff --git a/src/domain/ast/parser_instantiations.cpp b/src/domain/ast/parser_instantiations.cpp index 6748726f..c4b540c6 100644 --- a/src/domain/ast/parser_instantiations.cpp +++ b/src/domain/ast/parser_instantiations.cpp @@ -19,152 +19,151 @@ #include - namespace loki::domain::parser { - using iterator_type = loki::iterator_type; - using phrase_context_type = loki::phrase_context_type; - using context_type = loki::context_type; - - BOOST_SPIRIT_INSTANTIATE(name_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(variable_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(name_total_cost_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_symbol_total_cost_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_symbol_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(term_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(number_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(predicate_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(requirement_strips_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_typing_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_negative_preconditions_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_disjunctive_preconditions_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_equality_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_existential_preconditions_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_universal_preconditions_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_quantified_preconditions_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_conditional_effects_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_fluents_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_object_fluents_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_numeric_fluents_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_adl_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_durative_actions_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_derived_predicates_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_timed_initial_literals_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_preferences_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_constraints_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_action_costs_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirement_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(type_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(type_object_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(type_number_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(type_either_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(typed_list_of_names_recursively_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(typed_list_of_names_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(typed_list_of_variables_recursively_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(typed_list_of_variables_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(atomic_formula_skeleton_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(atomic_function_skeleton_total_cost_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(atomic_function_skeleton_general_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(atomic_function_skeleton_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_typed_list_of_atomic_function_skeletons_recursively_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_typed_list_of_atomic_function_skeletons_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(atomic_formula_of_terms_predicate_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(atomic_formula_of_terms_equality_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(atomic_formula_of_terms_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(atom_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(negated_atom_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(literal_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(multi_operator_mul_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(multi_operator_plus_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(multi_operator_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(binary_operator_minus_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(binary_operator_div_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(binary_operator_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(binary_comparator_greater_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(binary_comparator_less_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(binary_comparator_equal_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(binary_comparator_greater_equal_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(binary_comparator_less_equal_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(binary_comparator_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(function_expression_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_head_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_expression_number_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_expression_binary_op_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_expression_minus_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(function_expression_head_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_atom_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_literal_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_and_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_or_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_not_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_imply_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_exists_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_forall_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(goal_descriptor_function_comparison_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_and_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_forall_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_at_end_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_always_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_sometime_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_within_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_at_most_once_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_sometime_after_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_sometime_before_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_always_within_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_hold_during_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_hold_after_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(preference_name_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_simple_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_and_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_preference_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_forall_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(assign_operator_assign_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(assign_operator_scale_up_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(assign_operator_scale_down_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(assign_operator_increase_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(assign_operator_decrease_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(assign_operator_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(numeric_term_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(effect_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(effect_production_literal_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(effect_production_numeric_fluent_total_cost_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(effect_production_numeric_fluent_general_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(effect_production_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(effect_conditional_forall_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(effect_conditional_when_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(effect_conditional_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(action_symbol_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(action_body_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(action_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(derived_predicate_type, iterator_type, context_type) - - BOOST_SPIRIT_INSTANTIATE(define_keyword_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(domain_keyword_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(domain_name_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(requirements_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(types_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constants_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(predicates_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(functions_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(constraints_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(structure_type, iterator_type, context_type) - BOOST_SPIRIT_INSTANTIATE(domain_type, iterator_type, context_type) +using iterator_type = loki::iterator_type; +using phrase_context_type = loki::phrase_context_type; +using context_type = loki::context_type; + +BOOST_SPIRIT_INSTANTIATE(name_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(variable_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(name_total_cost_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_symbol_total_cost_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_symbol_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(term_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(number_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(predicate_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(requirement_strips_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_typing_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_negative_preconditions_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_disjunctive_preconditions_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_equality_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_existential_preconditions_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_universal_preconditions_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_quantified_preconditions_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_conditional_effects_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_fluents_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_object_fluents_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_numeric_fluents_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_adl_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_durative_actions_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_derived_predicates_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_timed_initial_literals_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_preferences_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_constraints_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_action_costs_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirement_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(type_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(type_object_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(type_number_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(type_either_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(typed_list_of_names_recursively_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(typed_list_of_names_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(typed_list_of_variables_recursively_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(typed_list_of_variables_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(atomic_formula_skeleton_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(atomic_function_skeleton_total_cost_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(atomic_function_skeleton_general_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(atomic_function_skeleton_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_typed_list_of_atomic_function_skeletons_recursively_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_typed_list_of_atomic_function_skeletons_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(atomic_formula_of_terms_predicate_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(atomic_formula_of_terms_equality_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(atomic_formula_of_terms_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(atom_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(negated_atom_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(literal_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(multi_operator_mul_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(multi_operator_plus_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(multi_operator_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(binary_operator_minus_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(binary_operator_div_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(binary_operator_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(binary_comparator_greater_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(binary_comparator_less_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(binary_comparator_equal_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(binary_comparator_greater_equal_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(binary_comparator_less_equal_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(binary_comparator_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(function_expression_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_head_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_expression_number_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_expression_binary_op_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_expression_minus_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(function_expression_head_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_atom_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_literal_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_and_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_or_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_not_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_imply_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_exists_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_forall_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(goal_descriptor_function_comparison_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_and_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_forall_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_at_end_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_always_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_sometime_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_within_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_at_most_once_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_sometime_after_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_sometime_before_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_always_within_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_hold_during_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraint_goal_descriptor_hold_after_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(preference_name_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_simple_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_and_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_preference_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(precondition_goal_descriptor_forall_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(assign_operator_assign_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(assign_operator_scale_up_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(assign_operator_scale_down_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(assign_operator_increase_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(assign_operator_decrease_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(assign_operator_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(numeric_term_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(effect_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(effect_production_literal_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(effect_production_numeric_fluent_total_cost_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(effect_production_numeric_fluent_general_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(effect_production_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(effect_conditional_forall_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(effect_conditional_when_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(effect_conditional_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(action_symbol_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(action_body_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(action_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(derived_predicate_type, iterator_type, context_type) + +BOOST_SPIRIT_INSTANTIATE(define_keyword_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(domain_keyword_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(domain_name_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(requirements_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(types_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constants_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(predicates_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(functions_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(constraints_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(structure_type, iterator_type, context_type) +BOOST_SPIRIT_INSTANTIATE(domain_type, iterator_type, context_type) } diff --git a/src/domain/ast/printer.cpp b/src/domain/ast/printer.cpp index 9357e877..83d02e93 100644 --- a/src/domain/ast/printer.cpp +++ b/src/domain/ast/printer.cpp @@ -16,689 +16,677 @@ */ #include - #include - #include #include using namespace std; - namespace loki { - // Printer for std::vector - template - inline std::string parse_text(const std::vector& nodes, const FormattingOptions& options); +// Printer for std::vector +template +inline std::string parse_text(const std::vector& nodes, const FormattingOptions& options); - // Printer for boost::variant - class NodeVisitorPrinter : public boost::static_visitor { - private: - const FormattingOptions* options; +// Printer for boost::variant +class NodeVisitorPrinter : public boost::static_visitor +{ +private: + const FormattingOptions* options; - public: - NodeVisitorPrinter(const FormattingOptions& options) : options(&options) { } +public: + NodeVisitorPrinter(const FormattingOptions& options) : options(&options) {} - template - std::string operator()(const Node& node) const - { - return parse_text(node, *options); - } - }; - - string parse_text(const domain::ast::Name& node, const FormattingOptions&) + template + std::string operator()(const Node& node) const { - return node.characters; + return parse_text(node, *options); } +}; - string parse_text(const domain::ast::Variable& node, const FormattingOptions&) - { - return node.characters; - } +string parse_text(const domain::ast::Name& node, const FormattingOptions&) { return node.characters; } - std::string parse_text(const domain::ast::FunctionSymbol& node, const FormattingOptions& options) - { - return parse_text(node.name, options); - } +string parse_text(const domain::ast::Variable& node, const FormattingOptions&) { return node.characters; } - string parse_text(const domain::ast::Term& node, const FormattingOptions& options) - { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::FunctionSymbol& node, const FormattingOptions& options) { return parse_text(node.name, options); } - std::string parse_text(const domain::ast::Predicate& node, const FormattingOptions& options) - { - return parse_text(node.name, options); - } +string parse_text(const domain::ast::Term& node, const FormattingOptions& options) { return boost::apply_visitor(NodeVisitorPrinter(options), node); } - string parse_text(const domain::ast::Number& node, const FormattingOptions&) - { - stringstream ss; - ss << node.value; - return ss.str(); - } +std::string parse_text(const domain::ast::Predicate& node, const FormattingOptions& options) { return parse_text(node.name, options); } - std::string parse_text(const domain::ast::RequirementStrips&, const FormattingOptions&) { return ":strips"; } - std::string parse_text(const domain::ast::RequirementTyping&, const FormattingOptions&) { return ":typing"; } - std::string parse_text(const domain::ast::RequirementNegativePreconditions&, const FormattingOptions&) { return ":negative-preconditions"; } - std::string parse_text(const domain::ast::RequirementDisjunctivePreconditions&, const FormattingOptions&) { return ":disjunctive-preconditions"; } - std::string parse_text(const domain::ast::RequirementEquality&, const FormattingOptions&) { return ":equality"; } - std::string parse_text(const domain::ast::RequirementExistentialPreconditions&, const FormattingOptions&) { return ":existential-preconditions"; } - std::string parse_text(const domain::ast::RequirementUniversalPreconditions&, const FormattingOptions&) { return ":universal-preconditions"; } - std::string parse_text(const domain::ast::RequirementQuantifiedPreconditions&, const FormattingOptions&) { return ":quantified-preconditions"; } - std::string parse_text(const domain::ast::RequirementConditionalEffects&, const FormattingOptions&) { return ":conditional-effects"; } - std::string parse_text(const domain::ast::RequirementFluents&, const FormattingOptions&) { return ":fluents"; } - std::string parse_text(const domain::ast::RequirementObjectFluents&, const FormattingOptions&) { return ":object-fluents"; } - std::string parse_text(const domain::ast::RequirementNumericFluents&, const FormattingOptions&) { return ":numeric-fluents"; } - std::string parse_text(const domain::ast::RequirementAdl&, const FormattingOptions&) { return ":adl"; } - std::string parse_text(const domain::ast::RequirementDurativeActions&, const FormattingOptions&) { return ":durative-actions"; } - std::string parse_text(const domain::ast::RequirementDerivedPredicates&, const FormattingOptions&) { return ":derived-predicates"; } - std::string parse_text(const domain::ast::RequirementTimedInitialLiterals&, const FormattingOptions&) { return ":timed-initial-literals"; } - std::string parse_text(const domain::ast::RequirementPreferences&, const FormattingOptions&) { return ":preferences"; } - std::string parse_text(const domain::ast::RequirementConstraints&, const FormattingOptions&) { return ":constraints"; } - std::string parse_text(const domain::ast::RequirementActionCosts&, const FormattingOptions&) { return ":action-costs";} - - std::string parse_text(const domain::ast::Requirement& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +string parse_text(const domain::ast::Number& node, const FormattingOptions&) +{ + stringstream ss; + ss << node.value; + return ss.str(); +} +std::string parse_text(const domain::ast::RequirementStrips&, const FormattingOptions&) { return ":strips"; } +std::string parse_text(const domain::ast::RequirementTyping&, const FormattingOptions&) { return ":typing"; } +std::string parse_text(const domain::ast::RequirementNegativePreconditions&, const FormattingOptions&) { return ":negative-preconditions"; } +std::string parse_text(const domain::ast::RequirementDisjunctivePreconditions&, const FormattingOptions&) { return ":disjunctive-preconditions"; } +std::string parse_text(const domain::ast::RequirementEquality&, const FormattingOptions&) { return ":equality"; } +std::string parse_text(const domain::ast::RequirementExistentialPreconditions&, const FormattingOptions&) { return ":existential-preconditions"; } +std::string parse_text(const domain::ast::RequirementUniversalPreconditions&, const FormattingOptions&) { return ":universal-preconditions"; } +std::string parse_text(const domain::ast::RequirementQuantifiedPreconditions&, const FormattingOptions&) { return ":quantified-preconditions"; } +std::string parse_text(const domain::ast::RequirementConditionalEffects&, const FormattingOptions&) { return ":conditional-effects"; } +std::string parse_text(const domain::ast::RequirementFluents&, const FormattingOptions&) { return ":fluents"; } +std::string parse_text(const domain::ast::RequirementObjectFluents&, const FormattingOptions&) { return ":object-fluents"; } +std::string parse_text(const domain::ast::RequirementNumericFluents&, const FormattingOptions&) { return ":numeric-fluents"; } +std::string parse_text(const domain::ast::RequirementAdl&, const FormattingOptions&) { return ":adl"; } +std::string parse_text(const domain::ast::RequirementDurativeActions&, const FormattingOptions&) { return ":durative-actions"; } +std::string parse_text(const domain::ast::RequirementDerivedPredicates&, const FormattingOptions&) { return ":derived-predicates"; } +std::string parse_text(const domain::ast::RequirementTimedInitialLiterals&, const FormattingOptions&) { return ":timed-initial-literals"; } +std::string parse_text(const domain::ast::RequirementPreferences&, const FormattingOptions&) { return ":preferences"; } +std::string parse_text(const domain::ast::RequirementConstraints&, const FormattingOptions&) { return ":constraints"; } +std::string parse_text(const domain::ast::RequirementActionCosts&, const FormattingOptions&) { return ":action-costs"; } + +std::string parse_text(const domain::ast::Requirement& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - string parse_text(const domain::ast::Type& node, const FormattingOptions& options) - { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +string parse_text(const domain::ast::Type& node, const FormattingOptions& options) { return boost::apply_visitor(NodeVisitorPrinter(options), node); } - string parse_text(const domain::ast::TypeObject& /*node*/, const FormattingOptions& /*options*/) - { - return "object"; - } +string parse_text(const domain::ast::TypeObject& /*node*/, const FormattingOptions& /*options*/) { return "object"; } - string parse_text(const domain::ast::TypeNumber& /*node*/, const FormattingOptions& /*options*/) - { - return "number"; - } +string parse_text(const domain::ast::TypeNumber& /*node*/, const FormattingOptions& /*options*/) { return "number"; } - string parse_text(const domain::ast::TypeEither& node, const FormattingOptions& options) +string parse_text(const domain::ast::TypeEither& node, const FormattingOptions& options) +{ + stringstream ss; + ss << "(either "; + for (size_t i = 0; i < node.types.size(); ++i) { - stringstream ss; - ss << "(either "; - for (size_t i = 0; i < node.types.size(); ++i) - { - if (i != 0) - ss << " "; - ss << parse_text(node.types[i], options); - } - ss << ")"; - return ss.str(); + if (i != 0) + ss << " "; + ss << parse_text(node.types[i], options); } + ss << ")"; + return ss.str(); +} - string parse_text(const domain::ast::TypedListOfNamesRecursively& node, const FormattingOptions& options) +string parse_text(const domain::ast::TypedListOfNamesRecursively& node, const FormattingOptions& options) +{ + stringstream ss; + for (size_t i = 0; i < node.names.size(); ++i) { - stringstream ss; - for (size_t i = 0; i < node.names.size(); ++i) - { - if (i != 0) - ss << " "; - ss << parse_text(node.names[i], options); - } - ss << " - " << parse_text(node.type, options); - - // lookahead - auto nested_options = FormattingOptions{options.indent + options.add_indent, options.add_indent}; - auto nested_text = parse_text(node.typed_list_of_names, nested_options); - if (nested_text.size() > 0) { - ss << "\n"; - ss << string(nested_options.indent, ' ') << nested_text; - } - return ss.str(); + if (i != 0) + ss << " "; + ss << parse_text(node.names[i], options); } + ss << " - " << parse_text(node.type, options); - string parse_text(const domain::ast::TypedListOfNames& node, const FormattingOptions& options) + // lookahead + auto nested_options = FormattingOptions { options.indent + options.add_indent, options.add_indent }; + auto nested_text = parse_text(node.typed_list_of_names, nested_options); + if (nested_text.size() > 0) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); + ss << "\n"; + ss << string(nested_options.indent, ' ') << nested_text; } + return ss.str(); +} - std::string parse_text(const domain::ast::TypedListOfVariablesRecursively& node, const FormattingOptions& options) - { - stringstream ss; - for (size_t i = 0; i < node.variables.size(); ++i) - { - if (i != 0) - ss << " "; - ss << parse_text(node.variables[i]); - } - ss << " - " << parse_text(node.type, options); - - // lookahead - auto nested_options = FormattingOptions{options.indent + options.add_indent, options.add_indent}; - auto nested_text = parse_text(node.typed_list_of_variables, options); - if (nested_text.size() > 0) { - ss << "\n"; - ss << string(nested_options.indent, ' ') << nested_text; - } - return ss.str(); - } +string parse_text(const domain::ast::TypedListOfNames& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::TypedListOfVariables& node, const FormattingOptions& options) +std::string parse_text(const domain::ast::TypedListOfVariablesRecursively& node, const FormattingOptions& options) +{ + stringstream ss; + for (size_t i = 0; i < node.variables.size(); ++i) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); + if (i != 0) + ss << " "; + ss << parse_text(node.variables[i]); } + ss << " - " << parse_text(node.type, options); - std::string parse_text(const domain::ast::AtomicFormulaSkeleton& node, const FormattingOptions& options) + // lookahead + auto nested_options = FormattingOptions { options.indent + options.add_indent, options.add_indent }; + auto nested_text = parse_text(node.typed_list_of_variables, options); + if (nested_text.size() > 0) { - std::stringstream ss; - ss << "(" - << parse_text(node.predicate, options) << " " - << parse_text(node.typed_list_of_variables, options) << ")"; - return ss.str(); + ss << "\n"; + ss << string(nested_options.indent, ' ') << nested_text; } + return ss.str(); +} +std::string parse_text(const domain::ast::TypedListOfVariables& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::AtomicFunctionSkeletonTotalCost& node, const FormattingOptions& /*options*/) - { - std::stringstream ss; - ss << "(" << parse_text(node.function_symbol) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::AtomicFormulaSkeleton& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(" << parse_text(node.predicate, options) << " " << parse_text(node.typed_list_of_variables, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::AtomicFunctionSkeletonGeneral& node, const FormattingOptions& options) - { - std::stringstream ss; - ss << "(" - << parse_text(node.function_symbol, options) << " " - << parse_text(node.arguments, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::AtomicFunctionSkeletonTotalCost& node, const FormattingOptions& /*options*/) +{ + std::stringstream ss; + ss << "(" << parse_text(node.function_symbol) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::AtomicFunctionSkeleton& node, const FormattingOptions& options) +std::string parse_text(const domain::ast::AtomicFunctionSkeletonGeneral& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(" << parse_text(node.function_symbol, options) << " " << parse_text(node.arguments, options) << ")"; + return ss.str(); +} + +std::string parse_text(const domain::ast::AtomicFunctionSkeleton& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} + +std::string parse_text(const domain::ast::FunctionTypedListOfAtomicFunctionSkeletonsRecursively& node, const FormattingOptions& options) +{ + stringstream ss; + for (size_t i = 0; i < node.atomic_function_skeletons.size(); ++i) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); + if (i != 0) + ss << " "; + ss << parse_text(node.atomic_function_skeletons[i], options); } + ss << " - " << parse_text(node.function_type, options); - std::string parse_text(const domain::ast::FunctionTypedListOfAtomicFunctionSkeletonsRecursively& node, const FormattingOptions& options) { - stringstream ss; - for (size_t i = 0; i < node.atomic_function_skeletons.size(); ++i) + // lookahead + auto nested_options = FormattingOptions { options.indent + options.add_indent, options.add_indent }; + if (node.function_typed_list_of_atomic_function_skeletons.has_value()) + { + auto nested_text = parse_text(node.function_typed_list_of_atomic_function_skeletons.value(), options); + if (nested_text.size() > 0) { - if (i != 0) - ss << " "; - ss << parse_text(node.atomic_function_skeletons[i], options); - } - ss << " - " << parse_text(node.function_type, options); - - // lookahead - auto nested_options = FormattingOptions{options.indent + options.add_indent, options.add_indent}; - if (node.function_typed_list_of_atomic_function_skeletons.has_value()) { - auto nested_text = parse_text(node.function_typed_list_of_atomic_function_skeletons.value(), options); - if (nested_text.size() > 0) { - ss << "\n"; - ss << string(nested_options.indent, ' ') << nested_text; - } + ss << "\n"; + ss << string(nested_options.indent, ' ') << nested_text; } - return ss.str(); - } - - std::string parse_text(const domain::ast::FunctionTypedListOfAtomicFunctionSkeletons& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } - - - std::string parse_text(const domain::ast::AtomicFormulaOfTermsPredicate& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(" << parse_text(node.predicate, options) << " " << parse_text(node.terms, options) << ")"; - return ss.str(); } + return ss.str(); +} - std::string parse_text(const domain::ast::AtomicFormulaOfTermsEquality& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(" << "= " << parse_text(node.term_left, options) << " " << parse_text(node.term_right, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::FunctionTypedListOfAtomicFunctionSkeletons& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::AtomicFormulaOfTerms& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::AtomicFormulaOfTermsPredicate& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(" << parse_text(node.predicate, options) << " " << parse_text(node.terms, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::Atom& node, const FormattingOptions& options) { - return parse_text(node.atomic_formula_of_terms, options); - } +std::string parse_text(const domain::ast::AtomicFormulaOfTermsEquality& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(" + << "= " << parse_text(node.term_left, options) << " " << parse_text(node.term_right, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::NegatedAtom& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(not " << parse_text(node.atomic_formula_of_terms, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::AtomicFormulaOfTerms& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::Literal& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::Atom& node, const FormattingOptions& options) { return parse_text(node.atomic_formula_of_terms, options); } - std::string parse_text(const domain::ast::MultiOperatorMul&, const FormattingOptions&) { return "*"; } - std::string parse_text(const domain::ast::MultiOperatorPlus&, const FormattingOptions&) { return "+"; } - std::string parse_text(const domain::ast::MultiOperator& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::NegatedAtom& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(not " << parse_text(node.atomic_formula_of_terms, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::BinaryOperatorMinus&, const FormattingOptions&) { return "-"; } - std::string parse_text(const domain::ast::BinaryOperatorDiv&, const FormattingOptions&) { return "/"; } - std::string parse_text(const domain::ast::BinaryOperator& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::Literal& node, const FormattingOptions& options) { return boost::apply_visitor(NodeVisitorPrinter(options), node); } +std::string parse_text(const domain::ast::MultiOperatorMul&, const FormattingOptions&) { return "*"; } +std::string parse_text(const domain::ast::MultiOperatorPlus&, const FormattingOptions&) { return "+"; } +std::string parse_text(const domain::ast::MultiOperator& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::BinaryComparatorGreater&, const FormattingOptions&) { return ">"; } - std::string parse_text(const domain::ast::BinaryComparatorLess&, const FormattingOptions&) { return "<"; } - std::string parse_text(const domain::ast::BinaryComparatorEqual&, const FormattingOptions&) { return "="; } - std::string parse_text(const domain::ast::BinaryComparatorGreaterEqual&, const FormattingOptions&) { return ">="; } - std::string parse_text(const domain::ast::BinaryComparatorLessEqual&, const FormattingOptions&) { return "<="; } - std::string parse_text(const domain::ast::BinaryComparator& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::BinaryOperatorMinus&, const FormattingOptions&) { return "-"; } +std::string parse_text(const domain::ast::BinaryOperatorDiv&, const FormattingOptions&) { return "/"; } +std::string parse_text(const domain::ast::BinaryOperator& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} +std::string parse_text(const domain::ast::BinaryComparatorGreater&, const FormattingOptions&) { return ">"; } +std::string parse_text(const domain::ast::BinaryComparatorLess&, const FormattingOptions&) { return "<"; } +std::string parse_text(const domain::ast::BinaryComparatorEqual&, const FormattingOptions&) { return "="; } +std::string parse_text(const domain::ast::BinaryComparatorGreaterEqual&, const FormattingOptions&) { return ">="; } +std::string parse_text(const domain::ast::BinaryComparatorLessEqual&, const FormattingOptions&) { return "<="; } +std::string parse_text(const domain::ast::BinaryComparator& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::FunctionHead& node, const FormattingOptions& options) { - std::stringstream ss; - if (node.terms.size() > 0) { - ss << "(" << parse_text(node.function_symbol, options) << " " << parse_text(node.terms, options) << ")"; - } else { - ss << parse_text(node.function_symbol, options); - } - return ss.str(); +std::string parse_text(const domain::ast::FunctionHead& node, const FormattingOptions& options) +{ + std::stringstream ss; + if (node.terms.size() > 0) + { + ss << "(" << parse_text(node.function_symbol, options) << " " << parse_text(node.terms, options) << ")"; } - - std::string parse_text(const domain::ast::FunctionExpression& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); + else + { + ss << parse_text(node.function_symbol, options); } + return ss.str(); +} - std::string parse_text(const domain::ast::FunctionExpressionNumber& node, const FormattingOptions& options) { - return parse_text(node.number, options); - } +std::string parse_text(const domain::ast::FunctionExpression& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::FunctionExpressionBinaryOp& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(" << parse_text(node.binary_operator, options) << " " - << parse_text(node.function_expression_left, options) << " " - << parse_text(node.function_expression_right, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::FunctionExpressionNumber& node, const FormattingOptions& options) { return parse_text(node.number, options); } - std::string parse_text(const domain::ast::FunctionExpressionMinus& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(- " << parse_text(node.function_expression, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::FunctionExpressionBinaryOp& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(" << parse_text(node.binary_operator, options) << " " << parse_text(node.function_expression_left, options) << " " + << parse_text(node.function_expression_right, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::FunctionExpressionHead& node, const FormattingOptions& options) { - return parse_text(node.function_head, options); - } +std::string parse_text(const domain::ast::FunctionExpressionMinus& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(- " << parse_text(node.function_expression, options) << ")"; + return ss.str(); +} +std::string parse_text(const domain::ast::FunctionExpressionHead& node, const FormattingOptions& options) { return parse_text(node.function_head, options); } - std::string parse_text(const domain::ast::GoalDescriptor& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::GoalDescriptor& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::GoalDescriptorAtom& node, const FormattingOptions& options) { - return parse_text(node.atom, options); - } +std::string parse_text(const domain::ast::GoalDescriptorAtom& node, const FormattingOptions& options) { return parse_text(node.atom, options); } - std::string parse_text(const domain::ast::GoalDescriptorLiteral& node, const FormattingOptions& options) { - return parse_text(node.literal, options); - } +std::string parse_text(const domain::ast::GoalDescriptorLiteral& node, const FormattingOptions& options) { return parse_text(node.literal, options); } - std::string parse_text(const domain::ast::GoalDescriptorAnd& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(and " << parse_text(node.goal_descriptors, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::GoalDescriptorAnd& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(and " << parse_text(node.goal_descriptors, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::GoalDescriptorOr& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(or " << parse_text(node.goal_descriptors, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::GoalDescriptorOr& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(or " << parse_text(node.goal_descriptors, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::GoalDescriptorNot& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(not " << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::GoalDescriptorNot& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(not " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::GoalDescriptorImply& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(imply " << parse_text(node.goal_descriptor_left, options) << " " - << parse_text(node.goal_descriptor_right, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::GoalDescriptorImply& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(imply " << parse_text(node.goal_descriptor_left, options) << " " << parse_text(node.goal_descriptor_right, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::GoalDescriptorExists& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(exists " << parse_text(node.typed_list_of_variables, options) << " " - << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::GoalDescriptorExists& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(exists " << parse_text(node.typed_list_of_variables, options) << " " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::GoalDescriptorForall& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(forall " << parse_text(node.typed_list_of_variables, options) << " " - << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::GoalDescriptorForall& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(forall " << parse_text(node.typed_list_of_variables, options) << " " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::GoalDescriptorFunctionComparison& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(" << parse_text(node.binary_comparator, options) << " " - << parse_text(node.function_expression_left, options) << " " - << parse_text(node.function_expression_right, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::GoalDescriptorFunctionComparison& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(" << parse_text(node.binary_comparator, options) << " " << parse_text(node.function_expression_left, options) << " " + << parse_text(node.function_expression_right, options) << ")"; + return ss.str(); +} +std::string parse_text(const domain::ast::ConstraintGoalDescriptor& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptor& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorAnd& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(and " << parse_text(node.constraint_goal_descriptors, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorAnd& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(and " << parse_text(node.constraint_goal_descriptors, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorForall& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(forall " << parse_text(node.typed_list_of_variables, options) << " " << parse_text(node.constraint_goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorForall& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(forall " << parse_text(node.typed_list_of_variables, options) << " " - << parse_text(node.constraint_goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorAtEnd& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(at end " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorAtEnd& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(at end " << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorAlways& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(always " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorAlways& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(always " << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometime& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(sometime " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometime& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(sometime " << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorWithin& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(within " << parse_text(node.number, options) << " " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorWithin& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(within " << parse_text(node.number, options) << " " - << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorAtMostOnce& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(at-most-once " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorAtMostOnce& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(at-most-once " << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometimeAfter& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(sometime-after " << parse_text(node.goal_descriptor_left, options) << " " << parse_text(node.goal_descriptor_right, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometimeAfter& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(sometime-after " << parse_text(node.goal_descriptor_left, options) << " " - << parse_text(node.goal_descriptor_right, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometimeBefore& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(sometime-before " << parse_text(node.goal_descriptor_left, options) << " " << parse_text(node.goal_descriptor_right, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorSometimeBefore& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(sometime-before " << parse_text(node.goal_descriptor_left, options) << " " - << parse_text(node.goal_descriptor_right, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorAlwaysWithin& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(always-within " << parse_text(node.number, options) << " " << parse_text(node.goal_descriptor_left, options) << " " + << parse_text(node.goal_descriptor_right, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorAlwaysWithin& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(always-within " << parse_text(node.number, options) << " " - << parse_text(node.goal_descriptor_left, options) << " " - << parse_text(node.goal_descriptor_right, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorHoldDuring& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(hold-during " << parse_text(node.number_left, options) << " " << parse_text(node.number_right, options) << " " + << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorHoldDuring& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(hold-during " << parse_text(node.number_left, options) << " " - << parse_text(node.number_right, options) << " " - << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ConstraintGoalDescriptorHoldAfter& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(hold-after " << parse_text(node.number, options) << " " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::ConstraintGoalDescriptorHoldAfter& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(hold-after " << parse_text(node.number, options) << " " - << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::PreferenceName& node, const FormattingOptions& options) { return parse_text(node.name, options); } +std::string parse_text(const domain::ast::PreconditionGoalDescriptor& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::PreferenceName& node, const FormattingOptions& options) { - return parse_text(node.name, options); - } +std::string parse_text(const domain::ast::PreconditionGoalDescriptorSimple& node, const FormattingOptions& options) +{ + return parse_text(node.goal_descriptor, options); +} - std::string parse_text(const domain::ast::PreconditionGoalDescriptor& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::PreconditionGoalDescriptorAnd& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(and " << parse_text(node.precondition_goal_descriptors, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::PreconditionGoalDescriptorSimple& node, const FormattingOptions& options) { - return parse_text(node.goal_descriptor, options); - } +std::string parse_text(const domain::ast::PreconditionGoalDescriptorPreference& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(preference " << parse_text(node.preference_name, options) << " " << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::PreconditionGoalDescriptorAnd& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(and " << parse_text(node.precondition_goal_descriptors, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::PreconditionGoalDescriptorForall& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(forall " << parse_text(node.typed_list_of_variables, options) << " " << parse_text(node.precondition_goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::PreconditionGoalDescriptorPreference& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(preference " << parse_text(node.preference_name, options) << " " - << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::AssignOperatorAssign&, const FormattingOptions&) { return "assign"; } +std::string parse_text(const domain::ast::AssignOperatorScaleUp&, const FormattingOptions&) { return "scale-up"; } +std::string parse_text(const domain::ast::AssignOperatorScaleDown&, const FormattingOptions&) { return "scale-down"; } +std::string parse_text(const domain::ast::AssignOperatorIncrease&, const FormattingOptions&) { return "increase"; } +std::string parse_text(const domain::ast::AssignOperatorDecrease&, const FormattingOptions&) { return "decrease"; } +std::string parse_text(const domain::ast::AssignOperator& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::PreconditionGoalDescriptorForall& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(forall " << parse_text(node.typed_list_of_variables, options) << " " - << parse_text(node.precondition_goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::Effect& node, const FormattingOptions& options) { return boost::apply_visitor(NodeVisitorPrinter(options), node); } - std::string parse_text(const domain::ast::AssignOperatorAssign&, const FormattingOptions&) { return "assign"; } - std::string parse_text(const domain::ast::AssignOperatorScaleUp&, const FormattingOptions&) { return "scale-up"; } - std::string parse_text(const domain::ast::AssignOperatorScaleDown&, const FormattingOptions&) { return "scale-down"; } - std::string parse_text(const domain::ast::AssignOperatorIncrease&, const FormattingOptions&) { return "increase"; } - std::string parse_text(const domain::ast::AssignOperatorDecrease&, const FormattingOptions&) { return "decrease"; } - std::string parse_text(const domain::ast::AssignOperator& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::EffectProductionLiteral& node, const FormattingOptions& options) { return parse_text(node.literal, options); } - std::string parse_text(const domain::ast::Effect& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::EffectProductionNumericFluentTotalCost& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(" << parse_text(node.assign_operator_increase, options) << " " << parse_text(node.function_symbol_total_cost, options) << " " + << parse_text(node.numeric_term, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::EffectProductionLiteral& node, const FormattingOptions& options) { - return parse_text(node.literal, options); - } +std::string parse_text(const domain::ast::EffectProductionNumericFluentGeneral& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(" << parse_text(node.assign_operator, options) << " " << parse_text(node.function_head, options) << " " + << parse_text(node.function_expression, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::EffectProductionNumericFluentTotalCost& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(" << parse_text(node.assign_operator_increase, options) << " " - << parse_text(node.function_symbol_total_cost, options) << " " - << parse_text(node.numeric_term, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::EffectProduction& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::EffectProductionNumericFluentGeneral& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(" << parse_text(node.assign_operator, options) << " " - << parse_text(node.function_head, options) << " " - << parse_text(node.function_expression, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::EffectConditionalForall& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(forall " << parse_text(node.typed_list_of_variables, options) << " " << parse_text(node.effect, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::EffectProduction& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); - } +std::string parse_text(const domain::ast::EffectConditionalWhen& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(when " << parse_text(node.goal_descriptor, options) << " " << parse_text(node.effect, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::EffectConditionalForall& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(forall " << parse_text(node.typed_list_of_variables, options) << " " - << parse_text(node.effect, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::EffectConditional& node, const FormattingOptions& options) +{ + return boost::apply_visitor(NodeVisitorPrinter(options), node); +} - std::string parse_text(const domain::ast::EffectConditionalWhen& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(when " << parse_text(node.goal_descriptor, options) << " " - << parse_text(node.effect, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::ActionSymbol& node, const FormattingOptions& options) { return parse_text(node.name, options); } - std::string parse_text(const domain::ast::EffectConditional& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); +std::string parse_text(const domain::ast::ActionBody& node, const FormattingOptions& options) +{ + std::stringstream ss; + if (node.precondition_goal_descriptor.has_value()) + { + ss << std::string(options.indent, ' ') << ":precondition " << parse_text(node.precondition_goal_descriptor.value(), options) << "\n"; } - - - std::string parse_text(const domain::ast::ActionSymbol& node, const FormattingOptions& options) { - return parse_text(node.name, options); + if (node.effect.has_value()) + { + ss << std::string(options.indent, ' ') << ":effect " << parse_text(node.effect.value(), options); } + return ss.str(); +} - std::string parse_text(const domain::ast::ActionBody& node, const FormattingOptions& options) { - std::stringstream ss; - if (node.precondition_goal_descriptor.has_value()) { - ss << std::string(options.indent, ' ') << ":precondition " << parse_text(node.precondition_goal_descriptor.value(), options) << "\n"; - } - if (node.effect.has_value()) { - ss << std::string(options.indent, ' ') << ":effect " << parse_text(node.effect.value(), options); - } - return ss.str(); - } +std::string parse_text(const domain::ast::Action& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << std::string(options.indent, ' ') << "(action " << parse_text(node.action_symbol, options) << "\n"; + FormattingOptions nested_options { options.indent + options.add_indent, options.add_indent }; + ss << std::string(nested_options.indent, ' ') << ":parameters (" << parse_text(node.typed_list_of_variables, nested_options) << ")\n" + << parse_text(node.action_body, nested_options) << "\n"; + ss << std::string(options.indent, ' ') << ")"; + + return ss.str(); +} +std::string parse_text(const domain::ast::DerivedPredicate& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << std::string(options.indent, ' ') << "(:derived " << parse_text(node.typed_list_of_variables, options) << " " + << parse_text(node.goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::Action& node, const FormattingOptions& options) { - std::stringstream ss; - ss << std::string(options.indent, ' ') - << "(action " - << parse_text(node.action_symbol, options) << "\n"; - FormattingOptions nested_options{options.indent + options.add_indent, options.add_indent}; - ss << std::string(nested_options.indent, ' ') - << ":parameters (" - << parse_text(node.typed_list_of_variables, nested_options) << ")\n" - << parse_text(node.action_body, nested_options) << "\n"; - ss << std::string(options.indent, ' ') << ")"; +std::string parse_text(const domain::ast::DomainName& node, const FormattingOptions& options) +{ + stringstream ss; + ss << "(domain " << parse_text(node.name, options) << ")"; + return ss.str(); +} - return ss.str(); +std::string parse_text(const domain::ast::Requirements& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(:requirements "; + for (size_t i = 0; i < node.requirements.size(); ++i) + { + if (i != 0) + ss << " "; + ss << parse_text(node.requirements[i], options); } + ss << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::DerivedPredicate& node, const FormattingOptions& options) { - std::stringstream ss; - ss << std::string(options.indent, ' ') << "(:derived " - << parse_text(node.typed_list_of_variables, options) << " " - << parse_text(node.goal_descriptor, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::Types& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(:types " << parse_text(node.typed_list_of_names, options) << ")"; + return ss.str(); +} +std::string parse_text(const domain::ast::Constants& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(:constants " << parse_text(node.typed_list_of_names, options) << ")"; + return ss.str(); +} +std::string parse_text(const domain::ast::Predicates& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(:predicates " << parse_text(node.atomic_formula_skeletons, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::DomainName& node, const FormattingOptions& options) { - stringstream ss; - ss << "(domain " << parse_text(node.name, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::Functions& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(:functions " << parse_text(node.function_types_list_of_atomic_function_skeletons, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::Requirements& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(:requirements "; - for (size_t i = 0; i < node.requirements.size(); ++i) { - if (i != 0) ss << " "; - ss << parse_text(node.requirements[i], options); - } - ss << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::Constraints& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << "(:constraints " << parse_text(node.constraint_goal_descriptor, options) << ")"; + return ss.str(); +} - std::string parse_text(const domain::ast::Types& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(:types " << parse_text(node.typed_list_of_names, options) << ")"; - return ss.str(); - } +std::string parse_text(const domain::ast::Structure& node, const FormattingOptions& options) { return boost::apply_visitor(NodeVisitorPrinter(options), node); } - std::string parse_text(const domain::ast::Constants& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(:constants " << parse_text(node.typed_list_of_names, options) << ")"; - return ss.str(); +std::string parse_text(const domain::ast::Domain& node, const FormattingOptions& options) +{ + std::stringstream ss; + ss << string(options.indent, ' ') << "(define " << parse_text(node.domain_name, options) << "\n"; + auto nested_options = FormattingOptions { options.indent + options.add_indent, options.add_indent }; + if (node.requirements.has_value()) + { + ss << string(nested_options.indent, ' ') << parse_text(node.requirements.value(), nested_options) << "\n"; } - - std::string parse_text(const domain::ast::Predicates& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(:predicates " << parse_text(node.atomic_formula_skeletons, options) << ")"; - return ss.str(); + if (node.types.has_value()) + { + ss << string(nested_options.indent, ' ') << parse_text(node.types.value(), nested_options) << "\n"; } - - std::string parse_text(const domain::ast::Functions& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(:functions " << parse_text(node.function_types_list_of_atomic_function_skeletons, options) << ")"; - return ss.str(); + if (node.constants.has_value()) + { + ss << string(nested_options.indent, ' ') << parse_text(node.constants.value(), nested_options) << "\n"; } - - std::string parse_text(const domain::ast::Constraints& node, const FormattingOptions& options) { - std::stringstream ss; - ss << "(:constraints " << parse_text(node.constraint_goal_descriptor, options) << ")"; - return ss.str(); + if (node.predicates.has_value()) + { + ss << string(nested_options.indent, ' ') << parse_text(node.predicates.value(), nested_options) << "\n"; } - - std::string parse_text(const domain::ast::Structure& node, const FormattingOptions& options) { - return boost::apply_visitor(NodeVisitorPrinter(options), node); + if (node.functions.has_value()) + { + ss << string(nested_options.indent, ' ') << parse_text(node.functions.value(), nested_options) << "\n"; } - - - std::string parse_text(const domain::ast::Domain& node, const FormattingOptions& options) { - std::stringstream ss; - ss << string(options.indent, ' ') << "(define " << parse_text(node.domain_name, options) << "\n"; - auto nested_options = FormattingOptions{options.indent + options.add_indent, options.add_indent}; - if (node.requirements.has_value()) { - ss << string(nested_options.indent, ' ') << parse_text(node.requirements.value(), nested_options) << "\n"; - } - if (node.types.has_value()) { - ss << string(nested_options.indent, ' ') << parse_text(node.types.value(), nested_options) << "\n"; - } - if (node.constants.has_value()) { - ss << string(nested_options.indent, ' ') << parse_text(node.constants.value(), nested_options) << "\n"; - } - if (node.predicates.has_value()) { - ss << string(nested_options.indent, ' ') << parse_text(node.predicates.value(), nested_options) << "\n"; - } - if (node.functions.has_value()) { - ss << string(nested_options.indent, ' ') << parse_text(node.functions.value(), nested_options) << "\n"; - } - if (node.constraints.has_value()) { - ss << string(nested_options.indent, ' ') << parse_text(node.constraints.value(), nested_options) << "\n"; - } - for (size_t i = 0; i < node.structures.size(); ++i) { - ss << string(nested_options.indent, ' ') << parse_text(node.structures[i], nested_options) << "\n"; - } - ss << std::string(options.indent, ' ') << ")"; - return ss.str(); + if (node.constraints.has_value()) + { + ss << string(nested_options.indent, ' ') << parse_text(node.constraints.value(), nested_options) << "\n"; } + for (size_t i = 0; i < node.structures.size(); ++i) + { + ss << string(nested_options.indent, ' ') << parse_text(node.structures[i], nested_options) << "\n"; + } + ss << std::string(options.indent, ' ') << ")"; + return ss.str(); +} - - template - inline std::string parse_text(const std::vector& nodes, const FormattingOptions& options) +template +inline std::string parse_text(const std::vector& nodes, const FormattingOptions& options) +{ + std::stringstream ss; + for (size_t i = 0; i < nodes.size(); ++i) { - std::stringstream ss; - for (size_t i = 0; i < nodes.size(); ++i) - { - if (i != 0) - ss << " "; - ss << parse_text(nodes[i], options); - } - return ss.str(); + if (i != 0) + ss << " "; + ss << parse_text(nodes[i], options); } + return ss.str(); +} } diff --git a/src/domain/pddl/parser/common.cpp b/src/domain/pddl/parser/common.cpp index e9e1b6a9..b3170479 100644 --- a/src/domain/pddl/parser/common.cpp +++ b/src/domain/pddl/parser/common.cpp @@ -22,16 +22,15 @@ using namespace loki::domain; using namespace std; - -namespace loki { +namespace loki +{ /* Name */ -string parse(const ast::Name& node) { - return node.characters; -} +string parse(const ast::Name& node) { return node.characters; } /* Variable */ -pddl::Variable parse(const ast::Variable& node, Context& context) { +pddl::Variable parse(const ast::Variable& node, Context& context) +{ const auto variable = context.factories.variables.get_or_create(node.characters); // Declare variable as being referenced. context.references.untrack(variable); @@ -41,15 +40,15 @@ pddl::Variable parse(const ast::Variable& node, Context& context) { } /* Term */ -TermDeclarationTermVisitor::TermDeclarationTermVisitor(Context& context_) - : context(context_) { } - +TermDeclarationTermVisitor::TermDeclarationTermVisitor(Context& context_) : context(context_) {} -pddl::Term TermDeclarationTermVisitor::operator()(const ast::Name& node) const { +pddl::Term TermDeclarationTermVisitor::operator()(const ast::Name& node) const +{ const auto constant_name = parse(node); // Test for undefined constant. const auto binding = context.scopes.get(constant_name); - if (!binding.has_value()) { + if (!binding.has_value()) + { throw UndefinedConstantError(constant_name, context.scopes.get_error_handler()(node, "")); } // Constant are not tracked and hence must not be untracked. @@ -61,12 +60,13 @@ pddl::Term TermDeclarationTermVisitor::operator()(const ast::Name& node) const { return term; } - -pddl::Term TermDeclarationTermVisitor::operator()(const ast::Variable& node) const { +pddl::Term TermDeclarationTermVisitor::operator()(const ast::Variable& node) const +{ const auto variable = parse(node, context); // Test for multiple definition const auto binding = context.scopes.get(variable->get_name()); - if (binding.has_value()) { + if (binding.has_value()) + { const auto message_1 = context.scopes.get_error_handler()(node, "Defined here:"); const auto [_constant, position, error_handler] = binding.value(); assert(position.has_value()); @@ -82,15 +82,15 @@ pddl::Term TermDeclarationTermVisitor::operator()(const ast::Variable& node) con return term; } +TermReferenceTermVisitor::TermReferenceTermVisitor(Context& context_) : context(context_) {} -TermReferenceTermVisitor::TermReferenceTermVisitor(Context& context_) - : context(context_) { } - -pddl::Term TermReferenceTermVisitor::operator()(const ast::Name& node) const { +pddl::Term TermReferenceTermVisitor::operator()(const ast::Name& node) const +{ const auto object_name = parse(node); // Test for undefined constant. const auto binding = context.scopes.get(object_name); - if (!binding.has_value()) { + if (!binding.has_value()) + { throw UndefinedConstantError(object_name, context.scopes.get_error_handler()(node, "")); } // Construct Term and return it @@ -102,11 +102,13 @@ pddl::Term TermReferenceTermVisitor::operator()(const ast::Name& node) const { return term; } -pddl::Term TermReferenceTermVisitor::operator()(const ast::Variable& node) const { +pddl::Term TermReferenceTermVisitor::operator()(const ast::Variable& node) const +{ const auto variable = parse(node, context); // Test for undefined variable const auto binding = context.scopes.get(variable->get_name()); - if (!binding.has_value()) { + if (!binding.has_value()) + { throw UndefinedVariableError(variable->get_name(), context.scopes.get_error_handler()(node, "")); } // Construct Term and return it @@ -117,8 +119,6 @@ pddl::Term TermReferenceTermVisitor::operator()(const ast::Variable& node) const } /* Number */ -double parse(const ast::Number& node) { - return node.value; -} +double parse(const ast::Number& node) { return node.value; } } diff --git a/src/domain/pddl/parser/common.hpp b/src/domain/pddl/parser/common.hpp index 8afd289c..f3645734 100644 --- a/src/domain/pddl/parser/common.hpp +++ b/src/domain/pddl/parser/common.hpp @@ -18,12 +18,11 @@ #ifndef LOKI_SRC_DOMAIN_PDDL_PARSER_COMMON_HPP_ #define LOKI_SRC_DOMAIN_PDDL_PARSER_COMMON_HPP_ -#include - #include +#include - -namespace loki { +namespace loki +{ /* Name */ extern std::string parse(const domain::ast::Name& node); @@ -32,7 +31,8 @@ extern std::string parse(const domain::ast::Name& node); extern pddl::Variable parse(const domain::ast::Variable& node, Context& context); /* Term */ -struct TermDeclarationTermVisitor : boost::static_visitor { +struct TermDeclarationTermVisitor : boost::static_visitor +{ Context& context; TermDeclarationTermVisitor(Context& context_); @@ -41,7 +41,8 @@ struct TermDeclarationTermVisitor : boost::static_visitor { pddl::Term operator()(const domain::ast::Variable& node) const; }; -struct TermReferenceTermVisitor : boost::static_visitor { +struct TermReferenceTermVisitor : boost::static_visitor +{ Context& context; TermReferenceTermVisitor(Context& context_); @@ -55,4 +56,4 @@ extern double parse(const domain::ast::Number& node); } -#endif // LOKI_SRC_DOMAIN_PDDL_PARSER_COMMON_HPP_ +#endif // LOKI_SRC_DOMAIN_PDDL_PARSER_COMMON_HPP_ diff --git a/src/domain/pddl/parser/conditions.cpp b/src/domain/pddl/parser/conditions.cpp index d4c9f671..6dcc6e99 100644 --- a/src/domain/pddl/parser/conditions.cpp +++ b/src/domain/pddl/parser/conditions.cpp @@ -23,31 +23,34 @@ #include - -namespace loki { +namespace loki +{ // parse a vector of goal descriptors template -static pddl::ConditionList parse(const std::vector& nodes, Context& context) { +static pddl::ConditionList parse(const std::vector& nodes, Context& context) +{ auto condition_list = pddl::ConditionList(); - for (const auto& node : nodes) { + for (const auto& node : nodes) + { condition_list.push_back(parse(node, context)); } return condition_list; } -pddl::Condition parse(const domain::ast::GoalDescriptor& node, Context& context) { - return boost::apply_visitor(ConditionVisitor(context), node); -} +pddl::Condition parse(const domain::ast::GoalDescriptor& node, Context& context) { return boost::apply_visitor(ConditionVisitor(context), node); } -pddl::Condition parse(const domain::ast::GoalDescriptorAtom& node, Context& context) { +pddl::Condition parse(const domain::ast::GoalDescriptorAtom& node, Context& context) +{ const auto condition = context.factories.conditions.get_or_create(parse(node.atom, context)); context.positions.push_back(condition, node); return condition; } -pddl::Condition parse(const domain::ast::GoalDescriptorLiteral& node, Context& context) { +pddl::Condition parse(const domain::ast::GoalDescriptorLiteral& node, Context& context) +{ // requires :negative-preconditions - if (!context.requirements->test(pddl::RequirementEnum::NEGATIVE_PRECONDITIONS)) { + if (!context.requirements->test(pddl::RequirementEnum::NEGATIVE_PRECONDITIONS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::NEGATIVE_PRECONDITIONS, context.scopes.get_error_handler()(node, "")); } context.references.untrack(pddl::RequirementEnum::NEGATIVE_PRECONDITIONS); @@ -56,16 +59,19 @@ pddl::Condition parse(const domain::ast::GoalDescriptorLiteral& node, Context& c return condition; } -pddl::Condition parse(const domain::ast::GoalDescriptorAnd& node, Context& context) { +pddl::Condition parse(const domain::ast::GoalDescriptorAnd& node, Context& context) +{ auto condition_list = parse(node.goal_descriptors, context); const auto condition = context.factories.conditions.get_or_create(condition_list); context.positions.push_back(condition, node); return condition; } -pddl::Condition parse(const domain::ast::GoalDescriptorOr& node, Context& context) { +pddl::Condition parse(const domain::ast::GoalDescriptorOr& node, Context& context) +{ // requires :disjunctive-preconditions - if (!context.requirements->test(pddl::RequirementEnum::DISJUNCTIVE_PRECONDITIONS)) { + if (!context.requirements->test(pddl::RequirementEnum::DISJUNCTIVE_PRECONDITIONS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::DISJUNCTIVE_PRECONDITIONS, context.scopes.get_error_handler()(node, "")); } context.references.untrack(pddl::RequirementEnum::DISJUNCTIVE_PRECONDITIONS); @@ -75,9 +81,11 @@ pddl::Condition parse(const domain::ast::GoalDescriptorOr& node, Context& contex return condition; } -pddl::Condition parse(const domain::ast::GoalDescriptorNot& node, Context& context) { +pddl::Condition parse(const domain::ast::GoalDescriptorNot& node, Context& context) +{ // requires :disjunctive-preconditions - if (!context.requirements->test(pddl::RequirementEnum::NEGATIVE_PRECONDITIONS)) { + if (!context.requirements->test(pddl::RequirementEnum::NEGATIVE_PRECONDITIONS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::NEGATIVE_PRECONDITIONS, context.scopes.get_error_handler()(node, "")); } context.references.untrack(pddl::RequirementEnum::NEGATIVE_PRECONDITIONS); @@ -87,8 +95,10 @@ pddl::Condition parse(const domain::ast::GoalDescriptorNot& node, Context& conte return condition; } -pddl::Condition parse(const domain::ast::GoalDescriptorImply& node, Context& context) { - if (!context.requirements->test(pddl::RequirementEnum::DISJUNCTIVE_PRECONDITIONS)) { +pddl::Condition parse(const domain::ast::GoalDescriptorImply& node, Context& context) +{ + if (!context.requirements->test(pddl::RequirementEnum::DISJUNCTIVE_PRECONDITIONS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::DISJUNCTIVE_PRECONDITIONS, context.scopes.get_error_handler()(node, "")); } context.references.untrack(pddl::RequirementEnum::DISJUNCTIVE_PRECONDITIONS); @@ -99,8 +109,10 @@ pddl::Condition parse(const domain::ast::GoalDescriptorImply& node, Context& con return condition; } -pddl::Condition parse(const domain::ast::GoalDescriptorExists& node, Context& context) { - if (!context.requirements->test(pddl::RequirementEnum::EXISTENTIAL_PRECONDITIONS)) { +pddl::Condition parse(const domain::ast::GoalDescriptorExists& node, Context& context) +{ + if (!context.requirements->test(pddl::RequirementEnum::EXISTENTIAL_PRECONDITIONS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::EXISTENTIAL_PRECONDITIONS, context.scopes.get_error_handler()(node, "")); } context.references.untrack(pddl::RequirementEnum::EXISTENTIAL_PRECONDITIONS); @@ -116,7 +128,8 @@ pddl::Condition parse(const domain::ast::GoalDescriptorExists& node, Context& co } template -pddl::Condition parse_condition_forall(const domain::ast::TypedListOfVariables& parameters_node, const ConditionNode& condition_node, Context& context) { +pddl::Condition parse_condition_forall(const domain::ast::TypedListOfVariables& parameters_node, const ConditionNode& condition_node, Context& context) +{ context.scopes.open_scope(); auto parameter_list = boost::apply_visitor(ParameterListVisitor(context), parameters_node); track_variable_references(parameter_list, context); @@ -128,29 +141,32 @@ pddl::Condition parse_condition_forall(const domain::ast::TypedListOfVariables& return condition; } -pddl::Condition parse(const domain::ast::GoalDescriptorForall& node, Context& context) { - if (!context.requirements->test(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS)) { +pddl::Condition parse(const domain::ast::GoalDescriptorForall& node, Context& context) +{ + if (!context.requirements->test(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS, context.scopes.get_error_handler()(node, "")); } context.references.untrack(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS); return parse_condition_forall(node.typed_list_of_variables, node.goal_descriptor, context); } -pddl::Condition parse(const domain::ast::GoalDescriptorFunctionComparison& node, Context& context) { - if (!context.requirements->test(pddl::RequirementEnum::NUMERIC_FLUENTS)) { +pddl::Condition parse(const domain::ast::GoalDescriptorFunctionComparison& node, Context& context) +{ + if (!context.requirements->test(pddl::RequirementEnum::NUMERIC_FLUENTS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::NUMERIC_FLUENTS, context.scopes.get_error_handler()(node, "")); } throw NotImplementedError("parse(const domain::ast::GoalDescriptorFunctionComparison& node, Context& context)"); } +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptor& node, Context& context) { return boost::apply_visitor(ConditionVisitor(context), node); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptor& node, Context& context) { - return boost::apply_visitor(ConditionVisitor(context), node); -} - -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAnd& node, Context& context) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAnd& node, Context& context) +{ auto condition_list = pddl::ConditionList(); - for (const auto& child_node : node.constraint_goal_descriptors) { + for (const auto& child_node : node.constraint_goal_descriptors) + { condition_list.push_back(parse(child_node, context)); } const auto condition = context.factories.conditions.get_or_create(condition_list); @@ -158,66 +174,75 @@ pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAnd& node, Cont return condition; } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorForall& node, Context& context) { - if (!context.requirements->test(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS)) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorForall& node, Context& context) +{ + if (!context.requirements->test(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS, context.scopes.get_error_handler()(node, "")); } context.references.untrack(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS); return parse_condition_forall(node.typed_list_of_variables, node.constraint_goal_descriptor, context); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAtEnd& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAtEnd& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorAtEnd& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAlways& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAlways& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorAlways& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorSometime& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorSometime& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorSometime& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorWithin& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorWithin& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorWithin& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAtMostOnce& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAtMostOnce& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorAtMostOnce& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorSometimeAfter& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorSometimeAfter& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorSometimeAfter& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorSometimeBefore& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorSometimeBefore& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorSometimeBefore& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAlwaysWithin& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorAlwaysWithin& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorAlwaysWithin& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorHoldDuring& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorHoldDuring& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorHoldDuring& node, Context& context)"); } -pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorHoldAfter& /*node*/, Context& /*context*/) { +pddl::Condition parse(const domain::ast::ConstraintGoalDescriptorHoldAfter& /*node*/, Context& /*context*/) +{ throw NotImplementedError("parse(const domain::ast::ConstraintGoalDescriptorHoldAfter& node, Context& context)"); } +pddl::Condition parse(const domain::ast::PreconditionGoalDescriptor& node, Context& context) { return boost::apply_visitor(ConditionVisitor(context), node); } -pddl::Condition parse(const domain::ast::PreconditionGoalDescriptor& node, Context& context) { - return boost::apply_visitor(ConditionVisitor(context), node); -} +pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorSimple& node, Context& context) { return parse(node.goal_descriptor, context); } -pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorSimple& node, Context& context) { - return parse(node.goal_descriptor, context); -} - -pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorAnd& node, Context& context) { +pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorAnd& node, Context& context) +{ auto condition_list = pddl::ConditionList(); - for (const auto& child_node : node.precondition_goal_descriptors) { + for (const auto& child_node : node.precondition_goal_descriptors) + { condition_list.push_back(parse(child_node, context)); } const auto condition = context.factories.conditions.get_or_create(condition_list); @@ -225,24 +250,25 @@ pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorAnd& node, Co return condition; } -pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorPreference& node, Context& context) { - if (!context.requirements->test(pddl::RequirementEnum::PREFERENCES)) { +pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorPreference& node, Context& context) +{ + if (!context.requirements->test(pddl::RequirementEnum::PREFERENCES)) + { throw UndefinedRequirementError(pddl::RequirementEnum::PREFERENCES, context.scopes.get_error_handler()(node, "")); } throw NotImplementedError("parse(const domain::ast::PreconditionGoalDescriptorPreference& node, Context& context)"); } -pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorForall& node, Context& context) { - if (!context.requirements->test(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS)) { +pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorForall& node, Context& context) +{ + if (!context.requirements->test(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS)) + { throw UndefinedRequirementError(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS, context.scopes.get_error_handler()(node, "")); } context.references.untrack(pddl::RequirementEnum::UNIVERSAL_PRECONDITIONS); return parse_condition_forall(node.typed_list_of_variables, node.precondition_goal_descriptor, context); } - - -ConditionVisitor::ConditionVisitor(Context& context_) - : context(context_) { } +ConditionVisitor::ConditionVisitor(Context& context_) : context(context_) {} } diff --git a/src/domain/pddl/parser/conditions.hpp b/src/domain/pddl/parser/conditions.hpp index 6d9549dc..8a02bd87 100644 --- a/src/domain/pddl/parser/conditions.hpp +++ b/src/domain/pddl/parser/conditions.hpp @@ -19,14 +19,13 @@ #define LOKI_SRC_DOMAIN_PDDL_PARSER_CONDITIONS_HPP_ #include -#include -#include #include - +#include +#include #include - -namespace loki { +namespace loki +{ extern pddl::Condition parse(const domain::ast::GoalDescriptor& node, Context& context); extern pddl::Condition parse(const domain::ast::GoalDescriptorAtom& node, Context& context); @@ -59,17 +58,19 @@ extern pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorAnd& n extern pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorPreference& node, Context& context); extern pddl::Condition parse(const domain::ast::PreconditionGoalDescriptorForall& node, Context& context); -struct ConditionVisitor : boost::static_visitor { +struct ConditionVisitor : boost::static_visitor +{ Context& context; ConditionVisitor(Context& context_); template - pddl::Condition operator()(const Node& node) const { + pddl::Condition operator()(const Node& node) const + { return parse(node, context); } }; } -#endif // LOKI_SRC_DOMAIN_PDDL_PARSER_CONDITIONS_HPP_ +#endif // LOKI_SRC_DOMAIN_PDDL_PARSER_CONDITIONS_HPP_ diff --git a/src/domain/pddl/parser/constants.cpp b/src/domain/pddl/parser/constants.cpp index 982b64d9..dc1a7c0c 100644 --- a/src/domain/pddl/parser/constants.cpp +++ b/src/domain/pddl/parser/constants.cpp @@ -17,77 +17,80 @@ #include "constants.hpp" -#include "types.hpp" #include "common.hpp" +#include "types.hpp" #include using namespace loki::domain; using namespace std; - -namespace loki { -static void test_multiple_definition(const pddl::Object& constant, const domain::ast::Name& node, const Context& context) { +namespace loki +{ +static void test_multiple_definition(const pddl::Object& constant, const domain::ast::Name& node, const Context& context) +{ const auto constant_name = constant->get_name(); const auto binding = context.scopes.get(constant_name); - if (binding.has_value()) { + if (binding.has_value()) + { const auto message_1 = context.scopes.get_error_handler()(node, "Defined here:"); auto message_2 = std::string(""); const auto [_object, position, error_handler] = binding.value(); - if (position.has_value()) { + if (position.has_value()) + { message_2 = error_handler(position.value(), "First defined here:"); } throw MultiDefinitionConstantError(constant_name, message_1 + message_2); } } - -static void insert_context_information(const pddl::Object& constant, const domain::ast::Name& node, Context& context) { +static void insert_context_information(const pddl::Object& constant, const domain::ast::Name& node, Context& context) +{ context.positions.push_back(constant, node); context.scopes.insert(constant->get_name(), constant, node); } - -static pddl::Object parse_constant_definition(const domain::ast::Name& node, const pddl::TypeList& type_list, Context& context) { - const auto constant = context.factories.objects.get_or_create( - parse(node), - type_list); +static pddl::Object parse_constant_definition(const domain::ast::Name& node, const pddl::TypeList& type_list, Context& context) +{ + const auto constant = context.factories.objects.get_or_create(parse(node), type_list); test_multiple_definition(constant, node, context); insert_context_information(constant, node, context); return constant; } - -static pddl::ObjectList parse_constant_definitions(const std::vector& nodes, const pddl::TypeList& type_list, Context& context) { +static pddl::ObjectList parse_constant_definitions(const std::vector& nodes, const pddl::TypeList& type_list, Context& context) +{ auto constant_list = pddl::ObjectList(); - for (const auto& node : nodes) { + for (const auto& node : nodes) + { constant_list.push_back(parse_constant_definition(node, type_list, context)); } return constant_list; } - -pddl::ObjectList parse(const ast::Constants& constants_node, Context& context) { +pddl::ObjectList parse(const ast::Constants& constants_node, Context& context) +{ return boost::apply_visitor(ConstantListVisitor(context), constants_node.typed_list_of_names.get()); } -ConstantListVisitor::ConstantListVisitor(Context& context_) - : context(context_) { } +ConstantListVisitor::ConstantListVisitor(Context& context_) : context(context_) {} -pddl::ObjectList ConstantListVisitor::operator()(const std::vector& name_nodes) { +pddl::ObjectList ConstantListVisitor::operator()(const std::vector& name_nodes) +{ // std::vector has single base type "object" assert(context.scopes.get("object").has_value()); const auto [type, _position, _error_handler] = context.scopes.get("object").value(); - return parse_constant_definitions(name_nodes, pddl::TypeList{type}, context); + return parse_constant_definitions(name_nodes, pddl::TypeList { type }, context); } -pddl::ObjectList ConstantListVisitor::operator()(const ast::TypedListOfNamesRecursively& typed_list_of_names_recursively_node) { - if (!context.requirements->test(pddl::RequirementEnum::TYPING)) { +pddl::ObjectList ConstantListVisitor::operator()(const ast::TypedListOfNamesRecursively& typed_list_of_names_recursively_node) +{ + if (!context.requirements->test(pddl::RequirementEnum::TYPING)) + { throw UndefinedRequirementError(pddl::RequirementEnum::TYPING, context.scopes.get_error_handler()(typed_list_of_names_recursively_node, "")); } context.references.untrack(pddl::RequirementEnum::TYPING); - const auto type_list = boost::apply_visitor( - TypeReferenceTypeVisitor(context), typed_list_of_names_recursively_node.type); + const auto type_list = boost::apply_visitor(TypeReferenceTypeVisitor(context), typed_list_of_names_recursively_node.type); // TypedListOfNamesRecursively has user defined base types auto constant_list = parse_constant_definitions(typed_list_of_names_recursively_node.names, type_list, context); // Recursively add objects. diff --git a/src/domain/pddl/parser/constants.hpp b/src/domain/pddl/parser/constants.hpp index 994419d7..0f634646 100644 --- a/src/domain/pddl/parser/constants.hpp +++ b/src/domain/pddl/parser/constants.hpp @@ -22,13 +22,14 @@ #include #include - -namespace loki { +namespace loki +{ /* Constants */ extern pddl::ObjectList parse(const domain::ast::Constants& constants_node, Context& context); -class ConstantListVisitor : boost::static_visitor { +class ConstantListVisitor : boost::static_visitor +{ private: Context& context; @@ -42,4 +43,4 @@ class ConstantListVisitor : boost::static_visitor { } -#endif // LOKI_SRC_DOMAIN_PDDL_PARSER_CONSTANTS_HPP_ +#endif // LOKI_SRC_DOMAIN_PDDL_PARSER_CONSTANTS_HPP_