PARSER_STATE->preemptCommand(cmd);
f = func;
}
-
- /* array literals */
- | ARRAY_TOK { PARSER_STATE->pushScope(); } LPAREN
- boundVarDecl[ids,t] RPAREN COLON formula[f]
- { PARSER_STATE->popScope();
- UNSUPPORTED("array literals not supported yet");
- f = EXPR_MANAGER->mkVar(EXPR_MANAGER->mkArrayType(t, f.getType()), ExprManager::VAR_FLAG_GLOBAL);
- }
;
instantiationPatterns[ CVC4::Expr& expr ]
std::vector<std::string> names;
Expr e;
Debug("parser-extra") << "term: " << AntlrInput::tokenText(LT(1)) << std::endl;
- Type t;
+ Type t, t2;
}
/* if-then-else */
: iteTerm[f]
f = MK_EXPR(kind::RECORD, MK_CONST(t.getRecord()), std::vector<Expr>());
}
-
/* empty set literal */
| LBRACE RBRACE
{ f = MK_CONST(EmptySet(Type())); }
}
}
+ /* array literals */
+ | ARRAY_TOK /* { PARSER_STATE->pushScope(); } */ LPAREN
+ restrictedType[t, CHECK_DECLARED] OF_TOK restrictedType[t2, CHECK_DECLARED]
+ RPAREN COLON simpleTerm[f]
+ { /* Eventually if we support a bound var (like a lambda) for array
+ * literals, we can use the push/pop scope. */
+ /* PARSER_STATE->popScope(); */
+ t = EXPR_MANAGER->mkArrayType(t, t2);
+ if(!f.isConst()) {
+ std::stringstream ss;
+ ss << "expected constant term inside array constant, but found "
+ << "nonconstant term" << std::endl
+ << "the term: " << f;
+ PARSER_STATE->parseError(ss.str());
+ }
+ if(!t2.isComparableTo(f.getType())) {
+ std::stringstream ss;
+ ss << "type mismatch inside array constant term:" << std::endl
+ << "array type: " << t << std::endl
+ << "expected const type: " << t2 << std::endl
+ << "computed const type: " << f.getType();
+ PARSER_STATE->parseError(ss.str());
+ }
+ f = MK_CONST( ArrayStoreAll(t, f) );
+ }
+
/* boolean literals */
| TRUE_TOK { f = MK_CONST(bool(true)); }
| FALSE_TOK { f = MK_CONST(bool(false)); }
;
/**
- * Matches (and performs) a type ascription.
+ * Matches a type ascription.
* The f arg is the term to check (it is an input-only argument).
*/
typeAscription[const CVC4::Expr& f, CVC4::Type& t]
RPAREN_TOK term[f, f2] RPAREN_TOK
{
if(!type.isArray()) {
- PARSER_STATE->parseError("(as const...) type ascription can only be used for array sorts.");
+ std::stringstream ss;
+ ss << "expected array constant term, but cast is not of array type" << std::endl
+ << "cast type: " << type;
+ PARSER_STATE->parseError(ss.str());
+ }
+ if(!f.isConst()) {
+ std::stringstream ss;
+ ss << "expected constant term inside array constant, but found "
+ << "nonconstant term:" << std::endl
+ << "the term: " << f;
+ PARSER_STATE->parseError(ss.str());
}
if(!ArrayType(type).getConstituentType().isComparableTo(f.getType())) {
- PARSER_STATE->parseError("type of the array cast is not compatible with term.");
+ std::stringstream ss;
+ ss << "type mismatch inside array constant term:" << std::endl
+ << "array type: " << type << std::endl
+ << "expected const type: " << ArrayType(type).getConstituentType() << std::endl
+ << "computed const type: " << f.getType();
+ PARSER_STATE->parseError(ss.str());
}
expr = MK_CONST( ::CVC4::ArrayStoreAll(type, f) );
}