From 5250e3714929164004f8dd5d7551a07f888ee311 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Tue, 30 Mar 2021 15:02:37 -0500 Subject: [PATCH] Fix printing for double patterns (#6235) --- src/printer/smt2/smt2_printer.cpp | 48 ++++++++++++++----------------- 1 file changed, 22 insertions(+), 26 deletions(-) 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 -- 2.30.2