This repository has been archived on 2023-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
Files
plasp/include/plasp/pddl/translation/Fact.h
Patrick Lühne 3a7b61de68 Fixed syntax error at end of initial state facts.
Due to a mistake in commit 6d07fcb, the closing parenthesis and period
at the end of initial state facts was omitted. This adds these back in
order to solve this syntax error.
2017-11-01 16:00:48 +01:00

72 lines
1.9 KiB
C++

#ifndef __PLASP__PDDL__TRANSLATION__FACT_H
#define __PLASP__PDDL__TRANSLATION__FACT_H
#include <pddl/NormalizedAST.h>
#include <plasp/TranslatorException.h>
#include <plasp/pddl/translation/Predicate.h>
namespace plasp
{
namespace pddl
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Fact
//
////////////////////////////////////////////////////////////////////////////////////////////////////
inline void translateFact(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::Fact &fact)
{
outputStream << std::endl << colorlog::Function("initialState") << "(";
const auto handlePredicate =
[&](const ::pddl::normalizedAST::PredicatePointer &predicate, bool isPositive = true)
{
translatePredicateToVariable(outputStream, *predicate, isPositive);
};
const auto handleNegatedPredicate =
[&](const ::pddl::normalizedAST::PredicatePointer &predicate)
{
return handlePredicate(predicate, false);
};
const auto handleDerivedPredicate =
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &, bool = true)
{
throw TranslatorException("derived predicates should not occur in initial state");
};
const auto handleNegatedDerivedPredicate =
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate)
{
return handleDerivedPredicate(derivedPredicate, false);
};
const auto handleAtomicFormula =
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
{
atomicFormula.match(handlePredicate, handleDerivedPredicate);
};
const auto handleNot =
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> &not_)
{
not_->argument.match(handleNegatedPredicate, handleNegatedDerivedPredicate);
};
fact.match(handleAtomicFormula, handleNot);
outputStream << ").";
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif