12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253(* Yoann Padioleau
*
* Copyright (C) 2010, 2011 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.
*)openCommonopenOcaml(* for v_int, v_bool, etc *)openCst_php(*****************************************************************************)(* Prelude *)(*****************************************************************************)(*****************************************************************************)(* Side effect style visitor *)(*****************************************************************************)(*
* Visitors for all language concepts, not just for expression.
*
* Note that I don't visit necesserally in the order of the tokens
* found in the original file. So don't assume such hypothesis!
*
* Mostly generated by ocamltarzan with: camlp4o -o /tmp/yyy.ml -I pa/ pa_type_conv.cmo pa_visitor.cmo pr_o.cmo /tmp/xxx.ml
* and then manually adjusted.
*
* update: used to have multiple v_parenxxx and v_wrap because of the "value
* restriction" of ocaml but 3.12 fixed that :)
* update: reordered a few things to help unparse_php.ml
* update: instead of generating a set of vxxx I now just generate
* a vout = vany. This helps avoid the proliferation of functions
* like ii_of_expr, ii_of_stmt, etc. You just need a ii_of_any now.
* Is is the final design ? Could we factorize vin ?
*)moduleScope_php=struct(* TODO ? need visitor for scope ? *)letv_phpscope_x=()end(* todo? why don't use the one in Ocaml.ml ? because it generates
* a compilation error :(
*)letv_ref_aref_x=()(* dont go into ref *)(* hooks *)typevisitor_in={kexpr:(expr->unit)*visitor_out->expr->unit;kstmt:(stmt->unit)*visitor_out->stmt->unit;ktop:(toplevel->unit)*visitor_out->toplevel->unit;kconstant:(constant->unit)*visitor_out->constant->unit;kscalar:(scalar->unit)*visitor_out->scalar->unit;kencaps:(encaps->unit)*visitor_out->encaps->unit;kclass_stmt:(class_stmt->unit)*visitor_out->class_stmt->unit;kparameter:(parameter->unit)*visitor_out->parameter->unit;kargument:(argument->unit)*visitor_out->argument->unit;kcatch:(catch->unit)*visitor_out->catch->unit;kfinally:(finally->unit)*visitor_out->finally->unit;kxhp_html:(xhp_html->unit)*visitor_out->xhp_html->unit;kxhp_tag:(xhp_tagwrap->unit)*visitor_out->xhp_tagwrap->unit;kxhp_attribute:(xhp_attribute->unit)*visitor_out->xhp_attribute->unit;kxhp_attr_decl:(xhp_attribute_decl->unit)*visitor_out->xhp_attribute_decl->unit;kxhp_children_decl:(xhp_children_decl->unit)*visitor_out->xhp_children_decl->unit;kfunc_def:(func_def->unit)*visitor_out->func_def->unit;kclass_def:(class_def->unit)*visitor_out->class_def->unit;kmethod_def:(method_def->unit)*visitor_out->method_def->unit;kstmt_and_def_list_scope:(stmt_and_deflist->unit)*visitor_out->stmt_and_deflist->unit;kname:(name->unit)*visitor_out->name->unit;khint_type:(hint_type->unit)*visitor_out->hint_type->unit;ktparam:(type_param->unit)*visitor_out->type_param->unit;karray_pair:(array_pair->unit)*visitor_out->array_pair->unit;karguments:(argumentcomma_listparen->unit)*visitor_out->argumentcomma_listparen->unit;kcomma:(tok->unit)*visitor_out->tok->unit;kinfo:(tok->unit)*visitor_out->tok->unit;}andvisitor_out=any->unitletdefault_visitor={kexpr=(fun(k,_)x->kx);kstmt=(fun(k,_)x->kx);ktop=(fun(k,_)x->kx);kconstant=(fun(k,_)x->kx);kscalar=(fun(k,_)x->kx);kencaps=(fun(k,_)x->kx);kinfo=(fun(k,_)x->kx);kclass_stmt=(fun(k,_)x->kx);kparameter=(fun(k,_)x->kx);kargument=(fun(k,_)x->kx);karguments=(fun(k,_)x->kx);kcatch=(fun(k,_)x->kx);kfinally=(fun(k,_)x->kx);kstmt_and_def_list_scope=(fun(k,_)x->kx);kfunc_def=(fun(k,_)x->kx);kmethod_def=(fun(k,_)x->kx);kclass_def=(fun(k,_)x->kx);kcomma=(fun(k,_)x->kx);khint_type=(fun(k,_)x->kx);kname=(fun(k,_)x->kx);kxhp_html=(fun(k,_)x->kx);kxhp_tag=(fun(k,_)x->kx);kxhp_attribute=(fun(k,_)x->kx);kxhp_attr_decl=(fun(k,_)x->kx);kxhp_children_decl=(fun(k,_)x->kx);karray_pair=(fun(k,_)x->kx);ktparam=(fun(k,_)x->kx);}let(mk_visitor:visitor_in->visitor_out)=funvin->(* start of auto generation *)letrecv_infox=letkx=matchxwith{Parse_info.token=_v_pinfo;_}->(* TODO ? not sure what behavior we want with tokens and fake tokens.
*)(*let arg = v_parse_info v_pinfo in *)()invin.kinfo(k,all_functions)x(* since ocaml 3.12 we can now use polymorphic recursion instead of having
* to duplicate the same function again and again.
*)andv_wrap:'a.('a->unit)->'awrap->unit=fun_of_a(v1,v2)->letv1=_of_av1andv2=v_infov2in()andv_tokv=v_infovandv_paren:'a.('a->unit)->'aparen->unit=fun_of_a(v1,v2,v3)->letv1=v_tokv1andv2=_of_av2andv3=v_tokv3in()andv_brace:'a.('a->unit)->'abrace->unit=fun_of_a(v1,v2,v3)->letv1=v_tokv1andv2=_of_av2andv3=v_tokv3in()andv_bracket:'a.('a->unit)->'abracket->unit=fun_of_a(v1,v2,v3)->letv1=v_tokv1andv2=_of_av2andv3=v_tokv3in()andv_single_angle:'a.('a->unit)->'asingle_angle->unit=fun_of_a(v1,v2,v3)->letv1=v_tokv1inletv2=_of_av2inletv3=v_tokv3in()andv_angle:'a.('a->unit)->'aangle->unit=fun_of_a(v1,v2,v3)->letv1=v_tokv1andv2=_of_av2andv3=v_tokv3in()andv_commax=letkinfo=v_tokinfoinvin.kcomma(k,all_functions)xandv_comma_list_dots:'a.('a->unit)->'acomma_list_dots->unit=fun_of_axs->xs|>List.iter(function|Left3x->_of_ax|Middle3info->v_tokinfo|Right3info->v_commainfo)andv_comma_list:'a.('a->unit)->'acomma_list->unit=fun_of_axs->xs|>List.iter(function|Leftx->_of_ax|Rightinfo->v_commainfo)andv_ptype=function|BoolTy->()|IntTy->()|DoubleTy->()|StringTy->()|ArrayTy->()|ObjectTy->()andv_ident=function|Namev1->letv1=v_wrapv_stringv1in()|XhpNamev1->letv1=v_xhp_tag_wrapv1in()andv_qualified_identv=v_listv_qualified_ident_elementvandv_qualified_ident_element=function|QIv1->letv1=v_identv1in()|QITokv1->letv1=v_tokv1in()andv_dname=function|DNamev1->letv1=v_wrapv_stringv1in()andv_xhp_tagv=v_listv_stringvandv_xhp_tag_wrapx=letkv=v_wrapv_xhp_tagvinvin.kxhp_tag(k,all_functions)xandv_namex=v_class_name_or_selfparentxandv_class_name_or_selfparentx=letkx=matchxwith|XName(v1)->letv1=v_qualified_identv1in()|Selfv1->letv1=v_tokv1in()|Parentv1->letv1=v_tokv1in()|LateStaticv1->letv1=v_tokv1in()invin.kname(k,all_functions)xandv_type_argsx=v_single_angle(v_comma_listv_hint_type)x;()andv_type_paramsv=v_single_angle(v_comma_listv_type_param)vandv_type_paramx=letkx=matchxwith|TParamv1->letv1=v_identv1in()|TParamConstraint((v1,v2,v3))->letv1=v_identv1andv2=v_tokv2andv3=v_class_namev3in()invin.ktparam(k,all_functions)xandv_class_namev=v_hint_typevandv_fully_qualified_class_namev=v_hint_typevandv_expr(x:expr)=(* tweak *)letkx=matchxwith|Idv1->v_namev1|IdVar((v1,v2))->letv1=v_dnamev1andv2=v_refScope_php.v_phpscopev2in()|Thisv1->letv1=v_tokv1in()|Call((v1,v2))->letv1=v_exprv1andv2=v_paren(v_comma_listv_argument)v2in()|ObjGet((v1,v2,v3))->letv1=v_exprv1andv2=v_tokv2andv3=v_exprv3in()|ClassGet((v1,v2,v3))->letv1=v_class_name_referencev1andv2=v_tokv2andv3=v_exprv3in()|ArrayGet((v1,v2))->letv1=v_exprv1andv2=v_bracket(v_optionv_expr)v2in()|HashGet((v1,v2))->letv1=v_exprv1andv2=v_bracev_exprv2in()|BraceIdentv1->letv1=v_bracev_exprv1in()|Deref((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|Scv1->letv1=v_scalarv1in()|Assign((v1,v2,v3))->letv1=v_lvaluev1andv2=v_tokv2andv3=v_exprv3in()|AssignRef((v1,v2,v3,v4))->letv1=v_lvaluev1andv2=v_tokv2andv3=v_tokv3andv4=v_lvaluev4in()|AssignNew((v1,v2,v3,v4,v5,v6))->letv1=v_lvaluev1andv2=v_tokv2andv3=v_tokv3andv4=v_tokv4andv5=v_class_name_referencev5andv6=v_option(v_arguments)v6in()|AssignOp((v1,v2,v3))->letv1=v_lvaluev1andv2=v_wrapv_assignOpv2andv3=v_exprv3in()|Postfix((v1,v2))->letv1=v_rw_variablev1andv2=v_wrapv_fixOpv2in()|Infix((v1,v2))->letv1=v_wrapv_fixOpv1andv2=v_rw_variablev2in()|Binary((v1,v2,v3))->letv1=v_exprv1andv2=v_wrapv_binaryOpv2andv3=v_exprv3in()|Unary((v1,v2))->letv1=v_wrapv_unaryOpv1andv2=v_exprv2in()|CondExpr((v1,v2,v3,v4,v5))->letv1=v_exprv1andv2=v_tokv2andv3=v_optionv_exprv3andv4=v_tokv4andv5=v_exprv5in()|AssignList((v1,v2,v3,v4))->letv1=v_tokv1andv2=v_paren(v_comma_listv_list_assign)v2andv3=v_tokv3andv4=v_exprv4in()|ArrayLong((v1,v2))->letv1=v_tokv1andv2=v_paren(v_comma_listv_array_pair)v2in()|ArrayShort((v1))->letv1=v_bracket(v_comma_listv_array_pair)v1in()|Collection((v1,v2))->letv1=v_namev1inletv2=v_brace(v_comma_listv_array_pair)v2in()|New((v1,v2,v3))->letv1=v_tokv1andv2=v_class_name_referencev2andv3=v_option(v_arguments)v3in()|Clone((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|InstanceOf((v1,v2,v3))->letv1=v_exprv1andv2=v_tokv2andv3=v_class_name_referencev3in()|Cast((v1,v2))->letv1=v_wrapv_castOpv1andv2=v_exprv2in()|CastUnset((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|Exit((v1,v2))->letv1=v_tokv1andv2=v_option(v_paren(v_optionv_expr))v2in()|At((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|Print((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|Lambdav1->letv1=v_lambda_defv1in()|ShortLambdav1->letv1=v_short_lambda_defv1in()|BackQuote((v1,v2,v3))->letv1=v_tokv1andv2=v_listv_encapsv2andv3=v_tokv3in()|Include((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|IncludeOnce((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|Require((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|RequireOnce((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|Yield((v1,v2))->letv1=v_tokv1andv2=v_array_pairv2in()|YieldBreak((v1,v2))->letv1=v_tokv1andv2=v_tokv2in()|Await((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|Empty((v1,v2))->letv1=v_tokv1andv2=v_parenv_lvaluev2in()|Isset((v1,v2))->letv1=v_tokv1andv2=v_paren(v_comma_listv_lvalue)v2in()|Eval((v1,v2))->letv1=v_tokv1andv2=v_parenv_exprv2in()|ParenExprv1->letv1=v_parenv_exprv1in()|SgrepExprDotsv1->letv1=v_tokv1in()|XhpHtmlv1->letv1=v_xhp_htmlv1in()invin.kexpr(k,all_functions)xandv_lambda_def(v1,v2)=letv1=v_optionv_lexical_varsv1andv2=v_func_defv2in()andv_short_lambda_def{sl_modifiers=v_sl_modifiers;sl_params=v_sl_params;sl_tok=v_sl_tok;sl_body=v_sl_body}=letarg=v_list(v_wrapv_modifier)v_sl_modifiersinletarg=v_short_lambda_paramsv_sl_paramsinletarg=v_optionv_tokv_sl_tokinletarg=v_short_lambda_bodyv_sl_bodyin()andv_short_lambda_params=function|SLSingleParamv1->letv1=v_parameterv1in()|SLParamsv1->letv1=v_paren(v_comma_list_dotsv_parameter)v1in()|SLParamsOmitted->()andv_short_lambda_body=function|SLExprv1->letv1=v_exprv1in()|SLBodyv1->letv1=v_brace(v_listv_stmt_and_def)v1in()andv_stmt_and_defx=v_stmtxandv_parametersx=v_paren(v_comma_list_dotsv_parameter)xandv_lexical_vars(v1,v2)=letv1=v_tokv1andv2=v_paren(v_comma_listv_lexical_var)v2in()andv_lexical_var=function|LexicalVar((v1,v2))->letv1=v_is_refv1andv2=v_dnamev2in()andv_scalarv=letkx=matchxwith|Cv1->letv1=v_constantv1in()|Guil((v1,v2,v3))->letv1=v_tokv1andv2=v_listv_encapsv2andv3=v_tokv3in()|HereDoc((v1,v2,v3))->letv1=v_tokv1andv2=v_listv_encapsv2andv3=v_tokv3in()invin.kscalar(k,all_functions)vandv_static_scalarx=v_exprxandv_static_scalar_affect(v1,v2)=letv1=v_tokv1andv2=v_static_scalarv2in()andv_constantx=letkx=matchxwith|Cst_php.Intv1->letv1=v_wrapv_stringv1in()|Doublev1->letv1=v_wrapv_stringv1in()|Stringv1->letv1=v_wrapv_stringv1in()|PreProcessv1->letv1=v_wrapv_cpp_directivev1in()|XdebugClass((v1,v2))->letv1=v_namev1andv2=v_listv_class_stmtv2in()|XdebugResource->()invin.kconstant(k,all_functions)xandv_cpp_directive=function|Line->()|File->()|Dir->()|ClassC->()|MethodC->()|FunctionC->()|TraitC->()|NamespaceC->()andv_encapsx=letkx=matchxwith|EncapsStringv1->letv1=v_wrapv_stringv1in()|EncapsVarv1->letv1=v_lvaluev1in()|EncapsCurly((v1,v2,v3))->letv1=v_tokv1andv2=v_lvaluev2andv3=v_tokv3in()|EncapsDollarCurly((v1,v2,v3))->letv1=v_tokv1andv2=v_lvaluev2andv3=v_tokv3in()|EncapsExpr((v1,v2,v3))->letv1=v_tokv1andv2=v_exprv2andv3=v_tokv3in()invin.kencaps(k,all_functions)xandv_fixOp_op=()andv_binaryOp=function|Arithv1->letv1=v_arithOpv1in()|Logicalv1->letv1=v_logicalOpv1in()|BinaryConcat->()|Pipe->()|CombinedComparison->()andv_arithOp=function|Plus->()|Minus->()|Mul->()|Div->()|Mod->()|DecLeft->()|DecRight->()|And->()|Or->()|Xor->()andv_logicalOp=function|Inf->()|Sup->()|InfEq->()|SupEq->()|Eq->()|NotEq->()|Identical->()|NotIdentical->()|AndLog->()|OrLog->()|XorLog->()|AndBool->()|OrBool->()andv_assignOp=function|AssignOpArithv1->letv1=v_arithOpv1in()|AssignConcat->()andv_unaryOp=function|UnPlus->()|UnMinus->()|UnBang->()|UnTilde->()andv_castOpv=v_ptypevandv_class_name_referencex=v_exprxandv_list_assign=function|ListVarv1->letv1=v_lvaluev1in()|ListList((v1,v2))->letv1=v_tokv1andv2=v_paren(v_comma_listv_list_assign)v2in()|ListEmpty->()andv_array_pairx=letkx=matchxwith|ArrayExprv1->letv1=v_exprv1in()|ArrayRef((v1,v2))->letv1=v_tokv1andv2=v_lvaluev2in()|ArrayArrowExpr((v1,v2,v3))->letv1=v_exprv1andv2=v_tokv2andv3=v_exprv3in()|ArrayArrowRef((v1,v2,v3,v4))->letv1=v_exprv1andv2=v_tokv2andv3=v_tokv3andv4=v_lvaluev4in()invin.karray_pair(k,all_functions)xandv_xhp_htmlx=letkx=matchxwith|Xhp((v1,v2,v3,v4,v5))->letv1=v_xhp_tag_wrapv1andv2=v_listv_xhp_attributev2andv3=v_tokv3andv4=v_listv_xhp_bodyv4andv5=v_wrap(v_optionv_xhp_tag)v5in()|XhpSingleton((v1,v2,v3))->letv1=v_xhp_tag_wrapv1andv2=v_listv_xhp_attributev2andv3=v_tokv3in()invin.kxhp_html(k,all_functions)xandv_xhp_attributex=letk(v1,v2,v3)=letv1=v_xhp_attr_namev1andv2=v_tokv2andv3=v_xhp_attr_valuev3in()invin.kxhp_attribute(k,all_functions)xandv_xhp_attr_namev=v_wrapv_stringvandv_xhp_attr_value=function|XhpAttrString((v1,v2,v3))->letv1=v_tokv1andv2=v_listv_encapsv2andv3=v_tokv3in()|XhpAttrExprv1->letv1=v_bracev_exprv1in()|SgrepXhpAttrValueMvarv1->letv1=v_wrapv_stringv1in()andv_xhp_body=function|XhpTextv1->letv1=v_wrapv_stringv1in()|XhpExprv1->letv1=v_bracev_exprv1in()|XhpNestedv1->letv1=v_xhp_htmlv1in()andv_lvaluex=v_exprxandv_argumentsx=letkx=v_paren(v_comma_listv_argument)xinvin.karguments(k,all_functions)xandv_argumentx=letk=function|Argv1->letv1=v_exprv1in()|ArgUnpack((v1,v2))->letv1=v_tokv1andv2=v_exprv2in()|ArgRef((v1,v2))->letv1=v_tokv1andv2=v_w_variablev2in()invin.kargument(k,all_functions)xandv_rw_variablev=v_lvaluevandv_r_variablev=v_lvaluevandv_w_variablev=v_lvaluevandv_stmtxxx=(* tweak *)letkxxx=matchxxxwith|ExprStmt((v1,v2))->letv1=v_exprv1andv2=v_tokv2in()|EmptyStmtv1->letv1=v_tokv1in()|Blockv1->letv1=v_brace(v_stmt_and_def_list_scope)v1in()|If((v1,v2,v3,v4,v5))->letv1=v_tokv1andv2=v_parenv_exprv2andv3=v_stmtv3andv4=v_listv_elseifv4andv5=v_optionv_xelsev5in()|IfColon((v1,v2,v3,v4,v5,v6,v7,v8))->letv1=v_tokv1andv2=v_parenv_exprv2andv3=v_tokv3andv4=v_stmt_and_def_list_scopev4andv5=v_listv_new_elseifv5andv6=v_optionv_new_elsev6andv7=v_tokv7andv8=v_tokv8in()|While((v1,v2,v3))->letv1=v_tokv1andv2=v_parenv_exprv2andv3=v_colon_stmtv3in()|Do((v1,v2,v3,v4,v5))->letv1=v_tokv1andv2=v_stmtv2andv3=v_tokv3andv4=v_parenv_exprv4andv5=v_tokv5in()|For((v1,v2,v3,v4,v5,v6,v7,v8,v9))->letv1=v_tokv1andv2=v_tokv2andv3=v_for_exprv3andv4=v_tokv4andv5=v_for_exprv5andv6=v_tokv6andv7=v_for_exprv7andv8=v_tokv8andv9=v_colon_stmtv9in()|Switch((v1,v2,v3))->letv1=v_tokv1andv2=v_parenv_exprv2andv3=v_switch_case_listv3in()|Foreach((v1,v2,v3,v4,v5,v6,v7,v8))->letv1=v_tokv1andv2=v_tokv2andv3=v_exprv3andv4=v_optionv_tokv4andv5=v_tokv5andv6=v_foreach_patternv6andv7=v_tokv7andv8=v_colon_stmtv8in()|Break((v1,v2,v3))->letv1=v_tokv1andv2=v_optionv_exprv2andv3=v_tokv3in()|Continue((v1,v2,v3))->letv1=v_tokv1andv2=v_optionv_exprv2andv3=v_tokv3in()|Return((v1,v2,v3))->letv1=v_tokv1andv2=v_optionv_exprv2andv3=v_tokv3in()|Throw((v1,v2,v3))->letv1=v_tokv1andv2=v_exprv2andv3=v_tokv3in()|Try((v1,v2,v3,v4))->letv1=v_tokv1andv2=v_brace(v_stmt_and_def_list_scope)v2andv3=v_listv_catchv3andv4=v_listv_finallyv4in()|Echo((v1,v2,v3))->letv1=v_tokv1andv2=v_comma_listv_exprv2andv3=v_tokv3in()|InlineHtml(v1)->letv1=v_wrapv_stringv1in()|Globals((v1,v2,v3))->letv1=v_tokv1andv2=v_comma_listv_global_varv2andv3=v_tokv3in()|StaticVars((v1,v2,v3))->letv1=v_tokv1andv2=v_comma_listv_static_varv2andv3=v_tokv3in()|Use((v1,v2,v3))->letv1=v_tokv1andv2=v_use_filenamev2andv3=v_tokv3in()|Unset((v1,v2,v3))->letv1=v_tokv1andv2=v_paren(v_comma_listv_lvalue)v2andv3=v_tokv3in()|Declare((v1,v2,v3))->letv1=v_tokv1andv2=v_paren(v_comma_listv_declare)v2andv3=v_colon_stmtv3in()|FuncDefNestedv1->letv1=v_func_defv1in()|ClassDefNestedv1->letv1=v_class_defv1in()invin.kstmt(k,all_functions)xxxandv_colon_stmt=function|SingleStmtv1->letv1=v_stmtv1in()|ColonStmt((v1,v2,v3,v4))->letv1=v_tokv1andv2=v_stmt_and_def_list_scopev2andv3=v_tokv3andv4=v_tokv4in()andv_elseif(v1,v2,v3)=letv1=v_tokv1andv2=v_parenv_exprv2andv3=v_stmtv3in()andv_xelse(v1,v2)=letv1=v_tokv1andv2=v_stmtv2in()andv_new_elseif(v1,v2,v3,v4)=letv1=v_tokv1andv2=v_parenv_exprv2andv3=v_tokv3andv4=v_stmt_and_def_list_scopev4in()andv_new_else(v1,v2,v3)=letv1=v_tokv1andv2=v_tokv2andv3=v_stmt_and_def_list_scopev3in()andv_for_exprv=v_comma_listv_exprvandv_foreach_pattern=function|ForeachVarv1->letv1=v_foreach_variablev1in()|ForeachArrow((v1,v2,v3))->letv1=v_foreach_patternv1andv2=v_tokv2andv3=v_foreach_patternv3in()|ForeachList((v1,v2))->letv1=v_tokv1andv2=v_paren(v_comma_listv_list_assign)v2in()andv_foreach_variable(v1,v2)=letv1=v_is_refv1andv2=v_lvaluev2in()andv_switch_case_list=function|CaseList((v1,v2,v3,v4))->letv1=v_tokv1andv2=v_optionv_tokv2andv3=v_listv_casev3andv4=v_tokv4in()|CaseColonList((v1,v2,v3,v4,v5))->letv1=v_tokv1andv2=v_optionv_tokv2andv3=v_listv_casev3andv4=v_tokv4andv5=v_tokv5in()andv_case=function|Case((v1,v2,v3,v4))->letv1=v_tokv1andv2=v_exprv2andv3=v_tokv3andv4=v_stmt_and_def_list_scopev4in()|Default((v1,v2,v3))->letv1=v_tokv1andv2=v_tokv2andv3=v_stmt_and_def_list_scopev3in()andv_catchx=letkx=let(v1,v2,v3)=xinletv1=v_tokv1andv2=v_paren(fun(v1,v2)->letv1=v_fully_qualified_class_namev1andv2=v_dnamev2in())v2andv3=v_brace(v_stmt_and_def_list_scope)v3in()invin.kcatch(k,all_functions)xandv_finallyx=letkx=let(v1,v2)=xinletv1=v_tokv1andv2=v_brace(v_stmt_and_def_list_scope)v2in()invin.kfinally(k,all_functions)xandv_use_filename=function|UseDirectv1->letv1=v_wrapv_stringv1in()|UseParenv1->letv1=v_paren(v_wrapv_string)v1in()andv_declare(v1,v2)=letv1=v_identv1andv2=v_static_scalar_affectv2in()andv_func_defx=letkx=matchxwith{f_tok=v_f_tok;f_type=v_f_type;f_attrs=v_f_attrs;f_modifiers=v_f_modifiers;f_ref=v_f_ref;f_tparams=v_f_tparams;f_name=v_f_name;f_params=v_f_params;f_body=v_f_body;f_return_type=v_f_return_type;}->letarg=v_tokv_f_tokinletarg=v_optionv_attributesv_f_attrsinletarg=v_function_typev_f_typeinletarg=v_list(v_wrapv_modifier)v_f_modifiersinletarg=v_is_refv_f_refinletarg=v_identv_f_nameinletarg=v_optionv_type_paramsv_f_tparamsinletarg=v_parametersv_f_paramsinletarg=v_bodyv_f_bodyinletarg=v_option(fun(v1,v2,v3)->letv1=v_tokv1andv2=v_optionv_tokv2andv3=v_hint_typev3in())v_f_return_typein()invin.kfunc_def(k,all_functions)xandv_function_type=function|FunctionRegular->()|FunctionLambda->()|MethodRegular->()|MethodAbstract->()andv_parameterx=letkx=matchxwith{p_attrs=v_p_attrs;p_modifier=v_p_modifier;p_soft_type=v_p_soft_type;p_type=v_p_type;p_ref=v_p_ref;p_name=v_p_name;p_default=v_p_default;p_variadic=v_p_variadic}->letarg=v_optionv_attributesv_p_attrsinletarg=v_option(v_wrapv_modifier)v_p_modifierinletarg=v_optionv_hint_typev_p_typeinletarg=v_optionv_tokv_p_soft_typeinletarg=v_is_refv_p_refinletarg=v_dnamev_p_nameinletarg=v_optionv_static_scalar_affectv_p_defaultinletarg=v_optionv_tokv_p_variadicin()invin.kparameter(k,all_functions)xandv_hint_typex=letkx=matchxwith|Hint(v1,v2)->letv1=v_class_name_or_selfparentv1inletv2=v_optionv_type_argsv2in()|HintArrayv1->letv1=v_tokv1in()|HintQuestion(v1,v2)->letv1=v_tokv1inletv2=v_hint_typev2in()|HintTuplev1->letv1=v_paren(v_comma_listv_hint_type)v1in()|HintCallbackv1->letv1=v_paren(fun(v1,v2,v3)->letv1=v_tokv1andv2=v_paren(v_comma_list_dotsv_hint_type)v2andv3=v_option(fun(v1,v2,v3)->letv1=v_tokv1andv2=v_optionv_tokv2andv3=v_hint_typev3in())v3in())v1in()|HintShape((v1,v2))->letv1=v_tokv1andv2=v_paren(v_comma_list(fun(v1,v2,v3)->letv1=v_exprv1andv2=v_tokv2andv3=v_hint_typev3in()))v2in()|HintTypeConst((v1,v2,v3))->letv1=v_hint_typev1andv2=v_tokv2andv3=v_hint_typev3in()|HintVariadic(v1,v2)->letv1=v_tokv1andv2=v_optionv_hint_typev2in()invin.khint_type(k,all_functions)xandv_is_refv=v_optionv_tokvandv_constraint(v1,v2)=letv1=v_tokv1inletv2=v_hint_typev2in()andv_enum_type{e_tok=v_e_tok;e_base=v_e_base;e_constraint=v_e_constraint;}=letv1=v_tokv_e_tokinletv2=v_hint_typev_e_baseinletv3=v_optionv_constraintv_e_constraintin()andv_class_defx=letk{c_type=v_c_type;c_name=v_c_name;c_tparams=v_c_tparams;c_extends=v_c_extends;c_implements=v_c_implements;c_body=v_c_body;c_attrs=v_c_attrs;c_enum_type=v_c_enum_type;}=letarg=v_class_typev_c_typeinletarg=v_identv_c_nameinletarg=v_optionv_type_paramsv_c_tparamsinletarg=v_optionv_extendv_c_extendsinletarg=v_optionv_interfacev_c_implementsinletarg=v_brace(v_listv_class_stmt)v_c_bodyinletarg=v_optionv_attributesv_c_attrsinletarg=v_optionv_enum_typev_c_enum_typein()invin.kclass_def(k,all_functions)xandv_class_type=function|ClassRegularv1->letv1=v_tokv1in()|ClassFinal((v1,v2))->letv1=v_tokv1andv2=v_tokv2in()|ClassAbstract((v1,v2))->letv1=v_tokv1andv2=v_tokv2in()|ClassAbstractFinal((v1,v2,v3))->letv1=v_tokv1andv2=v_tokv2andv3=v_tokv3in()|Interfacev1->letv1=v_tokv1in()|Traitv1->letv1=v_tokv1in()|Enumv1->letv1=v_tokv1in()andv_extend(v1,v2)=letv1=v_tokv1andv2=v_fully_qualified_class_namev2in()andv_interface(v1,v2)=letv1=v_tokv1andv2=v_comma_listv_fully_qualified_class_namev2in()andv_class_stmtx=letkx=matchxwith|TraitConstraint((v1,v2,v3,v4))->letv1=v_tokv1andv2=v_wrapv_trait_constraint_kindv2andv3=v_hint_typev3andv4=v_tokv4in()|ClassType((v1))->letv1=v_type_defv1in()|ClassConstants((v1,v2,opt_ty,v3,v4))->letv1=v_optionv_tokv1andv2=v_tokv2andopt_ty=v_optionv_hint_typeopt_tyandv3=v_comma_listv_class_constantv3andv4=v_tokv4in()|ClassVariables((v1,opt_ty,v2,v3))->letv1=v_class_var_modifierv1andopt_ty=v_optionv_hint_typeopt_tyandv2=v_comma_listv_class_variablev2andv3=v_tokv3in()|Methodv1->letv1=v_method_defv1in()|XhpDeclv1->letv1=v_xhp_declv1in()|UseTrait(v1,v2,v3)->letv1=v_tokv1inletv2=v_comma_listv_fully_qualified_class_namev2inletv3=Ocaml.v_eitherv_tok(v_brace(v_listv_trait_rule))v3in()invin.kclass_stmt(k,all_functions)xandv_trait_constraint_kind=function|MustExtend->()|MustImplement->()andv_trait_rule=function|InsteadOf((v1,v2,v3,v4,v5,v6))->letv1=v_namev1andv2=v_tokv2andv3=v_identv3andv4=v_tokv4andv5=v_comma_listv_class_namev5andv6=v_tokv6in()|As((v1,v2,v3,v4,v5))->letv1=Ocaml.v_eitherv_ident(fun(v1,v2,v3)->letv1=v_namev1andv2=v_tokv2andv3=v_identv3in())v1andv2=v_tokv2andv3=v_list(v_wrapv_modifier)v3andv4=v_optionv_identv4andv5=v_tokv5in()andv_xhp_declx=matchxwith|XhpAttributesDecl((v1,v2,v3))->letv1=v_tokv1andv2=v_comma_listv_xhp_attribute_declv2andv3=v_tokv3in()|XhpChildrenDecl((v1,v2,v3))->letv1=v_tokv1andv2=v_xhp_children_declv2andv3=v_tokv3in()|XhpCategoriesDecl((v1,v2,v3))->letv1=v_tokv1andv2=v_comma_listv_xhp_category_declv2andv3=v_tokv3in()andv_class_constant(v1,v2)=letv1=v_identv1andv2=v_optionv_static_scalar_affectv2in()andv_class_var_modifier=function|NoModifiersv1->letv1=v_tokv1in()|VModifiersv1->letv1=v_list(v_wrapv_modifier)v1in()andv_class_variable(v1,v2)=letv1=v_dnamev1andv2=v_optionv_static_scalar_affectv2in()andv_method_defx=letkx=v_func_defxinvin.kmethod_def(k,all_functions)xandv_modifier=function|Public->()|Private->()|Protected->()|Static->()|Abstract->()|Final->()|Async->()andv_xhp_attribute_declx=letkx=matchxwith|XhpAttrInheritv1->letv1=v_xhp_tag_wrapv1in()|XhpAttrDecl((v1,v2,v3,v4))->letv1=v_xhp_attribute_typev1andv2=v_xhp_attr_namev2andv3=v_optionv_xhp_value_affectv3andv4=v_optionv_tokv4in()invin.kxhp_attr_decl(k,all_functions)xandv_xhp_attribute_type=function|XhpAttrTypev1->letv1=v_hint_typev1in()|XhpAttrVarv1->letv1=v_tokv1in()|XhpAttrEnum((v1,v2))->letv1=v_tokv1andv2=v_brace(v_comma_listv_constant)v2in()andv_xhp_value_affect(v1,v2)=letv1=v_tokv1andv2=v_static_scalarv2in()andv_xhp_children_declx=letkx=matchxwith|XhpChildv1->letv1=v_xhp_tag_wrapv1in()|XhpChildCategoryv1->letv1=v_xhp_tag_wrapv1in()|XhpChildAnyv1->letv1=v_tokv1in()|XhpChildEmptyv1->letv1=v_tokv1in()|XhpChildPcdatav1->letv1=v_tokv1in()|XhpChildSequence((v1,v2,v3))->letv1=v_xhp_children_declv1andv2=v_tokv2andv3=v_xhp_children_declv3in()|XhpChildAlternative((v1,v2,v3))->letv1=v_xhp_children_declv1andv2=v_tokv2andv3=v_xhp_children_declv3in()|XhpChildMul((v1,v2))->letv1=v_xhp_children_declv1andv2=v_tokv2in()|XhpChildOption((v1,v2))->letv1=v_xhp_children_declv1andv2=v_tokv2in()|XhpChildPlus((v1,v2))->letv1=v_xhp_children_declv1andv2=v_tokv2in()|XhpChildParenv1->letv1=v_parenv_xhp_children_declv1in()invin.kxhp_children_decl(k,all_functions)xandv_xhp_category_declv=v_xhp_tag_wrapvandv_global_var=function|GlobalVarv1->letv1=v_dnamev1in()|GlobalDollar((v1,v2))->letv1=v_tokv1andv2=v_r_variablev2in()|GlobalDollarExpr((v1,v2))->letv1=v_tokv1andv2=v_bracev_exprv2in()andv_static_var(v1,v2)=letv1=v_dnamev1andv2=v_optionv_static_scalar_affectv2in()andv_topstatementx=v_stmtxandv_bodyx=v_brace(v_stmt_and_def_list_scope)xandv_stmt_and_def_list_scopex=letkx=v_listv_topstatementxinvin.kstmt_and_def_list_scope(k,all_functions)xandv_constant_def{cst_toks=v_cst_toks;cst_name=v_cst_name;cst_type=v_cst_type;cst_val=v_cst_val}=letarg=matchv_cst_tokswith|(v1,v2,v3)->letv1=v_tokv1andv2=v_tokv2andv3=v_tokv3in()inletarg=v_identv_cst_nameinletarg=v_optionv_hint_typev_cst_typeinletarg=v_static_scalarv_cst_valin()andv_attribute=function|Attributev1->letv1=v_wrapv_stringv1in()|AttributeWithArgs((v1,v2))->letv1=v_wrapv_stringv1andv2=v_paren(v_comma_listv_static_scalar)v2in()andv_attributesv=v_angle(v_comma_listv_attribute)vandv_type_def{t_tok=v_t_tok;t_name=v_t_name;t_tparams=v_t_tparams;t_tconstraint=v_t_tconstraint;t_tokeq=v_t_tokeq;t_kind=v_t_kind;t_sc=v_t_sc}=letarg=v_tokv_t_tokinletarg=v_identv_t_nameinletarg=v_optionv_type_paramsv_t_tparamsinletarg=v_optionv_constraintv_t_tconstraintinletarg=v_tokv_t_tokeqinletarg=v_type_def_kindv_t_kindinletarg=v_tokv_t_scin()andv_type_def_kind=function|Aliasv1->letv1=v_hint_typev1in()|Newtypev1->letv1=v_hint_typev1in()|ClassConstTypev1->letv1=v_optionv_hint_typev1in()andv_namespace_use_rule=function|ImportNamespacev1->letv1=v_qualified_identv1in()|AliasNamespace((v1,v2,v3))->letv1=v_qualified_identv1andv2=v_tokv2andv3=v_identv3in()andv_toplevelx=letkx=matchxwith|StmtListv1->letv1=v_listv_stmtv1in()|FuncDefv1->letv1=v_func_defv1in()|ClassDefv1->letv1=v_class_defv1in()|ConstantDefv1->letv1=v_constant_defv1in()|TypeDefv1->letv1=v_type_defv1in()|NotParsedCorrectlyxs->v_listv_infoxs|FinalDefv1->v_infov1|NamespaceDef((v1,v2,v3))->letv1=v_tokv1andv2=v_qualified_identv2andv3=v_tokv3in()|NamespaceBracketDef((v1,v2,v3))->letv1=v_tokv1andv2=v_optionv_qualified_identv2andv3=v_brace(v_listv_toplevel)v3in()|NamespaceUse((v1,v2,v3))->letv1=v_tokv1andv2=v_comma_listv_namespace_use_rulev2andv3=v_tokv3in()invin.ktop(k,all_functions)xandv_programv=v_listv_toplevelvandv_entity=function|FunctionEv1->letv1=v_func_defv1in()|ClassEv1->letv1=v_class_defv1in()|ConstantEv1->letv1=v_constant_defv1in()|TypedefEv1->letv1=v_type_defv1in()|StmtListEv1->letv1=v_listv_stmtv1in()|MethodEv1->letv1=v_method_defv1in()|ClassConstantEv1->letv1=v_class_constantv1in()|ClassVariableE((v1,v2))->letv1=v_class_variablev1andv2=v_listv_modifierv2in()|XhpAttrEv1->letv1=v_xhp_attribute_declv1in()|MiscEv1->letv1=v_listv_infov1in()andv_any=function|Exprv1->letv1=v_exprv1in()|Stmt2v1->letv1=v_stmtv1in()|Toplevelv1->letv1=v_toplevelv1in()|Programv1->letv1=v_programv1in()|Entityv1->letv1=v_entityv1in()|Argumentv1->letv1=v_argumentv1in()|Argumentsv1->letv1=(v_comma_listv_argument)v1in()|Parameterv1->letv1=v_parameterv1in()|Parametersv1->letv1=v_paren(v_comma_list_dotsv_parameter)v1in()|ClassStmtv1->letv1=v_class_stmtv1in()|ClassConstant2v1->letv1=v_class_constantv1in()|ClassVariablev1->letv1=v_class_variablev1in()|Bodyv1->letv1=v_brace(v_listv_topstatement)v1in()|StmtAndDefsv1->letv1=v_listv_topstatementv1in()|ListAssignv1->letv1=v_list_assignv1in()|XhpAttributev1->letv1=v_xhp_attributev1in()|XhpAttrValuev1->letv1=v_xhp_attr_valuev1in()|XhpHtml2v1->letv1=v_xhp_htmlv1in()|XhpChildrenDecl2v1->letv1=v_xhp_children_declv1in()|Infov1->letv1=v_infov1in()|InfoListv1->letv1=v_listv_infov1in()|ColonStmt2v1->letv1=v_colon_stmtv1in()|Case2v1->letv1=v_casev1in()|Ident2v1->letv1=v_identv1in()|Hint2v1->letv1=v_hint_typev1in()(* end of auto generation *)andall_functionsx=v_anyxinv_any(*****************************************************************************)(* Helpers *)(*****************************************************************************)letdo_visit_with_refmk_hooks=funany->letres=ref[]inlethooks=mk_hooksresinletvout=mk_visitorhooksinvoutany;List.rev!res