123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724(*$ open Ppxlib_cinaps_helpers $*)open!ImportopenCommonmoduleE=ExtensionmoduleEC=Extension.ContextmoduleA=AttributemoduleAC=Attribute.ContextmoduleRule=structmoduleAttr_group_inline=structtype('a,'b,'c)unpacked={attribute:('b,'c)Attribute.t;expect:bool;expand:(ctxt:Expansion_context.Deriver.t->Asttypes.rec_flag->'blist->'coptionlist->'alist)}type('a,'b)t=T:('a,'b,_)unpacked->('a,'b)tletattr_name(Tt)=Attribute.namet.attributeletsplit_normal_and_expectl=List.partition_tfl~f:(fun(Tt)->nott.expect)endmoduleAttr_inline=structtype('a,'b,'c)unpacked={attribute:('b,'c)Attribute.t;expect:bool;expand:(ctxt:Expansion_context.Deriver.t->'b->'c->'alist)}type('a,'b)t=T:('a,'b,_)unpacked->('a,'b)tletattr_name(Tt)=Attribute.namet.attributeletsplit_normal_and_expectl=List.partition_tfl~f:(fun(Tt)->nott.expect)endmoduleSpecial_function=structtypet={name:string;ident:Longident.t;expand:Parsetree.expression->Parsetree.expressionoption}endmoduleConstant_kind=structtypet=Float|IntegerendmoduleConstant=structtypet={suffix:char;kind:Constant_kind.t;expand:Location.t->string->Parsetree.expression}endmoduleField=structtype'at=|Extension:Extension.tt|Special_function:Special_function.tt|Constant:Constant.tt|Attr_str_type_decl:(structure_item,type_declaration)Attr_group_inline.tt|Attr_sig_type_decl:(signature_item,type_declaration)Attr_group_inline.tt|Attr_str_module_type_decl:(structure_item,module_type_declaration)Attr_inline.tt|Attr_sig_module_type_decl:(signature_item,module_type_declaration)Attr_inline.tt|Attr_str_type_ext:(structure_item,type_extension)Attr_inline.tt|Attr_sig_type_ext:(signature_item,type_extension)Attr_inline.tt|Attr_str_exception:(structure_item,type_exception)Attr_inline.tt|Attr_sig_exception:(signature_item,type_exception)Attr_inline.tttype(_,_)equality=Eq:('a,'a)equality|Ne:(_,_)equalityleteq:typeab.at->bt->(a,b)equality=funab->matcha,bwith|Extension,Extension->Eq|Special_function,Special_function->Eq|Constant,Constant->Eq|Attr_str_type_decl,Attr_str_type_decl->Eq|Attr_sig_type_decl,Attr_sig_type_decl->Eq|Attr_str_type_ext,Attr_str_type_ext->Eq|Attr_sig_type_ext,Attr_sig_type_ext->Eq|Attr_str_exception,Attr_str_exception->Eq|Attr_sig_exception,Attr_sig_exception->Eq|Attr_str_module_type_decl,Attr_str_module_type_decl->Eq|Attr_sig_module_type_decl,Attr_sig_module_type_decl->Eq|_->Neendtypet=T:'aField.t*'a->ttype('a,'b,'c)attr_group_inline=('b,'c)Attribute.t->(ctxt:Expansion_context.Deriver.t->Asttypes.rec_flag->'blist->'coptionlist->'alist)->ttype('a,'b,'c)attr_inline=('b,'c)Attribute.t->(ctxt:Expansion_context.Deriver.t->'b->'c->'alist)->tletrecfilter:typea.aField.t->tlist->alist=funfieldl->matchlwith|[]->[]|(T(field',x))::l->matchField.eqfieldfield'with|Field.Eq->x::filterfieldl|Field.Ne->filterfieldl;;letextensionext=T(Extension,ext)letspecial_functionidf=T(Special_function,{name=id;ident=Longident.parseid;expand=f});;letconstantkindsuffixexpand=T(Constant,{suffix;kind;expand});;letattr_str_type_declattributeexpand=T(Attr_str_type_decl,T{attribute;expand;expect=false});;letattr_sig_type_declattributeexpand=T(Attr_sig_type_decl,T{attribute;expand;expect=false});;letattr_str_module_type_declattributeexpand=T(Attr_str_module_type_decl,T{attribute;expand;expect=false});;letattr_sig_module_type_declattributeexpand=T(Attr_sig_module_type_decl,T{attribute;expand;expect=false});;letattr_str_type_extattributeexpand=T(Attr_str_type_ext,T{attribute;expand;expect=false});;letattr_sig_type_extattributeexpand=T(Attr_sig_type_ext,T{attribute;expand;expect=false});;letattr_str_exceptionattributeexpand=T(Attr_str_exception,T{attribute;expand;expect=false});;letattr_sig_exceptionattributeexpand=T(Attr_sig_exception,T{attribute;expand;expect=false});;letattr_str_type_decl_expectattributeexpand=T(Attr_str_type_decl,T{attribute;expand;expect=true});;letattr_sig_type_decl_expectattributeexpand=T(Attr_sig_type_decl,T{attribute;expand;expect=true});;letattr_str_module_type_decl_expectattributeexpand=T(Attr_str_module_type_decl,T{attribute;expand;expect=true});;letattr_sig_module_type_decl_expectattributeexpand=T(Attr_sig_module_type_decl,T{attribute;expand;expect=true});;letattr_str_type_ext_expectattributeexpand=T(Attr_str_type_ext,T{attribute;expand;expect=true});;letattr_sig_type_ext_expectattributeexpand=T(Attr_sig_type_ext,T{attribute;expand;expect=true});;letattr_str_exception_expectattributeexpand=T(Attr_str_exception,T{attribute;expand;expect=true});;letattr_sig_exception_expectattributeexpand=T(Attr_sig_exception,T{attribute;expand;expect=true});;endmoduleGenerated_code_hook=structtype'asingle_or_many=|Singleof'a|Manyof'alisttypet={f:'a.'aExtension.Context.t->Location.t->'asingle_or_many->unit}letnop={f=(fun___->())}letreplacetcontextlocx=t.fcontextlocxletinsert_aftertcontext(loc:Location.t)x=matchxwith|Many[]->()|_->t.fcontext{locwithloc_start=loc.loc_end}xendletrecmap_node_reccontexttssuper_calllocbase_ctxtx=letctxt=Expansion_context.Extension.make~extension_point_loc:loc~base:base_ctxt()inmatchEC.get_extensioncontextxwith|None->super_callbase_ctxtx|Some(ext,attrs)->matchE.For_context.convertts~ctxtextwith|None->super_callbase_ctxtx|Somex->map_node_reccontexttssuper_calllocbase_ctxt(EC.merge_attributescontextxattrs);;letmap_nodecontexttssuper_calllocbase_ctxtx~hook=letctxt=Expansion_context.Extension.make~extension_point_loc:loc~base:base_ctxt()inmatchEC.get_extensioncontextxwith|None->super_callbase_ctxtx|Some(ext,attrs)->matchE.For_context.convertts~ctxtextwith|None->super_callbase_ctxtx|Somex->letgenerated_code=map_node_reccontexttssuper_calllocbase_ctxt(EC.merge_attributescontextxattrs)inGenerated_code_hook.replacehookcontextloc(Singlegenerated_code);generated_code;;letrecmap_nodescontexttssuper_callget_locbase_ctxtl~hook~in_generated_code=matchlwith|[]->[]|x::l->matchEC.get_extensioncontextxwith|None->(* These two lets force the evaluation order, so that errors are reported in the
same order as they appear in the source file. *)letx=super_callbase_ctxtxinletl=map_nodescontexttssuper_callget_locbase_ctxtl~hook~in_generated_codeinx::l|Some(ext,attrs)->letextension_point_loc=get_locxinletctxt=Expansion_context.Extension.make~extension_point_loc~base:base_ctxt()inmatchE.For_context.convert_inlinets~ctxtextwith|None->letx=super_callbase_ctxtxinletl=map_nodescontexttssuper_callget_locbase_ctxtl~hook~in_generated_codeinx::l|Somex->assert_no_attributesattrs;letgenerated_code=map_nodescontexttssuper_callget_locbase_ctxtx~hook~in_generated_code:trueinifnotin_generated_codethenGenerated_code_hook.replacehookcontextextension_point_loc(Manygenerated_code);generated_code@map_nodescontexttssuper_callget_locbase_ctxtl~hook~in_generated_codeletmap_nodes=map_nodes~in_generated_code:falselettable_of_special_functionsspecial_functions=matchList.mapspecial_functions~f:(fun{Rule.Special_function.ident;expand;_}->(ident,expand))(* We expect the lookup to fail most of the time, by making the table big (and
sparse), we make it more likely to fail quickly *)|>Hashtbl.Poly.of_alist~size:(max1024(List.lengthspecial_functions*2))with|`Oktable->table|`Duplicate_keyident->Printf.ksprintfinvalid_arg"Context_free.V1.map_top_down: \
%s present twice in list of special functions"(List.find_map_exnspecial_functions~f:(funr->ifPoly.equalr.identidentthenSomer.nameelseNone));;letrecget_groupattrl=matchlwith|[]->None|x::l->matchAttribute.getattrx,get_groupattrlwith|None,None->None|None,Somevals->Some(None::vals)|Somevalue,None->Some(Somevalue::List.mapl~f:(fun_->None))|Somevalue,Somevals->Some(Somevalue::vals);;(* Same as [List.rev] then [List.concat] but expecting the input to be of length <= 2 *)letrev_concat=function|[]->[]|[x]->x|[x;y]->y@x|l->List.concat(List.revl);;letsort_attr_group_inlinel=List.sortl~compare:(funab->String.compare(Rule.Attr_group_inline.attr_namea)(Rule.Attr_group_inline.attr_nameb))letsort_attr_inlinel=List.sortl~compare:(funab->String.compare(Rule.Attr_inline.attr_namea)(Rule.Attr_inline.attr_nameb))(* Returns the code generated by attribute handlers. We don't remove these attributes, as
another pass might interpret them later. For instance both ppx_deriving and
ppxlib_deriving interprets [@@deriving] attributes.
This complexity is horrible, but in practice we don't care as [attrs] is always a list
of one element; it only has [@@deriving].
*)lethandle_attr_group_inlineattrsrfitems~loc~base_ctxt=List.fold_leftattrs~init:[]~f:(funacc(Rule.Attr_group_inline.Tgroup)->matchget_groupgroup.attributeitemswith|None->acc|Somevalues->letctxt=Expansion_context.Deriver.make~derived_item_loc:loc~inline:group.expect~base:base_ctxt()inletexpect_items=group.expand~ctxtrfitemsvaluesinexpect_items::acc)lethandle_attr_inlineattrsitem~loc~base_ctxt=List.fold_leftattrs~init:[]~f:(funacc(Rule.Attr_inline.Ta)->matchAttribute.geta.attributeitemwith|None->acc|Somevalue->letctxt=Expansion_context.Deriver.make~derived_item_loc:loc~inline:a.expect~base:base_ctxt()inletexpect_items=a.expand~ctxtitemvalueinexpect_items::acc)moduleExpect_mismatch_handler=structtypet={f:'a.'aAttribute.Floating.Context.t->Location.t->'alist->unit}letnop={f=fun___->()}endclassmap_top_down?(expect_mismatch_handler=Expect_mismatch_handler.nop)?(generated_code_hook=Generated_code_hook.nop)rules=lethook=generated_code_hookinletspecial_functions=Rule.filterSpecial_functionrules|>table_of_special_functionsinletconstants=Rule.filterConstantrules|>List.map~f:(fun(c:Rule.Constant.t)->((c.suffix,c.kind),c.expand))|>Hashtbl.Poly.of_alist_exninletextensions=Rule.filterExtensionrulesinletclass_expr=E.filter_by_contextEC.class_exprextensionsandclass_field=E.filter_by_contextEC.class_fieldextensionsandclass_type=E.filter_by_contextEC.class_typeextensionsandclass_type_field=E.filter_by_contextEC.class_type_fieldextensionsandcore_type=E.filter_by_contextEC.core_typeextensionsandexpression=E.filter_by_contextEC.expressionextensionsandmodule_expr=E.filter_by_contextEC.module_exprextensionsandmodule_type=E.filter_by_contextEC.module_typeextensionsandpattern=E.filter_by_contextEC.patternextensionsandsignature_item=E.filter_by_contextEC.signature_itemextensionsandstructure_item=E.filter_by_contextEC.structure_itemextensionsinletattr_str_type_decls,attr_str_type_decls_expect=Rule.filterAttr_str_type_declrules|>sort_attr_group_inline|>Rule.Attr_group_inline.split_normal_and_expectinletattr_sig_type_decls,attr_sig_type_decls_expect=Rule.filterAttr_sig_type_declrules|>sort_attr_group_inline|>Rule.Attr_group_inline.split_normal_and_expectinletattr_str_module_type_decls,attr_str_module_type_decls_expect=Rule.filterAttr_str_module_type_declrules|>sort_attr_inline|>Rule.Attr_inline.split_normal_and_expectinletattr_sig_module_type_decls,attr_sig_module_type_decls_expect=Rule.filterAttr_sig_module_type_declrules|>sort_attr_inline|>Rule.Attr_inline.split_normal_and_expectinletattr_str_type_exts,attr_str_type_exts_expect=Rule.filterAttr_str_type_extrules|>sort_attr_inline|>Rule.Attr_inline.split_normal_and_expectinletattr_sig_type_exts,attr_sig_type_exts_expect=Rule.filterAttr_sig_type_extrules|>sort_attr_inline|>Rule.Attr_inline.split_normal_and_expectinletattr_str_exceptions,attr_str_exceptions_expect=Rule.filterAttr_str_exceptionrules|>sort_attr_inline|>Rule.Attr_inline.split_normal_and_expectinletattr_sig_exceptions,attr_sig_exceptions_expect=Rule.filterAttr_sig_exceptionrules|>sort_attr_inline|>Rule.Attr_inline.split_normal_and_expectinletmap_node=map_node~hookinletmap_nodes=map_nodes~hookinobject(self)inheritAst_traverse.map_with_expansion_contextassuper(* No point recursing into every location *)method!location_x=xmethod!core_typebase_ctxtx=map_nodeEC.core_typecore_typesuper#core_typex.ptyp_locbase_ctxtxmethod!patternbase_ctxtx=map_nodeEC.patternpatternsuper#patternx.ppat_locbase_ctxtxmethod!expressionbase_ctxte=lete=matche.pexp_descwith|Pexp_extension_->map_nodeEC.expressionexpression(fun_e->e)e.pexp_locbase_ctxte|_->einletexpand_constantkindchartext=matchHashtbl.findconstants(char,kind)with|None->super#expressionbase_ctxte|Someexpand->self#expressionbase_ctxt(expande.pexp_loctext)inmatche.pexp_descwith|Pexp_apply({pexp_desc=Pexp_identid;_}asfunc,args)->beginmatchHashtbl.findspecial_functionsid.txtwith|None->self#pexp_apply_without_traversing_functionbase_ctxtefuncargs|Somepattern->matchpatternewith|None->self#pexp_apply_without_traversing_functionbase_ctxtefuncargs|Somee->self#expressionbase_ctxteend|Pexp_identid->beginmatchHashtbl.findspecial_functionsid.txtwith|None->super#expressionbase_ctxte|Somepattern->matchpatternewith|None->super#expressionbase_ctxte|Somee->self#expressionbase_ctxteend|Pexp_constant(Pconst_integer(s,Somec))->expand_constantIntegercs|Pexp_constant(Pconst_float(s,Somec))->expand_constantFloatcs|_->super#expressionbase_ctxte(* Pre-conditions:
- e.pexp_desc = Pexp_apply(func, args)
- func.pexp_desc = Pexp_ident _
*)methodprivatepexp_apply_without_traversing_functionbase_ctxtefuncargs=let{pexp_desc=_;pexp_loc;pexp_attributes;pexp_loc_stack;}=einletfunc=let{pexp_desc;pexp_loc;pexp_attributes;pexp_loc_stack}=funcinletpexp_attributes=self#attributesbase_ctxtpexp_attributesin{pexp_desc;pexp_loc(* location doesn't need to be traversed *);pexp_attributes;pexp_loc_stack}inletargs=List.mapargs~f:(fun(lab,exp)->(lab,self#expressionbase_ctxtexp))inletpexp_attributes=self#attributesbase_ctxtpexp_attributesin{pexp_loc;pexp_attributes;pexp_desc=Pexp_apply(func,args);pexp_loc_stack}method!class_typebase_ctxtx=map_nodeEC.class_typeclass_typesuper#class_typex.pcty_locbase_ctxtxmethod!class_type_fieldbase_ctxtx=map_nodeEC.class_type_fieldclass_type_fieldsuper#class_type_fieldx.pctf_locbase_ctxtxmethod!class_exprbase_ctxtx=map_nodeEC.class_exprclass_exprsuper#class_exprx.pcl_locbase_ctxtxmethod!class_fieldbase_ctxtx=map_nodeEC.class_fieldclass_fieldsuper#class_fieldx.pcf_locbase_ctxtxmethod!module_typebase_ctxtx=map_nodeEC.module_typemodule_typesuper#module_typex.pmty_locbase_ctxtxmethod!module_exprbase_ctxtx=map_nodeEC.module_exprmodule_exprsuper#module_exprx.pmod_locbase_ctxtxmethod!structure_itembase_ctxtx=map_nodeEC.structure_itemstructure_itemsuper#structure_itemx.pstr_locbase_ctxtxmethod!signature_itembase_ctxtx=map_nodeEC.signature_itemsignature_itemsuper#signature_itemx.psig_locbase_ctxtxmethod!class_structurebase_ctxt{pcstr_self;pcstr_fields}=letpcstr_self=self#patternbase_ctxtpcstr_selfinletpcstr_fields=map_nodesEC.class_fieldclass_fieldsuper#class_field(funx->x.pcf_loc)base_ctxtpcstr_fieldsin{pcstr_self;pcstr_fields}method!class_signaturebase_ctxt{pcsig_self;pcsig_fields}=letpcsig_self=self#core_typebase_ctxtpcsig_selfinletpcsig_fields=map_nodesEC.class_type_fieldclass_type_fieldsuper#class_type_field(funx->x.pctf_loc)base_ctxtpcsig_fieldsin{pcsig_self;pcsig_fields}(* TODO: try to factorize #structure and #signature without meta-programming *)(*$*)method!structurebase_ctxtst=letrecwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code=letitem=super#structure_itembase_ctxtiteminletextra_items=loop(rev_concatextra_items)~in_generated_code:trueinifnotin_generated_codethenGenerated_code_hook.insert_afterhookStructure_itemitem.pstr_loc(Manyextra_items);letoriginal_rest=restinletrest=looprest~in_generated_codein(matchexpect_itemswith|[]->()|_->letexpected=rev_concatexpect_itemsinletpos=item.pstr_loc.loc_endinCode_matcher.match_structureoriginal_rest~pos~expected~mismatch_handler:(funlocrepl->expect_mismatch_handler.fStructure_itemlocrepl));item::(extra_items@rest)andloopst~in_generated_code=matchstwith|[]->[]|item::rest->letloc=item.pstr_locinmatchitem.pstr_descwith|Pstr_extension(ext,attrs)->beginletextension_point_loc=item.pstr_locinletctxt=Expansion_context.Extension.make~extension_point_loc~base:base_ctxt()inmatchE.For_context.convert_inlinestructure_item~ctxtextwith|None->letitem=super#structure_itembase_ctxtiteminletrest=self#structurebase_ctxtrestinitem::rest|Someitems->assert_no_attributesattrs;letitems=loopitems~in_generated_code:trueinifnotin_generated_codethenGenerated_code_hook.replacehookStructure_itemitem.pstr_loc(Manyitems);items@looprest~in_generated_codeend|Pstr_type(rf,tds)->letextra_items=handle_attr_group_inlineattr_str_type_declsrftds~loc~base_ctxtinletexpect_items=handle_attr_group_inlineattr_str_type_decls_expectrftds~loc~base_ctxtinwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code|Pstr_modtypemtd->letextra_items=handle_attr_inlineattr_str_module_type_declsmtd~loc~base_ctxtinletexpect_items=handle_attr_inlineattr_str_module_type_decls_expectmtd~loc~base_ctxtinwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code|Pstr_typextte->letextra_items=handle_attr_inlineattr_str_type_extste~loc~base_ctxtinletexpect_items=handle_attr_inlineattr_str_type_exts_expectte~loc~base_ctxtinwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code|Pstr_exceptionec->letextra_items=handle_attr_inlineattr_str_exceptionsec~loc~base_ctxtinletexpect_items=handle_attr_inlineattr_str_exceptions_expectec~loc~base_ctxtinwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code|_->letitem=self#structure_itembase_ctxtiteminletrest=self#structurebase_ctxtrestinitem::restinloopst~in_generated_code:false(*$ str_to_sig _last_text_block *)method!signaturebase_ctxtsg=letrecwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code=letitem=super#signature_itembase_ctxtiteminletextra_items=loop(rev_concatextra_items)~in_generated_code:trueinifnotin_generated_codethenGenerated_code_hook.insert_afterhookSignature_itemitem.psig_loc(Manyextra_items);letoriginal_rest=restinletrest=looprest~in_generated_codein(matchexpect_itemswith|[]->()|_->letexpected=rev_concatexpect_itemsinletpos=item.psig_loc.loc_endinCode_matcher.match_signatureoriginal_rest~pos~expected~mismatch_handler:(funlocrepl->expect_mismatch_handler.fSignature_itemlocrepl));item::(extra_items@rest)andloopsg~in_generated_code=matchsgwith|[]->[]|item::rest->letloc=item.psig_locinmatchitem.psig_descwith|Psig_extension(ext,attrs)->beginletextension_point_loc=item.psig_locinletctxt=Expansion_context.Extension.make~extension_point_loc~base:base_ctxt()inmatchE.For_context.convert_inlinesignature_item~ctxtextwith|None->letitem=super#signature_itembase_ctxtiteminletrest=self#signaturebase_ctxtrestinitem::rest|Someitems->assert_no_attributesattrs;letitems=loopitems~in_generated_code:trueinifnotin_generated_codethenGenerated_code_hook.replacehookSignature_itemitem.psig_loc(Manyitems);items@looprest~in_generated_codeend|Psig_type(rf,tds)->letextra_items=handle_attr_group_inlineattr_sig_type_declsrftds~loc~base_ctxtinletexpect_items=handle_attr_group_inlineattr_sig_type_decls_expectrftds~loc~base_ctxtinwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code|Psig_modtypemtd->letextra_items=handle_attr_inlineattr_sig_module_type_declsmtd~loc~base_ctxtinletexpect_items=handle_attr_inlineattr_sig_module_type_decls_expectmtd~loc~base_ctxtinwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code|Psig_typextte->letextra_items=handle_attr_inlineattr_sig_type_extste~loc~base_ctxtinletexpect_items=handle_attr_inlineattr_sig_type_exts_expectte~loc~base_ctxtinwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code|Psig_exceptionec->letextra_items=handle_attr_inlineattr_sig_exceptionsec~loc~base_ctxtinletexpect_items=handle_attr_inlineattr_sig_exceptions_expectec~loc~base_ctxtinwith_extra_itemsitem~extra_items~expect_items~rest~in_generated_code|_->letitem=self#signature_itembase_ctxtiteminletrest=self#signaturebase_ctxtrestinitem::restinloopsg~in_generated_code:false(*$*)end