From: Andrew Reynolds Date: Tue, 30 Mar 2021 20:02:37 +0000 (-0500) Subject: Fix printing for double patterns (#6235) X-Git-Tag: cvc5-1.0.0~2007 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5250e3714929164004f8dd5d7551a07f888ee311;p=cvc5.git Fix printing for double patterns (#6235) --- diff --git a/src/printer/smt2/smt2_printer.cpp b/src/printer/smt2/smt2_printer.cpp index 3e99267cc..af555d298 100644 --- a/src/printer/smt2/smt2_printer.cpp +++ b/src/printer/smt2/smt2_printer.cpp @@ -942,22 +942,33 @@ void Smt2Printer::toStream(std::ostream& out, // do not letify the bound variable list toStream(out, n[0], toDepth, nullptr); out << " "; + std::stringstream annot; if (n.getNumChildren() == 3) { - out << "(! "; + annot << " "; + for (const Node& nc : n[2]) + { + if (nc.getKind() == kind::INST_PATTERN) + { + out << "(! "; + annot << ":pattern "; + toStream(annot, nc, toDepth, nullptr); + annot << ") "; + } + else if (nc.getKind() == kind::INST_NO_PATTERN) + { + out << "(! "; + annot << ":no-pattern "; + toStream(annot, nc, toDepth, nullptr); + annot << ") "; + } + } } // Use a fresh let binder, since using existing let symbols may violate // scoping issues for let-bound variables, see explanation in let_binding.h. size_t dag = lbind == nullptr ? 0 : lbind->getThreshold()-1; toStream(out, n[1], toDepth - 1, dag); - if (n.getNumChildren() == 3) - { - out << " "; - // do not letify the annotation - toStream(out, n[2], toDepth, nullptr); - out << ")"; - } - out << ")"; + out << annot.str() << ")"; return; break; } @@ -980,23 +991,8 @@ void Smt2Printer::toStream(std::ostream& out, return; } case kind::INST_PATTERN: - case kind::INST_NO_PATTERN: break; - case kind::INST_PATTERN_LIST: - { - for (const Node& nc : n) - { - if (nc.getKind() == kind::INST_PATTERN) - { - out << ":pattern " << nc; - } - else if (nc.getKind() == kind::INST_NO_PATTERN) - { - out << ":no-pattern " << nc[0]; - } - } - return; - break; - } + case kind::INST_NO_PATTERN: + case kind::INST_PATTERN_LIST: break; default: // fall back on however the kind prints itself; this probably // won't be SMT-LIB v2 compliant, but it will be clear from the