patrick
/
plasp
Archived
1
0
Fork 0

Removing trailing () at the end of 0-ary values for ASP output.

This commit is contained in:
Patrick Lühne 2016-05-21 16:27:30 +02:00
parent 273e310c60
commit d219ef0388
2 changed files with 13 additions and 1 deletions

View File

@ -44,6 +44,7 @@ struct Value
Sign m_sign;
std::string m_name;
bool m_hasArguments;
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -31,7 +31,8 @@ const Value Value::Any = Value::any();
////////////////////////////////////////////////////////////////////////////////////////////////////
Value::Value()
: m_sign(Sign::Positive)
: m_sign{Sign::Positive},
m_hasArguments{true}
{
}
@ -54,6 +55,13 @@ Value Value::fromSAS(std::istream &istream)
{
istream.ignore(1);
std::getline(istream, value.m_name);
// Remove trailing ()
if (value.m_name.find("()") != std::string::npos)
{
value.m_hasArguments = false;
value.m_name.resize(value.m_name.size() - 2);
}
}
catch (const std::exception &e)
{
@ -97,6 +105,9 @@ void Value::printAsSAS(std::ostream &ostream) const
ostream << "NegatedAtom ";
ostream << m_name;
if (!m_hasArguments)
ostream << "()";
}
////////////////////////////////////////////////////////////////////////////////////////////////////