Fixed unescaped fluent names.

This commit is contained in:
Patrick Lühne 2016-05-23 02:03:52 +02:00
parent 7d0f417ba4
commit 2ef710642b

View File

@ -1,6 +1,7 @@
#include <plasp/sas/TranslatorASP.h> #include <plasp/sas/TranslatorASP.h>
#include <plasp/sas/TranslatorException.h> #include <plasp/sas/TranslatorException.h>
#include <plasp/utils/Parsing.h>
namespace plasp namespace plasp
{ {
@ -64,7 +65,7 @@ void TranslatorASP::translate(std::ostream &ostream) const
ostream << "#program base." << std::endl << std::endl; ostream << "#program base." << std::endl << std::endl;
std::vector<const std::string *> fluents; std::vector<const Value *> fluents;
const auto &variables = m_description.variables(); const auto &variables = m_description.variables();
@ -82,14 +83,14 @@ void TranslatorASP::translate(std::ostream &ostream) const
const auto match = std::find_if(fluents.cbegin(), fluents.cend(), const auto match = std::find_if(fluents.cbegin(), fluents.cend(),
[&](const auto &fluent) [&](const auto &fluent)
{ {
return value.name() == *fluent; return value.name() == fluent->name();
}); });
// Dont add fluents if their negated form has already been added // Dont add fluents if their negated form has already been added
if (match != fluents.cend()) if (match != fluents.cend())
return; return;
fluents.push_back(&value.name()); fluents.push_back(&value);
}); });
}); });
@ -130,7 +131,9 @@ void TranslatorASP::translate(std::ostream &ostream) const
std::for_each(fluents.cbegin(), fluents.cend(), std::for_each(fluents.cbegin(), fluents.cend(),
[&](const auto *fluent) [&](const auto *fluent)
{ {
ostream << "fluent(" << *fluent << ")." << std::endl; ostream << "fluent(";
fluent->printAsASP(ostream);
ostream << ")." << std::endl;
}); });
ostream << std::endl; ostream << std::endl;