default:
if (language::isInputLang_smt2(lang))
{
- input = new Smt2Input(inputStream, lang);
+ input = new Smt2Input(inputStream);
}
else
{
/** Destructor. Frees the lexer and the parser. */
virtual ~CvcInput();
- /** Get the language that this Input is reading. */
- InputLanguage getLanguage() const override
- {
- return language::input::LANG_CVC4;
- }
-
protected:
/** Parse a command from the input. Returns <code>NULL</code> if there is
* no command there to parse.
/** Destructor. Frees the input stream and closes the input. */
virtual ~Input();
- /** Get the language that this Input is reading. */
- virtual InputLanguage getLanguage() const = 0;
-
/** Retrieve the name of the input stream */
const std::string getInputStreamName() { return getInputStream()->getName(); }
protected:
/** Destructor. Frees the lexer and the parser. */
virtual ~Smt1Input();
- /** Get the language that this Input is reading. */
- InputLanguage getLanguage() const override
- {
- return language::input::LANG_SMTLIB_V1;
- }
-
protected:
/**
* Parse a command from the input. Returns <code>NULL</code> if
{ name = AntlrInput::tokenText($KEYWORD);
if(name == ":cvc4-logic" || name == ":cvc4_logic") {
PARSER_STATE->setLogic(sexpr.getValue());
- } else if(name == ":smt-lib-version") {
- // if we don't recognize the revision name, just keep the current mode
- if( (sexpr.isRational() && sexpr.getRationalValue() == Rational(2)) ||
- sexpr.getValue() == "2" ||
- sexpr.getValue() == "2.0" ) {
- PARSER_STATE->setLanguage(language::input::LANG_SMTLIB_V2_0);
- } else if( (sexpr.isRational() &&
- sexpr.getRationalValue() == Rational(5, 2)) ||
- sexpr.getValue() == "2.5" ) {
- PARSER_STATE->setLanguage(language::input::LANG_SMTLIB_V2_5);
- } else if( (sexpr.isRational() &&
- sexpr.getRationalValue() == Rational(13, 5)) ||
- sexpr.getValue() == "2.6" ) {
- PARSER_STATE->setLanguage(language::input::LANG_SMTLIB_V2_6);
- }
}
PARSER_STATE->setInfo(name.c_str() + 1, sexpr);
cmd->reset(new SetInfoCommand(name.c_str() + 1, sexpr));
**/
#include "parser/smt2/smt2.h"
-
#include "expr/type.h"
+#include "options/options.h"
#include "parser/antlr_input.h"
#include "parser/parser.h"
#include "parser/smt1/smt1.h"
}
}
-void Smt2::setLanguage(InputLanguage lang) {
- ((Smt2Input*) getInput())->setLanguage(lang);
-}
-
void Smt2::addArithmeticOperators() {
Parser::addOperator(kind::PLUS);
Parser::addOperator(kind::MINUS);
addOperator(kind::STRING_PREFIX, "str.prefixof" );
addOperator(kind::STRING_SUFFIX, "str.suffixof" );
// at the moment, we only use this syntax for smt2.6.1
- if (getInput()->getLanguage() == language::input::LANG_SMTLIB_V2_6_1)
+ if (getLanguage() == language::input::LANG_SMTLIB_V2_6_1)
{
addOperator(kind::STRING_ITOS, "str.from-int");
addOperator(kind::STRING_STOI, "str.to-int");
preemptCommand(cattr);
}
+InputLanguage Smt2::getLanguage() const
+{
+ ExprManager* em = getExprManager();
+ return em->getOptions().getInputLanguage();
+}
+
}/* CVC4::parser namespace */
}/* CVC4 namespace */
const LogicInfo& getLogic() const { return d_logic; }
bool v2_0() const {
- return getInput()->getLanguage() == language::input::LANG_SMTLIB_V2_0;
+ return getLanguage() == language::input::LANG_SMTLIB_V2_0;
}
/**
* Are we using smtlib 2.5 or above? If exact=true, then this method returns
*/
bool v2_5(bool exact = false) const
{
- return language::isInputLang_smt2_5(getInput()->getLanguage(), exact);
+ return language::isInputLang_smt2_5(getLanguage(), exact);
}
/**
* Are we using smtlib 2.6 or above? If exact=true, then this method returns
*/
bool v2_6(bool exact = false) const
{
- return language::isInputLang_smt2_6(getInput()->getLanguage(), exact);
+ return language::isInputLang_smt2_6(getLanguage(), exact);
}
- bool sygus() const {
- return getInput()->getLanguage() == language::input::LANG_SYGUS;
- }
-
- void setLanguage(InputLanguage lang);
+ bool sygus() const { return getLanguage() == language::input::LANG_SYGUS; }
void setInfo(const std::string& flag, const SExpr& sexpr);
void addFloatingPointOperators();
void addSepOperators();
+
+ InputLanguage getLanguage() const;
};/* class Smt2 */
}/* CVC4::parser namespace */
namespace parser {
/* Use lookahead=2 */
-Smt2Input::Smt2Input(AntlrInputStream& inputStream, InputLanguage lang) :
- AntlrInput(inputStream, 2) {
-
+Smt2Input::Smt2Input(AntlrInputStream& inputStream) : AntlrInput(inputStream, 2)
+{
pANTLR3_INPUT_STREAM input = inputStream.getAntlr3InputStream();
assert( input != NULL );
}
setAntlr3Parser(d_pSmt2Parser->pParser);
-
- setLanguage(lang);
}
Smt2Input::~Smt2Input() {
d_pSmt2Parser->free(d_pSmt2Parser);
}
-void Smt2Input::setLanguage(InputLanguage lang) {
- CheckArgument(language::isInputLang_smt2(lang), lang);
- d_lang = lang;
-}
-
Command* Smt2Input::parseCommand() {
return d_pSmt2Parser->parseCommand(d_pSmt2Parser);
}
/** The ANTLR3 SMT2 parser for the input. */
pSmt2Parser d_pSmt2Parser;
- /** Which (variant of the) input language we're using */
- InputLanguage d_lang;
-
/**
* Initialize the class. Called from the constructors once the input
* stream is initialized.
*
* @param inputStream the input stream to use
*/
- Smt2Input(AntlrInputStream& inputStream,
- InputLanguage lang = language::input::LANG_SMTLIB_V2_5);
+ Smt2Input(AntlrInputStream& inputStream);
/** Destructor. Frees the lexer and the parser. */
virtual ~Smt2Input();
- /** Get the language that this Input is reading. */
- InputLanguage getLanguage() const override { return d_lang; }
- /** Set the language that this Input is reading. */
- void setLanguage(InputLanguage);
-
protected:
/**
* Parse a command from the input. Returns <code>NULL</code> if
/** Destructor. Frees the lexer and the parser. */
virtual ~SygusInput();
- /** Get the language that this Input is reading. */
- InputLanguage getLanguage() const override
- {
- return language::input::LANG_SYGUS;
- }
-
protected:
/**
* Parse a command from the input. Returns <code>NULL</code> if
/** Destructor. Frees the lexer and the parser. */
virtual ~TptpInput();
- /** Get the language that this Input is reading. */
- InputLanguage getLanguage() const override
- {
- return language::input::LANG_TPTP;
- }
-
protected:
/**
* Parse a command from the input. Returns <code>NULL</code> if