text
stringlengths
0
601k
let constructor_decl cd_cs cd_ld cd_loc cd_attrs = { cd_cs ; cd_ld ; cd_loc ; cd_attrs }
let type_declaration td_ts td_params td_cstrs td_kind td_private td_manifest td_attrs td_spec td_loc = { td_ts ; td_params ; td_cstrs ; td_kind ; td_private ; td_manifest ; td_attrs ; td_spec ; td_loc ; }
let axiom ax_name ax_term ax_loc ax_text = { ax_name ; ax_term ; ax_text ; ax_loc }
let mk_axiom id t l = t_ty_check t None ; axiom id t l
let fun_spec fun_req fun_ens fun_variant fun_coer fun_text fun_loc = { fun_req ; fun_ens ; fun_variant ; fun_coer ; fun_text ; fun_loc }
let mk_fun_spec req ens var coer = let t_ty_check ty t = t_ty_check t ty in List . iter ( t_ty_check None ) req ; List . iter ( t_ty_check None ) ens ; List . iter ( t_ty_check ( Some ty_integer ) ) var ; fun_spec req ens var coer
let function_ fun_ls fun_rec fun_params fun_def fun_spec fun_loc fun_text = { fun_ls ; fun_rec ; fun_params ; fun_def ; fun_spec ; fun_loc ; fun_text } we check the following 1 - no duplicate arguments ( Ident . tifiers may have the same string but still be different ) 2 - types or params match the type of lsymbol 3 - ...
let mk_function ? result ls r params def spec loc = let add_v s vs ty = if Svs . mem vs s then W . error ~ loc ( W . Duplicated_argument vs . vs_name . id_str ) ; ty_equal_check vs . vs_ty ty ; Svs . add vs s in let args = List . fold_left2 add_v Svs . empty params ls . ls_args in Option . iter ( t_free_vs_in_set args ...
let extension_constructor id xs kd loc attrs = { ext_ident = id ; ext_xs = xs ; ext_kind = kd ; ext_loc = loc ; ext_attributes = attrs ; }
let type_exception ctr loc attrs = { exn_constructor = ctr ; exn_loc = loc ; exn_attributes = attrs }
let sig_item sig_desc sig_loc = { sig_desc ; sig_loc }
let mk_sig_item desc loc = sig_item desc loc
let opt f = function None -> ( ) | Some x -> f x
let structure sub str = List . iter ( sub # structure_item ) str . str_items
let structure_item sub x = match x . str_desc with | Tstr_eval ( exp , _attrs ) -> sub # expression exp | Tstr_value ( rec_flag , list ) -> sub # bindings ( rec_flag , list ) | Tstr_primitive v -> sub # value_description v | Tstr_type list -> List . iter ( sub # type_declaration ) list | Tstr_typext te -> sub # type_ex...
let value_description sub x = sub # core_type x . val_desc
let constructor_decl sub cd = List . iter ( sub # core_type ) cd . cd_args ; opt ( sub # core_type ) cd . cd_res
let label_decl sub ld = sub # core_type ld . ld_type
let type_declaration sub decl = List . iter ( fun ( ct1 , ct2 , _loc ) -> sub # core_type ct1 ; sub # core_type ct2 ) decl . typ_cstrs ; begin match decl . typ_kind with | Ttype_abstract -> ( ) | Ttype_variant list -> List . iter ( constructor_decl sub ) list | Ttype_record list -> List . iter ( label_decl sub ) list |...
let type_extension sub te = List . iter ( sub # extension_constructor ) te . tyext_constructors
let extension_constructor sub ext = match ext . ext_kind with Text_decl ( ctl , cto ) -> List . iter ( sub # core_type ) ctl ; opt ( sub # core_type ) cto | Text_rebind _ -> ( )
let pattern sub pat = let extra = function | Tpat_type _ | Tpat_unpack -> ( ) | Tpat_constraint ct -> sub # core_type ct in List . iter ( fun ( c , _ , _ ) -> extra c ) pat . pat_extra ; match pat . pat_desc with | Tpat_any | Tpat_var _ | Tpat_constant _ -> ( ) | Tpat_tuple l | Tpat_construct ( _ , _ , l ) -> List . it...
let expression sub exp = let extra = function | Texp_constraint cty -> sub # core_type cty | Texp_coerce ( cty1 , cty2 ) -> opt ( sub # core_type ) cty1 ; sub # core_type cty2 | Texp_open _ | Texp_newtype _ -> ( ) | Texp_poly cto -> opt ( sub # core_type ) cto in List . iter ( fun ( c , _ , _ ) -> extra c ) exp . exp_e...
let package_type sub pack = List . iter ( fun ( _s , ct ) -> sub # core_type ct ) pack . pack_fields
let signature sub sg = List . iter ( sub # signature_item ) sg . sig_items
let signature_item sub item = match item . sig_desc with | Tsig_value v -> sub # value_description v | Tsig_type list -> List . iter ( sub # type_declaration ) list | Tsig_typext te -> sub # type_extension te | Tsig_exception ext -> sub # extension_constructor ext | Tsig_module md -> sub # module_type md . md_type | Ts...
let class_description sub cd = sub # class_type cd . ci_expr
let class_type_declaration sub cd = sub # class_type cd . ci_expr
let module_type sub mty = match mty . mty_desc with | Tmty_ident ( _path , _ ) -> ( ) | Tmty_alias ( _path , _ ) -> ( ) | Tmty_signature sg -> sub # signature sg | Tmty_functor ( _id , _ , mtype1 , mtype2 ) -> Misc . may ( sub # module_type ) mtype1 ; sub # module_type mtype2 | Tmty_with ( mtype , list ) -> sub # modul...
let with_constraint sub cstr = match cstr with | Twith_type decl -> sub # type_declaration decl | Twith_module _ -> ( ) | Twith_typesubst decl -> sub # type_declaration decl | Twith_modsubst _ -> ( )
let module_expr sub mexpr = match mexpr . mod_desc with | Tmod_ident ( _p , _ ) -> ( ) | Tmod_structure st -> sub # structure st | Tmod_functor ( _id , _ , mtype , mexpr ) -> Misc . may ( sub # module_type ) mtype ; sub # module_expr mexpr | Tmod_apply ( mexp1 , mexp2 , _ ) -> sub # module_expr mexp1 ; sub # module_exp...
let module_binding sub mb = module_expr sub mb . mb_expr
let class_expr sub cexpr = match cexpr . cl_desc with | Tcl_constraint ( cl , None , _ , _ , _ ) -> sub # class_expr cl ; | Tcl_structure clstr -> sub # class_structure clstr | Tcl_fun ( _label , pat , priv , cl , _partial ) -> sub # pattern pat ; List . iter ( fun ( _id , _ , exp ) -> sub # expression exp ) priv ; sub...
let class_type sub ct = match ct . cltyp_desc with | Tcty_signature csg -> sub # class_signature csg | Tcty_constr ( _path , _ , list ) -> List . iter ( sub # core_type ) list | Tcty_arrow ( _label , ct , cl ) -> sub # core_type ct ; sub # class_type cl
let class_signature sub cs = sub # core_type cs . csig_self ; List . iter ( sub # class_type_field ) cs . csig_fields
let class_type_field sub ctf = match ctf . ctf_desc with | Tctf_inherit ct -> sub # class_type ct | Tctf_val ( _s , _mut , _virt , ct ) -> sub # core_type ct | Tctf_method ( _s , _priv , _virt , ct ) -> sub # core_type ct | Tctf_constraint ( ct1 , ct2 ) -> sub # core_type ct1 ; sub # core_type ct2 | Tctf_attribute _ ->...
let core_type sub ct = match ct . ctyp_desc with | Ttyp_any -> ( ) | Ttyp_var _s -> ( ) | Ttyp_arrow ( _label , ct1 , ct2 ) -> sub # core_type ct1 ; sub # core_type ct2 | Ttyp_tuple list -> List . iter ( sub # core_type ) list | Ttyp_constr ( _path , _ , list ) -> List . iter ( sub # core_type ) list | Ttyp_object ( li...
let class_structure sub cs = sub # pattern cs . cstr_self ; List . iter ( sub # class_field ) cs . cstr_fields
let row_field sub rf = match rf with | Ttag ( _label , _attrs , _bool , list ) -> List . iter ( sub # core_type ) list | Tinherit ct -> sub # core_type ct
let class_field sub cf = match cf . cf_desc with | Tcf_inherit ( _ovf , cl , _super , _vals , _meths ) -> sub # class_expr cl | Tcf_constraint ( cty , cty ' ) -> sub # core_type cty ; sub # core_type cty ' | Tcf_val ( _ , _ , _mut , Tcfk_virtual cty , _override ) -> sub # core_type cty | Tcf_val ( _ , _ , _mut , Tcfk_c...
let bindings sub ( _rec_flag , list ) = List . iter ( sub # binding ) list
let cases sub l = List . iter ( sub # case ) l
let case sub { c_lhs ; c_guard ; c_rhs } = sub # pattern c_lhs ; opt ( sub # expression ) c_guard ; sub # expression c_rhs
let binding sub vb = sub # pattern vb . vb_pat ; sub # expression vb . vb_expr method binding = binding this method bindings = bindings this method case = case this method cases = cases this method class_description = class_description this method class_expr = class_expr this method class_field = class_field this metho...
type iterator = { binding_op : iterator -> binding_op -> unit ; case : iterator -> case -> unit ; cases : iterator -> case list -> unit ; class_declaration : iterator -> class_declaration -> unit ; class_description : iterator -> class_description -> unit ; class_expr : iterator -> class_expr -> unit ; class_field : it...
let structure sub { str_items ; str_final_env ; _ } = List . iter ( sub . structure_item sub ) str_items ; sub . env sub str_final_env
let class_infos sub f x = List . iter ( fun ( ct , _ ) -> sub . typ sub ct ) x . ci_params ; f x . ci_expr
let module_type_declaration sub { mtd_type ; _ } = Option . iter ( sub . module_type sub ) mtd_type
let module_declaration sub { md_type ; _ } = sub . module_type sub md_type
let module_substitution _ _ = ( )
let include_infos f { incl_mod ; _ } = f incl_mod
let class_type_declaration sub x = class_infos sub ( sub . class_type sub ) x
let class_declaration sub x = class_infos sub ( sub . class_expr sub ) x
let structure_item sub { str_desc ; str_env ; _ } = sub . env sub str_env ; match str_desc with | Tstr_eval ( exp , _ ) -> sub . expr sub exp | Tstr_value ( rec_flag , list ) -> sub . value_bindings sub ( rec_flag , list ) | Tstr_primitive v -> sub . value_description sub v | Tstr_type ( rec_flag , list ) -> sub . type...
let value_description sub x = sub . typ sub x . val_desc
let label_decl sub { ld_type ; _ } = sub . typ sub ld_type
let constructor_args sub = function | Cstr_tuple l -> List . iter ( sub . typ sub ) l | Cstr_record l -> List . iter ( label_decl sub ) l
let constructor_decl sub { cd_args ; cd_res ; _ } = constructor_args sub cd_args ; Option . iter ( sub . typ sub ) cd_res
let type_kind sub = function | Ttype_abstract -> ( ) | Ttype_variant list -> List . iter ( constructor_decl sub ) list | Ttype_record list -> List . iter ( label_decl sub ) list | Ttype_open -> ( )
let type_declaration sub { typ_cstrs ; typ_kind ; typ_manifest ; typ_params ; _ } = List . iter ( fun ( c1 , c2 , _ ) -> sub . typ sub c1 ; sub . typ sub c2 ) typ_cstrs ; sub . type_kind sub typ_kind ; Option . iter ( sub . typ sub ) typ_manifest ; List . iter ( fun ( c , _ ) -> sub . typ sub c ) typ_params
let type_declarations sub ( _ , list ) = List . iter ( sub . type_declaration sub ) list
let type_extension sub { tyext_constructors ; tyext_params ; _ } = List . iter ( fun ( c , _ ) -> sub . typ sub c ) tyext_params ; List . iter ( sub . extension_constructor sub ) tyext_constructors
let type_exception sub { tyexn_constructor ; _ } = sub . extension_constructor sub tyexn_constructor
let extension_constructor sub { ext_kind ; _ } = match ext_kind with | Text_decl ( ctl , cto ) -> constructor_args sub ctl ; Option . iter ( sub . typ sub ) cto | Text_rebind _ -> ( )
let pat sub { pat_extra ; pat_desc ; pat_env ; _ } = let extra = function | Tpat_type _ -> ( ) | Tpat_unpack -> ( ) | Tpat_open ( _ , _ , env ) -> sub . env sub env | Tpat_constraint ct -> sub . typ sub ct in sub . env sub pat_env ; List . iter ( fun ( e , _ , _ ) -> extra e ) pat_extra ; match pat_desc with | Tpat_any...
let expr sub { exp_extra ; exp_desc ; exp_env ; _ } = let extra = function | Texp_constraint cty -> sub . typ sub cty | Texp_coerce ( cty1 , cty2 ) -> Option . iter ( sub . typ sub ) cty1 ; sub . typ sub cty2 | Texp_newtype _ -> ( ) | Texp_poly cto -> Option . iter ( sub . typ sub ) cto in List . iter ( fun ( e , _ , _...
let package_type sub { pack_fields ; _ } = List . iter ( fun ( _ , p ) -> sub . typ sub p ) pack_fields
let binding_op sub { bop_exp ; _ } = sub . expr sub bop_exp
let signature sub { sig_items ; sig_final_env ; _ } = sub . env sub sig_final_env ; List . iter ( sub . signature_item sub ) sig_items
let signature_item sub { sig_desc ; sig_env ; _ } = sub . env sub sig_env ; match sig_desc with | Tsig_value v -> sub . value_description sub v | Tsig_type ( rf , tdl ) -> sub . type_declarations sub ( rf , tdl ) | Tsig_typesubst list -> sub . type_declarations sub ( Nonrecursive , list ) | Tsig_typext te -> sub . type...
let class_description sub x = class_infos sub ( sub . class_type sub ) x
let functor_parameter sub = function | Unit -> ( ) | Named ( _ , _ , mtype ) -> sub . module_type sub mtype
let module_type sub { mty_desc ; mty_env ; _ } = sub . env sub mty_env ; match mty_desc with | Tmty_ident _ -> ( ) | Tmty_alias _ -> ( ) | Tmty_signature sg -> sub . signature sub sg | Tmty_functor ( arg , mtype2 ) -> functor_parameter sub arg ; sub . module_type sub mtype2 | Tmty_with ( mtype , list ) -> sub . module_...
let with_constraint sub = function | Twith_type decl -> sub . type_declaration sub decl | Twith_typesubst decl -> sub . type_declaration sub decl | Twith_module _ -> ( ) | Twith_modsubst _ -> ( )
let open_description sub { open_env ; _ } = sub . env sub open_env
let open_declaration sub { open_expr ; open_env ; _ } = sub . module_expr sub open_expr ; sub . env sub open_env
let module_coercion sub = function | Tcoerce_none -> ( ) | Tcoerce_functor ( c1 , c2 ) -> sub . module_coercion sub c1 ; sub . module_coercion sub c2 | Tcoerce_alias ( env , _ , c1 ) -> sub . env sub env ; sub . module_coercion sub c1 | Tcoerce_structure ( l1 , l2 ) -> List . iter ( fun ( _ , c ) -> sub . module_coerci...
let module_expr sub { mod_desc ; mod_env ; _ } = sub . env sub mod_env ; match mod_desc with | Tmod_ident _ -> ( ) | Tmod_structure st -> sub . structure sub st | Tmod_functor ( arg , mexpr ) -> functor_parameter sub arg ; sub . module_expr sub mexpr | Tmod_apply ( mexp1 , mexp2 , c ) -> sub . module_expr sub mexp1 ; s...
let module_binding sub { mb_expr ; _ } = sub . module_expr sub mb_expr
let class_expr sub { cl_desc ; cl_env ; _ } = sub . env sub cl_env ; match cl_desc with | Tcl_constraint ( cl , clty , _ , _ , _ ) -> sub . class_expr sub cl ; Option . iter ( sub . class_type sub ) clty | Tcl_structure clstr -> sub . class_structure sub clstr | Tcl_fun ( _ , pat , priv , cl , _ ) -> sub . pat sub pat ...
let class_type sub { cltyp_desc ; cltyp_env ; _ } = sub . env sub cltyp_env ; match cltyp_desc with | Tcty_signature csg -> sub . class_signature sub csg | Tcty_constr ( _ , _ , list ) -> List . iter ( sub . typ sub ) list | Tcty_arrow ( _ , ct , cl ) -> sub . typ sub ct ; sub . class_type sub cl | Tcty_open ( od , e )...
let class_signature sub { csig_self ; csig_fields ; _ } = sub . typ sub csig_self ; List . iter ( sub . class_type_field sub ) csig_fields
let class_type_field sub { ctf_desc ; _ } = match ctf_desc with | Tctf_inherit ct -> sub . class_type sub ct | Tctf_val ( _ , _ , _ , ct ) -> sub . typ sub ct | Tctf_method ( _ , _ , _ , ct ) -> sub . typ sub ct | Tctf_constraint ( ct1 , ct2 ) -> sub . typ sub ct1 ; sub . typ sub ct2 | Tctf_attribute _ -> ( )
let typ sub { ctyp_desc ; ctyp_env ; _ } = sub . env sub ctyp_env ; match ctyp_desc with | Ttyp_any -> ( ) | Ttyp_var _ -> ( ) | Ttyp_arrow ( _ , ct1 , ct2 ) -> sub . typ sub ct1 ; sub . typ sub ct2 | Ttyp_tuple list -> List . iter ( sub . typ sub ) list | Ttyp_constr ( _ , _ , list ) -> List . iter ( sub . typ sub ) l...
let class_structure sub { cstr_self ; cstr_fields ; _ } = sub . pat sub cstr_self ; List . iter ( sub . class_field sub ) cstr_fields
let row_field sub { rf_desc ; _ } = match rf_desc with | Ttag ( _ , _ , list ) -> List . iter ( sub . typ sub ) list | Tinherit ct -> sub . typ sub ct
let object_field sub { of_desc ; _ } = match of_desc with | OTtag ( _ , ct ) -> sub . typ sub ct | OTinherit ct -> sub . typ sub ct
let class_field_kind sub = function | Tcfk_virtual ct -> sub . typ sub ct | Tcfk_concrete ( _ , e ) -> sub . expr sub e
let class_field sub { cf_desc ; _ } = match cf_desc with | Tcf_inherit ( _ , cl , _ , _ , _ ) -> sub . class_expr sub cl | Tcf_constraint ( cty1 , cty2 ) -> sub . typ sub cty1 ; sub . typ sub cty2 | Tcf_val ( _ , _ , _ , k , _ ) -> class_field_kind sub k | Tcf_method ( _ , _ , k ) -> class_field_kind sub k | Tcf_initia...
let value_bindings sub ( _ , list ) = List . iter ( sub . value_binding sub ) list
let cases sub l = List . iter ( sub . case sub ) l
let case sub { c_lhs ; c_guard ; c_rhs } = sub . pat sub c_lhs ; Option . iter ( sub . expr sub ) c_guard ; sub . expr sub c_rhs
let value_binding sub { vb_pat ; vb_expr ; _ } = sub . pat sub vb_pat ; sub . expr sub vb_expr
let env _sub _ = ( )
let default_iterator = { binding_op ; case ; cases ; class_declaration ; class_description ; class_expr ; class_field ; class_signature ; class_structure ; class_type ; class_type_declaration ; class_type_field ; env ; expr ; extension_constructor ; module_binding ; module_coercion ; module_declaration ; module_substit...
type mapper = { binding_op : mapper -> binding_op -> binding_op ; case : mapper -> case -> case ; cases : mapper -> case list -> case list ; class_declaration : mapper -> class_declaration -> class_declaration ; class_description : mapper -> class_description -> class_description ; class_expr : mapper -> class_expr -> ...
let id x = x
let tuple2 f1 f2 ( x , y ) = ( f1 x , f2 y )
let tuple3 f1 f2 f3 ( x , y , z ) = ( f1 x , f2 y , f3 z )
let structure sub { str_items ; str_type ; str_final_env } = { str_items = List . map ( sub . structure_item sub ) str_items ; str_final_env = sub . env sub str_final_env ; str_type ; }