Source

(* This help to manage param *)type'avalue=None|Someof'aexceptionNoValueexceptionNotImplementedofstringletgetValuev=matchvwithSomea->a|None->raiseNoValue(* Begin of the visitor class*)classvisitor=object(this)(* Complet this accept *)methodacceptFunctionDefinitiondecspedecdec_listcs=();if(decspe<>None)then();if(dec_list<>None)then();()methodacceptTranslationUnittued=if(tu<>None)thenthis#visitTranslationUnit(getValuetu);this#visitExternalDeclaration(getValueed)methodvisitFunctionDefinitionast=matchastwithAst.FUN_spec_dec_list(decspe,dec,dec_list,cs)->this#acceptFunctionDefinition(Somedecspe)(Somedec)(Somedec_list)(Somecs)|Ast.FUN_spec_dec(decspe,dec,cs)->this#acceptFunctionDefinition(Somedecspe)(Somedec)None(Somecs)|Ast.FUN_dec_list(dec,dec_list,cs)->this#acceptFunctionDefinitionNone(Somedec)(Somedec_list)(Somecs)|Ast.FUN_dec(dec,cs)->this#acceptFunctionDefinitionNone(Somedec)None(Somecs)(* Here i visite directly, but why not? *)methodvisitExternalDeclarationast=matchastwithAst.ED_fun_def(fd)->this#visitFunctionDefinitionfd|Ast.ED_dec(dec)->raise(NotImplemented"ED_dec")methodvisitTranslationUnitast=matchastwithAst.TU_dec(ed)->this#acceptTranslationUnitNone(Someed)|Ast.TU_tans(tu,ed)->this#acceptTranslationUnit(Sometu)(Someed)|Ast.None->()endclassprettyPrintVisitor=object(this)inheritvisitorasoldmethodacceptFunctionDefinitionabcd=print_endline"Function";old#acceptFunctionDefinitionabcdend