From 414fe86dbf3f4606d9e1382f238001f58d691620 Mon Sep 17 00:00:00 2001 From: Jon French Date: Wed, 25 Apr 2018 08:45:43 +0100 Subject: add mpats to asts --- src/parse_ast.ml | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src/parse_ast.ml') diff --git a/src/parse_ast.ml b/src/parse_ast.ml index f71498be..d845265f 100644 --- a/src/parse_ast.ml +++ b/src/parse_ast.ml @@ -151,6 +151,7 @@ atyp_aux = (* expressions of all kinds, to be translated to types, nats, orders | ATyp_default_ord (* default order for increasing or decreasing signficant bits *) | ATyp_set of (base_effect) list (* effect set *) | ATyp_fn of atyp * atyp * atyp (* Function type (first-order only in user code), last atyp is an effect *) + | ATyp_bidir of atyp * atyp (* Function type (first-order only in user code), last atyp is an effect *) | ATyp_wild | ATyp_tup of (atyp) list (* Tuple type *) | ATyp_app of id * (atyp) list (* type constructor application *) @@ -392,7 +393,6 @@ type funcl = FCL_aux of funcl_aux * l - type type_union = Tu_aux of type_union_aux * l @@ -420,6 +420,41 @@ default_typing_spec_aux = (* Default kinding or typing assumption, and default | DT_typ of typschm * id +type mpat_aux = (* Mapping pattern. Mostly the same as normal patterns but only constructible parts *) + | MP_lit of lit + | MP_id of id + | MP_app of id * ( mpat) list + | MP_record of ( fpat) list * bool + | MP_vector of ( mpat) list + | MP_vector_concat of ( mpat) list + | MP_tup of ( mpat) list + | MP_list of ( mpat) list + | MP_cons of ( mpat) * ( mpat) + | MP_string_append of ( mpat) * ( mpat) + +and mpat = + | MP_aux of ( mpat_aux) * l + +type mpexp_aux = + | MPat_pat of ( mpat) + | MPat_when of ( mpat) * ( exp) + +type mpexp = + | MPat_aux of ( mpexp_aux) * l + +type mapcl_aux = (* mapping clause (bidirectional pattern-match) *) + | MCL_mapcl of ( mpexp) * ( mpexp) + +type mapcl = + | MCL_aux of ( mapcl_aux) * l + +type mapdef_aux = (* mapping definition (bidirectional pattern-match function) *) + | MD_mapping of id * ( mapcl) list + +type mapdef = + | MD_aux of ( mapdef_aux) * l + + type fundef_aux = (* Function definition *) FD_function of rec_opt * tannot_opt * effect_opt * (funcl) list @@ -502,6 +537,7 @@ def = (* Top-level definition *) DEF_kind of kind_def (* definition of named kind identifiers *) | DEF_type of type_def (* type definition *) | DEF_fundef of fundef (* function definition *) + | DEF_mapdef of mapdef (* mapping definition *) | DEF_val of letbind (* value definition *) | DEF_overload of id * id list (* operator overload specifications *) | DEF_fixity of prec * Big_int.num * id (* fixity declaration *) -- cgit v1.2.3