From 639b7646c96c91108e26a34d7b463d554d10d89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sun, 12 Jun 2016 22:19:55 +0200 Subject: [PATCH] Making sure that PDDL predicates contain only primitive types for the time being. --- include/plasp/pddl/TranslatorASP.h | 5 +++-- src/plasp/pddl/TranslatorASP.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/plasp/pddl/TranslatorASP.h b/include/plasp/pddl/TranslatorASP.h index 06205d8..77e3faa 100644 --- a/include/plasp/pddl/TranslatorASP.h +++ b/include/plasp/pddl/TranslatorASP.h @@ -23,9 +23,10 @@ class TranslatorASP void translate(std::ostream &ostream) const; + private: + void checkSupport() const; + void translateDomain(std::ostream &ostream) const; - - void translateProblem(std::ostream &ostream) const; const Description &m_description; diff --git a/src/plasp/pddl/TranslatorASP.cpp b/src/plasp/pddl/TranslatorASP.cpp index 67513f1..82f8f41 100644 --- a/src/plasp/pddl/TranslatorASP.cpp +++ b/src/plasp/pddl/TranslatorASP.cpp @@ -20,8 +20,31 @@ TranslatorASP::TranslatorASP(const Description &description) //////////////////////////////////////////////////////////////////////////////////////////////////// +void TranslatorASP::checkSupport() const +{ + // Check for "either" types + const auto &predicates = m_description.domain().predicates(); + + std::for_each(predicates.cbegin(), predicates.cend(), + [&](const auto &predicate) + { + const auto &arguments = predicate->arguments(); + + std::for_each(arguments.cbegin(), arguments.cend(), + [&](const auto ¶meter) + { + if (parameter->type()->expressionType() != Expression::Type::PrimitiveType) + throw utils::TranslatorException("Only primitive types supported currently"); + }); + }); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + void TranslatorASP::translate(std::ostream &ostream) const { + checkSupport(); + translateDomain(ostream); if (m_description.containsProblem())