123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664# 1 "411/ast_mapper_class.ml"(* This file is part of the ppx_tools package. It is released *)(* under the terms of the MIT license (see LICENSE file). *)(* Copyright 2013 Alain Frisch and LexiFi *)(** Class-based customizable mapper *)openParsetreeopenAsttypesopenAst_helperletmap_fstf(x,y)=(fx,y)letmap_sndf(x,y)=(x,fy)letmap_tuplef1f2(x,y)=(f1x,f2y)letmap_tuple3f1f2f3(x,y,z)=(f1x,f2y,f3z)letmap_optf=functionNone->None|Somex->Some(fx)letmap_locsub{loc;txt}={loc=sub#locationloc;txt}moduleT=struct(* Type expressions for the core language *)letrow_field_descsub=function|Rtag(l,b,tl)->Rtag(l,b,List.map(sub#typ)tl)|Rinheritt->Rinherit(sub#typt)letrow_fieldsub{prf_desc=desc;prf_loc=loc;prf_attributes=attrs}=letdesc=row_field_descsubdescinletloc=sub#locationlocinletattrs=sub#attributesattrsin{prf_desc=desc;prf_loc=loc;prf_attributes=attrs}letobject_field_descsub=function|Otag(s,t)->Otag(s,sub#typt)|Oinheritt->Oinherit(sub#typt)letobject_fieldsub{pof_desc=desc;pof_loc=loc;pof_attributes=attrs}=letdesc=object_field_descsubdescinletloc=sub#locationlocinletattrs=sub#attributesattrsin{pof_desc=desc;pof_loc=loc;pof_attributes=attrs}letmapsub{ptyp_desc=desc;ptyp_loc=loc;ptyp_loc_stack=_;ptyp_attributes=attrs}=letopenTypinletloc=sub#locationlocinletattrs=sub#attributesattrsinmatchdescwith|Ptyp_any->any~loc~attrs()|Ptyp_vars->var~loc~attrss|Ptyp_arrow(lab,t1,t2)->arrow~loc~attrslab(sub#typt1)(sub#typt2)|Ptyp_tupletyl->tuple~loc~attrs(List.map(sub#typ)tyl)|Ptyp_constr(lid,tl)->constr~loc~attrs(map_locsublid)(List.map(sub#typ)tl)|Ptyp_object(l,o)->object_~loc~attrs(List.map(object_fieldsub)l)o|Ptyp_class(lid,tl)->class_~loc~attrs(map_locsublid)(List.map(sub#typ)tl)|Ptyp_alias(t,s)->alias~loc~attrs(sub#typt)s|Ptyp_variant(rl,b,ll)->variant~loc~attrs(List.map(row_fieldsub)rl)bll|Ptyp_poly(sl,t)->poly~loc~attrssl(sub#typt)|Ptyp_package(lid,l)->package~loc~attrs(map_locsublid)(List.map(map_tuple(map_locsub)(sub#typ))l)|Ptyp_extensionx->extension~loc~attrs(sub#extensionx)letmap_type_declarationsub{ptype_name;ptype_params;ptype_cstrs;ptype_kind;ptype_private;ptype_manifest;ptype_attributes;ptype_loc}=Type.mk(map_locsubptype_name)~params:(List.map(map_fst(sub#typ))ptype_params)~priv:ptype_private~cstrs:(List.map(map_tuple3(sub#typ)(sub#typ)(sub#location))ptype_cstrs)~kind:(sub#type_kindptype_kind)?manifest:(map_opt(sub#typ)ptype_manifest)~loc:(sub#locationptype_loc)~attrs:(sub#attributesptype_attributes)letmap_type_kindsub=function|Ptype_abstract->Ptype_abstract|Ptype_variantl->Ptype_variant(List.map(sub#constructor_declaration)l)|Ptype_recordl->Ptype_record(List.map(sub#label_declaration)l)|Ptype_open->Ptype_openletmap_type_extensionsub{ptyext_path;ptyext_params;ptyext_constructors;ptyext_private;ptyext_loc;ptyext_attributes}=Te.mk(map_locsubptyext_path)(List.map(sub#extension_constructor)ptyext_constructors)~params:(List.map(map_fst(sub#typ))ptyext_params)~priv:ptyext_private~loc:(sub#locationptyext_loc)~attrs:(sub#attributesptyext_attributes)letmap_extension_constructor_kindsub=functionPext_decl(ctl,cto)->Pext_decl(sub#constructor_argumentsctl,map_opt(sub#typ)cto)|Pext_rebindli->Pext_rebind(map_locsubli)letmap_extension_constructorsub{pext_name;pext_kind;pext_loc;pext_attributes}=Te.constructor(map_locsubpext_name)(map_extension_constructor_kindsubpext_kind)~loc:(sub#locationpext_loc)~attrs:(sub#attributespext_attributes)letmap_type_exceptionsub{ptyexn_constructor;ptyexn_loc;ptyexn_attributes}=Te.mk_exception(map_extension_constructorsubptyexn_constructor)~loc:(sub#locationptyexn_loc)~attrs:(sub#attributesptyexn_attributes)endmoduleCT=struct(* Type expressions for the class language *)letmapsub{pcty_loc=loc;pcty_desc=desc;pcty_attributes=attrs}=letopenCtyinletloc=sub#locationlocinmatchdescwith|Pcty_constr(lid,tys)->constr~loc~attrs(map_locsublid)(List.map(sub#typ)tys)|Pcty_signaturex->signature~loc~attrs(sub#class_signaturex)|Pcty_arrow(lab,t,ct)->arrow~loc~attrslab(sub#typt)(sub#class_typect)|Pcty_extensionx->extension~loc~attrs(sub#extensionx)|Pcty_open(od,ct)->open_~loc~attrs(sub#open_descriptionod)(sub#class_typect)letmap_fieldsub{pctf_desc=desc;pctf_loc=loc;pctf_attributes=attrs}=letopenCtfinletloc=sub#locationlocinmatchdescwith|Pctf_inheritct->inherit_~loc~attrs(sub#class_typect)|Pctf_val(s,m,v,t)->val_~loc~attrssmv(sub#typt)|Pctf_method(s,p,v,t)->method_~loc~attrsspv(sub#typt)|Pctf_constraint(t1,t2)->constraint_~loc~attrs(sub#typt1)(sub#typt2)|Pctf_attributex->attribute~loc(sub#attributex)|Pctf_extensionx->extension~loc~attrs(sub#extensionx)letmap_signaturesub{pcsig_self;pcsig_fields}=Csig.mk(sub#typpcsig_self)(List.map(sub#class_type_field)pcsig_fields)endletmap_functor_paramsub=function|Unit->Unit|Named(s,mt)->Named(map_locsubs,sub#module_typemt)moduleMT=struct(* Type expressions for the module language *)letmapsub{pmty_desc=desc;pmty_loc=loc;pmty_attributes=attrs}=letopenMtyinletloc=sub#locationlocinletattrs=sub#attributesattrsinmatchdescwith|Pmty_idents->ident~loc~attrs(map_locsubs)|Pmty_aliass->alias~loc~attrs(map_locsubs)|Pmty_signaturesg->signature~loc~attrs(sub#signaturesg)|Pmty_functor(param,mt)->functor_~loc~attrs(map_functor_paramsubparam)(sub#module_typemt)|Pmty_with(mt,l)->with_~loc~attrs(sub#module_typemt)(List.map(sub#with_constraint)l)|Pmty_typeofme->typeof_~loc~attrs(sub#module_exprme)|Pmty_extensionx->extension~loc~attrs(sub#extensionx)letmap_with_constraintsub=function|Pwith_type(lid,d)->Pwith_type(map_locsublid,sub#type_declarationd)|Pwith_module(lid,lid2)->Pwith_module(map_locsublid,map_locsublid2)|Pwith_typesubst(lid,d)->Pwith_typesubst(map_locsublid,sub#type_declarationd)|Pwith_modsubst(lid,lid2)->Pwith_modsubst(map_locsublid,map_locsublid2)letmap_signature_itemsub{psig_desc=desc;psig_loc=loc}=letopenSiginletloc=sub#locationlocinmatchdescwith|Psig_valuevd->value~loc(sub#value_descriptionvd)|Psig_type(rf,l)->type_~locrf(List.map(sub#type_declaration)l)|Psig_typesubstl->type_subst~loc(List.map(sub#type_declaration)l)|Psig_typextte->type_extension~loc(sub#type_extensionte)|Psig_exceptiontexn->exception_~loc(sub#type_exceptiontexn)|Psig_modulex->module_~loc(sub#module_declarationx)|Psig_modsubstms->mod_subst~loc(sub#module_substitutionms)|Psig_recmodulel->rec_module~loc(List.map(sub#module_declaration)l)|Psig_modtypex->modtype~loc(sub#module_type_declarationx)|Psig_openod->open_~loc(sub#open_descriptionod)|Psig_includex->include_~loc(sub#include_descriptionx)|Psig_classl->class_~loc(List.map(sub#class_description)l)|Psig_class_typel->class_type~loc(List.map(sub#class_type_declaration)l)|Psig_extension(x,attrs)->extension~loc(sub#extensionx)~attrs:(sub#attributesattrs)|Psig_attributex->attribute~loc(sub#attributex)endmoduleM=struct(* Value expressions for the module language *)letmapsub{pmod_loc=loc;pmod_desc=desc;pmod_attributes=attrs}=letopenModinletloc=sub#locationlocinletattrs=sub#attributesattrsinmatchdescwith|Pmod_identx->ident~loc~attrs(map_locsubx)|Pmod_structurestr->structure~loc~attrs(sub#structurestr)|Pmod_functor(param,body)->functor_~loc~attrs(map_functor_paramsubparam)(sub#module_exprbody)|Pmod_apply(m1,m2)->apply~loc~attrs(sub#module_exprm1)(sub#module_exprm2)|Pmod_constraint(m,mty)->constraint_~loc~attrs(sub#module_exprm)(sub#module_typemty)|Pmod_unpacke->unpack~loc~attrs(sub#expre)|Pmod_extensionx->extension~loc~attrs(sub#extensionx)letmap_structure_itemsub{pstr_loc=loc;pstr_desc=desc}=letopenStrinletloc=sub#locationlocinmatchdescwith|Pstr_eval(x,attrs)->eval~loc~attrs:(sub#attributesattrs)(sub#exprx)|Pstr_value(r,vbs)->value~locr(List.map(sub#value_binding)vbs)|Pstr_primitivevd->primitive~loc(sub#value_descriptionvd)|Pstr_type(rf,l)->type_~locrf(List.map(sub#type_declaration)l)|Pstr_typextte->type_extension~loc(sub#type_extensionte)|Pstr_exceptioned->exception_~loc(sub#type_exceptioned)|Pstr_modulex->module_~loc(sub#module_bindingx)|Pstr_recmodulel->rec_module~loc(List.map(sub#module_binding)l)|Pstr_modtypex->modtype~loc(sub#module_type_declarationx)|Pstr_openod->open_~loc(sub#open_declarationod)|Pstr_classl->class_~loc(List.map(sub#class_declaration)l)|Pstr_class_typel->class_type~loc(List.map(sub#class_type_declaration)l)|Pstr_includex->include_~loc(sub#include_declarationx)|Pstr_extension(x,attrs)->extension~loc(sub#extensionx)~attrs:(sub#attributesattrs)|Pstr_attributex->attribute~loc(sub#attributex)endmoduleE=struct(* Value expressions for the core language *)letmap_binding_opsub{pbop_op=op;pbop_pat=pat;pbop_exp=exp;pbop_loc=loc}=letop=map_locsubopinletpat=sub#patpatinletexp=sub#exprexpinletloc=sub#locationlocin{pbop_op=op;pbop_pat=pat;pbop_exp=exp;pbop_loc=loc}letmapsub{pexp_loc=loc;pexp_loc_stack=_;pexp_desc=desc;pexp_attributes=attrs}=letopenExpinletloc=sub#locationlocinletattrs=sub#attributesattrsinmatchdescwith|Pexp_identx->ident~loc~attrs(map_locsubx)|Pexp_constantx->constant~loc~attrsx|Pexp_let(r,vbs,e)->let_~loc~attrsr(List.map(sub#value_binding)vbs)(sub#expre)|Pexp_fun(lab,def,p,e)->fun_~loc~attrslab(map_opt(sub#expr)def)(sub#patp)(sub#expre)|Pexp_functionpel->function_~loc~attrs(sub#casespel)|Pexp_apply(e,l)->apply~loc~attrs(sub#expre)(List.map(map_snd(sub#expr))l)|Pexp_match(e,pel)->match_~loc~attrs(sub#expre)(sub#casespel)|Pexp_try(e,pel)->try_~loc~attrs(sub#expre)(sub#casespel)|Pexp_tupleel->tuple~loc~attrs(List.map(sub#expr)el)|Pexp_construct(lid,arg)->construct~loc~attrs(map_locsublid)(map_opt(sub#expr)arg)|Pexp_variant(lab,eo)->variant~loc~attrslab(map_opt(sub#expr)eo)|Pexp_record(l,eo)->record~loc~attrs(List.map(map_tuple(map_locsub)(sub#expr))l)(map_opt(sub#expr)eo)|Pexp_field(e,lid)->field~loc~attrs(sub#expre)(map_locsublid)|Pexp_setfield(e1,lid,e2)->setfield~loc~attrs(sub#expre1)(map_locsublid)(sub#expre2)|Pexp_arrayel->array~loc~attrs(List.map(sub#expr)el)|Pexp_ifthenelse(e1,e2,e3)->ifthenelse~loc~attrs(sub#expre1)(sub#expre2)(map_opt(sub#expr)e3)|Pexp_sequence(e1,e2)->sequence~loc~attrs(sub#expre1)(sub#expre2)|Pexp_while(e1,e2)->while_~loc~attrs(sub#expre1)(sub#expre2)|Pexp_for(p,e1,e2,d,e3)->for_~loc~attrs(sub#patp)(sub#expre1)(sub#expre2)d(sub#expre3)|Pexp_coerce(e,t1,t2)->coerce~loc~attrs(sub#expre)(map_opt(sub#typ)t1)(sub#typt2)|Pexp_constraint(e,t)->constraint_~loc~attrs(sub#expre)(sub#typt)|Pexp_send(e,s)->send~loc~attrs(sub#expre)s|Pexp_newlid->new_~loc~attrs(map_locsublid)|Pexp_setinstvar(s,e)->setinstvar~loc~attrs(map_locsubs)(sub#expre)|Pexp_overridesel->override~loc~attrs(List.map(map_tuple(map_locsub)(sub#expr))sel)|Pexp_letmodule(s,me,e)->letmodule~loc~attrs(map_locsubs)(sub#module_exprme)(sub#expre)|Pexp_letexception(cd,e)->letexception~loc~attrs(sub#extension_constructorcd)(sub#expre)|Pexp_asserte->assert_~loc~attrs(sub#expre)|Pexp_lazye->lazy_~loc~attrs(sub#expre)|Pexp_poly(e,t)->poly~loc~attrs(sub#expre)(map_opt(sub#typ)t)|Pexp_objectcls->object_~loc~attrs(sub#class_structurecls)|Pexp_newtype(s,e)->newtype~loc~attrss(sub#expre)|Pexp_packme->pack~loc~attrs(sub#module_exprme)|Pexp_open(od,e)->open_~loc~attrs(sub#open_declarationod)(sub#expre)|Pexp_letopx->letlet_=map_binding_opsubx.let_inletands=List.map(map_binding_opsub)x.andsinletbody=sub#exprx.bodyinletop~loc~attrslet_andsbody|Pexp_extensionx->extension~loc~attrs(sub#extensionx)|Pexp_unreachable->unreachable~loc~attrs()endmoduleP=struct(* Patterns *)letmapsub{ppat_desc=desc;ppat_loc=loc;ppat_loc_stack=_;ppat_attributes=attrs}=letopenPatinletloc=sub#locationlocinletattrs=sub#attributesattrsinmatchdescwith|Ppat_any->any~loc~attrs()|Ppat_vars->var~loc~attrs(map_locsubs)|Ppat_alias(p,s)->alias~loc~attrs(sub#patp)(map_locsubs)|Ppat_constantc->constant~loc~attrsc|Ppat_interval(c1,c2)->interval~loc~attrsc1c2|Ppat_tuplepl->tuple~loc~attrs(List.map(sub#pat)pl)|Ppat_construct(l,p)->construct~loc~attrs(map_locsubl)(map_opt(sub#pat)p)|Ppat_variant(l,p)->variant~loc~attrsl(map_opt(sub#pat)p)|Ppat_record(lpl,cf)->record~loc~attrs(List.map(map_tuple(map_locsub)(sub#pat))lpl)cf|Ppat_arraypl->array~loc~attrs(List.map(sub#pat)pl)|Ppat_or(p1,p2)->or_~loc~attrs(sub#patp1)(sub#patp2)|Ppat_constraint(p,t)->constraint_~loc~attrs(sub#patp)(sub#typt)|Ppat_types->type_~loc~attrs(map_locsubs)|Ppat_lazyp->lazy_~loc~attrs(sub#patp)|Ppat_unpacks->unpack~loc~attrs(map_locsubs)|Ppat_exceptionp->exception_~loc~attrs(sub#patp)|Ppat_extensionx->extension~loc~attrs(sub#extensionx)|Ppat_open(l,p)->open_~loc~attrs(map_locsubl)(sub#patp)endmoduleCE=struct(* Value expressions for the class language *)letmapsub{pcl_loc=loc;pcl_desc=desc;pcl_attributes=attrs}=letopenClinletloc=sub#locationlocinmatchdescwith|Pcl_constr(lid,tys)->constr~loc~attrs(map_locsublid)(List.map(sub#typ)tys)|Pcl_structures->structure~loc~attrs(sub#class_structures)|Pcl_fun(lab,e,p,ce)->fun_~loc~attrslab(map_opt(sub#expr)e)(sub#patp)(sub#class_exprce)|Pcl_apply(ce,l)->apply~loc~attrs(sub#class_exprce)(List.map(map_snd(sub#expr))l)|Pcl_let(r,vbs,ce)->let_~loc~attrsr(List.map(sub#value_binding)vbs)(sub#class_exprce)|Pcl_constraint(ce,ct)->constraint_~loc~attrs(sub#class_exprce)(sub#class_typect)|Pcl_extensionx->extension~loc~attrs(sub#extensionx)|Pcl_open(od,ce)->open_~loc~attrs(sub#open_descriptionod)(sub#class_exprce)letmap_kindsub=function|Cfk_concrete(o,e)->Cfk_concrete(o,sub#expre)|Cfk_virtualt->Cfk_virtual(sub#typt)letmap_fieldsub{pcf_desc=desc;pcf_loc=loc;pcf_attributes=attrs}=letopenCfinletloc=sub#locationlocinmatchdescwith|Pcf_inherit(o,ce,s)->inherit_~loc~attrso(sub#class_exprce)s|Pcf_val(s,m,k)->val_~loc~attrs(map_locsubs)m(map_kindsubk)|Pcf_method(s,p,k)->method_~loc~attrs(map_locsubs)p(map_kindsubk)|Pcf_constraint(t1,t2)->constraint_~loc~attrs(sub#typt1)(sub#typt2)|Pcf_initializere->initializer_~loc~attrs(sub#expre)|Pcf_attributex->attribute~loc(sub#attributex)|Pcf_extensionx->extension~loc~attrs(sub#extensionx)letmap_structuresub{pcstr_self;pcstr_fields}={pcstr_self=sub#patpcstr_self;pcstr_fields=List.map(sub#class_field)pcstr_fields;}letclass_infossubf{pci_virt;pci_params=pl;pci_name;pci_expr;pci_loc;pci_attributes}=Ci.mk~virt:pci_virt~params:(List.map(map_fst(sub#typ))pl)(map_locsubpci_name)(fpci_expr)~loc:(sub#locationpci_loc)~attrs:(sub#attributespci_attributes)end(* Now, a generic AST mapper class, to be extended to cover all kinds
and cases of the OCaml grammar. The default behavior of the mapper
is the identity. *)classmapper=object(this)methodstructurel=List.map(this#structure_item)lmethodstructure_itemsi=M.map_structure_itemthissimethodmodule_expr=M.mapthismethodsignaturel=List.map(this#signature_item)lmethodsignature_itemsi=MT.map_signature_itemthissimethodmodule_type=MT.mapthismethodwith_constraintc=MT.map_with_constraintthiscmethodclass_declaration=CE.class_infosthis(this#class_expr)methodclass_expr=CE.mapthismethodclass_field=CE.map_fieldthismethodclass_structure=CE.map_structurethismethodclass_type=CT.mapthismethodclass_type_field=CT.map_fieldthismethodclass_signature=CT.map_signaturethismethodclass_type_declaration=CE.class_infosthis(this#class_type)methodclass_description=CE.class_infosthis(this#class_type)methodbinding_op=E.map_binding_opthismethodtype_declaration=T.map_type_declarationthismethodtype_kind=T.map_type_kindthismethodtyp=T.mapthismethodtype_extension=T.map_type_extensionthismethodtype_exception=T.map_type_exceptionthismethodextension_constructor=T.map_extension_constructorthismethodvalue_description{pval_name;pval_type;pval_prim;pval_loc;pval_attributes}=Val.mk(map_locthispval_name)(this#typpval_type)~attrs:(this#attributespval_attributes)~loc:(this#locationpval_loc)~prim:pval_primmethodpat=P.mapthismethodexpr=E.mapthismethodmodule_declaration{pmd_name;pmd_type;pmd_attributes;pmd_loc}=Md.mk(map_locthispmd_name)(this#module_typepmd_type)~attrs:(this#attributespmd_attributes)~loc:(this#locationpmd_loc)methodmodule_substitution{pms_name;pms_manifest;pms_attributes;pms_loc}=Ms.mk(map_locthispms_name)(map_locthispms_manifest)~attrs:(this#attributespms_attributes)~loc:(this#locationpms_loc)methodmodule_type_declaration{pmtd_name;pmtd_type;pmtd_attributes;pmtd_loc}=Mtd.mk(map_locthispmtd_name)?typ:(map_opt(this#module_type)pmtd_type)~attrs:(this#attributespmtd_attributes)~loc:(this#locationpmtd_loc)methodmodule_binding{pmb_name;pmb_expr;pmb_attributes;pmb_loc}=Mb.mk(map_locthispmb_name)(this#module_exprpmb_expr)~attrs:(this#attributespmb_attributes)~loc:(this#locationpmb_loc)methodvalue_binding{pvb_pat;pvb_expr;pvb_attributes;pvb_loc}=Vb.mk(this#patpvb_pat)(this#exprpvb_expr)~attrs:(this#attributespvb_attributes)~loc:(this#locationpvb_loc)methodconstructor_arguments=function|Pcstr_tuple(tys)->Pcstr_tuple(List.map(this#typ)tys)|Pcstr_record(ls)->Pcstr_record(List.map(this#label_declaration)ls)methodconstructor_declaration{pcd_name;pcd_args;pcd_res;pcd_loc;pcd_attributes}=Type.constructor(map_locthispcd_name)~args:(this#constructor_argumentspcd_args)?res:(map_opt(this#typ)pcd_res)~loc:(this#locationpcd_loc)~attrs:(this#attributespcd_attributes)methodlabel_declaration{pld_name;pld_type;pld_loc;pld_mutable;pld_attributes}=Type.field(map_locthispld_name)(this#typpld_type)~mut:pld_mutable~loc:(this#locationpld_loc)~attrs:(this#attributespld_attributes)methodcasesl=List.map(this#case)lmethodcase{pc_lhs;pc_guard;pc_rhs}={pc_lhs=this#patpc_lhs;pc_guard=map_opt(this#expr)pc_guard;pc_rhs=this#exprpc_rhs;}methodopen_declaration{popen_expr;popen_override;popen_attributes;popen_loc}=Opn.mk(this#module_exprpopen_expr)~override:popen_override~loc:(this#locationpopen_loc)~attrs:(this#attributespopen_attributes)methodopen_description{popen_expr;popen_override;popen_attributes;popen_loc}=Opn.mk(map_locthispopen_expr)~override:popen_override~loc:(this#locationpopen_loc)~attrs:(this#attributespopen_attributes)methodinclude_description{pincl_mod;pincl_attributes;pincl_loc}=Incl.mk(this#module_typepincl_mod)~loc:(this#locationpincl_loc)~attrs:(this#attributespincl_attributes)methodinclude_declaration{pincl_mod;pincl_attributes;pincl_loc}=Incl.mk(this#module_exprpincl_mod)~loc:(this#locationpincl_loc)~attrs:(this#attributespincl_attributes)methodlocationl=lmethodextension(s,e)=(map_locthiss,this#payloade)methodattributea={attr_name=map_locthisa.attr_name;attr_payload=this#payloada.attr_payload;attr_loc=this#locationa.attr_loc;}methodattributesl=List.map(this#attribute)lmethodpayload=function|PStrx->PStr(this#structurex)|PTypx->PTyp(this#typx)|PPat(x,g)->PPat(this#patx,map_opt(this#expr)g)|PSigx->PSig(this#signaturex)methodconstant=function|Pconst_integer(str,suffix)->Pconst_integer(str,suffix)|Pconst_charc->Pconst_charc|Pconst_string(str,loc,delim)->Pconst_string(str,this#locationloc,delim)|Pconst_float(str,suffix)->Pconst_float(str,suffix)endletto_mapperthis=letopenAst_mapperin{attribute=(fun_->this#attribute);attributes=(fun_->this#attributes);binding_op=(fun_->this#binding_op);case=(fun_->this#case);cases=(fun_->this#cases);class_declaration=(fun_->this#class_declaration);class_description=(fun_->this#class_description);class_expr=(fun_->this#class_expr);class_field=(fun_->this#class_field);class_signature=(fun_->this#class_signature);class_structure=(fun_->this#class_structure);class_type=(fun_->this#class_type);class_type_declaration=(fun_->this#class_type_declaration);class_type_field=(fun_->this#class_type_field);constant=(fun_->this#constant);constructor_declaration=(fun_->this#constructor_declaration);expr=(fun_->this#expr);extension=(fun_->this#extension);extension_constructor=(fun_->this#extension_constructor);include_declaration=(fun_->this#include_declaration);include_description=(fun_->this#include_description);label_declaration=(fun_->this#label_declaration);location=(fun_->this#location);module_binding=(fun_->this#module_binding);module_declaration=(fun_->this#module_declaration);module_expr=(fun_->this#module_expr);module_substitution=(fun_->this#module_substitution);module_type=(fun_->this#module_type);module_type_declaration=(fun_->this#module_type_declaration);open_declaration=(fun_->this#open_declaration);open_description=(fun_->this#open_description);pat=(fun_->this#pat);payload=(fun_->this#payload);signature=(fun_->this#signature);signature_item=(fun_->this#signature_item);structure=(fun_->this#structure);structure_item=(fun_->this#structure_item);typ=(fun_->this#typ);type_declaration=(fun_->this#type_declaration);type_exception=(fun_->this#type_exception);type_extension=(fun_->this#type_extension);type_kind=(fun_->this#type_kind);value_binding=(fun_->this#value_binding);value_description=(fun_->this#value_description);with_constraint=(fun_->this#with_constraint);}