Towards parser migration.
Beyond Datatypes, there are still a handful of calls to the ExprManager in the parsers.
This eliminates a few missing cases from TPTP and also inlines the access of ExprManager in the places its used.
)* RBRACKET
)?
{
- datatypes.push_back(Datatype(PARSER_STATE->getExprManager(),
+ datatypes.push_back(Datatype(SOLVER->getExprManager(),
id,
api::sortVectorToTypes(params),
false));
delete d_input;
}
-ExprManager* Parser::getExprManager() const
-{
- return d_solver->getExprManager();
-}
-
api::Solver* Parser::getSolver() const { return d_solver; }
api::Term Parser::getSymbol(const std::string& name, SymbolType type)
api::Sort Parser::mkSort(const std::string& name, uint32_t flags)
{
Debug("parser") << "newSort(" << name << ")" << std::endl;
- api::Sort type = getExprManager()->mkSort(name, flags);
+ api::Sort type = d_solver->getExprManager()->mkSort(name, flags);
defineType(
name,
type,
{
Debug("parser") << "newSortConstructor(" << name << ", " << arity << ")"
<< std::endl;
- api::Sort type = getExprManager()->mkSortConstructor(name, arity, flags);
+ api::Sort type =
+ d_solver->getExprManager()->mkSortConstructor(name, arity, flags);
defineType(
name,
vector<api::Sort>(arity),
{
Debug("parser") << "newSortConstructor(P)(" << name << ", " << params.size()
<< ")" << std::endl;
- api::Sort unresolved = getExprManager()->mkSortConstructor(
+ api::Sort unresolved = d_solver->getExprManager()->mkSortConstructor(
name, params.size(), ExprManager::SORT_FLAG_PLACEHOLDER);
defineType(name, params, unresolved);
api::Sort t = getSort(name, params);
try {
std::set<Type> tset = api::sortSetToTypes(d_unresolved);
std::vector<DatatypeType> dtypes =
- getExprManager()->mkMutualDatatypeTypes(datatypes, tset, flags);
+ d_solver->getExprManager()->mkMutualDatatypeTypes(
+ datatypes, tset, flags);
std::vector<api::Sort> types;
for (unsigned i = 0, dtsize = dtypes.size(); i < dtsize; i++)
{
// parametric datatype.
if (s.isParametricDatatype())
{
- ExprManager* em = getExprManager();
+ ExprManager* em = d_solver->getExprManager();
// apply type ascription to the operator
Expr e = t.getExpr();
const DatatypeConstructor& dtc =
const api::Sort& type,
uint32_t flags)
{
- return api::Term(getExprManager()->mkVar(name, type.getType(), flags));
+ return api::Term(
+ d_solver->getExprManager()->mkVar(name, type.getType(), flags));
}
//!!!!!!!!!!! temporary
virtual ~Parser();
- /** Get the associated <code>ExprManager</code>. */
- ExprManager* getExprManager() const;
-
/** Get the associated solver. */
api::Solver* getSolver() const;
Trace("parser-sygus2") << "Declare datatype " << i.first << std::endl;
// make the datatype, which encodes terms generated by this non-terminal
std::string dname = i.first;
- datatypes.push_back(Datatype(PARSER_STATE->getExprManager(), dname));
+ datatypes.push_back(Datatype(SOLVER->getExprManager(), dname));
// make its unresolved type, used for referencing the final version of
// the datatype
PARSER_STATE->checkDeclaration(dname, CHECK_UNDECLARED, SYM_SORT);
PARSER_STATE->parseError("Wrong number of parameters for datatype.");
}
Debug("parser-dt") << params.size() << " parameters for " << dnames[dts.size()] << std::endl;
- dts.push_back(Datatype(PARSER_STATE->getExprManager(), dnames[dts.size()],api::sortVectorToTypes(params),isCo));
+ dts.push_back(Datatype(SOLVER->getExprManager(), dnames[dts.size()],api::sortVectorToTypes(params),isCo));
}
LPAREN_TOK
( LPAREN_TOK constructorDef[dts.back()] RPAREN_TOK )+
PARSER_STATE->parseError("No parameters given for datatype.");
}
Debug("parser-dt") << params.size() << " parameters for " << dnames[dts.size()] << std::endl;
- dts.push_back(Datatype(PARSER_STATE->getExprManager(),
+ dts.push_back(Datatype(SOLVER->getExprManager(),
dnames[dts.size()],
api::sortVectorToTypes(params),
isCo));
* below. */
: symbol[id,CHECK_NONE,SYM_SORT] { PARSER_STATE->pushScope(true); }
{
- datatypes.push_back(Datatype(PARSER_STATE->getExprManager(),
+ datatypes.push_back(Datatype(SOLVER->getExprManager(),
id,
api::sortVectorToTypes(params),
isCo));
std::vector<std::vector<std::string>>& unresolved_gterm_sym)
{
sorts.push_back(t);
- datatypes.push_back(Datatype(getExprManager(), dname));
+ datatypes.push_back(Datatype(d_solver->getExprManager(), dname));
ops.push_back(std::vector<ParseOp>());
cnames.push_back(std::vector<std::string>());
cargs.push_back(std::vector<std::vector<api::Sort>>());
InputLanguage Smt2::getLanguage() const
{
- return getExprManager()->getOptions().getInputLanguage();
+ return d_solver->getExprManager()->getOptions().getInputLanguage();
}
void Smt2::parseOpApplyTypeAscription(ParseOp& p, api::Sort type)
}
}
// Second phase: apply the arguments to the parse op
- ExprManager* em = getExprManager();
+ const Options& opts = d_solver->getExprManager()->getOptions();
// handle special cases
if (p.d_kind == api::STORE_ALL && !p.d_type.isNull())
{
else if (isBuiltinOperator)
{
Trace("ajr-temp") << "mkTerm builtin operator" << std::endl;
- if (!em->getOptions().getUfHo()
- && (kind == api::EQUAL || kind == api::DISTINCT))
+ if (!opts.getUfHo() && (kind == api::EQUAL || kind == api::DISTINCT))
{
// need --uf-ho if these operators are applied over function args
for (std::vector<api::Term>::iterator i = args.begin(); i != args.end();
unsigned arity = argt.getFunctionArity();
if (args.size() - 1 < arity)
{
- if (!em->getOptions().getUfHo())
+ if (!opts.getUfHo())
{
parseError("Cannot partially apply functions unless --uf-ho is set.");
}
}
void Tptp::addTheory(Theory theory) {
- ExprManager * em = getExprManager();
switch(theory) {
case THEORY_CORE:
//TPTP (CNF and FOF) is unsorted so we define this common type
{
std::string d_unsorted_name = "$$unsorted";
- d_unsorted = api::Sort(em->mkSort(d_unsorted_name));
+ d_unsorted = d_solver->mkUninterpretedSort(d_unsorted_name);
preemptCommand(
new DeclareTypeCommand(d_unsorted_name, 0, d_unsorted.getType()));
}
// propositionnal
- defineType("Bool", em->booleanType());
- defineVar("$true", em->mkConst(true));
- defineVar("$false", em->mkConst(false));
+ defineType("Bool", d_solver->getBooleanSort());
+ defineVar("$true", d_solver->mkTrue());
+ defineVar("$false", d_solver->mkFalse());
addOperator(api::AND);
addOperator(api::EQUAL);
addOperator(api::IMPLIES);
isBuiltinKind = true;
}
assert(kind != api::NULL_EXPR);
- ExprManager* em = getExprManager();
+ const Options& opts = d_solver->getExprManager()->getOptions();
// Second phase: apply parse op to the arguments
if (isBuiltinKind)
{
- if (!em->getOptions().getUfHo()
- && (kind == api::EQUAL || kind == api::DISTINCT))
+ if (!opts.getUfHo() && (kind == api::EQUAL || kind == api::DISTINCT))
{
// need --uf-ho if these operators are applied over function args
for (std::vector<api::Term>::iterator i = args.begin(); i != args.end();
unsigned arity = argt.getFunctionArity();
if (args.size() - 1 < arity)
{
- if (!em->getOptions().getUfHo())
+ if (!opts.getUfHo())
{
parseError("Cannot partially apply functions unless --uf-ho is set.");
}