#include #include #include #include #include #include #include namespace pddl { namespace detail { //////////////////////////////////////////////////////////////////////////////////////////////////// // // Effect // //////////////////////////////////////////////////////////////////////////////////////////////////// normalizedAST::Effect normalize(ast::Effect &&effect, detail::NormalizationContext &normalizationContext) { const auto handleLiteral = [](ast::Literal &literal) -> normalizedAST::Effect { return normalize(std::move(literal)); }; const auto handleAnd = [&](ast::AndPointer &and_) -> normalizedAST::Effect { normalizedAST::And::Arguments arguments; for (auto &argument : and_->arguments) arguments.emplace_back(normalize(std::move(argument), normalizationContext)); return std::make_unique>(std::move(arguments)); }; const auto handleForAll = [&](ast::ForAllPointer &forAll) -> normalizedAST::Effect { auto normalizedArgument = normalize(std::move(forAll->argument), normalizationContext); return std::make_unique>(std::move(forAll->parameters), std::move(normalizedArgument)); }; const auto handleWhen = [&](ast::WhenPointer &when) -> normalizedAST::Effect { auto normalizedCondition = normalize(std::move(when->argumentLeft), normalizationContext); auto normalizedConditionalEffect = normalize(std::move(when->argumentRight)); return std::make_unique>(std::move(normalizedCondition), std::move(normalizedConditionalEffect)); }; return effect.match(handleLiteral, handleAnd, handleForAll, handleWhen); } //////////////////////////////////////////////////////////////////////////////////////////////////// } }