From 1561aa5eb97ab56b2aeb23f57d58f4818201ffc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Thu, 8 Dec 2016 01:18:00 +0100 Subject: [PATCH] Put functions related to translation of predicates in separate file. --- include/plasp/pddl/translation/Predicate.h | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 include/plasp/pddl/translation/Predicate.h diff --git a/include/plasp/pddl/translation/Predicate.h b/include/plasp/pddl/translation/Predicate.h new file mode 100644 index 0000000..2b19230 --- /dev/null +++ b/include/plasp/pddl/translation/Predicate.h @@ -0,0 +1,68 @@ +#ifndef __PLASP__PDDL__TRANSLATION__PREDICATE_H +#define __PLASP__PDDL__TRANSLATION__PREDICATE_H + +#include +#include +#include +#include +#include + +namespace plasp +{ +namespace pddl +{ +namespace translation +{ + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Predicate +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +void printPredicateName(output::ColorStream &outputStream, const expressions::PredicateDeclaration &predicateDeclaration); +void printDerivedPredicateName(output::ColorStream &outputStream, const expressions::DerivedPredicate &derivedPredicate); + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +inline void printPredicateName(output::ColorStream &outputStream, const expressions::PredicateDeclaration &predicateDeclaration) +{ + outputStream << output::Keyword("variable") << "("; + + if (predicateDeclaration.parameters().empty()) + { + outputStream << output::String(predicateDeclaration.name().c_str()) << ")"; + return; + } + + outputStream << "(" << output::String(predicateDeclaration.name().c_str()); + translation::translateVariablesForRuleHead(outputStream, predicateDeclaration.parameters()); + outputStream << "))"; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +inline void printDerivedPredicateName(output::ColorStream &outputStream, const expressions::DerivedPredicate &derivedPredicate) +{ + outputStream << output::Keyword("derivedVariable") << "("; + + const auto id = derivedPredicate.id(); + + if (derivedPredicate.parameters().empty()) + { + outputStream << output::Number(id) << ")"; + return; + } + + outputStream << "(" << output::Number(id); + translation::translateVariablesForRuleHead(outputStream, derivedPredicate.parameters()); + outputStream << "))"; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +} +} +} + +#endif