summaryrefslogtreecommitdiff
path: root/src/printer
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2012-02-08 00:31:00 +0000
committerTim King <taking@cs.nyu.edu>2012-02-08 00:31:00 +0000
commit74e6f0b1ec3937f409ea5108fc7fb47ffc732f64 (patch)
treeca5600797dccb7e77907d6eaeb74b894969c742e /src/printer
parentd4727aa4f9efb41a2a1db699f477e643426a0740 (diff)
Number of changes to cvc_printer.cpp. Specialized the printing for BVPLUS, BVSUB, and BVMULT. Fixed a bug in printing on PREFIX operators. Added parenthsis for POSTFIX operators. Passing the ouroborous test now.
Diffstat (limited to 'src/printer')
-rw-r--r--src/printer/cvc/cvc_printer.cpp62
1 files changed, 44 insertions, 18 deletions
diff --git a/src/printer/cvc/cvc_printer.cpp b/src/printer/cvc/cvc_printer.cpp
index 26616259c..283cdd725 100644
--- a/src/printer/cvc/cvc_printer.cpp
+++ b/src/printer/cvc/cvc_printer.cpp
@@ -143,6 +143,9 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
POSTFIX
} opType;
+ //The default operation type is PREFIX
+ opType = PREFIX;
+
stringstream op; // operation (such as '+')
switch(n.getKind()) {
@@ -215,8 +218,9 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
// UF
case kind::APPLY_UF:
- toStream(op, n.getOperator(), depth, types, true);
+ toStream(op, n.getOperator(), depth, types, false);
break;
+
case kind::FUNCTION_TYPE:
if (n.getNumChildren() > 1) {
if (n.getNumChildren() > 2) {
@@ -280,7 +284,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
case kind::SELECT:
toStream(out, n[0], depth, types, false);
out << '[';
- toStream(out, n[0], depth, types, false);
+ toStream(out, n[1], depth, types, false);
out << ']';
return;
break;
@@ -354,12 +358,6 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
break;
// BITVECTORS
- case kind::BITVECTOR_PLUS:
- op << "BVPLUS";
- break;
- case kind::BITVECTOR_SUB:
- op << "BVSUB";
- break;
case kind::BITVECTOR_XOR:
op << "BVXOR";
break;
@@ -375,9 +373,6 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
case kind::BITVECTOR_COMP:
op << "BVCOMP";
break;
- case kind::BITVECTOR_MULT:
- op << "BVMULT";
- break;
case kind::BITVECTOR_UDIV:
op << "BVUDIV";
break;
@@ -444,6 +439,40 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
op << "@";
opType = INFIX;
break;
+ case kind::BITVECTOR_PLUS:
+ //This interprets a BITVECTOR_PLUS as a bvadd in SMT-LIB
+ out << "BVPLUS(";
+ Assert(n.getType().isBitVector());
+ out << BitVectorType(n.getType().toType()).getSize();
+ out << ',';
+ toStream(out, n[0], depth, types, false);
+ out << ',';
+ toStream(out, n[1], depth, types, false);
+ out << ')';
+ return;
+ break;
+ case kind::BITVECTOR_SUB:
+ out << "BVSUB(";
+ Assert(n.getType().isBitVector());
+ out << BitVectorType(n.getType().toType()).getSize();
+ out << ',';
+ toStream(out, n[0], depth, types, false);
+ out << ',';
+ toStream(out, n[1], depth, types, false);
+ out << ')';
+ return;
+ break;
+ case kind::BITVECTOR_MULT:
+ out << "BVMULT(";
+ Assert(n.getType().isBitVector());
+ out << BitVectorType(n.getType().toType()).getSize();
+ out << ',';
+ toStream(out, n[0], depth, types, false);
+ out << ',';
+ toStream(out, n[1], depth, types, false);
+ out << ')';
+ return;
+ break;
case kind::BITVECTOR_EXTRACT:
op << n.getOperator().getConst<BitVectorExtract>();
opType = POSTFIX;
@@ -485,9 +514,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
switch (opType) {
case PREFIX:
- if (bracket) {
- out << op.str() << '(';
- }
+ out << op.str() << '(';
break;
case INFIX:
if (bracket) {
@@ -495,6 +522,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
}
break;
case POSTFIX:
+ out << '(';
break;
}
@@ -511,9 +539,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
switch (opType) {
case PREFIX:
- if (bracket) {
- out << ')';
- }
+ out << ')';
break;
case INFIX:
if (bracket) {
@@ -521,7 +547,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo
}
break;
case POSTFIX:
- out << op.str();
+ out << ')' << op.str();
break;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback