SMT-LIBv2 compliance updates:
[cvc5.git] / src / printer / printer.h
1 /********************* */
2 /*! \file printer.h
3 ** \verbatim
4 ** Original author: mdeters
5 ** Major contributors: none
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
9 ** Courant Institute of Mathematical Sciences
10 ** New York University
11 ** See the file COPYING in the top-level source directory for licensing
12 ** information.\endverbatim
13 **
14 ** \brief Base of the pretty-printer interface
15 **
16 ** Base of the pretty-printer interface.
17 **/
18
19 #include "cvc4_private.h"
20
21 #ifndef __CVC4__PRINTER__PRINTER_H
22 #define __CVC4__PRINTER__PRINTER_H
23
24 #include "util/language.h"
25 #include "util/sexpr.h"
26 #include "expr/node.h"
27 #include "expr/command.h"
28
29 namespace CVC4 {
30
31 class Printer {
32 /** Printers for each OutputLanguage */
33 static Printer* d_printers[language::output::LANG_MAX];
34
35 /** Make a Printer for a given OutputLanguage */
36 static Printer* makePrinter(OutputLanguage lang) throw();
37
38 // disallow copy, assignment
39 Printer(const Printer&) CVC4_UNUSED;
40 Printer& operator=(const Printer&) CVC4_UNUSED;
41
42 protected:
43 // derived classes can construct, but no one else.
44 Printer() throw() {}
45
46 public:
47 /** Get the Printer for a given OutputLanguage */
48 static Printer* getPrinter(OutputLanguage lang) throw() {
49 if(d_printers[lang] == NULL) {
50 d_printers[lang] = makePrinter(lang);
51 }
52 return d_printers[lang];
53 }
54
55 /** Write a Node out to a stream with this Printer. */
56 virtual void toStream(std::ostream& out, TNode n,
57 int toDepth, bool types, size_t dag) const throw() = 0;
58
59 /** Write a Command out to a stream with this Printer. */
60 virtual void toStream(std::ostream& out, const Command* c,
61 int toDepth, bool types, size_t dag) const throw() = 0;
62
63 /** Write a CommandStatus out to a stream with this Printer. */
64 virtual void toStream(std::ostream& out, const CommandStatus* s) const throw() = 0;
65
66 /** Write an SExpr out to a stream with this Printer. */
67 virtual void toStream(std::ostream& out, const SExpr& sexpr) const throw();
68
69 /**
70 * Write a Result out to a stream with this Printer.
71 *
72 * The default implementation writes a reasonable string in lowercase
73 * for sat, unsat, valid, invalid, or unknown results. This behavior
74 * is overridable by each Printer, since sometimes an output language
75 * has a particular preference for how results should appear.
76 */
77 virtual void toStream(std::ostream& out, const Result& r) const throw();
78
79 };/* class Printer */
80
81 }/* CVC4 namespace */
82
83 #endif /* __CVC4__PRINTER__PRINTER_H */
84