}
}
+void toStreamRational(std::ostream& out, Node n, bool forceRational)
+{
+ Assert(n.getKind() == kind::CONST_RATIONAL);
+ const Rational& rat = n.getConst<Rational>();
+ if (rat.isIntegral() && !forceRational)
+ {
+ out << rat.getNumerator();
+ }
+ else
+ {
+ out << '(' << rat.getNumerator() << '/' << rat.getDenominator() << ')';
+ }
+}
+
void CvcPrinter::toStream(
std::ostream& out, TNode n, int depth, bool types, bool bracket) const
{
out << (n.getConst<bool>() ? "TRUE" : "FALSE");
break;
case kind::CONST_RATIONAL: {
- const Rational& rat = n.getConst<Rational>();
- if(rat.isIntegral()) {
- out << rat.getNumerator();
- } else {
- out << '(' << rat.getNumerator() << '/' << rat.getDenominator() << ')';
- }
+ toStreamRational(out, n, false);
break;
}
case kind::TYPE_CONSTANT:
opType = PREFIX;
break;
case kind::TO_REAL:
- // ignore, there is no to-real in CVC language
- toStream(out, n[0], depth, types, false);
+ if (n[0].getKind() == kind::CONST_RATIONAL)
+ {
+ // print the constant as a rational
+ toStreamRational(out, n[0], true);
+ }
+ else
+ {
+ // ignore, there is no to-real in CVC language
+ toStream(out, n[0], depth, types, false);
+ }
return;
case kind::DIVISIBLE:
out << "DIVISIBLE(";