Minor restructuring.

This commit is contained in:
Patrick Lühne 2017-03-06 15:42:38 +01:00
parent 70cb79b233
commit 71e6e4107a
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF

View File

@ -36,8 +36,6 @@ struct StatementVisitor
rule.head.data.accept(HeadLiteralCollectFunctionTermsVisitor(), rule.head, context);
// Print auxiliary variables replacing the head atoms arguments
if (!context.headTerms.empty())
{
for (auto i = context.headTerms.cbegin(); i != context.headTerms.cend(); i++)
{
const auto &headTerm = **i;
@ -51,12 +49,7 @@ struct StatementVisitor
<< output::Variable(variableName.c_str())
<< " " << output::Keyword("in") << " " << headTerm;
}
}
if (rule.body.empty() && context.headTerms.empty() && !context.isChoiceRule)
outputStream << Clingo::AST::Boolean({true});
else
{
// Print translated body literals
for (auto i = rule.body.cbegin(); i != rule.body.cend(); i++)
{
@ -70,7 +63,6 @@ struct StatementVisitor
bodyLiteral.data.accept(BodyLiteralPrintVisitor(), bodyLiteral, context);
}
}
// Handle choice rules
if (context.isChoiceRule)
@ -89,6 +81,10 @@ struct StatementVisitor
outputStream << ")";
}
// Print “true” on the left side of the formula in case there is nothing else
if (rule.body.empty() && context.headTerms.empty() && !context.isChoiceRule)
outputStream << Clingo::AST::Boolean({true});
outputStream << " " << output::Operator("->") << " ";
// Print consequent of the implication