12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879openMigrate_parsetreeopenAst_408.Parsetreeletrewriter_name="ppx_obus"letraise_errorf?sub?locmessage=message|>Printf.kprintf(funstr->leterr=Location.error?sub?locstrinraise(Location.Errorerr))letfind_attr_exprsattrs=letexpr_of_payload=function|PStr[{pstr_desc=Pstr_eval(e,_);_}]->Somee|_->Noneintryexpr_of_payload(letpayload=List.find(funattr->attr.Ast_408.Parsetree.attr_name.txt=s)attrsinpayload.Ast_408.Parsetree.attr_payload)withNot_found->Noneletregister_obus_exception=function|{pstr_desc=Pstr_exceptionexn;pstr_loc}->(matchfind_attr_expr"obus"exn.ptyexn_attributeswith|Someexpr->letregisterertyp=letloc=pstr_locinifFilename.basenamepstr_loc.loc_start.pos_fname="oBus_error.ml"then[%strilet()=letmoduleM=Register(structletname=[%eexpr]exceptionEof[%ttyp]end)in()]else[%strilet()=letmoduleM=OBus_error.Register(structletname=[%eexpr]exceptionEof[%ttyp]end)in()]in(matchexn.ptyexn_constructor.pext_kindwith|Pext_decl(Pcstr_tuple[typ],None)->Some(registerertyp)|_->raise_errorf~loc:pstr_loc"%s: OBus exceptions take a single string argument"rewriter_name)|_->None)|_->Noneletobus_mapper={Ast_408.Ast_mapper.default_mapperwithstructure=funmapperitems->List.fold_right(funitemacc->letitem'=Ast_408.Ast_mapper.default_mapper.structure_itemmapperiteminmatchregister_obus_exceptionitemwith|Somereg->item'::reg::acc|None->item'::acc)items[]}let()=Driver.register~name:rewriter_nameVersions.ocaml_408(fun__->obus_mapper)