From dbd59549e5e48118fdac71048de0a37059c1d5a1 Mon Sep 17 00:00:00 2001 From: François Bobot Date: Fri, 22 Jun 2012 15:11:11 +0000 Subject: Parser: add the possibility to bind at level 0. --- src/parser/parser.cpp | 25 +++++++++++++++---------- src/parser/parser.h | 18 ++++++++++++------ 2 files changed, 27 insertions(+), 16 deletions(-) (limited to 'src/parser') diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp index 3efc315cc..2265355f0 100644 --- a/src/parser/parser.cpp +++ b/src/parser/parser.cpp @@ -141,18 +141,20 @@ bool Parser::isPredicate(const std::string& name) { } Expr -Parser::mkVar(const std::string& name, const Type& type) { +Parser::mkVar(const std::string& name, const Type& type, + bool levelZero) { Debug("parser") << "mkVar(" << name << ", " << type << ")" << std::endl; Expr expr = d_exprManager->mkVar(name, type); - defineVar(name, expr); + defineVar(name, expr, levelZero); return expr; } Expr -Parser::mkFunction(const std::string& name, const Type& type) { +Parser::mkFunction(const std::string& name, const Type& type, + bool levelZero) { Debug("parser") << "mkVar(" << name << ", " << type << ")" << std::endl; Expr expr = d_exprManager->mkVar(name, type); - defineFunction(name, expr); + defineFunction(name, expr, levelZero); return expr; } @@ -165,23 +167,26 @@ Parser::mkAnonymousFunction(const std::string& prefix, const Type& type) { std::vector Parser::mkVars(const std::vector names, - const Type& type) { + const Type& type, + bool levelZero) { std::vector vars; for(unsigned i = 0; i < names.size(); ++i) { - vars.push_back(mkVar(names[i], type)); + vars.push_back(mkVar(names[i], type, levelZero)); } return vars; } void -Parser::defineVar(const std::string& name, const Expr& val) { - d_declScope->bind(name, val); +Parser::defineVar(const std::string& name, const Expr& val, + bool levelZero) { + d_declScope->bind(name, val, levelZero); Assert( isDeclared(name) ); } void -Parser::defineFunction(const std::string& name, const Expr& val) { - d_declScope->bindDefinedFunction(name, val); +Parser::defineFunction(const std::string& name, const Expr& val, + bool levelZero) { + d_declScope->bindDefinedFunction(name, val, levelZero); Assert( isDeclared(name) ); } diff --git a/src/parser/parser.h b/src/parser/parser.h index a3ddba013..635dd6b6c 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -337,16 +337,19 @@ public: Type getType(const std::string& var_name, SymbolType type = SYM_VARIABLE); /** Create a new CVC4 variable expression of the given type. */ - Expr mkVar(const std::string& name, const Type& type); + Expr mkVar(const std::string& name, const Type& type, + bool levelZero = false); /** * Create a set of new CVC4 variable expressions of the given type. */ std::vector - mkVars(const std::vector names, const Type& type); + mkVars(const std::vector names, const Type& type, + bool levelZero = false); /** Create a new CVC4 function expression of the given type. */ - Expr mkFunction(const std::string& name, const Type& type); + Expr mkFunction(const std::string& name, const Type& type, + bool levelZero = false); /** * Create a new CVC4 function expression of the given type, @@ -356,10 +359,12 @@ public: Expr mkAnonymousFunction(const std::string& prefix, const Type& type); /** Create a new variable definition (e.g., from a let binding). */ - void defineVar(const std::string& name, const Expr& val); + void defineVar(const std::string& name, const Expr& val, + bool levelZero = false); /** Create a new function definition (e.g., from a define-fun). */ - void defineFunction(const std::string& name, const Expr& val); + void defineFunction(const std::string& name, const Expr& val, + bool levelZero = false); /** Create a new type definition. */ void defineType(const std::string& name, const Type& type); @@ -432,7 +437,8 @@ public: /** * Preempt the next returned command with other ones; used to * support the :named attribute in SMT-LIBv2, which implicitly - * inserts a new command before the current one. + * inserts a new command before the current one. Also used in TPTP + * because function and predicate symbols are implicitly declared. */ void preemptCommand(Command* cmd); -- cgit v1.2.3