diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2020-02-26 13:09:51 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-26 13:09:51 -0600 |
commit | f26ea8026e94252e4f1418be473d10a5f957b988 (patch) | |
tree | 29798cb7eddc017b563ab3b494eb9399315a28b5 /src/parser/parser.h | |
parent | 51d9d5b94c1d635b63482ffdd5eaaa4481e62e9b (diff) |
Refactor type ascriptions in the parser (#3825)
Towards parser migration.
This consolidates two blocks of code (cvc/smt2) that do type ascriptions to a utility function in the parser. It updates this function to use the new API.
This code will be further refactored when the interface for parametric datatype constructors is further developed in the new API.
Diffstat (limited to 'src/parser/parser.h')
-rw-r--r-- | src/parser/parser.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/parser/parser.h b/src/parser/parser.h index 8447eb4dc..d40236208 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -678,6 +678,30 @@ public: */ Expr mkHoApply(Expr expr, std::vector<Expr>& args); + /** Apply type ascription + * + * Return term t with a type ascription applied to it. This is used for + * syntax like (as t T) in smt2 and t::T in the CVC language. This includes: + * - (as emptyset (Set T)) + * - (as univset (Set T)) + * - (as sep.nil T) + * - (cons T) + * - ((as cons T) t1 ... tn) where cons is a parametric datatype constructor. + * + * The term to ascribe t is a term whose kind and children (but not type) + * are equivalent to that of the term returned by this method. + * + * Notice that method is not necessarily a cast. In actuality, the above terms + * should be understood as symbols indexed by types. However, SMT-LIB does not + * permit types as indices, so we must use, e.g. (as emptyset (Set T)) + * instead of (_ emptyset (Set T)). + * + * @param t The term to ascribe a type + * @param s The sort to ascribe + * @return Term t with sort s ascribed. + */ + api::Term applyTypeAscription(api::Term t, api::Sort s); + /** * Add an operator to the current legal set. * |