123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343(* Copyright (C) 2012 Facebook
*
* 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_java(* Continuation-style visitor for a subset of concepts; similar to
visitor_php. The bulk of this file was generated with:
ocamltarzan -choice vi ast_java.ml
(cf. 'generated by' comment below). The main visitor hooks
were carefully handcrafted during a coffee binge.
*)(* hooks *)typevisitor_in={kident:(ident->unit)*visitor_out->ident->unit;kexpr:(expr->unit)*visitor_out->expr->unit;kstmt:(stmt->unit)*visitor_out->stmt->unit;ktype:(typ->unit)*visitor_out->typ->unit;kvar:(var->unit)*visitor_out->var->unit;kinit:(init->unit)*visitor_out->init->unit;kmethod:(method_decl->unit)*visitor_out->method_decl->unit;kfield:(field->unit)*visitor_out->field->unit;kclass:(class_decl->unit)*visitor_out->class_decl->unit;kdecl:(decl->unit)*visitor_out->decl->unit;kprogram:(program->unit)*visitor_out->program->unit;kinfo:(tok->unit)*visitor_out->tok->unit;}andvisitor_out=any->unitletdefault_visitor={kident=(fun(k,_)x->kx);kexpr=(fun(k,_)x->kx);kstmt=(fun(k,_)x->kx);ktype=(fun(k,_)x->kx);kvar=(fun(k,_)x->kx);kinit=(fun(k,_)x->kx);kmethod=(fun(k,_)x->kx);kfield=(fun(k,_)x->kx);kclass=(fun(k,_)x->kx);kdecl=(fun(k,_)x->kx);kprogram=(fun(k,_)x->kx);kinfo=(fun(k,_)x->kx);}let(mk_visitor:visitor_in->visitor_out)=funvin->letrecv_wrap:'a.('a->unit)->'awrap->unit=fun_of_a(v1,v2)->letv1=_of_av1andv2=v_infov2in()andv_infox=letk_x=()invin.kinfo(k,all_functions)xandv_tokx=v_infoxandv_incr_decr_x=()andv_modifiers_=()andv_programx=letkx=v_listv_declx.declsinvin.kprogram(k,all_functions)xandv_anyx=matchxwith|AIdenti->v_identi|AExpre->v_expre|AStmts->v_stmts|ATypt->v_typt|AVarv->v_varv|AIniti->v_initi|AMethodm->v_method_declm|AFieldf->v_fieldf|AClassc->v_class_declc|ADecld->v_decld|AProgramp->v_programp(* generated by ocamltarzan with: camlp4o -o /tmp/yyy.ml -I pa/ pa_type_conv.cmo pa_visitor.cmo pr_o.cmo /tmp/xxx.ml *)andv_type_parameter=function|TParam((v1,v2))->letv1=v_identv1andv2=v_listv_ref_typev2in()andv_qualified_identv=v_listv_identvandv_identv=letkx=v_wrapv_stringxinvin.kident(k,all_functions)vandv_typx=letkx=matchxwith|TBasicv1->letv1=v_wrapv_stringv1in()|TClassv1->letv1=v_class_typev1in()|TArrayv1->letv1=v_typv1in()invin.ktype(k,all_functions)xandv_class_typev=v_list(fun(v1,v2)->letv1=v_identv1andv2=v_listv_type_argumentv2in())vandv_list1_of_a=v_list_of_aandv_namev=v_list1(fun(v1,v2)->letv1=v_listv_type_argumentv1andv2=v_identv2in())vandv_name_or_class_typev=v_listv_identifier_vandv_identifier_=function|Idv1->letv1=v_identv1in()|Id_then_TypeArgs((v1,v2))->letv1=v_identv1andv2=v_listv_type_argumentv2in()|TypeArgs_then_Id((v1,v2))->letv1=v_listv_type_argumentv1andv2=v_identifier_v2in()andv_type_argument=function|TArgumentv1->letv1=v_ref_typev1in()|TQuestionv1->letv1=v_option(fun(v1,v2)->letv1=v_boolv1andv2=v_ref_typev2in())v1in()andv_literal=function|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()|Nullv1->letv1=v_tokv1in()andv_expr(x:expr)=letkx=matchxwith|Ellipsesv1->letv1=v_tokv1in()|Namev1->letv1=v_namev1in()|NameOrClassTypev1->letv1=v_name_or_class_typev1in()|Literalv1->letv1=v_literalv1in()|ClassLiteralv1->letv1=v_typv1in()|NewClass((v1,v2,v3))->letv1=v_typv1andv2=v_argumentsv2andv3=v_optionv_declsv3in()|NewArray((v1,v2,v3,v4))->letv1=v_typv1andv2=v_argumentsv2andv3=v_intv3andv4=v_optionv_initv4in()|NewQualifiedClass((v1,v2,v3,v4))->letv1=v_exprv1andv2=v_identv2andv3=v_argumentsv3andv4=v_optionv_declsv4in()|Call((v1,v2))->letv1=v_exprv1andv2=v_argumentsv2in()|Dot((v1,v2))->letv1=v_exprv1andv2=v_identv2in()|ArrayAccess((v1,v2))->letv1=v_exprv1andv2=v_exprv2in()|Postfix((v1,v2))->letv1=v_exprv1andv2=v_incr_decrv2in()|Prefix((v1,v2))->letv1=v_incr_decrv1andv2=v_exprv2in()|Unary((v1,v2))->letv1=v_wrapv_arith_opv1andv2=v_exprv2in()|Infix((v1,v2,v3))->letv1=v_exprv1andv2=v_wrapv_arith_opv2andv3=v_exprv3in()|Cast((v1,v2))->letv1=v_typv1andv2=v_exprv2in()|InstanceOf((v1,v2))->letv1=v_exprv1andv2=v_ref_typev2in()|Conditional((v1,v2,v3))->letv1=v_exprv1andv2=v_exprv2andv3=v_exprv3in()|AssignOp((v1,v2,v3))->letv1=v_exprv1andv2=v_wrapv_arith_opv2andv3=v_exprv3in()|Assign((v1,v2))->letv1=v_exprv1andv2=v_exprv2in()invin.kexpr(k,all_functions)xandv_ref_typev=v_typvandv_arith_op_v=()andv_argumentsv=v_listv_exprvandv_stmt(x:stmt)=letkx=matchxwith|Empty->()|Blockv1->letv1=v_stmtsv1in()|Exprv1->letv1=v_exprv1in()|If((v1,v2,v3))->letv1=v_exprv1andv2=v_stmtv2andv3=v_stmtv3in()|Switch((v1,v2))->letv1=v_exprv1andv2=v_list(fun(v1,v2)->letv1=v_casesv1andv2=v_stmtsv2in())v2in()|While((v1,v2))->letv1=v_exprv1andv2=v_stmtv2in()|Do((v1,v2))->letv1=v_stmtv1andv2=v_exprv2in()|For((v1,v2))->letv1=v_for_controlv1andv2=v_stmtv2in()|Breakv1->letv1=v_optionv_identv1in()|Continuev1->letv1=v_optionv_identv1in()|Returnv1->letv1=v_optionv_exprv1in()|Label((v1,v2))->letv1=v_identv1andv2=v_stmtv2in()|Sync((v1,v2))->letv1=v_exprv1andv2=v_stmtv2in()|Try((v1,v2,v3))->letv1=v_stmtv1andv2=v_catchesv2andv3=v_optionv_stmtv3in()|Throwv1->letv1=v_exprv1in()|LocalVarv1->letv1=v_var_with_initv1in()|LocalClassv1->letv1=v_class_declv1in()|Assert((v1,v2))->letv1=v_exprv1andv2=v_optionv_exprv2in()invin.kstmt(k,all_functions)xandv_stmtsv=v_listv_stmtvandv_case=function|Casev1->letv1=v_exprv1in()|Default->()andv_casesv=v_listv_casevandv_for_control=function|ForClassic((v1,v2,v3))->letv1=v_for_initv1andv2=v_listv_exprv2andv3=v_listv_exprv3in()|Foreach((v1,v2))->letv1=v_varv1andv2=v_exprv2in()andv_for_init=function|ForInitVarsv1->letv1=v_listv_var_with_initv1in()|ForInitExprsv1->letv1=v_listv_exprv1in()andv_catch(v1,v2)=letv1=v_varv1andv2=v_stmtv2in()andv_catchesv=v_listv_catchvandv_varx=letkx=matchxwith|{v_name=v_v_name;v_mods=v_v_mods;v_type=v_v_type}->letarg=v_identv_v_nameinletarg=v_modifiersv_v_modsinletarg=v_typv_v_typein()invin.kvar(k,all_functions)xandv_varsv=v_listv_varvandv_var_with_init{f_var=v_f_var;f_init=v_f_init}=letarg=v_varv_f_varinletarg=v_optionv_initv_f_initin()andv_init(x:init)=letkx=matchxwith|ExprInitv1->letv1=v_exprv1in()|ArrayInitv1->letv1=v_listv_initv1in()invin.kinit(k,all_functions)xandv_method_decl(x:method_decl)=letkx=matchxwith{m_var=v_m_var;m_formals=v_m_formals;m_throws=v_m_throws;m_body=v_m_body}->letarg=v_varv_m_varinletarg=v_varsv_m_formalsinletarg=v_listv_qualified_identv_m_throwsinletarg=v_stmtv_m_bodyin()invin.kmethod(k,all_functions)xandv_fieldv=letkx=v_var_with_initxinvin.kfield(k,all_functions)vandv_enum_decl{en_name=v_en_name;en_mods=v_en_mods;en_impls=v_en_impls;en_body=v_en_body}=letarg=v_identv_en_nameinletarg=v_modifiersv_en_modsinletarg=v_listv_ref_typev_en_implsinletarg=matchv_en_bodywith|(v1,v2)->letv1=v_listv_enum_constantv1andv2=v_declsv2in()in()andv_enum_constant=function|EnumSimplev1->letv1=v_identv1in()|EnumConstructor((v1,v2))->letv1=v_identv1andv2=v_argumentsv2in()|EnumWithMethods((v1,v2))->letv1=v_identv1andv2=v_listv_method_declv2in()andv_class_decl(x:class_decl)=letkx=matchxwith{cl_name=v_cl_name;cl_kind=v_cl_kind;cl_tparams=v_cl_tparams;cl_mods=v_cl_mods;cl_extends=v_cl_extends;cl_impls=v_cl_impls;cl_body=v_cl_body}->letarg=v_identv_cl_nameinletarg=v_class_kindv_cl_kindinletarg=v_listv_type_parameterv_cl_tparamsinletarg=v_modifiersv_cl_modsinletarg=v_optionv_typv_cl_extendsinletarg=v_listv_ref_typev_cl_implsinletarg=v_declsv_cl_bodyin()invin.kclass(k,all_functions)xandv_class_kind=function|ClassRegular->()|Interface->()andv_declx=letkx=matchxwith|Classv1->letv1=v_class_declv1in()|Methodv1->letv1=v_method_declv1in()|Fieldv1->letv1=v_fieldv1in()|Enumv1->letv1=v_enum_declv1in()|Init((v1,v2))->letv1=v_boolv1andv2=v_stmtv2in()invin.kdecl(k,all_functions)xandv_declsv=v_listv_declv(* end not-really-auto generation... *)andall_functionsx=v_anyxinv_any