diff options
author | Morgan Deters <mdeters@gmail.com> | 2012-06-08 21:21:42 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2012-06-08 21:21:42 +0000 |
commit | 58372a2ad23298810ae886a16db3c57f9df251af (patch) | |
tree | 7dd58f171e5b972f883a106f404aba989065c179 /src/printer | |
parent | f1b4a985be64e08b1a440b1eaf75d3f8e2105d01 (diff) |
Extend Printer infrastructure also to the "Result" class, meaning that different output languages can write "sat", "unsat", etc., in different ways. No output is changed by this commit, but the flexibility is added that Francois wanted at today's meeting.
Diffstat (limited to 'src/printer')
-rw-r--r-- | src/printer/printer.cpp | 35 | ||||
-rw-r--r-- | src/printer/printer.h | 10 |
2 files changed, 44 insertions, 1 deletions
diff --git a/src/printer/printer.cpp b/src/printer/printer.cpp index e3b2ed796..cde063584 100644 --- a/src/printer/printer.cpp +++ b/src/printer/printer.cpp @@ -48,7 +48,40 @@ Printer* Printer::makePrinter(OutputLanguage lang) throw() { default: Unhandled(lang); } - }/* Printer::makePrinter() */ +void Printer::toStream(std::ostream& out, const Result& r) const throw() { + if(r.getType() == Result::TYPE_SAT) { + switch(r.isSat()) { + case Result::UNSAT: + out << "unsat"; + break; + case Result::SAT: + out << "sat"; + break; + case Result::SAT_UNKNOWN: + out << "unknown"; + if(r.whyUnknown() != Result::UNKNOWN_REASON) { + out << " (" << r.whyUnknown() << ")"; + } + break; + } + } else { + switch(r.isValid()) { + case Result::INVALID: + out << "invalid"; + break; + case Result::VALID: + out << "valid"; + break; + case Result::VALIDITY_UNKNOWN: + out << "unknown"; + if(r.whyUnknown() != Result::UNKNOWN_REASON) { + out << " (" << r.whyUnknown() << ")"; + } + break; + } + } +}/* Printer::toStream() */ + }/* CVC4 namespace */ diff --git a/src/printer/printer.h b/src/printer/printer.h index 9bcbba3b0..04b435060 100644 --- a/src/printer/printer.h +++ b/src/printer/printer.h @@ -62,6 +62,16 @@ public: /** Write a CommandStatus out to a stream with this Printer. */ virtual void toStream(std::ostream& out, const CommandStatus* s) const throw() = 0; + /** + * Write a Result out to a stream with this Printer. + * + * The default implementation writes a reasonable string in lowercase + * for sat, unsat, valid, invalid, or unknown results. This behavior + * is overridable by each Printer, since sometimes an output language + * has a particular preference for how results should appear. + */ + virtual void toStream(std::ostream& out, const Result& r) const throw(); + };/* class Printer */ }/* CVC4 namespace */ |