1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253openAst_mappermoduleMake(A:sigvalname:stringvalmapper:Ast_mapper.mapperend)=structopenAlethandle_errorf=tryf()with|e->Format.eprintf"%a@."Location.report_exceptione;exit2letimplmapperfname=handle_error@@fun()->letstr=Pparse.parse_implementation~tool_name:namefnameinletstr=mapper.structuremapperstrinPprintast.structureFormat.std_formatterstr;Format.fprintfFormat.std_formatter"@."letintfmapperfname=handle_error@@fun()->letsg=Pparse.parse_interface~tool_name:namefnameinletsg=mapper.signaturemappersginPprintast.signatureFormat.std_formattersg;Format.fprintfFormat.std_formatter"@."letanonymousmapperfname=ifFilename.check_suffixfname".ml"thenimplmapperfname(* .mlt ? *)elseifFilename.check_suffixfname".mli"thenintfmapperfnameelseassertfalselet()=letdebug=reffalseinletrev_files=ref[]inArg.parse["-debug",Arg.Setdebug,"debug mode which can take .ml/.mli then print the result"](funs->rev_files:=s::!rev_files)name;trymatch!debug,List.rev!rev_fileswith|true,files->List.iter(anonymousmapper)files|false,[infile;outfile]->Ast_mapper.apply~source:infile~target:outfilemapper|_->failwith@@name^" infile outfile"with|Location.Error_ase->Location.report_exceptionFormat.err_formattereend