#include <string>
#include "parser/parser_builder.h"
+#include "util/options.h"
namespace CVC4 {
ParserBuilder d_parserBuilder;
public:
- InteractiveShell(std::istream& in,
- std::ostream& out,
- ParserBuilder& parserBuilder) :
- d_in(in),
- d_out(out),
+ InteractiveShell(ParserBuilder& parserBuilder,
+ const Options& options) :
+ d_in(*options.in),
+ d_out(*options.out),
d_parserBuilder(parserBuilder) {
}
<< "Without an input file, or with `-', CVC4 reads from standard input." << endl
<< endl
<< "CVC4 options:" << endl;
- Options::printUsage( ss.str(), options.out );
+ Options::printUsage( ss.str(), *options.out );
}
/**
return runCvc4(argc, argv);
} catch(OptionException& e) {
#ifdef CVC4_COMPETITION_MODE
- options.out << "unknown" << endl;
+ *options.out << "unknown" << endl;
#endif
cerr << "CVC4 Error:" << endl << e << endl;
printUsage();
exit(1);
} catch(Exception& e) {
#ifdef CVC4_COMPETITION_MODE
- options.out << "unknown" << endl;
+ *options.out << "unknown" << endl;
#endif
- options.err << "CVC4 Error:" << endl << e << endl;
+ *options.err << "CVC4 Error:" << endl << e << endl;
if(options.statistics) {
- StatisticsRegistry::flushStatistics(options.err);
+ StatisticsRegistry::flushStatistics(*options.err);
}
exit(1);
} catch(bad_alloc) {
#ifdef CVC4_COMPETITION_MODE
- options.out << "unknown" << endl;
+ *options.out << "unknown" << endl;
#endif
- options.err << "CVC4 ran out of memory." << endl;
+ *options.err << "CVC4 ran out of memory." << endl;
if(options.statistics) {
- StatisticsRegistry::flushStatistics(options.err);
+ StatisticsRegistry::flushStatistics(*options.err);
}
exit(1);
} catch(...) {
#ifdef CVC4_COMPETITION_MODE
- options.out << "unknown" << endl;
+ *options.out << "unknown" << endl;
#endif
- options.err << "CVC4 threw an exception of unknown type." << endl;
+ *options.err << "CVC4 threw an exception of unknown type." << endl;
exit(1);
}
}
printUsage();
exit(1);
} else if( options.languageHelp ) {
- Options::printLanguageHelp(options.out);
+ Options::printLanguageHelp(*options.out);
exit(1);
} else if( options.version ) {
- options.out << Configuration::about().c_str() << flush;
+ *options.out << Configuration::about().c_str() << flush;
exit(0);
}
// If in competition mode, set output stream option to flush immediately
#ifdef CVC4_COMPETITION_MODE
- options.out << unitbuf;
+ *options.out << unitbuf;
#endif
// We only accept one input file
}
ParserBuilder parserBuilder =
- ParserBuilder(exprMgr, filename)
- .withInputLanguage(options.inputLanguage)
- .withMmap(options.memoryMap)
- .withChecks(options.semanticChecks &&
- !Configuration::isMuzzledBuild() )
- .withStrictMode( options.strictParsing );
+ ParserBuilder(exprMgr, filename, options);
if( inputFromStdin ) {
parserBuilder.withStreamInput(cin);
// Parse and execute commands until we are done
Command* cmd;
if( options.interactive ) {
- InteractiveShell shell(options.in,options.out,parserBuilder);
+ InteractiveShell shell(parserBuilder,options);
while((cmd = shell.readCommand())) {
doCommand(smt,cmd);
delete cmd;
StatisticsRegistry::registerStat(&s_statSatResult);
if(options.statistics) {
- StatisticsRegistry::flushStatistics(options.err);
+ StatisticsRegistry::flushStatistics(*options.err);
}
StatisticsRegistry::unregisterStat(&s_statSatResult);
}
} else {
if(options.verbosity > 0) {
- options.out << "Invoking: " << *cmd << endl;
+ *options.out << "Invoking: " << *cmd << endl;
}
if(options.verbosity >= 0) {
- cmd->invoke(&smt, options.out);
+ cmd->invoke(&smt, *options.out);
} else {
cmd->invoke(&smt);
}
}
};*/
-ParserBuilder::ParserBuilder(ExprManager& exprManager, const std::string& filename) :
- d_inputType(FILE_INPUT),
- d_lang(language::input::LANG_AUTO),
- d_filename(filename),
- d_streamInput(NULL),
- d_exprManager(exprManager),
- d_checksEnabled(true),
- d_strictMode(false),
- d_mmap(false) {
+ParserBuilder::ParserBuilder(ExprManager& exprManager, const std::string& filename)// :
+ // d_inputType(FILE_INPUT),
+ // d_lang(language::input::LANG_AUTO),
+ : d_filename(filename),
+ // d_streamInput(NULL),
+ d_exprManager(exprManager)
+ // d_checksEnabled(true),
+ // d_strictMode(false),
+ // d_mmap(false)
+{
+ init(exprManager,filename);
+}
+
+ ParserBuilder::ParserBuilder(ExprManager& exprManager, const std::string& filename, const Options& options) :
+ d_filename(filename),
+ d_exprManager(exprManager)
+{
+ init(exprManager,filename);
+ withOptions(options);
+}
+
+ void ParserBuilder::init(ExprManager& exprManager, const std::string& filename) {
+ d_inputType = FILE_INPUT;
+ d_lang = language::input::LANG_AUTO;
+ d_filename = filename;
+ d_streamInput = NULL;
+ d_exprManager = exprManager;
+ d_checksEnabled = true;
+ d_strictMode = false;
+ d_mmap = false;
}
Parser *ParserBuilder::build() throw (InputStreamException,AssertionException) {
return *this;
}
+ParserBuilder& ParserBuilder::withOptions(const Options& options) {
+ return
+ withInputLanguage(options.inputLanguage)
+ .withMmap(options.memoryMap)
+ .withChecks(options.semanticChecks)
+ .withStrictMode(options.strictParsing);
+ }
+
ParserBuilder& ParserBuilder::withStrictMode(bool flag) {
d_strictMode = flag;
return *this;
#include <string>
-#include "parser/input.h"
-#include "parser/parser_options.h"
+#include "input.h"
+#include "parser_options.h"
+
+#include "util/options.h"
namespace CVC4 {
/** Should we memory-map a file input? */
bool d_mmap;
+ void init(ExprManager& exprManager, const std::string& filename);
+
public:
/** Create a parser builder using the given ExprManager and filename. */
ParserBuilder(ExprManager& exprManager, const std::string& filename);
+ ParserBuilder(ExprManager& exprManager, const std::string& filename,
+ const Options& options);
+
/** Build the parser, using the current settings. */
Parser *build() throw (InputStreamException,AssertionException);
* the parser will have a file input. (Default: no) */
ParserBuilder& withMmap(bool flag = true);
+ /** Derive settings from the given options. */
+ ParserBuilder& withOptions(const Options& options);
+
/** Should the parser use strict mode? (Default: no) */
ParserBuilder& withStrictMode(bool flag = true);
# define USE_EARLY_TYPE_CHECKING_BY_DEFAULT false
#endif /* CVC4_DEBUG */
+#ifdef CVC4_MUZZLED
+# define DO_SEMANTIC_CHECKS_BY_DEFAULT false
+#else
+# define DO_SEMANTIC_CHECKS_BY_DEFAULT true
+#endif
+
#include <iostream>
#include <string>
bool statistics;
- std::istream& in;
- std::ostream& out;
- std::ostream& err;
+ std::istream* in;
+ std::ostream* out;
+ std::ostream* err;
/* -1 means no output */
/* 0 is normal (and default) -- warnings only */
Options() :
binary_name(),
statistics(false),
- in(std::cin),
- out(std::cout),
- err(std::cerr),
+ in(&std::cin),
+ out(&std::cout),
+ err(&std::cerr),
verbosity(0),
inputLanguage(language::input::LANG_AUTO),
uf_implementation(MORGAN),
parseOnly(false),
- semanticChecks(true),
+ semanticChecks(DO_SEMANTIC_CHECKS_BY_DEFAULT),
memoryMap(false),
strictParsing(false),
lazyDefinitionExpansion(false),
segvNoSpin(false),
produceModels(false),
produceAssignments(false),
- typeChecking(true),
+ typeChecking(DO_SEMANTIC_CHECKS_BY_DEFAULT),
earlyTypeChecking(USE_EARLY_TYPE_CHECKING_BY_DEFAULT) {
}