Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file clim_ppx.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412openPpxlibletlabel_aka_attribute=Attribute.declare"cmdliner.aka"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_doc_attribute=Attribute.declare"cmdliner.doc"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_docv_attribute=Attribute.declare"cmdliner.docv"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_env_docs_attribute=Attribute.declare"cmdliner.env.docs"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_env_doc_attribute=Attribute.declare"cmdliner.env.doc"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_env_attribute=Attribute.declare"cmdliner.env"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_docs_attribute=Attribute.declare"cmdliner.docs"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_default_attribute=Attribute.declare"cmdliner.default"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_pos_attribute=Attribute.declare"cmdliner.pos"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_enum_attribute=Attribute.declare"cmdliner.enum"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letlabel_sep_attribute=Attribute.declare"cmdliner.sep"Attribute.Context.label_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)lettype_xrefs_attribute=Attribute.declare"cmdliner.xrefs"Attribute.Context.type_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)lettype_man_attribute=Attribute.declare"cmdliner.man"Attribute.Context.type_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)lettype_envs_attribute=Attribute.declare"cmdliner.envs"Attribute.Context.type_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)lettype_doc_attribute=Attribute.declare"cmdliner.doc"Attribute.Context.type_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)lettype_version_attribute=Attribute.declare"cmdliner.version"Attribute.Context.type_declarationAst_pattern.(single_expr_payload__)(funexpr->expr)letattributes=[Attribute.Tlabel_aka_attribute;Attribute.Tlabel_doc_attribute;Attribute.Tlabel_doc_attribute;Attribute.Tlabel_env_docs_attribute;Attribute.Tlabel_env_doc_attribute;Attribute.Tlabel_env_attribute;Attribute.Tlabel_docs_attribute;Attribute.Tlabel_default_attribute;Attribute.Tlabel_pos_attribute;Attribute.Tlabel_enum_attribute;Attribute.Tlabel_enum_attribute;Attribute.Ttype_xrefs_attribute;Attribute.Ttype_man_attribute;Attribute.Ttype_envs_attribute;Attribute.Ttype_doc_attribute;Attribute.Ttype_version_attribute;]letopt:loc:Location.t->expressionoption->expression=fun~loc->function|None->[%exprNone]|Some[%expr[%e?e]]->[%exprSome[%ee]]letrecocaml_doc:attributes->(string*Location.t)option=function|[]->None|{attr_name={txt=name;_};attr_payload=PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant(Pconst_string(doc_str,_));_},_);_}];attr_loc}::others->ifname="ocaml.doc"thenSome(doc_str,attr_loc)elseocaml_docothers|_::others->ocaml_docothersletlabel_aka:label_declaration->expression=funlabel->letloc=label.pld_locinmatchAttribute.getlabel_aka_attributelabelwith|Some[%expr[%e?names]]->names|_->(* default: use label name and its first character *)letname=label.pld_name.txtinletfirst=String.make1name.[0]in(* can't fail *)letename=Ast_builder.Default.(elist~loc[estring~locfirst;estring~locname])in[%expr[%eename]]letlabel_doc:label_declaration->expression=funlabel->letloc=label.pld_locinmatchAttribute.getlabel_doc_attributelabelwith|Some[%expr[%e?doc]]->[%exprSome[%edoc]]|_->beginmatchocaml_doclabel.pld_attributeswith|None->[%exprNone]|Some(doc,loc)->lettrim_doc=String.trimdocinletedoc=Ast_builder.Default.estring~loctrim_docin[%exprSome[%eedoc]]endletlabel_env_docs:label_declaration->expression=funlabel->letloc=label.pld_locinmatchAttribute.getlabel_env_docs_attributelabelwith|None->[%exprNone]|Some[%expr[%e?section]]->[%exprSome[%esection]]letlabel_env_doc:label_declaration->expression=funlabel->letloc=label.pld_locinmatchAttribute.getlabel_env_doc_attributelabelwith|None->[%exprNone]|Some[%expr[%e?doc]]->[%exprSome[%edoc]]letlabel_env:label_declaration->expression=funlabel->letloc=label.pld_locinmatchAttribute.getlabel_env_attributelabelwith|None->[%exprNone]|Some[%expr[%e?var]]->letdocs=label_env_docslabelinletdoc=label_env_doclabelin[%exprSome(Cmdliner.Arg.env_var?docs:[%edocs]?doc:[%edoc][%evar])]letlabel_docs:label_declaration->expression=funlabel->letloc=label.pld_locinmatchAttribute.getlabel_docs_attributelabelwith|None->[%exprNone]|Some[%expr[%e?section]]->[%exprSome[%esection]]letlabel_infos:label_declaration->expression=funlabel->letloc=label.pld_locinletaka=label_akalabelinletdocs=label_docslabelinletdoc=label_doclabelinletdocv=opt~loc:label.pld_loc@@Attribute.getlabel_docv_attributelabelinletenv=label_envlabelin[%exprletdocs=[%edocs]inletdoc=[%edoc]inletdocv=[%edocv]inletenv=[%eenv]inCmdliner.Arg.info?docs?doc?docv?env[%eaka]]letexpr_opt:loc:Location.t->expressionoption->expression=fun~loce->matchewith|None->[%exprNone]|Someexp->[%exprSome[%eexp]]letrecconverter:sep:expression->core_type->expression=fun~septyp->letloc=typ.ptyp_locinmatchtypwith|[%type:bool]->[%exprbool]|[%type:char]->[%exprchar]|[%type:int]->[%exprint]|[%type:nativeint]->[%exprnativeint]|[%type:int32]->[%exprint32]|[%type:int64]->[%exprint64]|[%type:float]->[%exprfloat]|[%type:string]->[%exprstring]|[%type:[%t?a]list]->[%exprlist?sep:[%esep][%econverter~sepa]]|[%type:[%t?a]array]->[%exprarray?sep:[%esep][%econverter~sepa]]|[%type:[%t?a]*[%t?b]]->[%exprt2[%econverter~sepa][%econverter~sepb]]|[%type:[%t?a]*[%t?b]*[%t?c]]->[%exprt3[%econverter~sepa][%econverter~sepb][%econverter~sepc]]|[%type:[%t?a]*[%t?b]*[%t?c]*[%t?d]]->[%exprt4[%econverter~sepa][%econverter~sepb][%econverter~sepc][%econverter~sepd]]|_->Location.raise_errorf~loc"cmdliner: don't know what to do with %a"Pprintast.core_typetypletlabel_conv:label_declaration->expression=funlabel->letloc=label.pld_locinmatchAttribute.getlabel_enum_attributelabelwith|None->letsep=expr_opt~loc@@Attribute.getlabel_sep_attributelabelinconverter~seplabel.pld_type|Some[%expr[%e?enum_list]]->[%exprenum[%eenum_list]]letlabel_term:label_declaration->expression=funlabel->letloc=label.pld_locinletinfos=label_infoslabelinletdefault_attr=Attribute.getlabel_default_attributelabelinletpos_attr=Attribute.getlabel_pos_attributelabelinletconv=label_convlabelinletterm=matchdefault_attr,pos_attr,label.pld_typewith|None,None,[%type:bool]->(* special case: boolean flag *)[%exprvalue&flaginfos]|None,None,[%type:[%t?_]list]->(* optional argument: special list case which can be specified in several chunks
with a empty list as default *)[%exprCmdliner.Term.(constList.concat$(value&opt_all[%econv][]&infos))]|None,None,_->(* required opt *)[%exprrequired&opt(some[%econv])None&infos]|None,Some[%expr[%e?index]],_->(* required pos *)[%exprrequired&pos[%eindex](some[%econv])None&infos]|Some[%expr[%e?default]],None,[%type:[%t?_]list]->(* optional argument: special list case which can be specified in several chunks *)[%exprCmdliner.Term.(constList.concat$(value&opt_all[%econv][%edefault]&infos))]|Some[%expr[%e?default]],None,_->(* optional argument *)[%exprvalue&opt[%econv][%edefault]&infos]|Some[%expr[%e?default]],Some[%expr[%e?index]],_->(* optional pos: don't understand clearly what this
means but i still forward to cmdliner... *)[%exprvalue&pos[%eindex][%econv][%edefault]&infos]in[%exprletinfos=[%einfos]inCmdliner.Arg.([%eterm])]letsuffix="cmdliner_t"lettype_env~loctd=matchAttribute.gettype_envs_attributetdwith|None->[%exprNone]|Somel->letrecenvs=function|[%expr[]]->[%expr[]]|[%expr([%e?name],[%e?doc],[%e?docs])::[%e?t]]->[%exprTerm.env_info?docs:[%edocs]?doc:[%edoc][%ename]::[%eenvst]]|e->Location.raise_errorf~loc"cmdliner: don't know what to do with %a"Pprintast.expressionein[%exprSome[%eenvsl]]lettype_doc:type_declaration->expression=funtd->letloc=td.ptype_locinmatchAttribute.gettype_doc_attributetdwith|Some[%expr[%e?doc]]->[%exprSome[%edoc]]|_->beginmatchocaml_doctd.ptype_attributeswith|None->[%exprNone]|Some(doc,loc)->lettrim_doc=String.trimdocinletedoc=Ast_builder.Default.estring~loctrim_docin[%exprSome[%eedoc]]endletexpand_str_type_decl:loc:Location.t->type_declaration->structure=fun~loctype_decl->matchtype_declwith|{ptype_name={txt=type_name;loc=type_name_loc};ptype_kind=Ptype_recordlabels;ptype_loc;_}->(* record *)letprefix=matchtype_namewith|"t"->""|_->Fmt.str"%s_"type_namein(* generate args *)letargs=List.map(funlabel->letlabel_id=Fmt.str"%s%s_%s"prefixlabel.pld_name.txtsuffixinletplabel_id=Ast_builder.Default.pvar~loclabel_idinlabel_id,[%strilet[%pplabel_id]=[%elabel_termlabel]])labelsin(* generate type's term *)lettype_id=Fmt.str"%s%s"prefixsuffixinletptype_id=Ast_builder.Default.pvar~loc:type_name_loctype_idinletfinal_record=Ast_builder.Default.pexp_record~loc(List.map(funlabel->letlid={txt=Lidentlabel.pld_name.txt;loc=label.pld_name.loc}inletexp=Ast_builder.Default.evar~loc:label.pld_name.loclabel.pld_name.txtinlid,exp)labels)Noneinletmk_exp=List.fold_right(funlabelexp->letplabel=Ast_builder.Default.pvar~loc:label.pld_name.loclabel.pld_name.txtinAst_builder.Default.pexp_fun~locNolabelNoneplabelexp)labelsfinal_recordinletfinal_app=List.fold_left(funexp(lbl_t,_)->lete_lbl_t=Ast_builder.Default.evar~loclbl_tin[%expr[%eexp]$[%ee_lbl_t]])[%exprconstmk]argsin(* generate cmdliner function *)letetype_id=Ast_builder.Default.evar~loc:type_name_loctype_idinletxrefs=opt~loc:ptype_loc@@Attribute.gettype_xrefs_attributetype_declinletman=opt~loc:ptype_loc@@Attribute.gettype_man_attributetype_declinletenvs=type_env~loc:ptype_loctype_declinletdoc=type_doctype_declinletversion=opt~loc:ptype_loc@@Attribute.gettype_version_attributetype_declinList.mapsndargs@[%strlet[%pptype_id]=letmk=[%emk_exp]inCmdliner.Term.([%efinal_app])letcmdlinerf=letname=Filename.basenameSys.executable_nameinletopenCmdlinerinletinfo=Term.infoname?man_xrefs:[%exrefs]?man:[%eman]?envs:[%eenvs]?doc:[%edoc]?version:[%eversion]~exits:Term.default_exitsinletterm_t=Term.(constf$[%eetype_id])inTerm.exit@@Term.eval(term_t,info)]|_->[]letexpand_str:ctxt:Expansion_context.Deriver.t->rec_flag*type_declarationlist->structure=fun~ctxt(_rec_flag,type_decl_list)->(* let omp_config = Expansion_context.Deriver.omp_config ctxt in *)letis_ocamldep_pass=String.equal"ocamldep"(Expansion_context.Deriver.tool_namectxt)inletloc=Expansion_context.Deriver.derived_item_locctxtinifis_ocamldep_passthen[]elseList.map(expand_str_type_decl~loc)type_decl_list|>List.concatletexpand_sig~ctxt_input_ast=(* let omp_config = Expansion_context.Deriver.omp_config ctxt in *)letis_ocamldep_pass=String.equal"ocamldep"(Expansion_context.Deriver.tool_namectxt)inletloc=Expansion_context.Deriver.derived_item_locctxtinifis_ocamldep_passthen[]else[%sig:valfoo:int]letstr_type_decl_generator=Deriving.Generator.V2.make_noarg~attributesexpand_strletsig_type_decl_generator=Deriving.Generator.V2.make_noarg~attributesexpand_sigletcmdliner_deriver=Deriving.add~str_type_decl:str_type_decl_generator~sig_type_decl:sig_type_decl_generator"cmdliner"