void getExpressionNames(const std::vector<api::Term>& ts,
std::vector<std::string>& names,
bool areAssertions = false) const;
+ /** get expression names */
+ std::map<api::Term, std::string> getExpressionNames(bool areAssertions) const;
/** reset */
void reset();
/** Push a scope in the expression names. */
}
}
+std::map<api::Term, std::string>
+SymbolManager::Implementation::getExpressionNames(bool areAssertions) const
+{
+ std::map<api::Term, std::string> emap;
+ for (TermStringMap::const_iterator it = d_names.begin(),
+ itend = d_names.end();
+ it != itend;
+ ++it)
+ {
+ api::Term t = (*it).first;
+ if (areAssertions && d_namedAsserts.find(t) == d_namedAsserts.end())
+ {
+ continue;
+ }
+ emap[t] = (*it).second;
+ }
+ return emap;
+}
+
void SymbolManager::Implementation::pushScope(bool isUserContext)
{
+ Trace("sym-manager") << "pushScope, isUserContext = " << isUserContext
+ << std::endl;
+ PrettyCheckArgument(!d_hasPushedScope.get() || !isUserContext,
+ "cannot push a user context within a scope context");
d_context.push();
if (!isUserContext)
{
void SymbolManager::Implementation::popScope()
{
+ Trace("sym-manager") << "popScope" << std::endl;
if (d_context.getLevel() == 0)
{
throw ScopeException();
}
d_context.pop();
+ Trace("sym-manager-debug")
+ << "d_hasPushedScope is now " << d_hasPushedScope.get() << std::endl;
}
void SymbolManager::Implementation::reset()
return d_implementation->getExpressionNames(ts, names, areAssertions);
}
+std::map<api::Term, std::string> SymbolManager::getExpressionNames(
+ bool areAssertions) const
+{
+ return d_implementation->getExpressionNames(areAssertions);
+}
+
size_t SymbolManager::scopeLevel() const
{
return d_symtabAllocated.getLevel();
d_symtabAllocated.pushScope();
}
-void SymbolManager::popScope() { d_symtabAllocated.popScope(); }
+void SymbolManager::popScope()
+{
+ d_symtabAllocated.popScope();
+ d_implementation->popScope();
+}
void SymbolManager::setGlobalDeclarations(bool flag)
{
symbol[name,CHECK_UNDECLARED,SYM_SORT]
{ PARSER_STATE->checkUserSymbol(name); }
LPAREN_TOK symbolList[names,CHECK_NONE,SYM_SORT] RPAREN_TOK
- { PARSER_STATE->pushScope(true);
+ { PARSER_STATE->pushScope();
for(std::vector<std::string>::const_iterator i = names.begin(),
iend = names.end();
i != iend;
}
t = PARSER_STATE->mkFlatFunctionType(sorts, t, flattenVars);
- PARSER_STATE->pushScope(true);
+ PARSER_STATE->pushScope();
terms = PARSER_STATE->bindBoundVars(sortedVarNames);
}
term[expr, expr2]
// set the expression name, if there was a named term
std::pair<api::Term, std::string> namedTerm =
PARSER_STATE->lastNamedTerm();
+ // TODO (projects-248)
+ // SYM_MAN->setExpressionName(namedTerm.first, namedTerm.second, true);
Command* csen =
new SetExpressionNameCommand(namedTerm.first, namedTerm.second);
csen->setMuted(true);
if(num == 0) {
cmd->reset(new EmptyCommand());
} else if(num == 1) {
- PARSER_STATE->pushScope();
+ PARSER_STATE->pushScope(true);
cmd->reset(new PushCommand());
} else {
std::unique_ptr<CommandSequence> seq(new CommandSequence());
do {
- PARSER_STATE->pushScope();
+ PARSER_STATE->pushScope(true);
Command* push_cmd = new PushCommand();
push_cmd->setMuted(num > 1);
seq->addCommand(push_cmd);
"Strict compliance mode demands an integer to be provided to "
"PUSH. Maybe you want (push 1)?");
} else {
- PARSER_STATE->pushScope();
+ PARSER_STATE->pushScope(true);
cmd->reset(new PushCommand());
}
} )
LPAREN_TOK sortedVarList[sortedVarNames] RPAREN_TOK
( sortSymbol[range,CHECK_DECLARED] )?
{
- PARSER_STATE->pushScope(true);
+ PARSER_STATE->pushScope();
sygusVars = PARSER_STATE->bindBoundVars(sortedVarNames);
}
(
RPAREN_TOK
{
// non-terminal symbols in the pre-declaration are locally scoped
- PARSER_STATE->pushScope(true);
+ PARSER_STATE->pushScope();
for (std::pair<std::string, api::Sort>& i : sortedVarNames)
{
PARSER_STATE->checkDeclaration(name, CHECK_UNDECLARED, SYM_SORT);
func =
PARSER_STATE->bindDefineFunRec(fname, sortedVarNames, t, flattenVars);
PARSER_STATE->pushDefineFunRecScope(
- sortedVarNames, func, flattenVars, bvs, true);
+ sortedVarNames, func, flattenVars, bvs);
}
term[expr, expr2]
{ PARSER_STATE->popScope();
}
bvs.clear();
PARSER_STATE->pushDefineFunRecScope( sortedVarNamesList[0], funcs[0],
- flattenVarsList[0], bvs, true);
+ flattenVarsList[0], bvs);
}
(
term[expr,expr2]
if( func_defs.size()<funcs.size() ){
bvs.clear();
PARSER_STATE->pushDefineFunRecScope( sortedVarNamesList[j], funcs[j],
- flattenVarsList[j], bvs, true);
+ flattenVarsList[j], bvs);
}
}
)+
sortedVarList[sortedVarNames] RPAREN_TOK
{ /* add variables to parser state before parsing term */
Debug("parser") << "define fun: '" << name << "'" << std::endl;
- PARSER_STATE->pushScope(true);
+ PARSER_STATE->pushScope();
terms = PARSER_STATE->bindBoundVars(sortedVarNames);
}
term[e,e2]
sortSymbol[t,CHECK_DECLARED]
{ /* add variables to parser state before parsing term */
Debug("parser") << "define const: '" << name << "'" << std::endl;
- PARSER_STATE->pushScope(true);
+ PARSER_STATE->pushScope();
terms = PARSER_STATE->bindBoundVars(sortedVarNames);
}
term[e, e2]
}
: { PARSER_STATE->checkThatLogicIsSet();
/* open a scope to keep the UnresolvedTypes contained */
- PARSER_STATE->pushScope(true); }
+ PARSER_STATE->pushScope(); }
LPAREN_TOK /* parametric sorts */
( symbol[name,CHECK_UNDECLARED,SYM_SORT]
{
std::string name;
std::vector<api::Sort> params;
}
- : { PARSER_STATE->pushScope(true);
+ : { PARSER_STATE->pushScope();
// Declare the datatypes that are currently being defined as unresolved
// types. If we do not know the arity of the datatype yet, we wait to
// define it until parsing the preamble of its body, which may optionally
PARSER_STATE->parseError("Too many datatypes defined in this block.");
}
}
- ( PAR_TOK { PARSER_STATE->pushScope(true); } LPAREN_TOK
+ ( PAR_TOK { PARSER_STATE->pushScope(); } LPAREN_TOK
( symbol[name,CHECK_UNDECLARED,SYM_SORT]
{
params.push_back( PARSER_STATE->mkSort(name, ExprManager::SORT_FLAG_PLACEHOLDER)); }
{
PARSER_STATE->parseError("Quantifier used in non-quantified logic.");
}
- PARSER_STATE->pushScope(true);
+ PARSER_STATE->pushScope();
}
boundVarList[bvl]
term[f, f2] RPAREN_TOK
expr = MK_TERM(kind, args);
}
| LPAREN_TOK COMPREHENSION_TOK
- { PARSER_STATE->pushScope(true); }
+ { PARSER_STATE->pushScope(); }
boundVarList[bvl]
{
args.push_back(bvl);
| /* a let or sygus let binding */
LPAREN_TOK
LET_TOK LPAREN_TOK
- { PARSER_STATE->pushScope(true); }
+ { PARSER_STATE->pushScope(); }
( LPAREN_TOK symbol[name,CHECK_NONE,SYM_VARIABLE]
term[expr, f2]
RPAREN_TOK
// case with non-nullary pattern
LPAREN_TOK LPAREN_TOK term[f, f2] {
args.clear();
- PARSER_STATE->pushScope(true);
+ PARSER_STATE->pushScope();
// f should be a constructor
type = f.getSort();
Debug("parser-dt") << "Pattern head : " << f << " " << type << std::endl;
}
| /* lambda */
LPAREN_TOK HO_LAMBDA_TOK
- { PARSER_STATE->pushScope(true); }
+ { PARSER_STATE->pushScope(); }
boundVarList[bvl]
term[f, f2] RPAREN_TOK
{
api::Term func = PARSER_STATE->setNamedAttribute(expr, sexpr);
std::string name = sexpr.getValue();
// bind name to expr with define-fun
+ // TODO (projects-248) SYM_MAN->setExpressionName(func, name, false);
Command* c =
new DefineNamedFunctionCommand(name,
func,
* datatypes won't work, because this type will already be
* "defined" as an unresolved type; don't worry, we check
* below. */
- : symbol[id,CHECK_NONE,SYM_SORT] { PARSER_STATE->pushScope(true); }
+ : symbol[id,CHECK_NONE,SYM_SORT] { PARSER_STATE->pushScope(); }
{
datatypes.push_back(SOLVER->mkDatatypeDecl(id, params, isCo));
}