** See the file COPYING in the top-level source directory for licensing
** information.
**
- ** [[ Add file-specific comments here ]]
+ ** Contains code for handling command-line options
**/
#include <cstdio>
#include "usage.h"
#include "about.h"
#include "util/output.h"
+#include "util/options.h"
using namespace std;
using namespace CVC4;
namespace main {
static const char lang_help[] = "\
-Languages currently supported to the -L / --lang option:\n\
+Languages currently supported as arguments to the -L / --lang option:\n\
auto attempt to automatically determine the input language\n\
pl | cvc4 CVC4 presentation language\n\
smt | smtlib SMT-LIB format\n\
// find the base name of the program
const char *x = strrchr(progName, '/');
- if(x != NULL)
+ if(x != NULL) {
progName = x + 1;
+ }
opts->binary_name = string(progName);
while((c = getopt_long(argc, argv, "+:hVvqL:d:", cmdlineOptions, NULL)) != -1) {
break;
}
- if(strcmp(optarg, "help"))
+ if(strcmp(optarg, "help")) {
throw OptionException(string("unknown language for --lang: `") + argv[optind] + "'. Try --lang help.");
+ }
fputs(lang_help, stdout);
exit(1);
** See the file COPYING in the top-level source directory for licensing
** information.
**
- ** [[ Add file-specific comments here ]]
+ ** Main driver for CVC4 executable.
**/
#include <iostream>
#include "smt/smt_engine.h"
#include "util/command.h"
#include "util/output.h"
+#include "util/options.h"
using namespace std;
using namespace CVC4;
// Parse the options
int firstArgIndex = parseOptions(argc, argv, &options);
- // If in competition mode, we flush the stdout immediately
- if(options.smtcomp_mode)
+ // If in competition mode, set output stream option to flush immediately
+ if(options.smtcomp_mode) {
cout << unitbuf;
+ }
// We only accept one input file
- if(argc > firstArgIndex + 1)
+ if(argc > firstArgIndex + 1) {
throw new Exception("Too many input files specified.");
+ }
// Create the expression manager
ExprManager exprMgr;
// If no file supplied we read from standard input
bool inputFromStdin = firstArgIndex >= argc;
+ // Auto-detect input language by filename extension
if(!inputFromStdin && options.lang == Options::LANG_AUTO) {
- if(!strcmp(".smt", argv[firstArgIndex] + strlen(argv[firstArgIndex]) - 4))
+ if(!strcmp(".smt", argv[firstArgIndex] + strlen(argv[firstArgIndex]) - 4)) {
options.lang = Options::LANG_SMTLIB;
+ }
else if(!strcmp(".cvc", argv[firstArgIndex] + strlen(argv[firstArgIndex]) - 4) ||
- !strcmp(".cvc4", argv[firstArgIndex] + strlen(argv[firstArgIndex]) - 5))
+ !strcmp(".cvc4", argv[firstArgIndex] + strlen(argv[firstArgIndex]) - 5)) {
options.lang = Options::LANG_CVC4;
+ }
}
+ // Determine which messages to show based on smtcomp_mode and verbosity
if(options.smtcomp_mode) {
Debug.setStream(CVC4::null_os);
Trace.setStream(CVC4::null_os);
Chat.setStream(CVC4::null_os);
Warning.setStream(CVC4::null_os);
} else {
- if(options.verbosity < 2)
+ if(options.verbosity < 2) {
Chat.setStream(CVC4::null_os);
- if(options.verbosity < 1)
+ }
+ if(options.verbosity < 1) {
Notice.setStream(CVC4::null_os);
- if(options.verbosity < 0)
+ }
+ if(options.verbosity < 0) {
Warning.setStream(CVC4::null_os);
+ }
}
+ // Set up the input stream, either cin or a file
const char* fname;
istream* in;
ifstream* file;
// Remove the parser
delete parser;
+ // Delete handle to input file
delete file;
} catch(OptionException& e) {
- if(options.smtcomp_mode)
+ if(options.smtcomp_mode) {
cout << "unknown" << endl;
+ }
cerr << "CVC4 Error:" << endl << e << endl;
printf(usage, options.binary_name.c_str());
abort();
} catch(CVC4::Exception& e) {
- if(options.smtcomp_mode)
+ if(options.smtcomp_mode) {
cout << "unknown" << endl;
+ }
cerr << "CVC4 Error:" << endl << e << endl;
abort();
} catch(bad_alloc) {
- if(options.smtcomp_mode)
+ if(options.smtcomp_mode) {
cout << "unknown" << endl;
+ }
cerr << "CVC4 ran out of memory." << endl;
abort();
} catch(...) {
+ if(options.smtcomp_mode) {
+ cout << "unknown" << endl;
+ }
cerr << "CVC4 threw an exception of unknown type." << endl;
abort();
}