123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321(* Yoann Padioleau
*
* Copyright (C) 2019 r2c
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)openOcamlopenAst_js(*****************************************************************************)(* Prelude *)(*****************************************************************************)(* hooks *)typevisitor_in={(*
kexpr: (expr -> expr) * visitor_out -> expr -> expr;
kstmt: (stmt -> stmt) * visitor_out -> stmt -> stmt;
*)kinfo:(tok->tok)*visitor_out->tok->tok;}andvisitor_out={vtop:toplevel->toplevel;vprogram:program->program;vexpr:expr->expr;vany:any->any;}letmap_option=Common2.map_optionletmap_scopex=xletdefault_visitor={(*
kexpr = (fun (k,_) x -> k x);
kstmt = (fun (k,_) x -> k x);
*)kinfo=(fun(k,_)x->kx);}let(mk_visitor:visitor_in->visitor_out)=funvin->(* start of auto generation *)(* generated by ocamltarzan with: camlp4o -o /tmp/yyy.ml -I pa/ pa_type_conv.cmo pa_map.cmo pr_o.cmo /tmp/xxx.ml *)letrecmap_tokv=(* old: Parse_info.map_info v *)letkx=matchxwith{Parse_info.token=v_pinfo;transfo=v_transfo;}->letv_pinfo=(* todo? map_pinfo v_pinfo *)v_pinfoin(* not recurse in transfo ? *){Parse_info.token=v_pinfo;(* generete a fresh field *)transfo=v_transfo;}invin.kinfo(k,all_functions)vandmap_wrap:'a.('a->'a)->'awrap->'awrap=fun_of_a(v1,v2)->letv1=_of_av1andv2=map_tokv2in(v1,v2)andmap_namev=map_wrapmap_of_stringvandmap_qualified_namev=map_of_stringvandmap_resolved_name=function|Local->Local|Param->Param|Globalv1->letv1=map_qualified_namev1inGlobal((v1))|NotResolved->NotResolvedandmap_special=function|Null->Null|Undefined->Undefined|This->This|Super->Super|Exports->Exports|Module->Module|Define->Define|Arguments->Arguments|New->New|NewTarget->NewTarget|Eval->Eval|Require->Require|Seq->Seq|Void->Void|Typeof->Typeof|Instanceof->Instanceof|In->In|Delete->Delete|Spread->Spread|Yield->Yield|YieldStar->YieldStar|Await->Await|Encapsv1->letv1=map_of_optionmap_namev1inEncaps((v1))|UseStrict->UseStrict|ArithOpv->letv=map_of_arith_opvinArithOpv|IncrDecrv->letv=map_of_inc_decvinIncrDecr((v))andmap_of_inc_decx=xandmap_of_arith_opx=xandmap_labelv=map_wrapmap_of_stringvandmap_filenamev=map_wrapmap_of_stringvandmap_property_name=function|PNv1->letv1=map_namev1inPN((v1))|PN_Computedv1->letv1=map_exprv1inPN_Computed((v1))andmap_expr=function|Boolv1->letv1=map_wrapmap_of_boolv1inBool((v1))|Numv1->letv1=map_wrapmap_of_stringv1inNum((v1))|Stringv1->letv1=map_wrapmap_of_stringv1inString((v1))|Regexpv1->letv1=map_wrapmap_of_stringv1inRegexp((v1))|Id((v1,v2))->letv1=map_namev1andv2=map_of_refmap_resolved_namev2inId((v1,v2))|IdSpecialv1->letv1=map_wrapmap_specialv1inIdSpecial((v1))|Nop->Nop|Assign((v1,v2))->letv1=map_exprv1andv2=map_exprv2inAssign((v1,v2))|Objv1->letv1=map_obj_v1inObj((v1))|Ellipsesv1->letv1=map_tokv1inEllipses((v1))|Class(v1,v2)->letv1=map_class_v1inletv2=map_optionmap_namev2inClass((v1,v2))|ObjAccess((v1,v2))->letv1=map_exprv1andv2=map_property_namev2inObjAccess((v1,v2))|Arrv1->letv1=map_of_listmap_exprv1inArr((v1))|ArrAccess((v1,v2))->letv1=map_exprv1andv2=map_exprv2inArrAccess((v1,v2))|Fun((v1,v2))->letv1=map_fun_v1andv2=map_of_optionmap_namev2inFun((v1,v2))|Apply((v1,v2))->letv1=map_exprv1andv2=map_of_listmap_exprv2inApply((v1,v2))|Conditional((v1,v2,v3))->letv1=map_exprv1andv2=map_exprv2andv3=map_exprv3inConditional((v1,v2,v3))andmap_stmt=function|VarDeclv1->letv1=map_varv1inVarDecl((v1))|Blockv1->letv1=map_of_listmap_stmtv1inBlock((v1))|ExprStmtv1->letv1=map_exprv1inExprStmt((v1))|If((v1,v2,v3))->letv1=map_exprv1andv2=map_stmtv2andv3=map_stmtv3inIf((v1,v2,v3))|Do((v1,v2))->letv1=map_stmtv1andv2=map_exprv2inDo((v1,v2))|While((v1,v2))->letv1=map_exprv1andv2=map_stmtv2inWhile((v1,v2))|For((v1,v2))->letv1=map_for_headerv1andv2=map_stmtv2inFor((v1,v2))|Switch((v1,v2))->letv1=map_exprv1andv2=map_of_listmap_casev2inSwitch((v1,v2))|Continuev1->letv1=map_of_optionmap_labelv1inContinue((v1))|Breakv1->letv1=map_of_optionmap_labelv1inBreak((v1))|Returnv1->letv1=map_exprv1inReturn((v1))|Label((v1,v2))->letv1=map_labelv1andv2=map_stmtv2inLabel((v1,v2))|Throwv1->letv1=map_exprv1inThrow((v1))|Try((v1,v2,v3))->letv1=map_stmtv1andv2=map_of_option(fun(v1,v2)->letv1=map_namev1andv2=map_stmtv2in(v1,v2))v2andv3=map_of_optionmap_stmtv3inTry((v1,v2,v3))andmap_for_header=function|ForClassic((v1,v2,v3))->letv1=Ocaml.map_of_either(map_of_listmap_var)map_exprv1andv2=map_exprv2andv3=map_exprv3inForClassic((v1,v2,v3))|ForIn((v1,v2))->letv1=Ocaml.map_of_eithermap_varmap_exprv1andv2=map_exprv2inForIn((v1,v2))andmap_case=function|Case((v1,v2))->letv1=map_exprv1andv2=map_stmtv2inCase((v1,v2))|Defaultv1->letv1=map_stmtv1inDefault((v1))andmap_var{v_name=v_v_name;v_kind=v_v_kind;v_init=v_v_init;v_resolved=v_v_resolved}=letv_v_resolved=map_of_refmap_resolved_namev_v_resolvedinletv_v_init=map_exprv_v_initinletv_v_kind=map_var_kindv_v_kindinletv_v_name=map_namev_v_namein{v_name=v_v_name;v_kind=v_v_kind;v_init=v_v_init;v_resolved=v_v_resolved}andmap_var_kind=function|Var->Var|Let->Let|Const->Constandmap_fun_{f_props=v_f_props;f_params=v_f_params;f_body=v_f_body}=letv_f_body=map_stmtv_f_bodyinletv_f_params=map_of_listmap_parameterv_f_paramsinletv_f_props=map_of_listmap_fun_propv_f_propsin{f_props=v_f_props;f_params=v_f_params;f_body=v_f_body}andmap_parameter{p_name=v_p_name;p_default=v_p_default;p_dots=v_p_dots}=letv_p_dots=map_of_boolv_p_dotsinletv_p_default=map_of_optionmap_exprv_p_defaultinletv_p_name=map_namev_p_namein{p_name=v_p_name;p_default=v_p_default;p_dots=v_p_dots}andmap_fun_prop=function|Get->Get|Set->Set|Generator->Generator|Async->Asyncandmap_obj_v=map_of_listmap_propertyvandmap_class_{c_extends=v_c_extends;c_body=v_c_body}=letv_c_body=map_of_listmap_propertyv_c_bodyinletv_c_extends=map_of_optionmap_exprv_c_extendsin{c_extends=v_c_extends;c_body=v_c_body}andmap_property=function|Field((v1,v2,v3))->letv1=map_property_namev1andv2=map_of_listmap_property_propv2andv3=map_exprv3inField((v1,v2,v3))|FieldSpreadv1->letv1=map_exprv1inFieldSpread((v1))andmap_property_prop=function|Static->Static|Public->Public|Private->Private|Protected->Protectedandmap_toplevel=function|Vv1->letv1=map_varv1inV((v1))|S((v1,v2))->letv1=map_tokv1andv2=map_stmtv2inS((v1,v2))|Mv1->letv1=map_module_directivev1inM((v1))andmap_module_directive=function|Import((v1,v2,v3))->letv1=map_namev1andv2=map_namev2andv3=map_filenamev3inImport((v1,v2,v3))|ImportCss((v1))->letv1=map_namev1inImportCss((v1))|ImportEffect((v1))->letv1=map_namev1inImportEffect((v1))|ModuleAlias((v1,v2))->letv1=map_namev1andv2=map_filenamev2inModuleAlias((v1,v2))|Exportv1->letv1=map_namev1inExport((v1))andmap_programv=map_of_listmap_toplevelvandmap_any=function|Exprv1->letv1=map_exprv1inExpr((v1))|Stmtv1->letv1=map_stmtv1inStmt((v1))|Topv1->letv1=map_toplevelv1inTop((v1))|Programv1->letv1=map_programv1inProgram((v1))andall_functions={vtop=map_toplevel;vprogram=map_program;vexpr=map_expr;vany=map_any;}inall_functions