using namespace CVC4::main;
static int runCvc4(int argc, char* argv[]);
-static void doCommand(SmtEngine&, Command*);
+static bool doCommand(SmtEngine&, Command*);
static void printUsage(bool full = false);
namespace CVC4 {
// Parse and execute commands until we are done
Command* cmd;
+ bool status = true;
if( options.interactive ) {
InteractiveShell shell(exprMgr, options);
Message() << Configuration::getPackageName()
replayParser->useDeclarationsFrom(shell.getParser());
}
while((cmd = shell.readCommand())) {
- doCommand(smt,cmd);
+ status = status && doCommand(smt, cmd);
delete cmd;
}
} else {
replayParser->useDeclarationsFrom(parser);
}
while((cmd = parser->nextCommand())) {
- doCommand(smt, cmd);
+ status = status && doCommand(smt, cmd);
delete cmd;
}
// Remove the parser
options.replayStream = NULL;
}
- string result = smt.getInfo(":status").getValue();
int returnValue;
-
- if(result == "sat") {
- returnValue = 10;
- } else if(result == "unsat") {
- returnValue = 20;
+ string result = "unknown";
+ if(status) {
+ result = smt.getInfo(":status").getValue();
+
+ if(result == "sat") {
+ returnValue = 10;
+ } else if(result == "unsat") {
+ returnValue = 20;
+ } else {
+ returnValue = 0;
+ }
} else {
- returnValue = 0;
+ // there was some kind of error
+ returnValue = 1;
}
#ifdef CVC4_COMPETITION_MODE
}
/** Executes a command. Deletes the command after execution. */
-static void doCommand(SmtEngine& smt, Command* cmd) {
+static bool doCommand(SmtEngine& smt, Command* cmd) {
if( options.parseOnly ) {
- return;
+ return true;
}
+ // assume no error
+ bool status = true;
+
CommandSequence *seq = dynamic_cast<CommandSequence*>(cmd);
if(seq != NULL) {
for(CommandSequence::iterator subcmd = seq->begin();
subcmd != seq->end();
++subcmd) {
- doCommand(smt, *subcmd);
+ status = status && doCommand(smt, *subcmd);
}
} else {
if(options.verbosity > 0) {
} else {
cmd->invoke(&smt);
}
+ status = status && cmd->ok();
}
+
+ return status;
}
# antlr doesn't overwrite output files, it just leaves them. So we have to delete them first.
@srcdir@/generated/CvcLexer.h: Cvc.g @srcdir@/stamp-generated
-$(AM_V_at)rm -f $(ANTLR_STUFF)
+ @if test -z "$(ANTLR)"; then echo "ERROR: antlr parser generator cannot be found, cannot generate the parser" >&2; exit 1; fi
$(AM_V_GEN)$(ANTLR) $(ANTLR_OPTS) -fo "@srcdir@/generated" "@srcdir@/Cvc.g"
# These don't actually depend on CvcLexer.h, but if we're doing parallel
# antlr doesn't overwrite output files, it just leaves them. So we have to delete them first.
@srcdir@/generated/SmtLexer.h: Smt.g @srcdir@/stamp-generated
-$(AM_V_at)rm -f $(ANTLR_STUFF)
+ @if test -z "$(ANTLR)"; then echo "ERROR: antlr parser generator cannot be found, cannot generate the parser" >&2; exit 1; fi
$(AM_V_GEN)$(ANTLR) $(ANTLR_OPTS) -fo "@srcdir@/generated" "@srcdir@/Smt.g"
# These don't actually depend on SmtLexer.h, but if we're doing parallel
# antlr doesn't overwrite output files, it just leaves them. So we have to delete them first.
@srcdir@/generated/Smt2Lexer.h: Smt2.g @srcdir@/stamp-generated
-$(AM_V_at)rm -f $(ANTLR_STUFF)
+ @if test -z "$(ANTLR)"; then echo "ERROR: antlr parser generator cannot be found, cannot generate the parser" >&2; exit 1; fi
$(AM_V_GEN)$(ANTLR) $(ANTLR_OPTS) -fo "@srcdir@/generated" "@srcdir@/Smt2.g"
# These don't actually depend on SmtLexer.h, but if we're doing parallel