From: Morgan Deters Date: Fri, 3 Oct 2014 15:50:10 +0000 (-0400) Subject: SMT-LIB parser support for array constants (Z3 syntax). X-Git-Tag: cvc5-1.0.0~6601 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd05758bc141f0b922916b63089e7e8748f8da31;p=cvc5.git SMT-LIB parser support for array constants (Z3 syntax). --- diff --git a/src/parser/smt2/Smt2.g b/src/parser/smt2/Smt2.g index 61b898806..4491e5643 100644 --- a/src/parser/smt2/Smt2.g +++ b/src/parser/smt2/Smt2.g @@ -999,11 +999,25 @@ term[CVC4::Expr& expr, CVC4::Expr& expr2] } expr = MK_EXPR(kind, args); } - | /* An indexed function application */ - LPAREN_TOK indexedFunctionName[op] termList[args,expr] RPAREN_TOK - { expr = MK_EXPR(op, args); - PARSER_STATE->checkOperator(expr.getKind(), args.size()); - } + | LPAREN_TOK + ( /* An indexed function application */ + indexedFunctionName[op] termList[args,expr] RPAREN_TOK + { expr = MK_EXPR(op, args); + PARSER_STATE->checkOperator(expr.getKind(), args.size()); + } + | /* Array constant (in Z3 syntax) */ + LPAREN_TOK AS_TOK CONST_TOK sortSymbol[type, CHECK_DECLARED] + RPAREN_TOK term[f, f2] RPAREN_TOK + { + if(!type.isArray()) { + PARSER_STATE->parseError("(as const...) type ascription can only be used for array sorts."); + } + if(!ArrayType(type).getConstituentType().isComparableTo(f.getType())) { + PARSER_STATE->parseError("type of the array cast is not compatible with term."); + } + expr = MK_CONST( ::CVC4::ArrayStoreAll(type, f) ); + } + ) | /* a let binding */ LPAREN_TOK LET_TOK LPAREN_TOK { PARSER_STATE->pushScope(true); } @@ -1710,6 +1724,7 @@ GET_OPTION_TOK : 'get-option'; PUSH_TOK : 'push'; POP_TOK : 'pop'; AS_TOK : 'as'; +CONST_TOK : 'const'; // extended commands DECLARE_DATATYPES_TOK : 'declare-datatypes';