<projects>
</projects>
<buildSpec>
+ <buildCommand>
+ <name>org.eclipse.dltk.core.scriptbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>net.certiv.antlrdt.core.nature</nature>
</natures>
</projectDescription>
Expr
AntlrParser::mkVar(const std::string& name, const Type* type) {
Debug("parser") << "mkVar(" << name << "," << *type << ")" << std::endl;
- Assert( !isDeclared(name) );
Expr expr = d_exprManager->mkVar(type, name);
- d_varSymbolTable.bindName(name, expr);
- Assert( isDeclared(name) );
+ defineVar(name,expr);
return expr;
}
return vars;
}
+void
+AntlrParser::defineVar(const std::string& name, const Expr& val) {
+ Assert(!isDeclared(name));
+ d_varSymbolTable.bindName(name,val);
+ Assert(isDeclared(name));
+}
const Type*
AntlrParser::newSort(const std::string& name) {
mkVars(const std::vector<std::string> names,
const Type* type);
+ /** Create a new variable definition (e.g., from a let binding). */
+ void defineVar(const std::string& name, const Expr& val);
/** Returns a function type over the given domain and range types. */
const Type* functionType(const Type* domain, const Type* range);
* Matches an identifier starting with a colon. An identifier is a sequence of letters,
* digits and "_", "'", "." symbols, starting with a colon.
*/
-C_IDENTIFIER options { paraphrase = "an identifier starting with a colon"; testLiterals = true; }
+C_IDENTIFIER options { paraphrase = "an attribute (e.g., ':x')"; testLiterals = true; }
: ':' ALPHA (ALPHA | DIGIT | '_' | '\'' | '.')*
;
+VAR_IDENTIFIER options { paraphrase = "a variable (e.g., '?x')"; testLiterals = false; }
+ : '?' IDENTIFIER
+ ;
+
+FUN_IDENTIFIER options { paraphrase = "a function variable (e.g, '$x')"; testLiterals = false; }
+ : '$' IDENTIFIER
+ ;
+
+
/**
* Matches the value of user-defined annotations or attributes. The only constraint imposed on a user-defined value is that it start with
* an open brace and end with closed brace.
Debug("parser") << "annotated formula: " << LT(1)->getText() << endl;
Kind kind = CVC4::kind::UNDEFINED_KIND;
vector<Expr> args;
+ std::string name;
+ Expr expr1, expr2, expr3;
}
: /* a built-in operator application */
LPAREN kind = builtinOp annotatedFormulas[args] RPAREN
formula = mkExpr(kind,args); }
| /* a "distinct" expr */
+ /* TODO: Should there be a DISTINCT kind in the Expr package? */
LPAREN DISTINCT annotatedFormulas[args] RPAREN
{ std::vector<Expr> diseqs;
for(unsigned i = 0; i < args.size(); ++i) {
RPAREN
{ formula = mkExpr(CVC4::kind::ITE, test, trueExpr, falseExpr); }
+ | /* A let binding */
+ /* TODO: Create an Expr of LET kind? */
+ LPAREN LET LPAREN name=variable[CHECK_UNDECLARED] expr1=annotatedFormula RPAREN
+ { defineVar(name,expr1); }
+ formula=annotatedFormula
+ RPAREN
+ | /* An flet binding */
+ /* TODO: Create an Expr of LET kind? */
+ LPAREN FLET LPAREN name=function_var[CHECK_UNDECLARED] expr1=annotatedFormula RPAREN
+ { defineVar(name,expr1); }
+ formula=annotatedFormula
+ RPAREN
+
| /* A non-built-in function application */
// Semantic predicate not necessary if parenthesized subexpressions
| /* a variable */
{ std::string name; }
- name = identifier[CHECK_DECLARED]
+ ( name = identifier[CHECK_DECLARED]
+ | name = variable[CHECK_DECLARED]
+ | name = function_var[CHECK_DECLARED] )
{ formula = getVariable(name); }
/* constants */
: C_IDENTIFIER
;
+variable[DeclarationCheck check = CHECK_NONE] returns [std::string name]
+ : x:VAR_IDENTIFIER
+ { name = x->getText();
+ checkDeclaration(name, check, SYM_VARIABLE); }
+ ;
+
+function_var[DeclarationCheck check = CHECK_NONE] returns [std::string name]
+ : x:FUN_IDENTIFIER
+ { name = x->getText();
+ checkDeclaration(name, check, SYM_FUNCTION); }
+ ;
+
/**
* Matches the sort symbol, which can be an arbitrary identifier.
* @param check the check to perform on the name
}
: x:IDENTIFIER
{ id = x->getText();
- checkDeclaration(id, check,type); }
+ checkDeclaration(id, check, type); }
;
TESTS_ENVIRONMENT = @srcdir@/../run_regression @top_builddir@/../../bin/cvc4
TESTS = bug32.cvc \
+ distinct.smt \
+ flet.smt \
+ flet2.smt \
hole6.cvc \
+ let.smt \
+ let2.smt \
logops.01.cvc \
logops.02.cvc \
logops.03.cvc \
--- /dev/null
+(benchmark flet_test
+ :logic QF_UF
+ :status unsat
+ :extrapreds ((a) (b))
+ :formula (flet ($x (and a b)) (and $x (or (not a) (not b)))))
\ No newline at end of file
--- /dev/null
+(benchmark flet_test
+ :logic QF_UF
+ :status sat
+ :extrapreds ((a) (b))
+ :formula (flet ($x (and a b)) (and $x (or a b))))
\ No newline at end of file
--- /dev/null
+(benchmark let_test
+ :logic QF_UF
+ :status unsat
+ :extrafuns ((a U) (b U) (f U U))
+ :formula (let (?x a) (not (= ?x a))))
\ No newline at end of file
--- /dev/null
+(benchmark let_test
+ :logic QF_UF
+ :status sat
+ :extrafuns ((a U) (b U) (f U U))
+ :formula (let (?x (f a)) (= ?x (f b))))
\ No newline at end of file