Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file ast_wrapper.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308moduleOCaml_version=Migrate_parsetree.OCaml_407moduleAst_helper=OCaml_version.Ast.Ast_helpermoduleAst_mapper=OCaml_version.Ast.Ast_mappermoduleAsttypes=OCaml_version.Ast.AsttypesmoduleParsetree=OCaml_version.Ast.ParsetreemoduleFrom=Migrate_parsetree.Convert(OCaml_version)(Migrate_parsetree.OCaml_current)moduletypeAst_types=sigtypeitemtypemodule_bindingtypemodule_exprendmoduleAst_definitions(Types:Ast_types)=structincludeTypestypecontents=itemlisttypeinclude_declaration=module_exprParsetree.include_infostypeitem_desc=|ExtensionofParsetree.extension*Parsetree.attributes|TypeofAsttypes.rec_flag*Parsetree.type_declarationlist|Moduleofmodule_binding|ModtypeofParsetree.module_type_declaration|Includeofinclude_declaration|Otherofitemtypewrapped_item=item_descLocation.loctype'aattributed={attrs:Parsetree.attributes;contents:'a;}letmkattr~loc?(attrs=[])contents:_attributedLocation.loc={loc;txt={attrs;contents}}typemodule_binding_desc={name:stringLocation.loc;expr:module_expr;}typewrapped_module_binding=module_binding_descattributedLocation.loctypemodule_expr_desc=|IdentofLongident.tLocation.loc|Contentsofcontents|FunctorofstringLocation.loc*Parsetree.module_typeoption*module_expr|Constraintofmodule_exprLazy.t*Parsetree.module_type|Otherofmodule_exprtypewrapped_module_expr=module_expr_descattributedLocation.locendmoduletypeS=sigmoduleTypes:Ast_typesincludemoduletypeofAst_definitions(Types)valempty:loc:Location.t->itemvaldestruct:item->wrapped_itemvalbuild:wrapped_item->itemvalchoose:(unit->Parsetree.structure_item)->(unit->Parsetree.signature_item)->itemvalmap:Ast_mapper.mapper->Ast_mapper.mapper->contents->contentsvalmap_item:Ast_mapper.mapper->Ast_mapper.mapper->item->itemvalformat:Format.formatter->contents->unitvaldestruct_payload:loc:Location.t->Parsetree.payload->contentsvaldestruct_module_binding:module_binding->wrapped_module_bindingvalbuild_module_binding:wrapped_module_binding->module_bindingvaldestruct_module_expr:module_expr->wrapped_module_exprvalbuild_module_expr:wrapped_module_expr->module_exprvalchoose_module_expr:(unit->Parsetree.module_expr)->(unit->Parsetree.module_type)->module_exprendmoduleStructure_types=structtypeitem=Parsetree.structure_itemtypemodule_binding=Parsetree.module_bindingtypemodule_expr=Parsetree.module_exprendletreclongident_of_module_expr(expr:Parsetree.module_expr):Longident.t=matchexpr.pmod_descwith|Pmod_identlid->lid.txt|Pmod_apply(e,x)->Lapply(longident_of_module_expre,longident_of_module_exprx)|_->invalid_arg"longident_of_module_expr"letrecmodule_expr_of_longident?(attrs=[])(lid:Longident.tLocation.loc)=letloc=lid.locinmatchlid.txtwith|Lapply(e,x)->Ast_helper.Mod.apply~loc~attrs(module_expr_of_longident{loc;txt=e})(module_expr_of_longident{loc;txt=x})|_->Ast_helper.Mod.ident~loc~attrslidmoduleStructure:SwithmoduleTypes=Structure_types=structmoduleTypes=Structure_typesincludeAst_definitions(Types)letempty~loc:item=[%striincludestructend]letdestruct(item:item):wrapped_item=lettxt=matchitem.pstr_descwith|Pstr_extension(ext,attrs)->Extension(ext,attrs)|Pstr_type(rec_flag,list)->Type(rec_flag,list)|Pstr_modulebinding->Modulebinding|Pstr_modtypedeclaration->Modtypedeclaration|Pstr_includeinc->Includeinc|_->Otheritemin{loc=item.pstr_loc;txt}letbuild(desc:wrapped_item):item=letloc=desc.locinmatchdesc.txtwith|Extension(ext,attrs)->Ast_helper.Str.extension~loc~attrsext|Type(rec_flag,list)->Ast_helper.Str.type_~locrec_flaglist|Modulebinding->Ast_helper.Str.module_~locbinding|Modtypedeclaration->Ast_helper.Str.modtype~locdeclaration|Includeinc->Ast_helper.Str.include_~locinc|Otheritem->Ast_helper.Str.mk~locitem.pstr_descletchoosestructure_signature=structure()letmap(mapper:Ast_mapper.mapper)submapper(contents:contents):contents=mapper.structuresubmappercontentsletmap_item(mapper:Ast_mapper.mapper)submapperitem=mapper.structure_itemsubmapperitemletformatformattercontents=Pprintast.structureformatter(From.copy_structurecontents)letdestruct_payload~loc(payload:Parsetree.payload)=letstructure_expectedpreceding_symbol=Location.raise_errorf~loc"Structure expected (try to remove the preceding `%s')."preceding_symbolinmatchpayloadwith|PStrs->s|PPat(_p,_e)->structure_expected"?"|PSig_|PTyp_->structure_expected":"letdestruct_module_binding(binding:module_binding):wrapped_module_binding={loc=binding.pmb_loc;txt={attrs=binding.pmb_attributes;contents={name=binding.pmb_name;expr=binding.pmb_expr;}}}letbuild_module_binding(binding:wrapped_module_binding)=matchbindingwith{loc;txt={attrs;contents={name;expr}}}->Ast_helper.Mb.mk~loc~attrsnameexprletdestruct_module_expr(expr:module_expr):wrapped_module_expr=letcontents=matchexpr.pmod_descwith|Pmod_identlid->Identlid|Pmod_structures->Contentss|Pmod_functor(x,t,s)->Functor(x,t,s)|Pmod_constraint(m,t)->Constraint(Lazy.from_valm,t)|Pmod_apply(e,x)->beginmatchlongident_of_module_expre,longident_of_module_exprxwith|e,x->Ident{loc=expr.pmod_loc;txt=Lapply(e,x)}|exception(Invalid_argument_)->Otherexprend|_->Otherexprin{loc=expr.pmod_loc;txt={attrs=expr.pmod_attributes;contents}}letbuild_module_expr(expr:wrapped_module_expr)=matchexprwith{loc;txt={attrs;contents}}->matchcontentswith|Identlid->module_expr_of_longidentlid|Contentss->Ast_helper.Mod.structure~loc~attrss|Functor(x,t,s)->Ast_helper.Mod.functor_~loc~attrsxts|Constraint(m,t)->Ast_helper.Mod.constraint_~loc~attrs(Lazy.forcem)t|Otherexpr->Ast_helper.Mod.mk~loc~attrsexpr.pmod_descletchoose_module_exprmake_expr_make_type=make_expr()endmoduleSignature_types=structtypeitem=Parsetree.signature_itemtypemodule_binding=Parsetree.module_declarationtypemodule_expr=Parsetree.module_typeendmoduleSignature:SwithmoduleTypes=Signature_types=structmoduleTypes=Signature_typesincludeAst_definitions(Types)letempty~loc:item=[%sigi:includesigend]letdestruct(item:item):item_descLocation.loc=lettxt=matchitem.psig_descwith|Psig_extension(ext,attrs)->Extension(ext,attrs)|Psig_type(rec_flag,list)->Type(rec_flag,list)|Psig_moduledeclaration->Moduledeclaration|Psig_modtypedeclaration->Modtypedeclaration|Psig_includeinc->Includeinc|_->Otheritemin{loc=item.psig_loc;txt}letbuild(desc:item_descLocation.loc)=letloc=desc.locinmatchdesc.txtwith|Extension(ext,attrs)->Ast_helper.Sig.extension~loc~attrsext|Type(rec_flag,list)->Ast_helper.Sig.type_~locrec_flaglist|Moduledeclaration->Ast_helper.Sig.module_~locdeclaration|Modtypedeclaration->Ast_helper.Sig.modtype~locdeclaration|Includeinc->Ast_helper.Sig.include_~locinc|Otheritem->itemletchoose_make_structuremake_signature=make_signature()letmap(mapper:Ast_mapper.mapper)submappercontents=mapper.signaturesubmappercontentsletmap_item(mapper:Ast_mapper.mapper)submapperitem=mapper.signature_itemsubmapperitemletformatformattercontents=Pprintast.signatureformatter(From.copy_signaturecontents)letdestruct_payload~loc(payload:Parsetree.payload)=matchpayloadwith|PSigs->s|PTyp_t->Location.raise_errorf~loc"Signature expected (try to capitalize the leading identifier)."|PPat_->Location.raise_errorf~loc"Signature expected (try to replace the preceding `?' by `:`)."|PStr_->Location.raise_errorf~loc"Signature expected (try to add `:' before)."letdestruct_module_binding(declaration:module_binding):wrapped_module_binding={loc=declaration.pmd_loc;txt={attrs=declaration.pmd_attributes;contents={name=declaration.pmd_name;expr=declaration.pmd_type;}}}letbuild_module_binding(binding:wrapped_module_binding)=matchbindingwith{loc;txt={attrs;contents={name;expr}}}->Ast_helper.Md.mk~loc~attrsnameexprletdestruct_module_expr(expr:module_expr):wrapped_module_expr=letcontents=matchexpr.pmty_descwith|Pmty_identlid->Identlid|Pmty_signatures->Contentss|Pmty_functor(x,t,s)->Functor(x,t,s)|_->Otherexprin{loc=expr.pmty_loc;txt={attrs=expr.pmty_attributes;contents}}letbuild_module_expr(expr:wrapped_module_expr)=matchexprwith{loc;txt={attrs;contents}}->matchcontentswith|Identlid->Ast_helper.Mty.ident~loc~attrslid|Contentss->Ast_helper.Mty.signature~loc~attrss|Functor(x,t,s)->Ast_helper.Mty.functor_~loc~attrsxts|Constraint(_m,t)->t|Otherexpr->Ast_helper.Mty.mk~loc~attrsexpr.pmty_descletchoose_module_expr_make_exprmake_type=make_type()end