#include "parser/parser.h"
#include "parser/parser_builder.h"
#include "options/options.h"
+#include "smt/options.h"
#include "main/options.h"
#include "util/language.h"
#include "util/output.h"
ParserBuilder parserBuilder(&exprManager, INPUT_FILENAME, options);
/* Create parser with bogus input. */
d_parser = parserBuilder.withStringInput("").build();
+ if(d_options.wasSetByUser(options::forceLogic)) {
+ d_parser->forceLogic(d_options[options::forceLogic].getLogicString());
+ }
#if HAVE_LIBREADLINE
if(d_in == cin) {
d_checksEnabled(true),
d_strictMode(strictMode),
d_parseOnly(parseOnly),
- d_canIncludeFile(true) {
+ d_canIncludeFile(true),
+ d_logicIsForced(false),
+ d_forcedLogic() {
d_input->setParser(*this);
}
*/
bool d_canIncludeFile;
+ /**
+ * Whether the logic has been forced with --force-logic.
+ */
+ bool d_logicIsForced;
+
+ /**
+ * The logic, if d_logicIsForced == true.
+ */
+ std::string d_forcedLogic;
+
/** The set of operators available in the current logic. */
std::set<Kind> d_logicOperators;
void disallowIncludeFile() { d_canIncludeFile = false; }
bool canIncludeFile() const { return d_canIncludeFile; }
+ void forceLogic(const std::string& logic) { assert(!d_logicIsForced); d_logicIsForced = true; d_forcedLogic = logic; }
+ const std::string& getForcedLogic() const { return d_forcedLogic; }
+ bool logicIsForced() const { return d_logicIsForced; }
+
/**
* Returns a variable, given a name.
*
#include "expr/expr_manager.h"
#include "parser/options.h"
+#include "smt/options.h"
namespace CVC4 {
namespace parser {
d_canIncludeFile = true;
d_mmap = false;
d_parseOnly = false;
+ d_logicIsForced = false;
+ d_forcedLogic = "";
}
Parser* ParserBuilder::build()
parser->disallowIncludeFile();
}
+ if( d_logicIsForced ) {
+ parser->forceLogic(d_forcedLogic);
+ }
+
return parser;
}
}
ParserBuilder& ParserBuilder::withOptions(const Options& options) {
- return
- withInputLanguage(options[options::inputLanguage])
+ ParserBuilder& retval = *this;
+ retval =
+ retval.withInputLanguage(options[options::inputLanguage])
.withMmap(options[options::memoryMap])
.withChecks(options[options::semanticChecks])
.withStrictMode(options[options::strictParsing])
.withParseOnly(options[options::parseOnly])
.withIncludeFile(options[options::filesystemAccess]);
+ if(options.wasSetByUser(options::forceLogic)) {
+ retval = retval.withForcedLogic(options[options::forceLogic].getLogicString());
}
+ return retval;
+}
ParserBuilder& ParserBuilder::withStrictMode(bool flag) {
d_strictMode = flag;
return *this;
}
+ParserBuilder& ParserBuilder::withForcedLogic(const std::string& logic) {
+ d_logicIsForced = true;
+ d_forcedLogic = logic;
+ return *this;
+}
+
ParserBuilder& ParserBuilder::withStreamInput(std::istream& input) {
d_inputType = STREAM_INPUT;
d_streamInput = &input;
/** Are we parsing only? */
bool d_parseOnly;
+ /** Is the logic forced by the user? */
+ bool d_logicIsForced;
+
+ /** The forced logic name */
+ std::string d_forcedLogic;
+
/** Initialize this parser builder */
void init(ExprManager* exprManager, const std::string& filename);
/** Set the parser to use the given string for its input. */
ParserBuilder& withStringInput(const std::string& input);
+
+ /** Set the parser to use the given logic string. */
+ ParserBuilder& withForcedLogic(const std::string& logic);
};/* class ParserBuilder */
}/* CVC4::parser namespace */
void Smt1::setLogic(const std::string& name) {
d_logicSet = true;
- d_logic = toLogic(name);
+ if(logicIsForced()) {
+ d_logic = toLogic(getForcedLogic());
+ } else {
+ d_logic = toLogic(name);
+ }
switch(d_logic) {
case QF_S:
void Smt2::setLogic(const std::string& name) {
d_logicSet = true;
- d_logic = name;
+ if(logicIsForced()) {
+ d_logic = getForcedLogic();
+ } else {
+ d_logic = name;
+ }
// Core theory belongs to every logic
addTheory(THEORY_CORE);