* SMT-LIBv2 parser now supports (echo...).
* Dump() gestures can now dump EchoCommands in CVC and SMT-LIB formats.
This can make it much easier to interpret output.
return new EmptyCommand(d_name);
}
+/* class EchoCommand */
+
+EchoCommand::EchoCommand(std::string output) throw() :
+ d_output(output) {
+}
+
+std::string EchoCommand::getOutput() const throw() {
+ return d_output;
+}
+
+void EchoCommand::invoke(SmtEngine* smtEngine) throw() {
+ /* we don't have an output stream here, nothing to do */
+ d_commandStatus = CommandSuccess::instance();
+}
+
+void EchoCommand::invoke(SmtEngine* smtEngine, std::ostream& out) throw() {
+ out << d_output << std::endl;
+ d_commandStatus = CommandSuccess::instance();
+ printResult(out);
+}
+
+Command* EchoCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new EchoCommand(d_output);
+}
+
+Command* EchoCommand::clone() const {
+ return new EchoCommand(d_output);
+}
+
/* class AssertCommand */
AssertCommand::AssertCommand(const BoolExpr& e) throw() :
Command* clone() const;
};/* class EmptyCommand */
+class CVC4_PUBLIC EchoCommand : public Command {
+protected:
+ std::string d_output;
+public:
+ EchoCommand(std::string output = "") throw();
+ ~EchoCommand() throw() {}
+ std::string getOutput() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+};/* class EchoCommand */
+
class CVC4_PUBLIC AssertCommand : public Command {
protected:
BoolExpr d_expr;
| ECHO_TOK
( simpleSymbolicExpr[sexpr]
- { Message() << sexpr << std::endl; }
- | { Message() << std::endl; }
+ { std::stringstream ss;
+ ss << sexpr;
+ cmd = new EchoCommand(ss.str());
+ }
+ | { cmd = new EchoCommand(); }
)
| EXIT_TOK
LPAREN_TOK ( LPAREN_TOK datatypeDef[dts] RPAREN_TOK )+ RPAREN_TOK
{ PARSER_STATE->popScope();
cmd = new DatatypeDeclarationCommand(PARSER_STATE->mkMutualDatatypeTypes(dts)); }
+ | ECHO_TOK
+ ( simpleSymbolicExpr[sexpr]
+ { std::stringstream ss;
+ ss << sexpr;
+ cmd = new EchoCommand(ss.str());
+ }
+ | { cmd = new EchoCommand(); }
+ )
;
simpleSymbolicExpr[CVC4::SExpr& sexpr]
// extended commands
DECLARE_DATATYPES_TOK : 'declare-datatypes';
+ECHO_TOK : 'echo';
// operators (NOTE: theory symbols go here)
AMPERSAND_TOK : '&';
tryToStream<GetOptionCommand>(out, c) ||
tryToStream<DatatypeDeclarationCommand>(out, c) ||
tryToStream<CommentCommand>(out, c) ||
- tryToStream<EmptyCommand>(out, c)) {
+ tryToStream<EmptyCommand>(out, c) ||
+ tryToStream<EchoCommand>(out, c)) {
return;
}
static void toStream(std::ostream& out, const EmptyCommand* c) throw() {
}
+static void toStream(std::ostream& out, const EchoCommand* c) throw() {
+ out << "ECHO \"" << c->getOutput() << "\";";
+}
+
template <class T>
static bool tryToStream(std::ostream& out, const Command* c) throw() {
if(typeid(*c) == typeid(T)) {
tryToStream<GetOptionCommand>(out, c) ||
tryToStream<DatatypeDeclarationCommand>(out, c) ||
tryToStream<CommentCommand>(out, c) ||
- tryToStream<EmptyCommand>(out, c)) {
+ tryToStream<EmptyCommand>(out, c) ||
+ tryToStream<EchoCommand>(out, c)) {
return;
}
static void toStream(std::ostream& out, const EmptyCommand* c) throw() {
}
+static void toStream(std::ostream& out, const EchoCommand* c) throw() {
+ out << "(echo \"" << c->getOutput() << "\")";
+}
+
template <class T>
static bool tryToStream(std::ostream& out, const Command* c) throw() {
if(typeid(*c) == typeid(T)) {