(* Abstract syntax tree after typing *)openAsttypes(* Type expressions for the core language *)typetype_expr=Tvaroftype_variable|Tarrowoftype_expr*type_expr|Ttupleoftype_exprlist|TconstrofPath.t*type_exprlistandtype_variable={mutabletvar_level:int;mutabletvar_link:type_exproption}(* Value descriptions *)typevalue_description={val_type:type_expr;(* Type of the val *)val_prim:primitive_description}(* Is this a primitive? *)andprimitive_description=Not_prim|Primitiveofstring*int(* Constructor descriptions *)typeconstructor_description={cstr_res:type_expr;(* Type of the result *)cstr_args:type_exprlist;(* Type of the arguments *)cstr_arity:int;(* Number of arguments *)cstr_tag:constructor_tag;(* Tag for heap blocks *)cstr_consts:int;(* Number of constant constructors *)cstr_nonconsts:int}(* Number of non-const constructors *)andconstructor_tag=Cstr_constantofint(* Constant constructor (an int) *)|Cstr_blockofint(* Regular constructor (a block) *)|Cstr_exceptionofPath.t(* Exception constructor *)(* Record label descriptions *)typelabel_description={lbl_res:type_expr;(* Type of the result *)lbl_arg:type_expr;(* Type of the argument *)lbl_mut:mutable_flag;(* Is this a mutable field? *)lbl_pos:int;(* Position in block *)lbl_all:label_descriptionarray(* All the labels in this type *)}(* Value expressions for the core language *)typepattern={pat_desc:pattern_desc;pat_loc:Location.t;pat_type:type_expr}andpattern_desc=Tpat_any|Tpat_varofIdent.t|Tpat_aliasofpattern*Ident.t|Tpat_constantofconstant|Tpat_tupleofpatternlist|Tpat_constructofconstructor_description*patternlist|Tpat_recordof(label_description*pattern)list|Tpat_orofpattern*patterntypeexpression={exp_desc:expression_desc;exp_loc:Location.t;exp_type:type_expr}andexpression_desc=Texp_identofPath.t*value_description|Texp_constantofconstant|Texp_letofrec_flag*(pattern*expression)list*expression|Texp_functionof(pattern*expression)list|Texp_applyofexpression*expressionlist|Texp_matchofexpression*(pattern*expression)list|Texp_tryofexpression*(pattern*expression)list|Texp_tupleofexpressionlist|Texp_constructofconstructor_description*expressionlist|Texp_recordof(label_description*expression)list|Texp_fieldofexpression*label_description|Texp_setfieldofexpression*label_description*expression|Texp_arrayofexpressionlist|Texp_ifthenelseofexpression*expression*expressionoption|Texp_sequenceofexpression*expression|Texp_whileofexpression*expression|Texp_forofIdent.t*expression*expression*direction_flag*expression|Texp_whenofexpression*expression(* Type definitions *)typetype_declaration={mutabletype_params:type_exprlist;type_arity:int;mutabletype_kind:type_kind}andtype_kind=Type_abstract|Type_manifestoftype_expr|Type_variantof(string*type_exprlist)list|Type_recordof(string*mutable_flag*type_expr)listtypeexception_declaration=type_exprlist(* Type expressions for the module language *)typemodule_type=Tmty_identofPath.t|Tmty_signatureofsignature|Tmty_functorofIdent.t*module_type*module_typeandsignature=signature_itemlistandsignature_item=Tsig_valueofIdent.t*value_description|Tsig_typeofIdent.t*type_declaration|Tsig_exceptionofIdent.t*exception_declaration|Tsig_moduleofIdent.t*module_type|Tsig_modtypeofIdent.t*modtype_declarationandmodtype_declaration=Tmodtype_abstract|Tmodtype_manifestofmodule_type(* Value expressions for the module language *)typemodule_expr={mod_desc:module_expr_desc;mod_loc:Location.t;mod_type:module_type}andmodule_expr_desc=Tmod_identofPath.t|Tmod_structureofstructure|Tmod_functorofIdent.t*module_type*module_expr|Tmod_applyofmodule_expr*module_expr*module_coercion|Tmod_constraintofmodule_expr*module_type*module_coercionandstructure=structure_itemlistandstructure_item=Tstr_evalofexpression|Tstr_valueofrec_flag*(pattern*expression)list|Tstr_primitiveofIdent.t*value_description|Tstr_typeof(Ident.t*type_declaration)list|Tstr_exceptionofIdent.t*exception_declaration|Tstr_moduleofIdent.t*module_expr|Tstr_modtypeofIdent.t*module_type|Tstr_openofPath.tandmodule_coercion=Tcoerce_none|Tcoerce_structureof(int*module_coercion)list|Tcoerce_functorofmodule_coercion*module_coercion(* Auxiliary functions over the a.s.t. *)valpat_bound_idents:pattern->Ident.tlistvallet_bound_idents:(pattern*expression)list->Ident.tlist