1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Abdalrhman Mohamed, Andrew Reynolds, Tim King |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* The pretty-printer interface for the AST output language. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__PRINTER__AST_PRINTER_H |
19 |
|
#define CVC5__PRINTER__AST_PRINTER_H |
20 |
|
|
21 |
|
#include <iostream> |
22 |
|
|
23 |
|
#include "printer/printer.h" |
24 |
|
|
25 |
|
namespace cvc5 { |
26 |
|
|
27 |
|
class LetBinding; |
28 |
|
|
29 |
|
namespace printer { |
30 |
|
namespace ast { |
31 |
|
|
32 |
12 |
class AstPrinter : public cvc5::Printer |
33 |
|
{ |
34 |
|
public: |
35 |
|
using cvc5::Printer::toStream; |
36 |
|
void toStream(std::ostream& out, |
37 |
|
TNode n, |
38 |
|
int toDepth, |
39 |
|
size_t dag) const override; |
40 |
|
void toStream(std::ostream& out, const CommandStatus* s) const override; |
41 |
|
void toStream(std::ostream& out, const smt::Model& m) const override; |
42 |
|
|
43 |
|
/** Print empty command */ |
44 |
|
void toStreamCmdEmpty(std::ostream& out, |
45 |
|
const std::string& name) const override; |
46 |
|
|
47 |
|
/** Print echo command */ |
48 |
|
void toStreamCmdEcho(std::ostream& out, |
49 |
|
const std::string& output) const override; |
50 |
|
|
51 |
|
/** Print assert command */ |
52 |
|
void toStreamCmdAssert(std::ostream& out, Node n) const override; |
53 |
|
|
54 |
|
/** Print push command */ |
55 |
|
void toStreamCmdPush(std::ostream& out) const override; |
56 |
|
|
57 |
|
/** Print pop command */ |
58 |
|
void toStreamCmdPop(std::ostream& out) const override; |
59 |
|
|
60 |
|
/** Print declare-fun command */ |
61 |
|
void toStreamCmdDeclareFunction(std::ostream& out, |
62 |
|
const std::string& id, |
63 |
|
TypeNode type) const override; |
64 |
|
|
65 |
|
/** Print declare-sort command */ |
66 |
|
void toStreamCmdDeclareType(std::ostream& out, |
67 |
|
TypeNode type) const override; |
68 |
|
|
69 |
|
/** Print define-sort command */ |
70 |
|
void toStreamCmdDefineType(std::ostream& out, |
71 |
|
const std::string& id, |
72 |
|
const std::vector<TypeNode>& params, |
73 |
|
TypeNode t) const override; |
74 |
|
|
75 |
|
/** Print define-fun command */ |
76 |
|
void toStreamCmdDefineFunction(std::ostream& out, |
77 |
|
const std::string& id, |
78 |
|
const std::vector<Node>& formals, |
79 |
|
TypeNode range, |
80 |
|
Node formula) const override; |
81 |
|
|
82 |
|
/** Print check-sat command */ |
83 |
|
void toStreamCmdCheckSat(std::ostream& out) const override; |
84 |
|
|
85 |
|
/** Print check-sat-assuming command */ |
86 |
|
void toStreamCmdCheckSatAssuming( |
87 |
|
std::ostream& out, const std::vector<Node>& nodes) const override; |
88 |
|
|
89 |
|
/** Print query command */ |
90 |
|
void toStreamCmdQuery(std::ostream& out, Node n) const override; |
91 |
|
|
92 |
|
/** Print simplify command */ |
93 |
|
void toStreamCmdSimplify(std::ostream& out, Node nodes) const override; |
94 |
|
|
95 |
|
/** Print get-value command */ |
96 |
|
void toStreamCmdGetValue(std::ostream& out, |
97 |
|
const std::vector<Node>& n) const override; |
98 |
|
|
99 |
|
/** Print get-assignment command */ |
100 |
|
void toStreamCmdGetAssignment(std::ostream& out) const override; |
101 |
|
|
102 |
|
/** Print get-model command */ |
103 |
|
void toStreamCmdGetModel(std::ostream& out) const override; |
104 |
|
|
105 |
|
/** Print get-proof command */ |
106 |
|
void toStreamCmdGetProof(std::ostream& out) const override; |
107 |
|
|
108 |
|
/** Print get-unsat-core command */ |
109 |
|
void toStreamCmdGetUnsatCore(std::ostream& out) const override; |
110 |
|
|
111 |
|
/** Print get-assertions command */ |
112 |
|
void toStreamCmdGetAssertions(std::ostream& out) const override; |
113 |
|
|
114 |
|
/** Print set-logic command */ |
115 |
|
void toStreamCmdSetBenchmarkLogic(std::ostream& out, |
116 |
|
const std::string& logic) const override; |
117 |
|
|
118 |
|
/** Print set-info command */ |
119 |
|
void toStreamCmdSetInfo(std::ostream& out, |
120 |
|
const std::string& flag, |
121 |
|
const std::string& value) const override; |
122 |
|
|
123 |
|
/** Print get-info command */ |
124 |
|
void toStreamCmdGetInfo(std::ostream& out, |
125 |
|
const std::string& flag) const override; |
126 |
|
|
127 |
|
/** Print set-option command */ |
128 |
|
void toStreamCmdSetOption(std::ostream& out, |
129 |
|
const std::string& flag, |
130 |
|
const std::string& value) const override; |
131 |
|
|
132 |
|
/** Print get-option command */ |
133 |
|
void toStreamCmdGetOption(std::ostream& out, |
134 |
|
const std::string& flag) const override; |
135 |
|
|
136 |
|
/** Print declare-datatype(s) command */ |
137 |
|
void toStreamCmdDatatypeDeclaration( |
138 |
|
std::ostream& out, const std::vector<TypeNode>& datatypes) const override; |
139 |
|
|
140 |
|
/** Print reset command */ |
141 |
|
void toStreamCmdReset(std::ostream& out) const override; |
142 |
|
|
143 |
|
/** Print reset-assertions command */ |
144 |
|
void toStreamCmdResetAssertions(std::ostream& out) const override; |
145 |
|
|
146 |
|
/** Print quit command */ |
147 |
|
void toStreamCmdQuit(std::ostream& out) const override; |
148 |
|
|
149 |
|
/** Print command sequence command */ |
150 |
|
void toStreamCmdCommandSequence( |
151 |
|
std::ostream& out, const std::vector<Command*>& sequence) const override; |
152 |
|
|
153 |
|
/** Print declaration sequence command */ |
154 |
|
void toStreamCmdDeclarationSequence( |
155 |
|
std::ostream& out, const std::vector<Command*>& sequence) const override; |
156 |
|
|
157 |
|
private: |
158 |
|
void toStream(std::ostream& out, |
159 |
|
TNode n, |
160 |
|
int toDepth, |
161 |
|
LetBinding* lbind = nullptr) const; |
162 |
|
/** |
163 |
|
* To stream model sort. This prints the appropriate output for type |
164 |
|
* tn declared via declare-sort or declare-datatype. |
165 |
|
*/ |
166 |
|
void toStreamModelSort(std::ostream& out, |
167 |
|
TypeNode tn, |
168 |
|
const std::vector<Node>& elements) const override; |
169 |
|
|
170 |
|
/** |
171 |
|
* To stream model term. This prints the appropriate output for term |
172 |
|
* n declared via declare-fun. |
173 |
|
*/ |
174 |
|
void toStreamModelTerm(std::ostream& out, |
175 |
|
const Node& n, |
176 |
|
const Node& value) const override; |
177 |
|
/** |
178 |
|
* To stream with let binding. This prints n, possibly in the scope |
179 |
|
* of letification generated by this method based on lbind. |
180 |
|
*/ |
181 |
|
void toStreamWithLetify(std::ostream& out, |
182 |
|
Node n, |
183 |
|
int toDepth, |
184 |
|
LetBinding* lbind) const; |
185 |
|
}; /* class AstPrinter */ |
186 |
|
|
187 |
|
} // namespace ast |
188 |
|
} // namespace printer |
189 |
|
} // namespace cvc5 |
190 |
|
|
191 |
|
#endif /* CVC5__PRINTER__AST_PRINTER_H */ |