From 7f05246786b587f0301cbf9aa1d66783747b8828 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Thu, 23 Jan 2014 14:25:42 +0100 Subject: Fixed a bug with brackets --- src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp index 9bd8d9e..b32fecf 100644 --- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp +++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp @@ -327,9 +327,11 @@ void SWIDataModel::setEvent(const Event& event) { void SWIDataModel::assertFromData(const Data& data, const std::string& expr, size_t nesting) { if (data.atom.size() > 0) { + // terminal branch, this is where we assert + std::stringstream ss; - ss << expr << "("; - nesting++; + ss << expr; +// nesting++; if (data.type == Data::VERBATIM) { ss << "\"" << data.atom << "\""; @@ -340,6 +342,8 @@ void SWIDataModel::assertFromData(const Data& data, const std::string& expr, siz for (size_t i = 0; i < nesting; i++) { ss << ")"; } + +// std::cout << ss.str() << std::endl; PlCall("assert", PlCompound(ss.str().c_str())); return; } @@ -347,7 +351,8 @@ void SWIDataModel::assertFromData(const Data& data, const std::string& expr, siz if (data.compound.size() > 0) { std::map::const_iterator compIter = data.compound.begin(); while(compIter != data.compound.end()) { - assertFromData(compIter->second, expr + "(" + compIter->first, nesting + 1); + assert(compIter->first.length() > 0); + assertFromData(compIter->second, expr + compIter->first + "(", nesting + 1); compIter++; } } -- cgit v0.12