123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549(* 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_generic(*****************************************************************************)(* Prelude *)(*****************************************************************************)(* hooks *)typevisitor_in={kexpr:(expr->unit)*visitor_out->expr->unit;kstmt:(stmt->unit)*visitor_out->stmt->unit;ktype_:(type_->unit)*visitor_out->type_->unit;kpattern:(pattern->unit)*visitor_out->pattern->unit;kdef:(definition->unit)*visitor_out->definition->unit;kdir:(directive->unit)*visitor_out->directive->unit;kitem:(item->unit)*visitor_out->item->unit;kattr:(attribute->unit)*visitor_out->attribute->unit;kparam:(parameter->unit)*visitor_out->parameter->unit;kname:(name->unit)*visitor_out->name->unit;kentity:(entity->unit)*visitor_out->entity->unit;kinfo:(tok->unit)*visitor_out->tok->unit;}andvisitor_out=any->unitletdefault_visitor={kexpr=(fun(k,_)x->kx);kstmt=(fun(k,_)x->kx);ktype_=(fun(k,_)x->kx);kpattern=(fun(k,_)x->kx);kdef=(fun(k,_)x->kx);kdir=(fun(k,_)x->kx);kitem=(fun(k,_)x->kx);kattr=(fun(k,_)x->kx);kparam=(fun(k,_)x->kx);kname=(fun(k,_)x->kx);kentity=(fun(k,_)x->kx);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_visitor.cmo pr_o.cmo /tmp/xxx.ml *)letrecv_infox=letkx=matchxwith{Parse_info.token=_v_pinfox;transfo=_v_transfo}->(*
let arg = Parse_info.v_pinfo v_pinfox in
let arg = v_unit v_comments in
let arg = Parse_info.v_transformation v_transfo in
*)()invin.kinfo(k,all_functions)xandv_tokv=v_infovandv_wrap:'a.('a->unit)->'awrap->unit=fun_of_a(v1,v2)->letv1=_of_av1andv2=v_infov2in()andv_namev=letkx=v_wrapv_stringxinvin.kname(k,all_functions)vandv_dotted_namev=v_listv_namevandv_qualified_namev=v_dotted_namevandv_module_name=function|FileNamev1->letv1=v_wrapv_stringv1in()|DottedNamev1->letv1=v_dotted_namev1in()andv_resolved_name=function|Local->()|Param->()|Globalv1->letv1=v_qualified_namev1in()|NotResolved->()|Macro->()|EnumConstant->()|ImportedModule->()andv_exprx=letkx=matchxwith|Lv1->letv1=v_literalv1in()|Ellipsesv1->letv1=v_tokv1in()|Container((v1,v2))->letv1=v_container_operatorv1andv2=v_listv_exprv2in()|Tuplev1->letv1=v_listv_exprv1in()|Recordv1->letv1=v_listv_fieldv1in()|Constructor((v1,v2))->letv1=v_namev1andv2=v_listv_exprv2in()|Lambda((v1,v2))->letv1=v_parametersv1andv2=v_stmtv2in()|Nop->()|Id((v1,v2))->letv1=v_namev1andv2=v_id_infov2in()|IdSpecialv1->letv1=v_specialv1in()|Call((v1,v2))->letv1=v_exprv1andv2=v_argumentsv2in()|Assign((v1,v2))->letv1=v_exprv1andv2=v_exprv2in()|AssignOp((v1,v2,v3))->letv1=v_exprv1andv2=v_arithmetic_operatorv2andv3=v_exprv3in()|LetPattern((v1,v2))->letv1=v_patternv1andv2=v_exprv2in()|ObjAccess((v1,v2))->letv1=v_exprv1andv2=v_namev2in()|ArrayAccess((v1,v2))->letv1=v_exprv1andv2=v_exprv2in()|Conditional((v1,v2,v3))->letv1=v_exprv1andv2=v_exprv2andv3=v_exprv3in()|MatchPattern((v1,v2))->letv1=v_exprv1andv2=v_list(fun(v1,v2)->letv1=v_patternv1andv2=v_exprv2in())v2in()|Yieldv1->letv1=v_exprv1in()|Awaitv1->letv1=v_exprv1in()|Cast((v1,v2))->letv1=v_type_v1andv2=v_exprv2in()|Seqv1->letv1=v_listv_exprv1in()|Refv1->letv1=v_exprv1in()|DeRefv1->letv1=v_exprv1in()|OtherExpr((v1,v2))->letv1=v_other_expr_operatorv1andv2=v_listv_anyv2in()invin.kexpr(k,all_functions)xandv_literal=function|Unitv1->letv1=v_tokv1in()|Boolv1->letv1=v_wrapv_boolv1in()|Intv1->letv1=v_wrapv_stringv1in()|Floatv1->letv1=v_wrapv_stringv1in()|Charv1->letv1=v_wrapv_stringv1in()|Stringv1->letv1=v_wrapv_stringv1in()|Regexpv1->letv1=v_wrapv_stringv1in()|Nullv1->letv1=v_tokv1in()|Undefinedv1->letv1=v_tokv1in()andv_container_operator=function|Array->()|List->()|Set->()|Dict->()andv_id_info{id_qualifier=v_id_qualifier;id_typeargs=v_id_typeargs;id_resolved=v_id_resolved;id_type=v_id_type}=letarg=v_optionv_dotted_namev_id_qualifierinletarg=v_optionv_type_argumentsv_id_typeargsinletarg=v_refv_resolved_namev_id_resolvedinletarg=v_ref(v_optionv_type_)v_id_typein()andv_special=function|This->()|Super->()|Self->()|Parent->()|Eval->()|Typeof->()|Instanceof->()|Sizeof->()|New->()|Concat->()|Spread->()|ArithOpv1->letv1=v_arithmetic_operatorv1in()|IncrDecr((v1,v2))->letv1=v_incr_decrv1andv2=v_prepostv2in()andv_incr_decr_=()andv_prepost_=()andv_arithmetic_operator=function|Plus->()|Minus->()|Mult->()|Div->()|Mod->()|Pow->()|FloorDiv->()|LSL->()|LSR->()|ASR->()|BitOr->()|BitXor->()|BitAnd->()|BitNot->()|And->()|Or->()|Not->()|Eq->()|NotEq->()|PhysEq->()|NotPhysEq->()|Lt->()|LtE->()|Gt->()|GtE->()andv_argumentsv=v_listv_argumentvandv_argument=function|Argv1->letv1=v_exprv1in()|ArgKwd((v1,v2))->letv1=v_namev1andv2=v_exprv2in()|ArgOther((v1,v2))->letv1=v_other_argument_operatorv1andv2=v_listv_anyv2in()andv_other_argument_operator_x=()andv_other_expr_operator_x=()andv_type_x=letkx=matchxwith|TyBuiltinv1->letv1=v_wrapv_stringv1in()|TyFun((v1,v2))->letv1=v_listv_type_v1andv2=v_type_v2in()|TyApply((v1,v2))->letv1=v_namev1andv2=v_type_argumentsv2in()|TyVarv1->letv1=v_namev1in()|TyArray((v1,v2))->letv1=v_optionv_exprv1andv2=v_type_v2in()|TyPointerv1->letv1=v_type_v1in()|TyTuplev1->letv1=v_listv_type_v1in()|TyQuestionv1->letv1=v_type_v1in()|OtherType((v1,v2))->letv1=v_other_type_operatorv1andv2=v_listv_anyv2in()invin.ktype_(k,all_functions)xandv_type_argumentsv=v_listv_type_argumentvandv_type_argument=function|TypeArgv1->letv1=v_type_v1in()|OtherTypeArg((v1,v2))->letv1=v_other_type_argument_operatorv1andv2=v_listv_anyv2in()andv_other_type_argument_operator=function|OTA_Question->()andv_other_type_operator_=()andv_type_parameter(v1,v2)=letv1=v_namev1andv2=v_type_parameter_constraintsv2in()andv_type_parameter_constraintsv=v_listv_type_parameter_constraintvandv_type_parameter_constraint=function|Extendsv1->letv1=v_type_v1in()andv_attributex=letkx=matchxwith|Static->()|Volatile->()|Extern->()|Public->()|Private->()|Protected->()|Abstract->()|Final->()|Var->()|Let->()|Const->()|Generator->()|Async->()|Ctor->()|Dtor->()|Getter->()|Setter->()|Variadic->()|NamedAttr((v1,v2))->letv1=v_namev1andv2=v_listv_anyv2in()|OtherAttribute((v1,v2))->letv1=v_other_attribute_operatorv1andv2=v_listv_anyv2in()invin.kattr(k,all_functions)xandv_other_attribute_operator_=()andv_stmtx=letkx=matchxwith|ExprStmtv1->letv1=v_exprv1in()|LocalDefv1->letv1=v_defv1in()|LocalDirectivev1->letv1=v_directivev1in()|Blockv1->letv1=v_listv_stmtv1in()|If((v1,v2,v3))->letv1=v_exprv1andv2=v_stmtv2andv3=v_stmtv3in()|While((v1,v2))->letv1=v_exprv1andv2=v_stmtv2in()|DoWhile((v1,v2))->letv1=v_stmtv1andv2=v_exprv2in()|For((v1,v2))->letv1=v_for_headerv1andv2=v_stmtv2in()|Switch((v1,v2))->letv1=v_exprv1andv2=v_list(fun(v1,v2)->letv1=v_listv_casev1andv2=v_stmtv2in())v2in()|Returnv1->letv1=v_exprv1in()|Continuev1->letv1=v_optionv_exprv1in()|Breakv1->letv1=v_optionv_exprv1in()|Label((v1,v2))->letv1=v_labelv1andv2=v_stmtv2in()|Gotov1->letv1=v_labelv1in()|Throwv1->letv1=v_exprv1in()|Try((v1,v2,v3))->letv1=v_stmtv1andv2=v_listv_catchv2andv3=v_optionv_finallyv3in()|Assert((v1,v2))->letv1=v_exprv1andv2=v_optionv_exprv2in()|OtherStmt((v1,v2))->letv1=v_other_stmt_operatorv1andv2=v_listv_anyv2in()invin.kstmt(k,all_functions)xandv_case=function|Casev1->letv1=v_exprv1in()|Default->()andv_catch(v1,v2)=letv1=v_patternv1andv2=v_stmtv2in()andv_finallyv=v_stmtvandv_labelv=v_namevandv_for_header=function|ForClassic((v1,v2,v3))->letv1=v_listv_for_var_or_exprv1andv2=v_exprv2andv3=v_exprv3in()|ForEach((v1,v2))->letv1=v_patternv1andv2=v_exprv2in()andv_for_var_or_expr=function|ForInitVar((v1,v2))->letv1=v_entityv1andv2=v_variable_definitionv2in()|ForInitExprv1->letv1=v_exprv1in()andv_other_stmt_operator_x=()andv_patternx=letkx=matchxwith|PatVarv1->letv1=v_namev1in()|PatLiteralv1->letv1=v_literalv1in()|PatConstructor((v1,v2))->letv1=v_namev1andv2=v_listv_patternv2in()|PatTuplev1->letv1=v_listv_patternv1in()|PatListv1->letv1=v_listv_patternv1in()|PatKeyVal((v1,v2))->letv1=v_patternv1andv2=v_patternv2in()|PatUnderscorev1->letv1=v_tokv1in()|PatDisj((v1,v2))->letv1=v_patternv1andv2=v_patternv2in()|PatTyped((v1,v2))->letv1=v_patternv1andv2=v_type_v2in()|OtherPat((v1,v2))->letv1=v_other_pattern_operatorv1andv2=v_listv_anyv2in()invin.kpattern(k,all_functions)xandv_other_pattern_operator=function|OP_Expr->()|OP_Var->()andv_defx=letkx=let(v1,v2)=xinletv1=v_entityv1andv2=v_def_kindv2in()invin.kdef(k,all_functions)xandv_entityx=letkx=let{name=x_name;attrs=v_attrs;type_=x_type_;tparams=v_tparams}=xinletarg=v_namex_nameinletarg=v_listv_attributev_attrsinletarg=v_optionv_type_x_type_inletarg=v_listv_type_parameterv_tparamsin()invin.kentity(k,all_functions)xandv_def_kind=function|FuncDefv1->letv1=v_function_definitionv1in()|VarDefv1->letv1=v_variable_definitionv1in()|ClassDefv1->letv1=v_class_definitionv1in()|TypeDefv1->letv1=v_type_definitionv1in()andv_function_definition{fparams=v_fparams;frettype=v_frettype;fbody=v_fbody;}=letarg=v_parametersv_fparamsinletarg=v_optionv_type_v_frettypeinletarg=v_stmtv_fbodyin()andv_parametersv=v_listv_parametervandv_parameterx=letkx=matchxwith|ParamClassicv1->letv1=v_parameter_classicv1in()|ParamPatternv1->letv1=v_patternv1in()|OtherParam((v1,v2))->letv1=v_other_parameter_operatorv1andv2=v_listv_anyv2in()invin.kparam(k,all_functions)xandv_parameter_classic{pname=v_pname;pdefault=v_pdefault;ptype=v_ptype;pattrs=v_pattrs}=letarg=v_namev_pnameinletarg=v_optionv_exprv_pdefaultinletarg=v_optionv_type_v_ptypeinletarg=v_listv_attributev_pattrsin()andv_other_parameter_operator=function|OPO_KwdParam->()|OPO_Ref->()andv_variable_definition{vinit=v_vinit;vtype=v_vtype;}=letarg=v_optionv_exprv_vinitinletarg=v_optionv_type_v_vtypein()andv_field=function|FieldVar((v1,v2))->letv1=v_entityv1andv2=v_variable_definitionv2in()|FieldMethod((v1,v2))->letv1=v_entityv1andv2=v_function_definitionv2in()|FieldDynamic((v1,v2,v3))->letv1=v_exprv1andv2=v_listv_attributev2andv3=v_exprv3in()|FieldSpreadv1->letv1=v_exprv1in()|FieldStmtv1->letv1=v_stmtv1in()andv_type_definition=function|OrTypev1->letv1=v_listv_or_type_elementv1in()|AndTypev1->letv1=v_listv_fieldv1in()|AliasTypev1->letv1=v_type_v1in()|OtherTypeKind((v1,v2))->letv1=v_other_type_kind_operatorv1andv2=v_listv_anyv2in()andv_other_type_kind_operator=function|OTKO_EnumWithValue->()andv_or_type_element=function|OrConstructor((v1,v2))->letv1=v_namev1andv2=v_listv_type_v2in()|OrEnum((v1,v2))->letv1=v_namev1andv2=v_exprv2in()|OrUnion((v1,v2))->letv1=v_namev1andv2=v_type_v2in()andv_class_definition{ckind=v_ckind;cextends=v_cextends;cimplements=v_cimplements;cbody=v_cbody;}=letarg=v_class_kindv_ckindinletarg=v_listv_type_v_cextendsinletarg=v_listv_type_v_cimplementsinletarg=v_listv_fieldv_cbodyin()andv_class_kind=function|Class->()|Interface->()|Trait->()andv_directivex=letkx=matchxwith|Import((v1,v2))->letv1=v_module_namev1andv2=v_listv_aliasv2in()|ImportAll((v1,v2))->letv1=v_module_namev1andv2=v_optionv_namev2in()|OtherDirective((v1,v2))->letv1=v_other_directive_operatorv1andv2=v_listv_anyv2in()invin.kdir(k,all_functions)xandv_alias(v1,v2)=letv1=v_namev1andv2=v_optionv_namev2in()andv_other_directive_operator=function|OI_Export->()|OI_ImportCss->()|OI_ImportEffect->()|OI_Package->()|OI_Define->()|OI_Macro->()|OI_Prototype->()|OI_Namespace->()andv_itemx=letkx=matchxwith|IStmtv1->letv1=v_stmtv1in()|IDefv1->letv1=v_defv1in()|IDirv1->letv1=v_directivev1in()invin.kitem(k,all_functions)xandv_programv=v_listv_itemvandv_any=function|Nv1->letv1=v_namev1in()|Env1->letv1=v_entityv1in()|Ev1->letv1=v_exprv1in()|Sv1->letv1=v_stmtv1in()|Tv1->letv1=v_type_v1in()|Pv1->letv1=v_patternv1in()|Dv1->letv1=v_defv1in()|Div1->letv1=v_directivev1in()|Dkv1->letv1=v_def_kindv1in()|Dnv1->letv1=v_dotted_namev1in()|Iv1->letv1=v_itemv1in()|Pav1->letv1=v_parameterv1in()|Arv1->letv1=v_argumentv1in()|Atv1->letv1=v_attributev1in()|Prv1->letv1=v_programv1in()andall_functionsx=v_anyxinall_functions(*****************************************************************************)(* Helpers *)(*****************************************************************************)