123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182(**************************************************************************)(* *)(* OCaml Migrate Parsetree *)(* *)(* Frédéric Bour, Facebook *)(* Jérémie Dimino and Leo White, Jane Street Europe *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* Alain Frisch, LexiFi *)(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 2018 Institut National de Recherche en Informatique et *)(* en Automatique (INRIA). *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)openStdlib0openAst_409_helpermoduleLocation=LocationmoduleLongident=Longident[@@@warning "-9"]moduleAsttypes=structtypeconstant(*IF_CURRENT = Asttypes.constant *)=Const_intofint|Const_charofchar|Const_stringofstring*Location.t*stringoption|Const_float ofstring|Const_int32 ofint32|Const_int64 ofint64|Const_nativeint ofnativeinttyperec_flag(*IF_CURRENT = Asttypes.rec_flag *) =Nonrecursive|Recursivetypedirection_flag(*IF_CURRENT = Asttypes.direction_flag *) =Upto|Downto(* Order matters, used inpolymorphic comparison *)typeprivate_flag(*IF_CURRENT = Asttypes.private_flag *)=Private|Publictypemutable_flag(*IF_CURRENT = Asttypes.mutable_flag *)=Immutable|Mutabletypevirtual_flag(*IF_CURRENT = Asttypes.virtual_flag *)=Virtual|Concretetypeoverride_flag(*IF_CURRENT = Asttypes.override_flag *)=Override|Freshtypeclosed_flag(*IF_CURRENT = Asttypes.closed_flag *)=Closed|Opentypelabel=stringtypearg_label(*IF_CURRENT = Asttypes.arg_label *)=Nolabel|Labelledofstring(* label:T -> ... *)|Optionalofstring(* ?label:T -> ... *)type'aloc='aLocation.loc={txt:'a;loc:Location.t;}typevariance(*IF_CURRENT = Asttypes.variance *) =|Covariant|Contravariant|InvariantendmoduleParsetree=structopenAsttypestypeconstant(*IF_CURRENT = Parsetree.constant *)=Pconst_integerofstring*charoption(* 3 3l 3L 3n
Suffixes [g-z][G-Z] are accepted by the parser.
Suffixes except 'l', 'L' and 'n' are rejected by the typechecker
*)|Pconst_charofchar(* 'c' *)|Pconst_stringofstring*Location.t*stringoption(* "constant"
{delim|other constant|delim}
The location span the content of the string, without the delimiters.
*)|Pconst_floatofstring*charoption(* 3.4 2e5 1.4e-4
Suffixes [g-z][G-Z] are accepted by the parser.
Suffixes are rejected by the typechecker.
*)typelocation_stack=Location.tlist(** {1 Extension points} *)type attribute(*IF_CURRENT = Parsetree.attribute *)={attr_name:stringloc;attr_payload:payload;attr_loc:Location.t;}(* [@id ARG]
[@@id ARG]
Metadata containers passed around within the AST.
The compiler ignores unknown attributes.
*)andextension=stringloc*payload(* [%id ARG]
[%%id ARG]
Sub-language placeholder -- rejected by the typechecker.
*)andattributes=attributelistandpayload(*IF_CURRENT = Parsetree.payload *) =|PStrofstructure|PSigofsignature(* : SIG *)|PTypofcore_type(* : T *)|PPatofpattern*expressionoption(* ? P or ? P when E *)(** {1 Core language} *)(* Type expressions *)andcore_type(*IF_CURRENT = Parsetree.core_type *)={ptyp_desc:core_type_desc;ptyp_loc:Location.t;ptyp_loc_stack:location_stack;ptyp_attributes:attributes;(* ... [@id1] [@id2] *)}andcore_type_desc(*IF_CURRENT = Parsetree.core_type_desc *)=|Ptyp_any(* _ *)|Ptyp_varofstring(* 'a *)|Ptyp_arrowofarg_label *core_type*core_type(* T1 -> T2 Simple
~l:T1 -> T2 Labelled
?l:T1 -> T2 Optional
*)|Ptyp_tupleofcore_typelist(* T1 * ... * Tn
Invariant: n >= 2
*)|Ptyp_constrofLongident.tloc*core_typelist(* tconstr
T tconstr
(T1, ..., Tn) tconstr
*)|Ptyp_objectofobject_fieldlist*closed_flag(* < l1:T1; ...; ln:Tn > (flag = Closed)
< l1:T1; ...; ln:Tn; .. > (flag = Open)
*)|Ptyp_classofLongident.tloc*core_typelist(* #tconstr
T #tconstr
(T1, ..., Tn) #tconstr
*)|Ptyp_aliasofcore_type*string(* T as 'a *)|Ptyp_variant ofrow_fieldlist*closed_flag*labellistoption(* [ `A|`B ] (flag = Closed; labels = None)
[> `A|`B ] (flag = Open; labels = None)
[< `A|`B ] (flag = Closed; labels = Some [])
[< `A|`B > `X `Y ](flag = Closed; labels = Some ["X";"Y"])
*)|Ptyp_polyofstringloclist*core_type(* 'a1 ... 'an. T
Can only appear in the following context:
- As the core_type of a Ppat_constraint node corresponding
to a constraint on a let-binding: let x : 'a1 ... 'an. T
= e ...
- Under Cfk_virtual for methods (not values).
- As the core_type of a Pctf_method node.
- As the core_type of a Pexp_poly node.
- As the pld_type field of a label_declaration.
- As a core_type of a Ptyp_object node.
*)|Ptyp_packageofpackage_type(* (module S) *)|Ptyp_extension ofextension(* [%id] *)andpackage_type=Longident.tloc*(Longident.tloc*core_type)list(*
(module S)
(module S with type t1 = T1 and ... and tn = Tn)
*)androw_field(*IF_CURRENT = Parsetree.row_field *)={prf_desc:row_field_desc;prf_loc:Location.t;prf_attributes :attributes;}androw_field_desc(*IF_CURRENT = Parsetree.row_field_desc *)=|Rtagoflabelloc*bool*core_typelist(* [`A] ( true, [] )
[`A of T] ( false, [T] )
[`A of T1 & .. & Tn] ( false, [T1;...Tn] )
[`A of & T1 & .. & Tn] ( true, [T1;...Tn] )
- The 'bool' field is true if the tag contains a
constant (empty) constructor.
- '&' occurs when several types are used for the same constructor
(see 4.2 in the manual)
*)|Rinheritofcore_type(* [ T ] *)andobject_field(*IF_CURRENT = Parsetree.object_field *)={pof_desc:object_field_desc;pof_loc:Location.t;pof_attributes:attributes;}andobject_field_desc(*IF_CURRENT = Parsetree.object_field_desc *)=|Otagoflabelloc*core_type|Oinheritofcore_type(* Patterns *)andpattern(*IF_CURRENT = Parsetree.pattern *) ={ppat_desc:pattern_desc;ppat_loc:Location.t;ppat_loc_stack:location_stack;ppat_attributes:attributes;(* ... [@id1] [@id2] *)}andpattern_desc(*IF_CURRENT = Parsetree.pattern_desc *) =|Ppat_any(* _ *)|Ppat_varofstringloc(* x *)|Ppat_aliasofpattern *stringloc(* P as 'a *)|Ppat_constantofconstant(* 1, 'a', "true", 1.0, 1l, 1L, 1n *)|Ppat_intervalofconstant*constant(* 'a'..'z'
Other forms of interval are recognized by the parser
but rejected by the type-checker. *)|Ppat_tupleofpatternlist(* (P1, ..., Pn)
Invariant: n >= 2
*)|Ppat_constructofLongident.tloc*patternoption(* C None
C P Some P
C (P1, ..., Pn) Some (Ppat_tuple [P1; ...; Pn])
*)|Ppat_variantoflabel*patternoption(* `A (None)
`A P (Some P)
*)|Ppat_recordof(Longident.tloc*pattern)list*closed_flag(* { l1=P1; ...; ln=Pn } (flag = Closed)
{ l1=P1; ...; ln=Pn; _} (flag = Open)
Invariant: n > 0
*)|Ppat_arrayofpatternlist(* [| P1; ...; Pn |] *)|Ppat_orofpattern*pattern(* P1 | P2 *)|Ppat_constraint ofpattern*core_type(* (P : T) *)|Ppat_type ofLongident.tloc(* #tconst *)|Ppat_lazyofpattern(* lazy P *)|Ppat_unpackofstringoptionloc(* (module P) Some "P"
(module _) None
Note: (module P : S) is represented as
Ppat_constraint(Ppat_unpack, Ptyp_package)
*)|Ppat_exceptionofpattern(* exception P *)|Ppat_extensionofextension(* [%id] *)|Ppat_openofLongident.tloc*pattern(* M.(P) *)(* Value expressions *)andexpression(*IF_CURRENT = Parsetree.expression *)={pexp_desc:expression_desc;pexp_loc:Location.t;pexp_loc_stack:location_stack;pexp_attributes:attributes;(* ... [@id1] [@id2] *)}andexpression_desc(*IF_CURRENT = Parsetree.expression_desc *)=|Pexp_identofLongident.tloc(* x
M.x
*)|Pexp_constantofconstant(* 1, 'a', "true", 1.0, 1l, 1L, 1n *)|Pexp_letofrec_flag*value_bindinglist*expression(* let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive)
let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive)
*)|Pexp_functionofcaselist(* function P1 -> E1 | ... | Pn -> En *)|Pexp_funofarg_label*expressionoption*pattern*expression(* fun P -> E1 (Simple, None)
fun ~l:P -> E1 (Labelled l, None)
fun ?l:P -> E1 (Optional l, None)
fun ?l:(P = E0) -> E1 (Optional l, Some E0)
Notes:
- If E0 is provided, only Optional is allowed.
- "fun P1 P2 .. Pn -> E1" is represented as nested Pexp_fun.
- "let f P = E" is represented using Pexp_fun.
*)|Pexp_applyofexpression*(arg_label*expression)list(* E0 ~l1:E1 ... ~ln:En
li can be empty (non labeled argument) or start with '?'
(optional argument).
Invariant: n > 0
*)|Pexp_matchofexpression*caselist(* match E0 with P1 -> E1 | ... | Pn -> En *)|Pexp_tryofexpression*caselist(* try E0 with P1 -> E1 | ... | Pn -> En *)|Pexp_tupleofexpressionlist(* (E1, ..., En)
Invariant: n >= 2
*)|Pexp_constructofLongident.tloc*expressionoption(* C None
C E Some E
C (E1, ..., En) Some (Pexp_tuple[E1;...;En])
*)|Pexp_variantoflabel*expressionoption(* `A (None)
`A E (Some E)
*)|Pexp_recordof(Longident.tloc*expression)list*expressionoption(* { l1=P1; ...; ln=Pn } (None)
{ E0 with l1=P1; ...; ln=Pn } (Some E0)
Invariant: n > 0
*)|Pexp_fieldofexpression*Longident.tloc(* E.l *)|Pexp_setfieldofexpression*Longident.tloc*expression(* E1.l <- E2 *)|Pexp_arrayofexpressionlist(* [| E1; ...; En |] *)|Pexp_ifthenelseofexpression*expression*expressionoption(* if E1 then E2 else E3 *)|Pexp_sequenceofexpression*expression(* E1; E2 *)|Pexp_whileofexpression*expression(* while E1 do E2 done *)|Pexp_forofpattern*expression*expression*direction_flag*expression(* for i = E1 to E2 do E3 done (flag = Upto)
for i = E1 downto E2 do E3 done (flag = Downto)
*)|Pexp_constraintofexpression*core_type(* (E : T) *)|Pexp_coerceofexpression*core_typeoption*core_type(* (E :> T) (None, T)
(E : T0 :> T) (Some T0, T)
*)|Pexp_sendofexpression*labelloc(* E # m *)|Pexp_newofLongident.tloc(* new M.c *)|Pexp_setinstvaroflabelloc*expression(* x <- 2 *)|Pexp_overrideof(labelloc*expression)list(* {< x1 = E1; ...; Xn = En >} *)|Pexp_letmoduleofstringoptionloc*module_expr*expression(* let module M = ME in E *)|Pexp_letexceptionofextension_constructor*expression(* let exception C in E *)|Pexp_assertofexpression(* assert E
Note: "assert false" is treated in a special way by the
type-checker. *)|Pexp_lazyofexpression(* lazy E *)|Pexp_polyofexpression*core_typeoption(* Used for method bodies.
Can only be used as the expression under Cfk_concrete
for methods (not values). *)|Pexp_objectofclass_structure(* object ... end *)|Pexp_newtypeofstringloc*expression(* fun (type t) -> E *)|Pexp_pack ofmodule_expr(* (module ME)
(module ME : S) is represented as
Pexp_constraint(Pexp_pack, Ptyp_package S) *)|Pexp_openofopen_declaration*expression(* M.(E)
let open M in E
let! open M in E *)|Pexp_letopofletop(* let* P = E in E
let* P = E and* P = E in E *)|Pexp_extensionofextension(* [%id] *)|Pexp_unreachable(* . *)andcase(*IF_CURRENT = Parsetree.case *) =(* (P -> E) or (P when E0 -> E) *){pc_lhs:pattern;pc_guard:expressionoption;pc_rhs:expression;}andletop(*IF_CURRENT = Parsetree.letop *) ={let_:binding_op;ands:binding_oplist;body:expression;}andbinding_op(*IF_CURRENT = Parsetree.binding_op *) ={pbop_op:stringloc;pbop_pat:pattern;pbop_exp:expression;pbop_loc :Location.t;}(* Value descriptions *)andvalue_description (*IF_CURRENT = Parsetree.value_description *)={pval_name:stringloc;pval_type:core_type;pval_prim:stringlist;pval_attributes:attributes;(* ... [@@id1] [@@id2] *)pval_loc:Location.t;}(*
val x: T (prim = [])
external x: T = "s1" ... "sn" (prim = ["s1";..."sn"])
*)(* Type declarations *)andtype_declaration(*IF_CURRENT = Parsetree.type_declaration *)={ptype_name:stringloc;ptype_params:(core_type*variance)list;(* ('a1,...'an) t; None represents _*)ptype_cstrs:(core_type*core_type*Location.t)list;(* ... constraint T1=T1' ... constraint Tn=Tn' *)ptype_kind:type_kind;ptype_private:private_flag;(* = private ... *)ptype_manifest:core_typeoption;(* = T *)ptype_attributes:attributes;(* ... [@@id1] [@@id2] *)ptype_loc:Location.t;}(*
type t (abstract, no manifest)
type t = T0 (abstract, manifest=T0)
type t = C of T | ... (variant, no manifest)
type t = T0 = C of T | ... (variant, manifest=T0)
type t = {l: T; ...} (record, no manifest)
type t = T0 = {l : T; ...} (record, manifest=T0)
type t = .. (open, no manifest)
*)andtype_kind(*IF_CURRENT = Parsetree.type_kind *)=|Ptype_abstract|Ptype_variantofconstructor_declarationlist|Ptype_recordoflabel_declarationlist(* Invariant: non-empty list *)|Ptype_openandlabel_declaration(*IF_CURRENT = Parsetree.label_declaration *)={pld_name:stringloc;pld_mutable:mutable_flag;pld_type:core_type;pld_loc:Location.t;pld_attributes:attributes;(* l : T [@id1] [@id2] *)}(* { ...; l: T; ... } (mutable=Immutable)
{ ...; mutable l: T; ... } (mutable=Mutable)
Note: T can be a Ptyp_poly.
*)andconstructor_declaration(*IF_CURRENT = Parsetree.constructor_declaration *)={pcd_name:stringloc;pcd_args:constructor_arguments;pcd_res:core_typeoption;pcd_loc:Location.t;pcd_attributes:attributes;(* C of ... [@id1] [@id2] *)}andconstructor_arguments(*IF_CURRENT = Parsetree.constructor_arguments *)=|Pcstr_tupleofcore_typelist|Pcstr_recordoflabel_declaration list(*
| C of T1 * ... * Tn (res = None, args = Pcstr_tuple [])
| C: T0 (res = Some T0, args = [])
| C: T1 * ... * Tn -> T0 (res = Some T0, args = Pcstr_tuple)
| C of {...} (res = None, args = Pcstr_record)
| C: {...} -> T0 (res = Some T0, args = Pcstr_record)
| C of {...} as t (res = None, args = Pcstr_record)
*)andtype_extension(*IF_CURRENT = Parsetree.type_extension *)={ptyext_path:Longident.tloc;ptyext_params:(core_type*variance)list;ptyext_constructors:extension_constructorlist;ptyext_private:private_flag;ptyext_loc:Location.t;ptyext_attributes:attributes;(* ... [@@id1] [@@id2] *)}(*
type t += ...
*)andextension_constructor(*IF_CURRENT = Parsetree.extension_constructor *)={pext_name:stringloc;pext_kind:extension_constructor_kind;pext_loc:Location.t;pext_attributes:attributes;(* C of ... [@id1] [@id2] *)}(* exception E *)andtype_exception(*IF_CURRENT = Parsetree.type_exception *)={ptyexn_constructor:extension_constructor;ptyexn_loc:Location.t;ptyexn_attributes:attributes;(* ... [@@id1] [@@id2] *)}and extension_constructor_kind(*IF_CURRENT = Parsetree.extension_constructor_kind *)=Pext_declofconstructor_arguments*core_typeoption(*
| C of T1 * ... * Tn ([T1; ...; Tn], None)
| C: T0 ([], Some T0)
| C: T1 * ... * Tn -> T0 ([T1; ...; Tn], Some T0)
*)|Pext_rebindofLongident.tloc(*
| C = D
*)(** {1 Class language} *)(* Type expressions for the class language *)andclass_type(*IF_CURRENT = Parsetree.class_type *)={pcty_desc:class_type_desc;pcty_loc:Location.t;pcty_attributes:attributes;(* ... [@id1] [@id2] *)}andclass_type_desc(*IF_CURRENT = Parsetree.class_type_desc *)=|Pcty_constrofLongident.tloc*core_typelist(* c
['a1, ..., 'an] c *)|Pcty_signatureofclass_signature(* object ... end *)|Pcty_arrow ofarg_label*core_type*class_type(* T -> CT Simple
~l:T -> CT Labelled l
?l:T -> CT Optional l
*)|Pcty_extensionofextension(* [%id] *)|Pcty_openofopen_description*class_type(* let open M in CT *)andclass_signature (*IF_CURRENT = Parsetree.class_signature *)={pcsig_self:core_type;pcsig_fields:class_type_fieldlist;}(* object('selfpat) ... end
object ... end (self = Ptyp_any)
*)andclass_type_field(*IF_CURRENT = Parsetree.class_type_field *)={pctf_desc:class_type_field_desc;pctf_loc:Location.t;pctf_attributes:attributes;(* ... [@@id1] [@@id2] *)}and class_type_field_desc(*IF_CURRENT = Parsetree.class_type_field_desc *)=|Pctf_inheritofclass_type(* inherit CT *)|Pctf_valof (labelloc*mutable_flag*virtual_flag*core_type)(* val x: T *)|Pctf_methodof(labelloc*private_flag*virtual_flag*core_type)(* method x: T
Note: T can be a Ptyp_poly.
*)|Pctf_constraintof(core_type*core_type)(* constraint T1 = T2 *)|Pctf_attributeofattribute(* [@@@id] *)|Pctf_extensionofextension(* [%%id] *)and'aclass_infos(*IF_CURRENT = 'a Parsetree.class_infos *)={pci_virt:virtual_flag;pci_params:(core_type*variance)list;pci_name:stringloc;pci_expr:'a;pci_loc:Location.t;pci_attributes:attributes;(* ... [@@id1] [@@id2] *)}(* class c = ...
class ['a1,...,'an] c = ...
class virtual c = ...
Also used for "class type" declaration.
*)andclass_description=class_typeclass_infosandclass_type_declaration=class_typeclass_infos(* Value expressions for the class language *)andclass_expr(*IF_CURRENT = Parsetree.class_expr *)={pcl_desc:class_expr_desc;pcl_loc:Location.t;pcl_attributes:attributes;(* ... [@id1] [@id2] *)}andclass_expr_desc(*IF_CURRENT = Parsetree.class_expr_desc *)=|Pcl_constrofLongident.tloc*core_typelist(* c
['a1, ..., 'an] c *)|Pcl_structureofclass_structure(* object ... end *)|Pcl_fun ofarg_label*expressionoption*pattern*class_expr(* fun P -> CE (Simple, None)
fun ~l:P -> CE (Labelled l, None)
fun ?l:P -> CE (Optional l, None)
fun ?l:(P = E0) -> CE (Optional l, Some E0)
*)|Pcl_applyofclass_expr*(arg_label*expression)list(* CE ~l1:E1 ... ~ln:En
li can be empty (non labeled argument) or start with '?'
(optional argument).
Invariant: n > 0
*)|Pcl_letofrec_flag*value_bindinglist*class_expr(* let P1 = E1 and ... and Pn = EN in CE (flag = Nonrecursive)
let rec P1 = E1 and ... and Pn = EN in CE (flag = Recursive)
*)|Pcl_constraintofclass_expr*class_type(* (CE : CT) *)|Pcl_extensionofextension(* [%id] *)|Pcl_openofopen_description*class_expr(* let open M in CE *)andclass_structure (*IF_CURRENT = Parsetree.class_structure *)={pcstr_self:pattern;pcstr_fields:class_fieldlist;}(* object(selfpat) ... end
object ... end (self = Ppat_any)
*)andclass_field(*IF_CURRENT = Parsetree.class_field *)={pcf_desc:class_field_desc;pcf_loc:Location.t;pcf_attributes:attributes;(* ... [@@id1] [@@id2] *)}and class_field_desc(*IF_CURRENT = Parsetree.class_field_desc *)=|Pcf_inheritofoverride_flag*class_expr*stringlocoption(* inherit CE
inherit CE as x
inherit! CE
inherit! CE as x
*)|Pcf_valof(labelloc*mutable_flag*class_field_kind)(* val x = E
val virtual x: T
*)|Pcf_methodof(labelloc*private_flag*class_field_kind)(* method x = E (E can be a Pexp_poly)
method virtual x: T (T can be a Ptyp_poly)
*)|Pcf_constraintof(core_type*core_type)(* constraint T1 = T2 *)|Pcf_initializerofexpression(* initializer E *)|Pcf_attribute ofattribute(* [@@@id] *)|Pcf_extensionofextension(* [%%id] *)andclass_field_kind(*IF_CURRENT = Parsetree.class_field_kind *)=|Cfk_virtualofcore_type|Cfk_concreteofoverride_flag*expressionandclass_declaration=class_exprclass_infos(** {1 Module language} *)(* Type expressions for the module language *)andmodule_type(*IF_CURRENT = Parsetree.module_type *)={pmty_desc:module_type_desc;pmty_loc:Location.t;pmty_attributes:attributes;(* ... [@id1] [@id2] *)}andmodule_type_desc(*IF_CURRENT = Parsetree.module_type_desc *)=|Pmty_identofLongident.tloc(* S *)|Pmty_signatureofsignature(* sig ... end *)|Pmty_functoroffunctor_parameter*module_type(* functor(X : MT1) -> MT2 *)|Pmty_withofmodule_type*with_constraintlist(* MT with ... *)|Pmty_typeof ofmodule_expr(* module type of ME *)|Pmty_extensionofextension(* [%id] *)|Pmty_aliasofLongident.tloc(* (module M) *)andfunctor_parameter(*IF_CURRENT = Parsetree.functor_parameter *)=|Unit(* () *)|Namedofstringoptionloc*module_type(* (X : MT) Some X, MT
(_ : MT) None, MT *)andsignature=signature_itemlistandsignature_item(*IF_CURRENT = Parsetree.signature_item *) ={psig_desc:signature_item_desc;psig_loc:Location.t;}andsignature_item_desc(*IF_CURRENT = Parsetree.signature_item_desc *) =|Psig_valueofvalue_description(*
val x: T
external x: T = "s1" ... "sn"
*)|Psig_typeofrec_flag*type_declarationlist(* type t1 = ... and ... and tn = ... *)|Psig_typesubstoftype_declarationlist(* type t1 := ... and ... and tn := ... *)|Psig_typextoftype_extension(* type t1 += ... *)|Psig_exceptionoftype_exception(* exception C of T *)|Psig_module ofmodule_declaration(* module X = M
module X : MT *)|Psig_modsubstofmodule_substitution(* module X := M *)|Psig_recmodule ofmodule_declarationlist(* module rec X1 : MT1 and ... and Xn : MTn *)|Psig_modtypeofmodule_type_declaration(* module type S = MT
module type S *)|Psig_openofopen_description(* open X *)|Psig_includeof include_description(* include MT *)|Psig_classofclass_descriptionlist(* class c1 : ... and ... and cn : ... *)|Psig_class_typeofclass_type_declarationlist(* class type ct1 = ... and ... and ctn = ... *)|Psig_attributeofattribute(* [@@@id] *)|Psig_extensionofextension*attributes(* [%%id] *)andmodule_declaration (*IF_CURRENT = Parsetree.module_declaration *)={pmd_name:stringoptionloc;pmd_type:module_type;pmd_attributes:attributes;(* ... [@@id1] [@@id2] *)pmd_loc:Location.t;}(* S : MT *)andmodule_substitution(*IF_CURRENT = Parsetree.module_substitution *)={pms_name:stringloc;pms_manifest:Longident.tloc;pms_attributes:attributes;(* ... [@@id1] [@@id2] *)pms_loc:Location.t;}andmodule_type_declaration(*IF_CURRENT = Parsetree.module_type_declaration *)={pmtd_name:stringloc;pmtd_type:module_typeoption;pmtd_attributes:attributes;(* ... [@@id1] [@@id2] *)pmtd_loc:Location.t;}(* S = MT
S (abstract module type declaration, pmtd_type = None)
*)and'aopen_infos(*IF_CURRENT = 'a Parsetree.open_infos *)={popen_expr:'a;popen_override:override_flag;popen_loc:Location.t;popen_attributes:attributes;}(* open! X - popen_override = Override (silences the 'used identifier
shadowing' warning)
open X - popen_override = Fresh
*)andopen_description=Longident.tlocopen_infos(* open M.N
open M(N).O *)andopen_declaration=module_expropen_infos(* open M.N
open M(N).O
open struct ... end *)and'ainclude_infos(*IF_CURRENT = 'a Parsetree.include_infos *)={pincl_mod:'a;pincl_loc:Location.t;pincl_attributes:attributes;}andinclude_description=module_typeinclude_infos(* include MT *)andinclude_declaration =module_exprinclude_infos(* include ME *)andwith_constraint (*IF_CURRENT = Parsetree.with_constraint *)=|Pwith_typeofLongident.tloc*type_declaration(* with type X.t = ...
Note: the last component of the longident must match
the name of the type_declaration. *)|Pwith_moduleofLongident.tloc*Longident.tloc(* with module X.Y = Z *)|Pwith_typesubstofLongident.tloc*type_declaration(* with type X.t := ..., same format as [Pwith_type] *)|Pwith_modsubstofLongident.tloc*Longident.tloc(* with module X.Y := Z *)(* Value expressions for the module language *)andmodule_expr(*IF_CURRENT = Parsetree.module_expr *)={pmod_desc:module_expr_desc;pmod_loc:Location.t;pmod_attributes:attributes;(* ... [@id1] [@id2] *)}andmodule_expr_desc(*IF_CURRENT = Parsetree.module_expr_desc *)=|Pmod_identofLongident.tloc(* X *)|Pmod_structureofstructure(* struct ... end *)|Pmod_functor offunctor_parameter*module_expr(* functor(X : MT1) -> ME *)|Pmod_applyofmodule_expr*module_expr(* ME1(ME2) *)|Pmod_constraintofmodule_expr*module_type(* (ME : MT) *)|Pmod_unpackofexpression(* (val E) *)|Pmod_extensionofextension(* [%id] *)andstructure=structure_itemlistandstructure_item(*IF_CURRENT = Parsetree.structure_item *) ={pstr_desc:structure_item_desc;pstr_loc:Location.t;}andstructure_item_desc(*IF_CURRENT = Parsetree.structure_item_desc *) =|Pstr_evalofexpression*attributes(* E *)|Pstr_value ofrec_flag *value_bindinglist(* let P1 = E1 and ... and Pn = EN (flag = Nonrecursive)
let rec P1 = E1 and ... and Pn = EN (flag = Recursive)
*)|Pstr_primitiveofvalue_description(* val x: T
external x: T = "s1" ... "sn" *)|Pstr_typeofrec_flag*type_declarationlist(* type t1 = ... and ... and tn = ... *)|Pstr_typextoftype_extension(* type t1 += ... *)|Pstr_exceptionoftype_exception(* exception C of T
exception C = M.X *)|Pstr_moduleofmodule_binding(* module X = ME *)|Pstr_recmodule ofmodule_bindinglist(* module rec X1 = ME1 and ... and Xn = MEn *)|Pstr_modtypeofmodule_type_declaration(* module type S = MT *)|Pstr_openofopen_declaration(* open X *)|Pstr_classofclass_declarationlist(* class c1 = ... and ... and cn = ... *)|Pstr_class_typeofclass_type_declarationlist(* class type ct1 = ... and ... and ctn = ... *)|Pstr_includeofinclude_declaration(* include ME *)|Pstr_attribute ofattribute(* [@@@id] *)|Pstr_extensionofextension*attributes(* [%%id] *)andvalue_binding(*IF_CURRENT = Parsetree.value_binding *)={pvb_pat:pattern;pvb_expr:expression;pvb_attributes:attributes;pvb_loc:Location.t;}andmodule_binding(*IF_CURRENT = Parsetree.module_binding *)={pmb_name:stringoptionloc;pmb_expr:module_expr;pmb_attributes:attributes;pmb_loc:Location.t;}(* X = ME *)(** {1 Toplevel} *)(* Toplevel phrases *)typetoplevel_phrase(*IF_CURRENT = Parsetree.toplevel_phrase *)=|Ptop_defofstructure|Ptop_diroftoplevel_directive(* #use, #load ... *)andtoplevel_directive(*IF_CURRENT = Parsetree.toplevel_directive *)={pdir_name:stringloc;pdir_arg:directive_argumentoption;pdir_loc:Location.t;}anddirective_argument(*IF_CURRENT = Parsetree.directive_argument *)={pdira_desc:directive_argument_desc;pdira_loc:Location.t;}anddirective_argument_desc(*IF_CURRENT = Parsetree.directive_argument_desc *)=|Pdir_stringofstring|Pdir_intofstring*charoption|Pdir_identofLongident.t|Pdir_boolofboolendmoduleDocstrings:sig(** (Re)Initialise all docstring state *)valinit:unit->unit(** Emit warnings for unattached and ambiguous docstrings *)valwarn_bad_docstrings:unit->unit(** {2 Docstrings} *)(** Documentation comments *)typedocstring(** Create a docstring *)valdocstring:string->Location.t->docstring(** Register a docstring *)valregister:docstring->unit(** Get the text of a docstring *)valdocstring_body:docstring->string(** Get the location of a docstring *)valdocstring_loc:docstring->Location.t(** {2 Set functions}
These functions are used by the lexer to associate docstrings to
the locations of tokens. *)(** Docstrings immediately preceding a token *)valset_pre_docstrings:Lexing.position->docstringlist->unit(** Docstrings immediately following a token *)valset_post_docstrings:Lexing.position->docstringlist->unit(** Docstrings not immediately adjacent to a token *)valset_floating_docstrings:Lexing.position->docstringlist->unit(** Docstrings immediately following the token which precedes this one *)valset_pre_extra_docstrings:Lexing.position->docstringlist->unit(** Docstrings immediately preceding the token which follows this one *)valset_post_extra_docstrings:Lexing.position->docstringlist->unit(** {2 Items}
The {!docs} type represents documentation attached to an item. *)typedocs={docs_pre:docstringoption;docs_post:docstringoption;}valempty_docs:docsvaldocs_attr:docstring->Parsetree.attribute(** Convert item documentation to attributes and add them to an
attribute list *)valadd_docs_attrs:docs->Parsetree.attributes->Parsetree.attributes(** Fetch the item documentation for the current symbol. This also
marks this documentation (for ambiguity warnings). *)valsymbol_docs:unit->docsvalsymbol_docs_lazy:unit->docsLazy.t(** Fetch the item documentation for the symbols between two
positions. This also marks this documentation (for ambiguity
warnings). *)valrhs_docs:int->int->docsvalrhs_docs_lazy:int->int->docsLazy.t(** Mark the item documentation for the current symbol (for ambiguity
warnings). *)valmark_symbol_docs:unit->unit(** Mark as associated the item documentation for the symbols between
two positions (for ambiguity warnings) *)valmark_rhs_docs:int->int->unit(** {2 Fields and constructors}
The {!info} type represents documentation attached to a field or
constructor. *)typeinfo=docstringoptionvalempty_info:infovalinfo_attr:docstring->Parsetree.attribute(** Convert field info to attributes and add them to an
attribute list *)valadd_info_attrs:info->Parsetree.attributes->Parsetree.attributes(** Fetch the field info for the current symbol. *)valsymbol_info:unit->info(** Fetch the field info following the symbol at a given position. *)valrhs_info:int->info(** {2 Unattached comments}
The {!text} type represents documentation which is not attached to
anything. *)typetext=docstringlistvalempty_text:textvalempty_text_lazy:textLazy.tvaltext_attr:docstring->Parsetree.attribute(** Convert text to attributes and add them to an attribute list *)valadd_text_attrs:text->Parsetree.attributes->Parsetree.attributes(** Fetch the text preceding the current symbol. *)valsymbol_text:unit->textvalsymbol_text_lazy:unit->textLazy.t(** Fetch the text preceding the symbol at the given position. *)valrhs_text:int->textvalrhs_text_lazy:int->textLazy.t(** {2 Extra text}
There may be additional text attached to the delimiters of a block
(e.g. [struct] and [end]). This is fetched by the following
functions, which are applied to the contents of the block rather
than the delimiters. *)(** Fetch additional text preceding the current symbol *)valsymbol_pre_extra_text:unit->text(** Fetch additional text following the current symbol *)valsymbol_post_extra_text:unit->text(** Fetch additional text preceding the symbol at the given position *)valrhs_pre_extra_text:int->text(** Fetch additional text following the symbol at the given position *)valrhs_post_extra_text:int->text(** Fetch text following the symbol at the given position *)valrhs_post_text:int->textmoduleWithMenhir:sig(** Fetch the item documentation for the current symbol. This also
marks this documentation (for ambiguity warnings). *)valsymbol_docs:Lexing.position*Lexing.position->docsvalsymbol_docs_lazy:Lexing.position*Lexing.position->docsLazy.t(** Fetch the item documentation for the symbols between two
positions. This also marks this documentation (for ambiguity
warnings). *)valrhs_docs:Lexing.position->Lexing.position->docsvalrhs_docs_lazy :Lexing.position->Lexing.position->docsLazy.t(** Mark the item documentation for the current symbol (for ambiguity
warnings). *)valmark_symbol_docs:Lexing.position*Lexing.position->unit(** Mark as associated the item documentation for the symbols between
two positions (for ambiguity warnings) *)valmark_rhs_docs:Lexing.position->Lexing.position->unit(** Fetch the field info for the current symbol. *)valsymbol_info:Lexing.position->info(** Fetch the field info following the symbol at a given position. *)valrhs_info:Lexing.position->info(** Fetch the text preceding the current symbol. *)valsymbol_text:Lexing.position->textvalsymbol_text_lazy:Lexing.position->textLazy.t(** Fetch the text preceding the symbol at the given position. *)valrhs_text:Lexing.position->textvalrhs_text_lazy:Lexing.position ->textLazy.t(** {3 Extra text}
There may be additional text attached to the delimiters of a block
(e.g. [struct] and [end]). This is fetched by the following
functions, which are applied to the contents of the block rather
than the delimiters. *)(** Fetch additional text preceding the current symbol *)valsymbol_pre_extra_text:Lexing.position->text(** Fetch additional text following the current symbol *)valsymbol_post_extra_text:Lexing.position->text(** Fetch additional text preceding the symbol at the given position *)valrhs_pre_extra_text:Lexing.position->text(** Fetch additional text following the symbol at the given position *)valrhs_post_extra_text:Lexing.position->text(** Fetch text following the symbol at the given position *)valrhs_post_text:Lexing.position->textendend=structopenLocation(* Docstrings *)(* A docstring is "attached" if it has been inserted in the AST. This
is used for generating unexpected docstring warnings. *)typeds_attached=|Unattached(* Not yet attached anything.*)|Info(* Attached to a field or constructor. *)|Docs(* Attached to an item or as floating text. *)(* A docstring is "associated" with an item if there are no blank lines between
them. This is used for generating docstring ambiguity warnings. *)typeds_associated=|Zero(* Not associated with an item *)|One(* Associated with one item *)|Many(* Associated with multiple items (ambiguity) *)typedocstring={ds_body:string;ds_loc:Location.t;mutable ds_attached:ds_attached;mutableds_associated:ds_associated;}(* List of docstrings *)letdocstrings :docstringlistref=ref[](* Warn for unused and ambiguous docstrings *)letwarn_bad_docstrings()=ifWarnings.is_active(Migrate_parsetree_compiler_functions.bad_docstringtrue)thenbeginList.iter(funds->matchds.ds_attachedwith|Info->()|Unattached->prerr_warningds.ds_loc(Migrate_parsetree_compiler_functions.bad_docstringtrue)|Docs->matchds.ds_associatedwith|Zero |One->()|Many->prerr_warningds.ds_loc(Migrate_parsetree_compiler_functions.bad_docstringfalse))(List.rev!docstrings)end(* Docstring constructors and destructors *)letdocstringbodyloc=letds={ds_body =body;ds_loc=loc;ds_attached=Unattached;ds_associated=Zero;}indsletregisterds=docstrings:= ds::!docstringsletdocstring_bodyds=ds.ds_bodyletdocstring_locds=ds.ds_loc(* Docstrings attached to items *)typedocs={docs_pre:docstringoption;docs_post:docstringoption;}letempty_docs={docs_pre =None;docs_post=None}letdoc_loc={txt="ocaml.doc";loc=Location.none}letdocs_attrds=letopenParsetreeinletexp ={pexp_desc=Pexp_constant(Pconst_string(ds.ds_body,ds.ds_loc,None));pexp_loc =ds.ds_loc;pexp_loc_stack=[];pexp_attributes=[];}inletitem={pstr_desc=Pstr_eval(exp,[]);pstr_loc=exp.pexp_loc}in{attr_name=doc_loc;attr_payload=PStr[item];attr_loc=Location.none}letadd_docs_attrsdocsattrs=letattrs=matchdocs.docs_prewith|None|Some{ds_body="";_}->attrs|Someds->docs_attrds::attrsinlet attrs=matchdocs.docs_postwith|None|Some{ds_body="";_}->attrs|Someds->attrs@[docs_attrds]inattrs(* Docstrings attached to constructors or fields *)typeinfo=docstringoptionletempty_info=Noneletinfo_attr=docs_attrletadd_info_attrsinfoattrs=matchinfowith|None|Some {ds_body="";_}->attrs|Someds->attrs@[info_attrds](* Docstrings notattached to a specific item *)typetext=docstringlistletempty_text=[]letempty_text_lazy =lazy[]lettext_loc={txt="ocaml.text";loc=Location.none}lettext_attrds=letopenParsetreeinletexp ={pexp_desc=Pexp_constant(Pconst_string(ds.ds_body,ds.ds_loc,None));pexp_loc =ds.ds_loc;pexp_loc_stack=[];pexp_attributes=[];}inletitem={pstr_desc=Pstr_eval(exp,[]);pstr_loc=exp.pexp_loc}in{attr_name=text_loc;attr_payload=PStr[item];attr_loc=Location.none}letadd_text_attrsdslattrs=letfdsl=List.filter(function {ds_body=""}->false|_->true)dslin(List.maptext_attrfdsl)@attrs(* Find the first non-info docstring in a list, attach it and return it *)letget_docstring~infodsl=letrecloop=function|[]->None|{ds_attached=Info;_}::rest->looprest|ds::_->ds.ds_attached<-if infothenInfoelseDocs;Somedsinloopdsl(* Find all the non-info docstrings in a list, attach them and return them *)letget_docstringsdsl=letrecloopacc=function|[]->List.revacc|{ds_attached=Info;_}::rest ->loopaccrest|ds::rest->ds.ds_attached<- Docs;loop(ds::acc)restinloop[]dsl(* "Associate" all the docstrings in a list *)letassociate_docstringsdsl=List.iter(funds->matchds.ds_associatedwith|Zero->ds.ds_associated<-One|(One|Many)->ds.ds_associated<-Many)dsl(* Map from positions to pre docstrings *)letpre_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_pre_docstringsposdsl=ifdsl<>[]thenHashtbl.addpre_tableposdslletget_pre_docspos=tryletdsl=Hashtbl.findpre_tableposinassociate_docstringsdsl;get_docstring~info:falsedslwithNot_found->Noneletmark_pre_docspos=tryletdsl=Hashtbl.findpre_tableposinassociate_docstringsdslwithNot_found->()(* Map from positions to post docstrings *)letpost_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_post_docstringsposdsl=ifdsl<>[]thenHashtbl.addpost_tableposdslletget_post_docspos=tryletdsl=Hashtbl.findpost_tableposinassociate_docstringsdsl;get_docstring~info:falsedslwithNot_found->Noneletmark_post_docspos=tryletdsl=Hashtbl.findpost_tableposinassociate_docstringsdslwithNot_found->()letget_infopos=tryletdsl=Hashtbl.findpost_tableposinget_docstring~info:truedslwithNot_found->None(* Map from positions to floating docstrings *)letfloating_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_floating_docstringsposdsl=ifdsl<>[]thenHashtbl.add floating_tableposdslletget_text pos=trylet dsl=Hashtbl.findfloating_tableposinget_docstrings dslwithNot_found->[]letget_post_textpos=tryletdsl=Hashtbl.findpost_tableposinget_docstringsdslwithNot_found->[](* Maps from positions to extra docstrings *)letpre_extra_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_pre_extra_docstringsposdsl=ifdsl<>[]thenHashtbl.add pre_extra_tablepos dslletget_pre_extra_text pos=tryletdsl=Hashtbl.findpre_extra_tableposinget_docstrings dslwithNot_found->[]letpost_extra_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_post_extra_docstringsposdsl=ifdsl<>[]thenHashtbl.add post_extra_table posdslletget_post_extra_text pos=tryletdsl=Hashtbl.findpost_extra_tableposinget_docstrings dslwithNot_found->[](* Docstrings from parser actions *)moduleWithParsing=structletsymbol_docs()={docs_pre=get_pre_docs(Parsing.symbol_start_pos());docs_post=get_post_docs (Parsing.symbol_end_pos());}letsymbol_docs_lazy()=letp1=Parsing.symbol_start_pos()inletp2=Parsing.symbol_end_pos()inlazy{docs_pre=get_pre_docsp1;docs_post=get_post_docsp2;}letrhs_docspos1pos2={docs_pre=get_pre_docs(Parsing.rhs_start_pospos1);docs_post=get_post_docs(Parsing.rhs_end_pospos2);}letrhs_docs_lazypos1pos2=letp1=Parsing.rhs_start_pos pos1inletp2=Parsing.rhs_end_pospos2inlazy{docs_pre=get_pre_docs p1;docs_post=get_post_docsp2;}letmark_symbol_docs()=mark_pre_docs(Parsing.symbol_start_pos());mark_post_docs(Parsing.symbol_end_pos())letmark_rhs_docspos1pos2=mark_pre_docs(Parsing.rhs_start_pospos1);mark_post_docs(Parsing.rhs_end_pospos2)letsymbol_info()=get_info(Parsing.symbol_end_pos())letrhs_infopos=get_info(Parsing.rhs_end_pospos)letsymbol_text()=get_text(Parsing.symbol_start_pos())letsymbol_text_lazy()=letpos=Parsing.symbol_start_pos ()inlazy(get_textpos)letrhs_textpos=get_text(Parsing.rhs_start_pos pos)letrhs_post_textpos=get_post_text (Parsing.rhs_end_pos pos)letrhs_text_lazypos=let pos=Parsing.rhs_start_posposinlazy(get_textpos)letsymbol_pre_extra_text()=get_pre_extra_text(Parsing.symbol_start_pos())letsymbol_post_extra_text()=get_post_extra_text(Parsing.symbol_end_pos())letrhs_pre_extra_textpos=get_pre_extra_text(Parsing.rhs_start_pospos)letrhs_post_extra_textpos=get_post_extra_text(Parsing.rhs_end_pospos)endincludeWithParsingmoduleWithMenhir=structletsymbol_docs(startpos,endpos)={docs_pre=get_pre_docs startpos;docs_post=get_post_docsendpos;}letsymbol_docs_lazy(p1,p2)=lazy{docs_pre=get_pre_docs p1;docs_post=get_post_docsp2;}letrhs_docspos1pos2={docs_pre=get_pre_docspos1;docs_post=get_post_docspos2;}letrhs_docs_lazyp1p2=lazy{docs_pre=get_pre_docsp1;docs_post=get_post_docsp2;}letmark_symbol_docs(startpos,endpos)=mark_pre_docs startpos;mark_post_docsendpos;()letmark_rhs_docspos1pos2=mark_pre_docspos1;mark_post_docs pos2;()letsymbol_infoendpos=get_infoendposletrhs_infoendpos=get_info endposletsymbol_textstartpos=get_textstartposletsymbol_text_lazy startpos=lazy(get_textstartpos)letrhs_textpos=get_text posletrhs_post_text pos=get_post_text posletrhs_text_lazy pos=lazy (get_textpos)letsymbol_pre_extra_textstartpos=get_pre_extra_textstartposletsymbol_post_extra_textendpos=get_post_extra_textendposletrhs_pre_extra_textpos=get_pre_extra_textposlet rhs_post_extra_textpos=get_post_extra_textposend(* (Re)Initialise all comment state *)letinit()=docstrings:=[];Hashtbl.resetpre_table;Hashtbl.resetpost_table;Hashtbl.resetfloating_table;Hashtbl.resetpre_extra_table;Hashtbl.resetpost_extra_tableendmoduleAst_helper:sigopenAsttypesopenDocstringsopenParsetreetype'awith_loc='aLocation.loctypeloc=Location.ttypelid=Longident.twith_loctypestr=stringwith_loctypestr_opt =stringoptionwith_loctypeattrs=attributelist(** {1 Default locations} *)val default_loc:locref(** Default value for all optional location arguments. *)valwith_default_loc:loc->(unit->'a)->'a(** Set the [default_loc] within the scope of the execution
of the provided function. *)(** {1 Constants} *)moduleConst:sigvalchar:char->constantvalstring:?quotation_delimiter:string->?loc:Location.t->string->constantvalinteger:?suffix:char->string ->constantvalint:?suffix:char ->int->constantvalint32:?suffix:char ->int32->constantvalint64:?suffix:char->int64->constantvalnativeint:?suffix:char->nativeint->constantvalfloat:?suffix:char ->string->constantend(** {1 Attributes} *)module Attr :sigvalmk:?loc:loc->str->payload->attributeend(** {1 Core language} *)(** Type expressions *)moduleTyp:sigvalmk:?loc:loc->?attrs:attrs->core_type_desc->core_typeval attr:core_type->attribute->core_typevalany:?loc:loc->?attrs:attrs->unit->core_typevalvar:?loc:loc->?attrs:attrs->string->core_typevalarrow:?loc:loc->?attrs:attrs->arg_label->core_type->core_type->core_typevaltuple:?loc:loc->?attrs:attrs ->core_typelist->core_typeval constr:?loc:loc->?attrs:attrs ->lid->core_typelist->core_typeval object_:?loc:loc->?attrs:attrs->object_fieldlist->closed_flag->core_typevalclass_:?loc:loc->?attrs:attrs ->lid->core_typelist->core_typeval alias:?loc:loc->?attrs:attrs->core_type->string->core_typevalvariant:?loc:loc->?attrs:attrs ->row_fieldlist->closed_flag->labellistoption ->core_typevalpoly:?loc:loc-> ?attrs:attrs ->strlist->core_type->core_typeval package:?loc:loc->?attrs:attrs ->lid->(lid*core_type)list->core_typevalextension:?loc:loc->?attrs:attrs->extension->core_typevalforce_poly:core_type->core_typevalvarify_constructors:strlist ->core_type->core_type(** [varify_constructors newtypes te] is type expression [te], of which
any of nullary type constructor [tc] is replaced by type variable of
the same name, if [tc]'s name appears in [newtypes].
Raise [Syntaxerr.Variable_in_scope] if any type variable inside [te]
appears in [newtypes].
@since 4.05
*)end(** Patterns *)modulePat:sigvalmk:?loc:loc->?attrs:attrs->pattern_desc->patternvalattr:pattern->attribute->patternvalany:?loc:loc->?attrs:attrs->unit->patternvalvar:?loc:loc->?attrs:attrs->str->patternvalalias:?loc:loc->?attrs:attrs->pattern->str->patternvalconstant:?loc:loc->?attrs:attrs->constant->patternvalinterval:?loc:loc->?attrs:attrs->constant->constant->patternvaltuple:?loc:loc->?attrs:attrs ->patternlist->patternvalconstruct:?loc:loc->?attrs:attrs->lid->patternoption->patternvalvariant:?loc:loc->?attrs:attrs->label->patternoption->patternvalrecord:?loc:loc->?attrs:attrs ->(lid*pattern)list ->closed_flag->patternval array:?loc:loc->?attrs:attrs->patternlist->patternvalor_:?loc:loc->?attrs:attrs->pattern->pattern->patternvalconstraint_:?loc:loc->?attrs:attrs->pattern->core_type->patternvaltype_:?loc:loc->?attrs:attrs->lid->patternvallazy_:?loc:loc->?attrs:attrs ->pattern->patternvalunpack:?loc:loc->?attrs:attrs ->str_opt->patternvalopen_:?loc:loc->?attrs:attrs->lid->pattern->patternvalexception_:?loc:loc->?attrs:attrs->pattern->patternvalextension:?loc:loc->?attrs:attrs->extension->patternend(** Expressions *)moduleExp:sigvalmk:?loc:loc->?attrs:attrs->expression_desc->expressionvalattr:expression->attribute->expressionvalident:?loc:loc->?attrs:attrs->lid->expressionvalconstant:?loc:loc->?attrs:attrs->constant->expressionvallet_:?loc:loc->?attrs:attrs ->rec_flag->value_bindinglist->expression->expressionvalfun_:?loc:loc->?attrs:attrs ->arg_label->expressionoption->pattern->expression->expressionvalfunction_:?loc:loc->?attrs:attrs->caselist->expressionvalapply:?loc:loc->?attrs:attrs->expression-> (arg_label*expression)list->expressionvalmatch_:?loc:loc->?attrs:attrs ->expression->caselist->expressionvaltry_:?loc:loc->?attrs:attrs->expression->caselist->expressionvaltuple:?loc:loc->?attrs:attrs ->expressionlist->expressionvalconstruct:?loc:loc->?attrs:attrs->lid->expressionoption->expressionvalvariant:?loc:loc->?attrs:attrs->label->expressionoption-> expressionvalrecord:?loc:loc->?attrs:attrs ->(lid*expression)list->expression option->expressionvalfield:?loc:loc->?attrs:attrs->expression->lid->expressionvalsetfield:?loc:loc->?attrs:attrs->expression->lid->expression->expressionvalarray:?loc:loc->?attrs:attrs ->expressionlist->expressionvalifthenelse:?loc:loc->?attrs:attrs->expression->expression->expressionoption->expressionvalsequence:?loc:loc->?attrs:attrs->expression->expression->expressionvalwhile_:?loc:loc->?attrs:attrs ->expression->expression->expressionvalfor_:?loc:loc->?attrs:attrs->pattern->expression->expression->direction_flag->expression->expressionvalcoerce:?loc:loc->?attrs:attrs ->expression->core_typeoption->core_type->expressionvalconstraint_:?loc:loc->?attrs:attrs->expression->core_type->expressionvalsend:?loc:loc->?attrs:attrs->expression->str->expressionvalnew_:?loc:loc->?attrs:attrs ->lid->expressionvalsetinstvar:?loc:loc->?attrs:attrs->str->expression->expressionvaloverride:?loc:loc->?attrs:attrs->(str*expression)list->expressionvalletmodule:?loc:loc->?attrs:attrs->str_opt->module_expr->expression ->expressionvalletexception:?loc:loc->?attrs:attrs->extension_constructor->expression->expressionvalassert_:?loc:loc->?attrs:attrs->expression->expressionvallazy_:?loc:loc->?attrs:attrs ->expression->expressionvalpoly:?loc:loc->?attrs:attrs ->expression->core_typeoption->expressionvalobject_:?loc:loc->?attrs:attrs ->class_structure->expressionvalnewtype:?loc:loc->?attrs:attrs ->str->expression->expressionvalpack:?loc:loc->?attrs:attrs ->module_expr->expressionvalopen_:?loc:loc->?attrs:attrs ->open_declaration->expression->expressionvalletop:?loc:loc->?attrs:attrs ->binding_op-> binding_oplist->expression->expressionvalextension:?loc:loc->?attrs:attrs->extension->expressionvalunreachable:?loc:loc->?attrs:attrs->unit->expressionvalcase:pattern->?guard:expression->expression->casevalbinding_op:str->pattern->expression->loc->binding_opend(** Value declarations *)moduleVal:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?prim:stringlist->str->core_type->value_descriptionend(** Type declarations *)moduleType:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->?params:(core_type*variance)list->?cstrs:(core_type*core_type*loc)list->?kind:type_kind->?priv:private_flag ->?manifest:core_type->str->type_declarationvalconstructor:?loc:loc->?attrs:attrs->?info:info->?args:constructor_arguments->?res:core_type->str->constructor_declarationvalfield:?loc:loc->?attrs:attrs->?info:info->?mut:mutable_flag->str->core_type->label_declarationend(** Type extensions *)module Te:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?params:(core_type*variance)list->?priv:private_flag->lid->extension_constructorlist->type_extensionvalmk_exception:?loc:loc->?attrs:attrs->?docs:docs->extension_constructor->type_exceptionvalconstructor:?loc:loc->?attrs:attrs->?docs:docs->?info:info->str->extension_constructor_kind->extension_constructorvaldecl:?loc:loc->?attrs:attrs->?docs:docs->?info:info->?args:constructor_arguments->?res:core_type->str->extension_constructorval rebind:?loc:loc->?attrs:attrs ->?docs:docs->?info:info->str->lid->extension_constructorend(** {1 Module language} *)(** Module type expressions *)moduleMty:sigvalmk:?loc:loc->?attrs:attrs->module_type_desc->module_typevalattr:module_type->attribute->module_typevalident:?loc:loc->?attrs:attrs ->lid->module_typevalalias:?loc:loc->?attrs:attrs ->lid->module_typevalsignature:?loc:loc->?attrs:attrs->signature->module_typevalfunctor_:?loc:loc->?attrs:attrs->functor_parameter->module_type->module_typevalwith_:?loc:loc->?attrs:attrs ->module_type->with_constraintlist->module_typevaltypeof_:?loc:loc->?attrs:attrs ->module_expr->module_typevalextension:?loc:loc->?attrs:attrs->extension->module_typeend(** Module expressions *)moduleMod:sigvalmk:?loc:loc->?attrs:attrs->module_expr_desc->module_exprvalattr:module_expr->attribute->module_exprvalident:?loc:loc->?attrs:attrs ->lid->module_exprvalstructure:?loc:loc->?attrs:attrs->structure->module_exprvalfunctor_:?loc:loc->?attrs:attrs->functor_parameter->module_expr->module_exprvalapply:?loc:loc->?attrs:attrs ->module_expr->module_expr->module_exprvalconstraint_:?loc:loc->?attrs:attrs->module_expr->module_type->module_exprvalunpack:?loc:loc->?attrs:attrs->expression->module_exprvalextension:?loc:loc->?attrs:attrs->extension->module_exprend(** Signature items *)moduleSig:sigvalmk:?loc:loc->signature_item_desc->signature_itemvalvalue:?loc:loc->value_description->signature_itemvaltype_:?loc:loc->rec_flag->type_declarationlist->signature_itemvaltype_subst:?loc:loc->type_declarationlist->signature_itemvaltype_extension:?loc:loc->type_extension->signature_itemvalexception_:?loc:loc->type_exception->signature_itemvalmodule_:?loc:loc->module_declaration->signature_itemvalmod_subst:?loc:loc->module_substitution->signature_itemvalrec_module:?loc:loc->module_declarationlist->signature_itemvalmodtype:?loc:loc->module_type_declaration->signature_itemvalopen_:?loc:loc->open_description->signature_itemvalinclude_:?loc:loc->include_description->signature_itemvalclass_:?loc:loc->class_descriptionlist->signature_itemvalclass_type:?loc:loc->class_type_declarationlist->signature_itemvalextension:?loc:loc->?attrs:attrs->extension->signature_itemval attribute:?loc:loc->attribute->signature_itemval text:text->signature_itemlistend(** Structure items *)module Str:sigvalmk:?loc:loc->structure_item_desc->structure_itemvaleval:?loc:loc->?attrs:attributes->expression->structure_itemvalvalue:?loc:loc->rec_flag->value_bindinglist->structure_itemvalprimitive:?loc:loc->value_description->structure_itemvaltype_:?loc:loc->rec_flag->type_declarationlist->structure_itemvaltype_extension:?loc:loc->type_extension->structure_itemvalexception_:?loc:loc->type_exception->structure_itemvalmodule_:?loc:loc->module_binding->structure_itemvalrec_module:?loc:loc->module_bindinglist->structure_itemvalmodtype:?loc:loc->module_type_declaration->structure_itemvalopen_:?loc:loc->open_declaration->structure_itemvalclass_:?loc:loc->class_declarationlist->structure_itemvalclass_type:?loc:loc->class_type_declarationlist->structure_itemvalinclude_:?loc:loc->include_declaration->structure_itemvalextension:?loc:loc->?attrs:attrs->extension->structure_itemval attribute:?loc:loc->attribute->structure_itemval text:text->structure_itemlistend(** Module declarations *)module Md:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->str_opt->module_type->module_declarationend(** Module substitutions *)module Ms:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->str->lid->module_substitutionend(** Module type declarations *)moduleMtd:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->?typ:module_type->str->module_type_declarationend(** Module bindings *)moduleMb:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->str_opt->module_expr->module_bindingend(** Opens *)moduleOpn:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?override:override_flag->'a->'aopen_infosend(** Includes *)moduleIncl:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->'a-> 'ainclude_infosend(** Value bindings *)moduleVb:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->pattern->expression->value_bindingend(** {1 Class language} *)(** Class type expressions *)moduleCty:sigvalmk:?loc:loc->?attrs:attrs->class_type_desc->class_typevalattr:class_type->attribute->class_typevalconstr:?loc:loc->?attrs:attrs->lid->core_typelist->class_typeval signature:?loc:loc->?attrs:attrs->class_signature->class_typevalarrow:?loc:loc->?attrs:attrs->arg_label->core_type->class_type ->class_typevalextension:?loc:loc->?attrs:attrs->extension->class_typevalopen_:?loc:loc->?attrs:attrs->open_description->class_type->class_typeend(** Class type fields *)module Ctf:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->class_type_field_desc->class_type_fieldvalattr:class_type_field->attribute->class_type_fieldvalinherit_:?loc:loc->?attrs:attrs->class_type->class_type_fieldvalval_:?loc:loc->?attrs:attrs ->str->mutable_flag->virtual_flag->core_type->class_type_fieldvalmethod_:?loc:loc->?attrs:attrs ->str->private_flag->virtual_flag->core_type->class_type_fieldvalconstraint_:?loc:loc->?attrs:attrs->core_type->core_type->class_type_fieldvalextension:?loc:loc->?attrs:attrs->extension->class_type_fieldvalattribute:?loc:loc->attribute->class_type_fieldvaltext:text->class_type_fieldlistend(** Class expressions *)moduleCl:sigvalmk:?loc:loc->?attrs:attrs->class_expr_desc->class_exprvalattr:class_expr->attribute->class_exprvalconstr:?loc:loc->?attrs:attrs->lid->core_typelist->class_exprval structure:?loc:loc->?attrs:attrs->class_structure->class_exprvalfun_:?loc:loc->?attrs:attrs->arg_label->expressionoption->pattern->class_expr->class_exprvalapply:?loc:loc->?attrs:attrs ->class_expr->(arg_label*expression)list->class_exprvallet_:?loc:loc->?attrs:attrs ->rec_flag->value_bindinglist->class_expr->class_exprvalconstraint_:?loc:loc->?attrs:attrs->class_expr->class_type->class_exprvalextension:?loc:loc->?attrs:attrs->extension->class_exprvalopen_:?loc:loc->?attrs:attrs->open_description->class_expr->class_exprend(** Class fields *)moduleCf:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->class_field_desc->class_fieldvalattr:class_field->attribute->class_fieldvalinherit_:?loc:loc->?attrs:attrs->override_flag->class_expr->stroption->class_fieldvalval_:?loc:loc->?attrs:attrs ->str->mutable_flag->class_field_kind->class_fieldvalmethod_:?loc:loc->?attrs:attrs ->str->private_flag->class_field_kind->class_fieldvalconstraint_:?loc:loc->?attrs:attrs->core_type->core_type->class_fieldvalinitializer_:?loc:loc->?attrs:attrs->expression->class_fieldvalextension:?loc:loc->?attrs:attrs->extension->class_fieldvalattribute:?loc:loc->attribute->class_fieldvaltext:text->class_fieldlistvalvirtual_:core_type->class_field_kindvalconcrete:override_flag->expression ->class_field_kindend(** Classes *)moduleCi:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->?virt:virtual_flag->?params:(core_type*variance)list->str->'a->'aclass_infosend(** Class signatures *)moduleCsig:sigvalmk:core_type->class_type_fieldlist->class_signatureend(** Class structures *)module Cstr:sigvalmk:pattern->class_fieldlist->class_structureend(** Row fields *)moduleRf:sigvalmk:?loc:loc->?attrs:attrs->row_field_desc->row_fieldval tag:?loc:loc->?attrs:attrs->labelwith_loc->bool->core_type list->row_fieldval inherit_:?loc:loc->core_type ->row_fieldend(** Object fields *)module Of:sigvalmk:?loc:loc->?attrs:attrs->object_field_desc->object_fieldvaltag:?loc:loc->?attrs:attrs->labelwith_loc->core_type->object_fieldvalinherit_:?loc:loc->core_type ->object_fieldendend =structopenAsttypesopenParsetreeopenDocstringstype'awith_loc='aLocation.loctypeloc=Location.ttypelid=Longident.twith_loctypestr=stringwith_loctypestr_opt =stringoptionwith_loctypeattrs=attributelistletdefault_loc=refLocation.noneletwith_default_loclf=Misc.protect_refs[Misc.R(default_loc,l)]fmoduleConst=structletinteger?suffixi=Pconst_integer(i,suffix)letint?suffixi=integer?suffix(Int.to_stringi)letint32?(suffix='l')i=integer ~suffix(Int32.to_stringi)letint64?(suffix='L')i=integer~suffix(Int64.to_stringi)letnativeint?(suffix='n')i=integer~suffix(Nativeint.to_stringi)letfloat?suffixf=Pconst_float (f,suffix)letcharc=Pconst_charclet string?quotation_delimiter ?(loc=!default_loc)s=Pconst_string(s,loc,quotation_delimiter)endmoduleAttr=structletmk?(loc=!default_loc)namepayload={attr_name=name;attr_payload =payload;attr_loc=loc}endmoduleTyp=structlet mk?(loc =!default_loc)?(attrs=[])d={ptyp_desc=d;ptyp_loc=loc;ptyp_loc_stack=[];ptyp_attributes =attrs}letattrda={dwithptyp_attributes=d.ptyp_attributes @[a]}letany?loc?attrs()=mk?loc?attrsPtyp_anyletvar?loc?attrsa=mk?loc?attrs(Ptyp_vara)letarrow?loc ?attrs abc=mk?loc?attrs(Ptyp_arrow(a,b,c))lettuple?loc?attrsa=mk?loc?attrs(Ptyp_tuplea)letconstr?loc?attrsab=mk?loc?attrs(Ptyp_constr(a,b))letobject_?loc?attrsab=mk?loc?attrs(Ptyp_object(a,b))letclass_?loc?attrsab=mk?loc?attrs(Ptyp_class(a,b))letalias ?loc ?attrsab=mk?loc?attrs(Ptyp_alias(a,b))letvariant ?loc?attrsabc=mk?loc?attrs(Ptyp_variant(a,b,c))letpoly?loc?attrsab=mk?loc?attrs(Ptyp_poly (a,b))letpackage?loc?attrsab=mk?loc?attrs(Ptyp_package(a,b))letextension?loc?attrsa=mk?loc?attrs(Ptyp_extensiona)letforce_poly t=matcht.ptyp_descwith|Ptyp_poly_->t|_->poly~loc:t.ptyp_loc[]t(* -> ghost? *)letvarify_constructorsvar_namest=letcheck_variablevllocv=ifList.memvvlthenraiseSyntaxerr.(Error(Variable_in_scope(loc,v)))inletvar_names=List.map(funv->v.txt)var_namesinlet recloopt=letdesc=matcht.ptyp_descwith|Ptyp_any->Ptyp_any|Ptyp_varx->check_variablevar_namest.ptyp_locx;Ptyp_varx|Ptyp_arrow(label,core_type,core_type')->Ptyp_arrow(label,loop core_type,loopcore_type')|Ptyp_tuple lst->Ptyp_tuple (List.maplooplst)|Ptyp_constr({txt=Longident.Lidents},[])whenList.memsvar_names->Ptyp_vars|Ptyp_constr(longident,lst)->Ptyp_constr(longident,List.maplooplst)|Ptyp_object (lst,o)->Ptyp_object(List.maploop_object_fieldlst,o)|Ptyp_class(longident,lst)->Ptyp_class(longident,List.maplooplst)|Ptyp_alias(core_type,string)->check_variablevar_namest.ptyp_locstring;Ptyp_alias(loopcore_type,string)|Ptyp_variant(row_field_list,flag,lbl_lst_option)->Ptyp_variant(List.map loop_row_fieldrow_field_list,flag,lbl_lst_option)|Ptyp_poly(string_lst,core_type)->List.iter (funv->check_variablevar_namest.ptyp_locv.txt)string_lst;Ptyp_poly(string_lst,loopcore_type)|Ptyp_package(longident,lst)->Ptyp_package(longident,List.map(fun(n,typ)->(n,looptyp))lst)|Ptyp_extension(s,arg)->Ptyp_extension(s,arg)in{twithptyp_desc=desc}andloop_row_fieldfield=letprf_desc=matchfield.prf_descwith|Rtag(label,flag,lst)->Rtag(label,flag,List.maplooplst)|Rinherit t->Rinherit(loopt)in{fieldwithprf_desc;}andloop_object_fieldfield=letpof_desc=matchfield.pof_descwith|Otag(label,t)->Otag(label,loopt)|Oinheritt->Oinherit(loopt)in{fieldwithpof_desc;}inlooptendmodulePat=structletmk?(loc =!default_loc)?(attrs=[])d={ppat_desc=d;ppat_loc=loc;ppat_loc_stack=[];ppat_attributes =attrs}letattrda={dwithppat_attributes=d.ppat_attributes @[a]}letany?loc?attrs()=mk?loc?attrsPpat_anyletvar?loc?attrsa=mk?loc?attrs(Ppat_vara)letalias?loc ?attrs ab=mk?loc?attrs(Ppat_alias(a,b))letconstant ?loc?attrsa=mk?loc?attrs(Ppat_constanta)letinterval?loc?attrsab=mk?loc?attrs(Ppat_interval(a,b))lettuple?loc?attrsa=mk?loc?attrs(Ppat_tuplea)letconstruct?loc?attrsab=mk?loc?attrs(Ppat_construct(a,b))let variant?loc?attrsab=mk?loc?attrs(Ppat_variant(a,b))letrecord?loc?attrsab=mk?loc?attrs(Ppat_record(a,b))letarray?loc?attrsa=mk?loc?attrs(Ppat_arraya)letor_?loc ?attrs ab=mk?loc?attrs(Ppat_or(a,b))letconstraint_?loc?attrsab=mk?loc?attrs(Ppat_constraint(a,b))lettype_ ?loc?attrsa=mk?loc?attrs(Ppat_typea)letlazy_?loc?attrs a=mk?loc?attrs(Ppat_lazya)letunpack?loc?attrsa=mk?loc?attrs(Ppat_unpack a)letopen_?loc?attrsab=mk?loc?attrs(Ppat_open (a,b))letexception_?loc?attrsa=mk?loc?attrs(Ppat_exceptiona)letextension?loc?attrsa=mk?loc?attrs(Ppat_extensiona)endmodule Exp =structletmk?(loc =!default_loc)?(attrs=[])d={pexp_desc=d;pexp_loc=loc;pexp_loc_stack=[];pexp_attributes =attrs}letattrda={dwithpexp_attributes=d.pexp_attributes @[a]}letident?loc?attrsa=mk?loc?attrs(Pexp_identa)letconstant?loc?attrsa=mk?loc?attrs(Pexp_constanta)letlet_?loc?attrsabc=mk?loc?attrs(Pexp_let(a,b,c))letfun_?loc?attrsabcd=mk?loc?attrs(Pexp_fun(a,b,c,d))let function_?loc?attrsa=mk?loc?attrs(Pexp_functiona)letapply?loc?attrsab=mk?loc?attrs(Pexp_apply(a,b))letmatch_ ?loc ?attrsab=mk?loc?attrs(Pexp_match(a,b))lettry_?loc?attrsab=mk?loc?attrs(Pexp_try(a,b))lettuple?loc?attrsa=mk?loc?attrs(Pexp_tuplea)letconstruct?loc?attrsab=mk?loc?attrs(Pexp_construct(a,b))let variant?loc?attrsab=mk?loc?attrs(Pexp_variant(a,b))letrecord?loc?attrsab=mk?loc?attrs(Pexp_record(a,b))letfield?loc?attrsab=mk?loc?attrs(Pexp_field(a,b))letsetfield ?loc?attrsabc=mk?loc?attrs(Pexp_setfield(a,b,c))letarray?loc?attrsa=mk?loc?attrs(Pexp_arraya)letifthenelse?loc?attrsabc=mk?loc?attrs(Pexp_ifthenelse(a,b,c))letsequence ?loc?attrsab=mk?loc?attrs(Pexp_sequence(a,b))letwhile_?loc?attrsab=mk?loc?attrs(Pexp_while(a,b))letfor_?loc?attrsabcde=mk?loc?attrs(Pexp_for (a,b,c,d,e))letconstraint_?loc?attrsab=mk?loc?attrs(Pexp_constraint(a,b))letcoerce ?loc?attrsabc=mk?loc?attrs(Pexp_coerce(a,b,c))let send?loc?attrsab=mk?loc?attrs(Pexp_send (a,b))letnew_?loc?attrsa=mk?loc?attrs(Pexp_newa)letsetinstvar?loc?attrsab=mk?loc?attrs(Pexp_setinstvar(a,b))letoverride ?loc?attrsa=mk?loc?attrs(Pexp_overridea)letletmodule?loc?attrsabc=mk?loc?attrs(Pexp_letmodule(a,b,c))letletexception?loc?attrsab=mk?loc?attrs(Pexp_letexception(a,b))letassert_?loc?attrsa=mk?loc?attrs(Pexp_assert a)letlazy_?loc?attrsa=mk?loc?attrs(Pexp_lazya)letpoly?loc ?attrs ab=mk?loc?attrs(Pexp_poly (a,b))letobject_?loc?attrsa=mk?loc?attrs(Pexp_object a)letnewtype?loc?attrsab=mk?loc?attrs(Pexp_newtype(a,b))letpack?loc?attrsa=mk?loc?attrs(Pexp_packa)letopen_?loc?attrs ab=mk?loc?attrs(Pexp_open (a,b))letletop?loc?attrslet_andsbody=mk?loc?attrs(Pexp_letop {let_;ands;body})let extension?loc?attrsa=mk ?loc?attrs(Pexp_extensiona)letunreachable?loc?attrs()=mk?loc?attrsPexp_unreachableletcaselhs?guardrhs={pc_lhs=lhs;pc_guard=guard;pc_rhs =rhs;}let binding_opoppatexploc={pbop_op=op;pbop_pat=pat;pbop_exp=exp;pbop_loc=loc;}endmoduleMty=structletmk?(loc =!default_loc)?(attrs=[])d={pmty_desc=d;pmty_loc=loc;pmty_attributes=attrs}letattrda={dwithpmty_attributes=d.pmty_attributes @[a]}letident?loc?attrsa=mk?loc?attrs(Pmty_identa)letalias?loc?attrsa=mk?loc?attrs(Pmty_aliasa)letsignature?loc?attrsa=mk?loc?attrs(Pmty_signaturea)letfunctor_?loc?attrsab=mk?loc?attrs(Pmty_functor(a,b))letwith_?loc?attrsab=mk?loc?attrs(Pmty_with (a,b))lettypeof_?loc?attrsa=mk?loc?attrs(Pmty_typeof a)letextension?loc?attrsa=mk?loc?attrs(Pmty_extensiona)endmodule Mod =structletmk?(loc =!default_loc)?(attrs=[])d={pmod_desc=d;pmod_loc=loc;pmod_attributes=attrs}letattrda={dwithpmod_attributes=d.pmod_attributes @[a]}letident?loc?attrsx=mk?loc?attrs(Pmod_identx)letstructure?loc?attrsx=mk?loc?attrs(Pmod_structurex)letfunctor_?loc?attrsargbody=mk?loc?attrs(Pmod_functor (arg,body))letapply?loc?attrsm1m2=mk ?loc?attrs(Pmod_apply(m1,m2))letconstraint_?loc?attrsmmty =mk?loc?attrs(Pmod_constraint(m,mty))letunpack?loc?attrse=mk?loc?attrs(Pmod_unpack e)letextension?loc?attrsa=mk?loc?attrs(Pmod_extensiona)endmodule Sig =structletmk?(loc =!default_loc)d={psig_desc=d;psig_loc =loc}letvalue?loca=mk?loc(Psig_valuea)lettype_ ?locrec_flaga=mk?loc(Psig_type(rec_flag,a))lettype_subst?loca=mk?loc(Psig_typesubsta)lettype_extension?loca=mk?loc(Psig_typexta)letexception_?loc a=mk?loc(Psig_exceptiona)letmodule_?loc a=mk?loc(Psig_modulea)letmod_subst?loc a=mk?loc(Psig_modsubsta)letrec_module?loca=mk?loc(Psig_recmodulea)letmodtype?loc a=mk?loc(Psig_modtypea)letopen_?loca=mk?loc(Psig_opena)let include_?loca=mk?loc(Psig_includea)letclass_?loca=mk?loc(Psig_classa)letclass_type ?loc a=mk?loc(Psig_class_typea)letextension?loc?(attrs=[])a=mk?loc(Psig_extension(a,attrs))letattribute?loca=mk?loc(Psig_attributea)lettexttxt=letf_txt=List.filter(funds->docstring_bodyds<>"")txt inList.map(funds->attribute~loc:(docstring_loc ds)(text_attrds))f_txtendmoduleStr=structletmk?(loc =!default_loc)d={pstr_desc=d;pstr_loc =loc}leteval?loc?(attrs=[])a=mk?loc(Pstr_eval(a,attrs))letvalue?locab=mk?loc(Pstr_value(a,b))letprimitive?loca=mk?loc(Pstr_primitivea)lettype_?locrec_flaga=mk?loc(Pstr_type(rec_flag,a))lettype_extension?loca=mk?loc(Pstr_typexta)letexception_?loc a=mk?loc(Pstr_exceptiona)letmodule_?loc a=mk?loc(Pstr_modulea)letrec_module?loc a=mk?loc(Pstr_recmodulea)letmodtype?loc a=mk?loc(Pstr_modtypea)letopen_?loca=mk?loc(Pstr_opena)let class_?loca=mk?loc(Pstr_classa)letclass_type ?loc a=mk?loc(Pstr_class_typea)letinclude_?loca=mk?loc(Pstr_includea)letextension?loc ?(attrs=[])a=mk?loc(Pstr_extension(a,attrs))letattribute?loca=mk?loc(Pstr_attributea)lettexttxt=letf_txt=List.filter(funds->docstring_bodyds<>"")txt inList.map(funds->attribute~loc:(docstring_loc ds)(text_attrds))f_txtendmoduleCl=structletmk ?(loc =!default_loc)?(attrs=[])d={pcl_desc =d;pcl_loc=loc;pcl_attributes=attrs;}letattrda={dwithpcl_attributes=d.pcl_attributes@[a]}letconstr?loc?attrsab=mk?loc?attrs(Pcl_constr(a,b))letstructure?loc?attrsa=mk?loc?attrs(Pcl_structurea)letfun_?loc?attrsabcd=mk?loc?attrs(Pcl_fun(a,b,c,d))letapply?loc?attrsab=mk?loc?attrs(Pcl_apply (a,b))letlet_?loc?attrsabc=mk?loc?attrs(Pcl_let(a,b,c))letconstraint_ ?loc?attrsab=mk?loc?attrs(Pcl_constraint (a,b))let extension?loc?attrsa=mk?loc?attrs(Pcl_extensiona)letopen_?loc?attrsab=mk?loc?attrs(Pcl_open(a,b))endmoduleCty=structletmk?(loc =!default_loc)?(attrs=[])d={pcty_desc =d;pcty_loc=loc;pcty_attributes=attrs;}letattrda={dwithpcty_attributes=d.pcty_attributes @[a]}letconstr?loc?attrsab=mk?loc?attrs(Pcty_constr(a,b))letsignature?loc?attrsa=mk?loc?attrs(Pcty_signaturea)letarrow?loc?attrsabc=mk?loc?attrs(Pcty_arrow(a,b,c))letextension?loc?attrsa=mk?loc?attrs(Pcty_extensiona)letopen_?loc?attrsab=mk?loc?attrs(Pcty_open (a,b))endmodule Ctf =structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)d={pctf_desc =d;pctf_loc=loc;pctf_attributes=add_docs_attrsdocsattrs;}letinherit_?loc?attrs a=mk?loc?attrs(Pctf_inherita)letval_?loc?attrsabcd=mk?loc?attrs(Pctf_val(a,b,c,d))let method_?loc?attrsabcd=mk?loc?attrs(Pctf_method(a,b,c,d))letconstraint_?loc?attrsab=mk?loc?attrs(Pctf_constraint(a,b))letextension ?loc?attrsa=mk?loc?attrs(Pctf_extensiona)letattribute?loca=mk?loc(Pctf_attributea)lettexttxt=letf_txt=List.filter(funds->docstring_bodyds<>"")txt inList.map(funds->attribute~loc:(docstring_loc ds)(text_attrds))f_txtlet attrda={dwithpctf_attributes=d.pctf_attributes @[a]}endmoduleCf=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)d={pcf_desc =d;pcf_loc=loc;pcf_attributes=add_docs_attrsdocsattrs;}letinherit_?loc?attrs abc=mk?loc?attrs(Pcf_inherit (a,b,c))let val_?loc?attrsabc=mk?loc?attrs(Pcf_val(a,b,c))letmethod_ ?loc?attrsabc=mk?loc?attrs(Pcf_method(a,b,c))letconstraint_?loc?attrsab=mk?loc?attrs(Pcf_constraint (a,b))let initializer_?loc?attrsa=mk?loc?attrs(Pcf_initializer a)letextension?loc?attrsa=mk?loc?attrs(Pcf_extensiona)letattribute?loca=mk?loc(Pcf_attributea)lettexttxt=letf_txt=List.filter(funds->docstring_bodyds<>"")txt inList.map(funds->attribute~loc:(docstring_loc ds)(text_attrds))f_txtlet virtual_ct=Cfk_virtualctletconcreteoe=Cfk_concrete(o,e)letattrda={dwithpcf_attributes=d.pcf_attributes@[a]}endmoduleVal=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)?(prim=[])name typ={pval_name=name;pval_type=typ;pval_attributes =add_docs_attrsdocsattrs;pval_loc=loc;pval_prim =prim;}endmoduleMd=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])nametyp={pmd_name=name;pmd_type=typ;pmd_attributes=add_text_attrs text(add_docs_attrsdocsattrs);pmd_loc=loc;}endmoduleMs=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])namesyn={pms_name=name;pms_manifest=syn;pms_attributes=add_text_attrs text(add_docs_attrsdocsattrs);pms_loc=loc;}endmoduleMtd=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])?typname={pmtd_name =name;pmtd_type=typ;pmtd_attributes =add_text_attrstext(add_docs_attrsdocsattrs);pmtd_loc=loc;}endmoduleMb=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])nameexpr={pmb_name=name;pmb_expr=expr;pmb_attributes =add_text_attrs text(add_docs_attrsdocsattrs);pmb_loc=loc;}endmoduleOpn=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)?(override=Fresh)expr={popen_expr =expr;popen_override=override;popen_loc=loc;popen_attributes =add_docs_attrsdocsattrs;}endmoduleIncl=structletmk?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)mexpr={pincl_mod=mexpr;pincl_loc=loc;pincl_attributes =add_docs_attrsdocsattrs;}endmoduleVb=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])pat expr={pvb_pat=pat;pvb_expr=expr;pvb_attributes=add_text_attrs text(add_docs_attrsdocsattrs);pvb_loc=loc;}endmoduleCi=structletmk?(loc =!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])?(virt=Concrete)?(params =[])nameexpr={pci_virt=virt;pci_params=params;pci_name=name;pci_expr =expr;pci_attributes =add_text_attrs text(add_docs_attrsdocsattrs);pci_loc=loc;}endmoduleType=structletmk?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])?(params=[])?(cstrs=[])?(kind=Ptype_abstract)?(priv=Public)?manifestname={ptype_name =name;ptype_params=params;ptype_cstrs=cstrs;ptype_kind=kind;ptype_private =priv;ptype_manifest=manifest;ptype_attributes=add_text_attrstext(add_docs_attrsdocsattrs);ptype_loc=loc;}letconstructor?(loc=!default_loc)?(attrs=[])?(info=empty_info)?(args=Pcstr_tuple[])?resname={pcd_name=name;pcd_args=args;pcd_res =res;pcd_loc=loc;pcd_attributes=add_info_attrsinfoattrs;}letfield?(loc=!default_loc)?(attrs=[])?(info=empty_info)?(mut=Immutable)nametyp={pld_name=name;pld_mutable=mut;pld_type =typ;pld_loc=loc;pld_attributes=add_info_attrsinfoattrs;}end(** Type extensions *)moduleTe=structletmk?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(params=[])?(priv=Public)pathconstructors={ptyext_path=path;ptyext_params=params;ptyext_constructors=constructors;ptyext_private=priv;ptyext_loc=loc;ptyext_attributes =add_docs_attrsdocsattrs;}letmk_exception?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)constructor={ptyexn_constructor=constructor;ptyexn_loc=loc;ptyexn_attributes =add_docs_attrsdocsattrs;}letconstructor?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(info=empty_info)name kind={pext_name =name;pext_kind=kind;pext_loc =loc;pext_attributes=add_docs_attrsdocs(add_info_attrsinfoattrs);}letdecl?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(info=empty_info)?(args=Pcstr_tuple[])?resname={pext_name =name;pext_kind=Pext_decl(args,res);pext_loc=loc;pext_attributes=add_docs_attrsdocs(add_info_attrsinfoattrs);}letrebind?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(info=empty_info)name lid={pext_name=name;pext_kind=Pext_rebindlid;pext_loc=loc;pext_attributes=add_docs_attrsdocs(add_info_attrsinfoattrs);}endmoduleCsig=structletmkself fields={pcsig_self=self;pcsig_fields=fields;}endmoduleCstr=structletmkselffields={pcstr_self=self;pcstr_fields=fields;}end(** Row fields *)moduleRf=structletmk?(loc=!default_loc)?(attrs=[])desc={prf_desc =desc;prf_loc=loc;prf_attributes=attrs;}lettag?loc?attrslabelconsttys=mk ?loc ?attrs(Rtag(label,const,tys))letinherit_?locty=mk?loc(Rinheritty)end(** Object fields *)moduleOf=structletmk?(loc=!default_loc)?(attrs=[])desc={pof_desc=desc;pof_loc=loc;pof_attributes=attrs;}lettag?loc?attrslabelty=mk?loc?attrs(Otag(label,ty))letinherit_?locty=mk?loc(Oinheritty)endendmoduleAst_mapper:sigopenParsetree(** {1 A generic Parsetree mapper} *)typemapper(*IF_CURRENT = Ast_mapper.mapper *)={attribute:mapper->attribute->attribute;attributes:mapper->attributelist->attributelist;binding_op:mapper ->binding_op->binding_op;case:mapper->case->case;cases:mapper->caselist->caselist;class_declaration:mapper->class_declaration->class_declaration;class_description:mapper->class_description->class_description;class_expr:mapper->class_expr->class_expr;class_field:mapper->class_field->class_field;class_signature:mapper->class_signature->class_signature;class_structure:mapper->class_structure->class_structure;class_type:mapper->class_type->class_type;class_type_declaration:mapper->class_type_declaration->class_type_declaration;class_type_field:mapper->class_type_field->class_type_field;constant:mapper->constant->constant;constructor_declaration:mapper->constructor_declaration->constructor_declaration;expr:mapper->expression->expression;extension:mapper->extension->extension;extension_constructor:mapper->extension_constructor->extension_constructor;include_declaration:mapper->include_declaration->include_declaration;include_description:mapper->include_description->include_description;label_declaration:mapper->label_declaration->label_declaration;location:mapper->Location.t->Location.t;module_binding:mapper->module_binding->module_binding;module_declaration:mapper->module_declaration->module_declaration;module_substitution:mapper->module_substitution->module_substitution;module_expr:mapper->module_expr->module_expr;module_type:mapper->module_type->module_type;module_type_declaration:mapper->module_type_declaration->module_type_declaration;open_declaration:mapper->open_declaration->open_declaration;open_description:mapper->open_description->open_description;pat:mapper->pattern->pattern;payload:mapper->payload->payload;signature:mapper->signature->signature;signature_item:mapper->signature_item->signature_item;structure:mapper->structure->structure;structure_item:mapper->structure_item->structure_item;typ:mapper->core_type->core_type;type_declaration:mapper->type_declaration->type_declaration;type_extension:mapper->type_extension->type_extension;type_exception:mapper->type_exception->type_exception;type_kind:mapper->type_kind->type_kind;value_binding:mapper->value_binding->value_binding;value_description:mapper->value_description->value_description;with_constraint:mapper->with_constraint->with_constraint;}(** A mapper record implements one "method" per syntactic category,
using an open recursion style: each method takes as its first
argument the mapper to be applied to children in the syntax
tree. *)valdefault_mapper:mapper(** A default mapper, which implements a "deep identity" mapping. *)(** {1 Apply mappers to compilation units} *)valtool_name:unit->string(** Can be used within a ppx preprocessor to know which tool is
calling it ["ocamlc"], ["ocamlopt"], ["ocamldoc"], ["ocamldep"],
["ocaml"], ... Some global variables that reflect command-line
options are automatically synchronized between the calling tool
and the ppx preprocessor: {!Clflags.include_dirs},
{!Load_path}, {!Clflags.open_modules}, {!Clflags.for_package},
{!Clflags.debug}. *)valapply:source:string->target:string->mapper->unit(** Apply a mapper (parametrized by the unit name) to a dumped
parsetree found in the [source] file and put the result in the
[target] file. The [structure] or [signature] field of the mapper
is applied to the implementation or interface. *)valrun_main:(stringlist->mapper)->unit(** Entry point to call to implement a standalone -ppx rewriter from a
mapper, parametrized by the command line arguments. The current
unit name can be obtained from {!Location.input_name}. This
function implements proper error reporting for uncaught
exceptions. *)(** {1 Registration API} *)valregister_function:(string->(stringlist->mapper)->unit)refvalregister:string->(stringlist ->mapper)->unit(** Apply the [register_function]. The default behavior is to run the
mapper immediately, taking arguments from the process command
line. This is to support a scenario where a mapper is linked as a
stand-alone executable.
It is possible to overwrite the [register_function] to define
"-ppx drivers", which combine several mappers in a single process.
Typically, a driver starts by defining [register_function] to a
custom implementation, then lets ppx rewriters (linked statically
or dynamically) register themselves, and then run all or some of
them. It is also possible to have -ppx drivers apply rewriters to
only specific parts of an AST.
The first argument to [register] is a symbolic name to be used by
the ppx driver. *)(** {1 Convenience functions to write mappers} *)valmap_opt:('a->'b)->'aoption->'boptionvalextension_of_error:Locations.location_error->extension(** Encode an error into an 'ocaml.error' extension node which can be
inserted in a generated Parsetree. The compiler will be
responsible for reporting the error. *)valattribute_of_warning:Location.t->string->attribute(** Encode a warning message into an 'ocaml.ppwarning' attribute which can be
inserted in a generated Parsetree. The compiler will be
responsible for reporting the warning. *)includeLocations.Helpers_intf(** {1 Helper functions to call external mappers} *)valadd_ppx_context_str:tool_name:string->Parsetree.structure->Parsetree.structure(** Extract information from the current environment and encode it
into an attribute which is prepended to the list of structure
items in order to pass the information to an external
processor. *)valadd_ppx_context_sig:tool_name:string->Parsetree.signature->Parsetree.signature(** Same as [add_ppx_context_str], but for signatures. *)valdrop_ppx_context_str:restore:bool->Parsetree.structure->Parsetree.structure(** Drop the ocaml.ppx.context attribute from a structure. If
[restore] is true, also restore the associated data in the current
process. *)valdrop_ppx_context_sig:restore:bool->Parsetree.signature->Parsetree.signature(** Same as [drop_ppx_context_str], but for signatures. *)(** {1 Cookies} *)(** Cookies are used to pass information from a ppx processor to
a further invocation of itself, when called from the OCaml
toplevel (or other tools that support cookies). *)valset_cookie:string->Parsetree.expression->unitvalget_cookie:string->Parsetree.expressionoptionend=structopenParsetreeopenAst_helperopenLocationmoduleString=Misc.Stdlib.Stringtypemapper(*IF_CURRENT = Ast_mapper.mapper *) ={attribute:mapper->attribute->attribute;attributes:mapper->attributelist->attributelist;binding_op:mapper ->binding_op->binding_op;case:mapper->case->case;cases:mapper->caselist->caselist;class_declaration:mapper->class_declaration->class_declaration;class_description:mapper->class_description->class_description;class_expr:mapper->class_expr->class_expr;class_field:mapper->class_field->class_field;class_signature:mapper->class_signature->class_signature;class_structure:mapper->class_structure->class_structure;class_type:mapper->class_type->class_type;class_type_declaration:mapper->class_type_declaration->class_type_declaration;class_type_field:mapper->class_type_field->class_type_field;constant:mapper->constant->constant;constructor_declaration:mapper->constructor_declaration->constructor_declaration;expr:mapper->expression->expression;extension:mapper->extension->extension;extension_constructor:mapper->extension_constructor->extension_constructor;include_declaration:mapper->include_declaration->include_declaration;include_description:mapper->include_description->include_description;label_declaration:mapper->label_declaration->label_declaration;location:mapper->Location.t->Location.t;module_binding:mapper->module_binding->module_binding;module_declaration:mapper->module_declaration->module_declaration;module_substitution:mapper->module_substitution->module_substitution;module_expr:mapper->module_expr->module_expr;module_type:mapper->module_type->module_type;module_type_declaration:mapper->module_type_declaration->module_type_declaration;open_declaration:mapper->open_declaration->open_declaration;open_description:mapper->open_description->open_description;pat:mapper->pattern->pattern;payload:mapper->payload->payload;signature:mapper->signature->signature;signature_item:mapper->signature_item->signature_item;structure:mapper->structure->structure;structure_item:mapper->structure_item->structure_item;typ:mapper->core_type->core_type;type_declaration:mapper->type_declaration->type_declaration;type_extension:mapper->type_extension->type_extension;type_exception:mapper->type_exception->type_exception;type_kind:mapper->type_kind->type_kind;value_binding:mapper->value_binding->value_binding;value_description:mapper->value_description->value_description;with_constraint:mapper->with_constraint->with_constraint;}letmap_fstf(x,y)=(fx,y)letmap_sndf(x,y)=(x,fy)letmap_tuplef1f2(x,y)=(f1x,f2y)letmap_tuple3 f1f2f3(x,y,z)=(f1x,f2y,f3z)let map_optf=functionNone ->None|Somex->Some(fx)letmap_locsub{loc;txt}={loc=sub.locationsubloc;txt}moduleC=struct(*Constants *)letmapsubc=matchcwith|Pconst_integer_|Pconst_char_|Pconst_float_->c|Pconst_string(s,loc,quotation_delimiter)->let loc=sub.locationsublocinConst.string ~loc?quotation_delimiter sendmoduleT=struct(* Type expressions for the core language *)letrow_fieldsub{prf_desc;prf_loc;prf_attributes;}=letloc=sub.locationsubprf_locinlet attrs=sub.attributessubprf_attributesinletdesc=match prf_descwith|Rtag(l,b,tl)->Rtag (map_locsubl,b,List.map(sub.typsub)tl)|Rinheritt->Rinherit(sub.typsubt)inRf.mk~loc~attrsdescletobject_fieldsub{pof_desc;pof_loc;pof_attributes;}=letloc=sub.locationsubpof_locinlet attrs=sub.attributessubpof_attributesinletdesc=match pof_descwith|Otag(l,t)->Otag(map_loc subl,sub.typsubt)|Oinheritt->Oinherit (sub.typsubt)inOf.mk~loc~attrsdescletmapsub{ptyp_desc=desc;ptyp_loc =loc;ptyp_attributes =attrs}=letopenTypinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Ptyp_any ->any~loc~attrs ()|Ptyp_vars->var~loc~attrss|Ptyp_arrow(lab,t1,t2)->arrow~loc~attrslab(sub.typsubt1)(sub.typsubt2)|Ptyp_tupletyl->tuple~loc~attrs(List.map(sub.typsub)tyl)|Ptyp_constr(lid,tl)->constr~loc~attrs(map_locsublid)(List.map(sub.typsub)tl)|Ptyp_object(l,o)->object_~loc~attrs(List.map(object_fieldsub)l)o|Ptyp_class (lid,tl)->class_~loc~attrs(map_locsublid)(List.map(sub.typsub)tl)|Ptyp_alias(t,s)->alias~loc~attrs(sub.typsubt)s|Ptyp_variant(rl,b,ll)->variant~loc~attrs(List.map(row_fieldsub)rl)bll|Ptyp_poly (sl,t)-> poly~loc~attrs(List.map(map_locsub)sl)(sub.typsubt)|Ptyp_package(lid,l)->package~loc~attrs(map_locsublid)(List.map(map_tuple(map_loc sub)(sub.typsub))l)|Ptyp_extensionx->extension~loc~attrs(sub.extensionsubx)letmap_type_declarationsub{ptype_name;ptype_params;ptype_cstrs;ptype_kind;ptype_private;ptype_manifest;ptype_attributes;ptype_loc}=letloc=sub.locationsubptype_locinletattrs=sub.attributes sub ptype_attributesinType.mk~loc~attrs(map_locsubptype_name)~params:(List.map(map_fst(sub.typsub))ptype_params)~priv:ptype_private~cstrs:(List.map(map_tuple3(sub.typ sub)(sub.typsub)(sub.locationsub))ptype_cstrs)~kind:(sub.type_kindsubptype_kind)?manifest:(map_opt(sub.typsub)ptype_manifest)letmap_type_kindsub=function|Ptype_abstract->Ptype_abstract|Ptype_variantl->Ptype_variant(List.map(sub.constructor_declarationsub)l)|Ptype_recordl->Ptype_record(List.map(sub.label_declarationsub)l)|Ptype_open->Ptype_openletmap_constructor_argumentssub=function|Pcstr_tuplel->Pcstr_tuple(List.map(sub.typsub)l)|Pcstr_recordl->Pcstr_record(List.map(sub.label_declarationsub)l)letmap_type_extension sub{ptyext_path;ptyext_params;ptyext_constructors;ptyext_private;ptyext_loc;ptyext_attributes}=letloc=sub.locationsubptyext_locinletattrs=sub.attributessubptyext_attributesinTe.mk~loc~attrs(map_loc subptyext_path)(List.map(sub.extension_constructorsub)ptyext_constructors)~params:(List.map(map_fst(sub.typsub))ptyext_params)~priv:ptyext_privateletmap_type_exceptionsub{ptyexn_constructor;ptyexn_loc;ptyexn_attributes}=letloc=sub.locationsubptyexn_locinletattrs=sub.attributessubptyexn_attributesinTe.mk_exception~loc~attrs(sub.extension_constructorsubptyexn_constructor)letmap_extension_constructor_kindsub=functionPext_decl(ctl,cto)->Pext_decl(map_constructor_argumentssubctl,map_opt(sub.typsub)cto)|Pext_rebind li->Pext_rebind(map_locsubli)letmap_extension_constructorsub{pext_name;pext_kind;pext_loc;pext_attributes}=let loc=sub.locationsubpext_loc inletattrs =sub.attributessubpext_attributesinTe.constructor~loc~attrs(map_locsubpext_name)(map_extension_constructor_kindsubpext_kind)endmoduleCT=struct(* Type expressions for the class language *)letmapsub{pcty_loc=loc;pcty_desc=desc;pcty_attributes=attrs}=letopenCtyinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Pcty_constr (lid,tys)->constr~loc~attrs(map_locsublid)(List.map(sub.typsub)tys)|Pcty_signaturex->signature~loc~attrs(sub.class_signaturesubx)|Pcty_arrow (lab,t,ct)->arrow~loc~attrslab(sub.typsubt)(sub.class_typesubct)|Pcty_extension x->extension~loc~attrs(sub.extensionsubx)|Pcty_open(o,ct)->open_~loc~attrs(sub.open_descriptionsubo)(sub.class_typesubct)letmap_fieldsub{pctf_desc=desc;pctf_loc=loc;pctf_attributes =attrs}=letopenCtfinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Pctf_inherit ct->inherit_~loc~attrs(sub.class_typesubct)|Pctf_val(s,m,v,t)->val_~loc~attrs(map_locsubs)mv(sub.typsubt)|Pctf_method(s,p,v,t)->method_~loc~attrs(map_locsubs)pv(sub.typsubt)|Pctf_constraint(t1,t2)->constraint_~loc~attrs(sub.typsubt1)(sub.typsubt2)|Pctf_attributex->attribute~loc(sub.attributesubx)|Pctf_extensionx->extension~loc~attrs(sub.extensionsubx)letmap_signaturesub{pcsig_self;pcsig_fields}=Csig.mk(sub.typsubpcsig_self)(List.map(sub.class_type_field sub)pcsig_fields)endletmap_functor_paramsub=function|Unit->Unit|Named (s,mt)->Named(map_locsubs,sub.module_typesubmt)moduleMT=struct(* Typeexpressions for the module language *)letmapsub{pmty_desc=desc;pmty_loc=loc;pmty_attributes =attrs}=letopenMtyinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Pmty_ident s->ident~loc~attrs(map_locsubs)|Pmty_aliass->alias~loc~attrs(map_locsubs)|Pmty_signaturesg->signature~loc~attrs(sub.signaturesubsg)|Pmty_functor(param,mt)->functor_~loc~attrs(map_functor_paramsubparam)(sub.module_typesubmt)|Pmty_with(mt,l)->with_~loc~attrs(sub.module_typesubmt)(List.map(sub.with_constraintsub)l)|Pmty_typeofme->typeof_~loc~attrs(sub.module_exprsubme)|Pmty_extension x->extension~loc~attrs(sub.extensionsubx)letmap_with_constraintsub=function|Pwith_type(lid,d)->Pwith_type(map_locsublid,sub.type_declarationsubd)|Pwith_module(lid,lid2)->Pwith_module(map_locsublid,map_locsublid2)|Pwith_typesubst(lid,d)->Pwith_typesubst(map_locsublid,sub.type_declarationsubd)|Pwith_modsubst(s,lid)->Pwith_modsubst(map_locsubs,map_locsublid)letmap_signature_itemsub{psig_desc=desc;psig_loc=loc}=letopenSiginletloc =sub.locationsublocinmatchdescwith|Psig_valuevd->value~loc(sub.value_descriptionsubvd)|Psig_type(rf,l)->type_~locrf(List.map(sub.type_declarationsub)l)|Psig_typesubstl->type_subst~loc(List.map(sub.type_declarationsub)l)|Psig_typextte->type_extension~loc(sub.type_extensionsubte)|Psig_exception ed->exception_~loc(sub.type_exceptionsubed)|Psig_module x->module_~loc(sub.module_declarationsubx)|Psig_modsubstx->mod_subst~loc(sub.module_substitutionsubx)|Psig_recmodule l->rec_module~loc(List.map(sub.module_declarationsub)l)|Psig_modtype x->modtype~loc(sub.module_type_declarationsubx)|Psig_openx->open_~loc(sub.open_descriptionsubx)|Psig_includex->include_~loc(sub.include_descriptionsubx)|Psig_class l->class_~loc(List.map(sub.class_descriptionsub)l)|Psig_class_typel->class_type~loc(List.map(sub.class_type_declarationsub)l)|Psig_extension(x,attrs)->letattrs=sub.attributessubattrsinextension~loc~attrs (sub.extensionsubx)|Psig_attributex->attribute~loc(sub.attributesubx)endmoduleM=struct(*Value expressions for the module language *)letmapsub{pmod_loc=loc;pmod_desc=desc;pmod_attributes=attrs}=letopenModinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Pmod_ident x->ident~loc~attrs(map_locsubx)|Pmod_structurestr->structure~loc~attrs(sub.structuresubstr)|Pmod_functor(param,body)->functor_~loc~attrs(map_functor_paramsubparam)(sub.module_exprsubbody)|Pmod_apply(m1,m2)->apply~loc~attrs(sub.module_exprsubm1)(sub.module_exprsubm2)|Pmod_constraint(m,mty)->constraint_~loc~attrs(sub.module_exprsubm)(sub.module_typesubmty)|Pmod_unpacke->unpack~loc~attrs(sub.exprsube)|Pmod_extensionx->extension~loc~attrs(sub.extensionsubx)letmap_structure_itemsub{pstr_loc =loc;pstr_desc=desc}=letopenStrinletloc=sub.locationsublocinmatchdescwith|Pstr_eval(x,attrs)->letattrs=sub.attributessubattrsineval~loc~attrs(sub.exprsubx)|Pstr_value(r,vbs)->value~locr(List.map(sub.value_bindingsub)vbs)|Pstr_primitivevd->primitive ~loc(sub.value_descriptionsubvd)|Pstr_type(rf,l)->type_~locrf(List.map(sub.type_declarationsub)l)|Pstr_typextte->type_extension~loc(sub.type_extensionsubte)|Pstr_exception ed->exception_~loc(sub.type_exceptionsubed)|Pstr_module x->module_~loc(sub.module_bindingsubx)|Pstr_recmodule l->rec_module~loc(List.map(sub.module_bindingsub)l)|Pstr_modtype x->modtype~loc(sub.module_type_declarationsubx)|Pstr_openx->open_~loc(sub.open_declarationsubx)|Pstr_classl->class_~loc(List.map(sub.class_declarationsub)l)|Pstr_class_typel->class_type~loc(List.map(sub.class_type_declarationsub)l)|Pstr_includex->include_~loc(sub.include_declarationsubx)|Pstr_extension (x,attrs)->letattrs=sub.attributessubattrsinextension~loc~attrs (sub.extensionsubx)|Pstr_attributex->attribute~loc(sub.attributesubx)endmoduleE=struct(* Value expressions for the core language *)letmapsub{pexp_loc=loc;pexp_desc=desc;pexp_attributes=attrs}=letopenExpinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Pexp_ident x->ident~loc~attrs(map_locsubx)|Pexp_constantx->constant~loc~attrs(sub.constantsubx)|Pexp_let(r,vbs,e)->let_~loc~attrsr(List.map(sub.value_bindingsub)vbs)(sub.exprsube)|Pexp_fun(lab,def,p,e)->fun_~loc~attrs lab(map_opt(sub.exprsub)def)(sub.patsubp)(sub.exprsube)|Pexp_functionpel->function_~loc~attrs(sub.casessubpel)|Pexp_apply (e,l)->apply~loc~attrs(sub.exprsube)(List.map(map_snd (sub.exprsub))l)|Pexp_match (e,pel)->match_~loc~attrs(sub.exprsube)(sub.casessub pel)|Pexp_try(e,pel)->try_~loc ~attrs(sub.exprsube)(sub.casessub pel)|Pexp_tupleel->tuple~loc~attrs(List.map(sub.expr sub)el)|Pexp_construct(lid,arg)->construct~loc~attrs (map_locsublid)(map_opt(sub.exprsub)arg)|Pexp_variant(lab,eo)->variant~loc~attrslab(map_opt(sub.exprsub)eo)|Pexp_record (l,eo)->record~loc~attrs(List.map(map_tuple(map_locsub)(sub.exprsub))l)(map_opt(sub.exprsub)eo)|Pexp_field(e,lid)->field~loc~attrs(sub.exprsube)(map_locsublid)|Pexp_setfield(e1,lid,e2)->setfield~loc~attrs(sub.exprsube1)(map_locsublid)(sub.expr sube2)|Pexp_arrayel->array~loc ~attrs(List.map(sub.expr sub)el)|Pexp_ifthenelse(e1,e2,e3)->ifthenelse~loc~attrs(sub.exprsube1)(sub.exprsub e2)(map_opt (sub.exprsub)e3)|Pexp_sequence(e1,e2)->sequence~loc~attrs(sub.exprsube1)(sub.exprsub e2)|Pexp_while(e1,e2)->while_~loc~attrs(sub.exprsube1)(sub.exprsub e2)|Pexp_for(p,e1,e2,d,e3)->for_~loc~attrs(sub.pat subp)(sub.exprsube1)(sub.exprsube2)d(sub.exprsube3)|Pexp_coerce(e,t1,t2)->coerce~loc~attrs(sub.exprsube)(map_opt(sub.typsub)t1)(sub.typsubt2)|Pexp_constraint(e,t)->constraint_~loc~attrs(sub.exprsube)(sub.typsubt)|Pexp_send (e,s)->send~loc~attrs(sub.exprsube)(map_locsubs)|Pexp_new lid->new_~loc~attrs(map_locsublid)|Pexp_setinstvar(s,e)->setinstvar~loc~attrs(map_locsubs)(sub.exprsube)|Pexp_overridesel->override~loc~attrs(List.map(map_tuple(map_loc sub)(sub.exprsub))sel)|Pexp_letmodule(s,me,e)->letmodule~loc~attrs(map_locsubs)(sub.module_exprsubme)(sub.exprsube)|Pexp_letexception(cd,e)->letexception~loc~attrs(sub.extension_constructorsubcd)(sub.exprsube)|Pexp_asserte->assert_~loc~attrs(sub.exprsube)|Pexp_lazye->lazy_ ~loc~attrs(sub.exprsube)|Pexp_poly(e,t)->poly~loc~attrs(sub.exprsube)(map_opt(sub.typsub)t)|Pexp_objectcls->object_~loc~attrs(sub.class_structuresubcls)|Pexp_newtype(s,e)->newtype~loc~attrs(map_locsubs)(sub.exprsube)|Pexp_packme->pack~loc~attrs(sub.module_exprsubme)|Pexp_open(o,e)->open_~loc~attrs(sub.open_declarationsubo)(sub.exprsube)|Pexp_letop{let_;ands;body}->letop~loc~attrs(sub.binding_opsublet_)(List.map(sub.binding_opsub)ands)(sub.exprsubbody)|Pexp_extensionx->extension~loc~attrs(sub.extensionsubx)|Pexp_unreachable->unreachable~loc~attrs()letmap_binding_opsub{pbop_op;pbop_pat;pbop_exp;pbop_loc}=letopenExpinletop=map_locsubpbop_opinletpat=sub.patsubpbop_pat inletexp=sub.exprsubpbop_expinletloc=sub.locationsubpbop_locinbinding_opoppatexplocendmoduleP=struct(* Patterns *)letmapsub{ppat_desc=desc;ppat_loc=loc;ppat_attributes =attrs}=letopenPatinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Ppat_any ->any~loc~attrs ()|Ppat_vars->var~loc~attrs(map_locsubs)|Ppat_alias(p,s)->alias~loc~attrs(sub.patsubp)(map_locsubs)|Ppat_constant c->constant~loc~attrs(sub.constantsubc)|Ppat_interval(c1,c2)->interval~loc~attrsc1c2|Ppat_tuplepl->tuple~loc~attrs(List.map(sub.pat sub)pl)|Ppat_construct (l,p)->construct~loc~attrs(map_locsubl)(map_opt(sub.patsub)p)|Ppat_variant(l,p)->variant ~loc~attrsl(map_opt(sub.patsub)p)|Ppat_record (lpl,cf)->record~loc~attrs(List.map(map_tuple(map_loc sub)(sub.patsub))lpl)cf|Ppat_arraypl->array~loc~attrs(List.map(sub.pat sub)pl)|Ppat_or (p1,p2)->or_~loc~attrs(sub.patsubp1)(sub.patsubp2)|Ppat_constraint(p,t)->constraint_~loc~attrs(sub.patsubp)(sub.typsubt)|Ppat_type s->type_~loc~attrs(map_locsubs)|Ppat_lazyp->lazy_~loc~attrs(sub.patsubp)|Ppat_unpacks->unpack~loc~attrs(map_locsubs)|Ppat_open(lid,p)->open_~loc~attrs(map_locsublid)(sub.patsubp)|Ppat_exceptionp-> exception_~loc~attrs(sub.patsubp)|Ppat_extensionx-> extension~loc~attrs(sub.extensionsubx)endmoduleCE=struct(*Value expressions for the class language *)letmapsub{pcl_loc=loc;pcl_desc=desc;pcl_attributes=attrs}=letopenClinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Pcl_constr (lid,tys)->constr~loc~attrs(map_locsublid)(List.map(sub.typsub)tys)|Pcl_structures->structure~loc~attrs(sub.class_structuresubs)|Pcl_fun (lab,e,p,ce)->fun_~loc~attrslab(map_opt(sub.exprsub)e)(sub.patsubp)(sub.class_exprsubce)|Pcl_apply(ce,l)->apply~loc~attrs(sub.class_exprsubce)(List.map(map_snd(sub.exprsub))l)|Pcl_let (r,vbs,ce)->let_~loc~attrsr(List.map(sub.value_bindingsub)vbs)(sub.class_exprsubce)|Pcl_constraint(ce,ct)->constraint_~loc~attrs(sub.class_exprsubce)(sub.class_typesub ct)|Pcl_extension x->extension~loc~attrs(sub.extensionsubx)|Pcl_open(o,ce)->open_~loc~attrs(sub.open_descriptionsubo)(sub.class_exprsubce)letmap_kindsub=function|Cfk_concrete(o,e)->Cfk_concrete(o,sub.exprsube)|Cfk_virtualt->Cfk_virtual(sub.typsubt)letmap_fieldsub{pcf_desc =desc;pcf_loc=loc;pcf_attributes=attrs}=letopenCfinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatch desc with|Pcf_inherit (o,ce,s)->inherit_~loc~attrso(sub.class_exprsubce)(map_opt(map_locsub)s)|Pcf_val(s,m,k)->val_~loc~attrs(map_locsubs)m(map_kindsub k)|Pcf_method(s,p,k)->method_~loc~attrs(map_locsubs)p(map_kindsub k)|Pcf_constraint(t1,t2)->constraint_~loc~attrs(sub.typsubt1)(sub.typsubt2)|Pcf_initializere->initializer_~loc~attrs(sub.exprsube)|Pcf_attributex-> attribute~loc(sub.attributesubx)|Pcf_extensionx->extension~loc~attrs(sub.extensionsubx)letmap_structuresub{pcstr_self;pcstr_fields}={pcstr_self =sub.pat subpcstr_self;pcstr_fields=List.map(sub.class_fieldsub)pcstr_fields;}letclass_infossubf{pci_virt;pci_params=pl;pci_name;pci_expr;pci_loc;pci_attributes}=letloc=sub.locationsubpci_loc inlet attrs=sub.attributessubpci_attributesinCi.mk~loc~attrs~virt:pci_virt~params:(List.map(map_fst(sub.typsub))pl)(map_locsubpci_name)(fpci_expr)end(* Now, a genericAST mapper, to be extended to cover all kinds and
cases of the OCaml grammar. The default behavior of the mapper is
the identity. *)letdefault_mapper={constant=C.map;structure=(funthisl->List.map(this.structure_itemthis)l);structure_item=M.map_structure_item;module_expr=M.map;signature=(funthisl->List.map(this.signature_itemthis)l);signature_item=MT.map_signature_item;module_type=MT.map;with_constraint=MT.map_with_constraint;class_declaration=(funthis->CE.class_infosthis(this.class_exprthis));class_expr=CE.map;class_field =CE.map_field;class_structure=CE.map_structure;class_type=CT.map;class_type_field=CT.map_field;class_signature=CT.map_signature;class_type_declaration=(funthis->CE.class_infosthis(this.class_typethis));class_description=(funthis->CE.class_infosthis(this.class_typethis));type_declaration=T.map_type_declaration;type_kind=T.map_type_kind;typ=T.map;type_extension=T.map_type_extension;type_exception=T.map_type_exception;extension_constructor=T.map_extension_constructor;value_description=(funthis{pval_name;pval_type;pval_prim;pval_loc;pval_attributes}->Val.mk(map_loc thispval_name)(this.typthispval_type)~attrs:(this.attributesthispval_attributes)~loc:(this.locationthispval_loc)~prim:pval_prim);pat=P.map;expr=E.map;binding_op=E.map_binding_op;module_declaration=(funthis{pmd_name;pmd_type;pmd_attributes;pmd_loc}->Md.mk(map_loc thispmd_name)(this.module_typethispmd_type)~attrs:(this.attributesthispmd_attributes)~loc:(this.locationthispmd_loc));module_substitution=(funthis{pms_name;pms_manifest;pms_attributes;pms_loc}->Ms.mk(map_loc thispms_name)(map_locthispms_manifest)~attrs:(this.attributesthispms_attributes)~loc:(this.locationthispms_loc));module_type_declaration=(funthis{pmtd_name;pmtd_type;pmtd_attributes;pmtd_loc}->Mtd.mk(map_loc thispmtd_name)?typ:(map_opt(this.module_type this)pmtd_type)~attrs:(this.attributesthispmtd_attributes)~loc:(this.locationthispmtd_loc));module_binding=(funthis{pmb_name;pmb_expr;pmb_attributes;pmb_loc}->Mb.mk(map_loc thispmb_name)(this.module_exprthispmb_expr)~attrs:(this.attributesthispmb_attributes)~loc:(this.locationthispmb_loc));open_declaration=(funthis{popen_expr;popen_override;popen_attributes;popen_loc}->Opn.mk(this.module_exprthispopen_expr)~override:popen_override~loc:(this.locationthispopen_loc)~attrs:(this.attributesthispopen_attributes));open_description =(funthis{popen_expr;popen_override;popen_attributes;popen_loc}->Opn.mk(map_loc thispopen_expr)~override:popen_override~loc:(this.locationthispopen_loc)~attrs:(this.attributesthispopen_attributes));include_description =(funthis{pincl_mod;pincl_attributes;pincl_loc}->Incl.mk(this.module_type thispincl_mod)~loc:(this.locationthispincl_loc)~attrs:(this.attributesthispincl_attributes));include_declaration =(funthis{pincl_mod;pincl_attributes;pincl_loc}->Incl.mk(this.module_expr thispincl_mod)~loc:(this.locationthispincl_loc)~attrs:(this.attributesthispincl_attributes));value_binding=(funthis{pvb_pat;pvb_expr;pvb_attributes;pvb_loc}->Vb.mk(this.patthispvb_pat)(this.exprthispvb_expr)~loc:(this.location this pvb_loc)~attrs:(this.attributesthispvb_attributes));constructor_declaration =(funthis{pcd_name;pcd_args;pcd_res;pcd_loc;pcd_attributes}->Type.constructor(map_locthispcd_name)~args:(T.map_constructor_argumentsthispcd_args)?res:(map_opt(this.typthis)pcd_res)~loc:(this.location this pcd_loc)~attrs:(this.attributesthispcd_attributes));label_declaration =(funthis{pld_name;pld_type;pld_loc;pld_mutable;pld_attributes}->Type.field(map_locthispld_name)(this.typthispld_type)~mut:pld_mutable~loc:(this.locationthispld_loc)~attrs:(this.attributesthispld_attributes));cases =(funthisl->List.map(this.casethis)l);case=(funthis{pc_lhs;pc_guard;pc_rhs}->{pc_lhs=this.patthispc_lhs;pc_guard=map_opt(this.exprthis)pc_guard;pc_rhs =this.exprthispc_rhs;});location =(fun_thisl->l);extension=(funthis(s,e)->(map_locthiss,this.payloadthise));attribute=(funthisa->{attr_name=map_locthisa.attr_name;attr_payload=this.payloadthisa.attr_payload;attr_loc=this.locationthisa.attr_loc});attributes=(funthisl->List.map(this.attributethis)l);payload=(funthis ->function|PStrx->PStr(this.structurethisx)|PSigx->PSig(this.signaturethisx)|PTypx->PTyp(this.typthisx)|PPat(x,g)->PPat(this.patthisx,map_opt(this.exprthis)g));}letextension_of_error(error:Locations.location_error):extension=Locations.extension_of_error~mk_pstr:(funx->PStrx)~mk_extension:(funx->Str.extensionx)~mk_string_constant:(funx->Str.eval(Exp.constant(Pconst_string(x,Location.none(* XXX *),None))))errorletattribute_of_warninglocs=Attr.mk{loc;txt="ocaml.ppwarning"}(PStr([Str.eval~loc(Exp.constant(Pconst_string(s,loc,None)))]))includeLocations.Helpers_implletcookies=refString.Map.emptyletget_cookiek=trySome(String.Map.findk!cookies)withNot_found->Noneletset_cookiekv=cookies:=String.Map.addkv!cookieslettool_name_ref=ref"_none_"lettool_name()=!tool_name_refmodulePpxContext=structopenLongidentopenAsttypesopenAst_helperletlidname={txt=Lidentname;loc=Location.none}letmake_strings=Exp.constant(Const.strings)letmake_boolx=ifxthenExp.construct(lid"true")NoneelseExp.construct(lid"false")Noneletrecmake_listflst=matchlstwith|x::rest->Exp.construct(lid"::")(Some(Exp.tuple[fx;make_listfrest]))|[]->Exp.construct(lid"[]")Noneletmake_pairf1f2(x1,x2)=Exp.tuple[f1x1;f2x2]letmake_optionfopt=match optwith|Somex->Exp.construct(lid"Some")(Some(fx))|None->Exp.construct(lid"None")Noneletget_cookies()=lid"cookies",make_list (make_pairmake_string(funx->x))(String.Map.bindings!cookies)letmkfields={attr_name={txt="ocaml.ppx.context";loc=Location.none};attr_payload=Parsetree.PStr[Str.eval(Exp.recordfieldsNone)];attr_loc=Location.none}letmake~tool_name()=letfields=[lid"tool_name",make_stringtool_name;lid"include_dirs",make_listmake_string!Clflags.include_dirs;lid"load_path",make_listmake_string(Migrate_parsetree_compiler_functions.get_load_paths());lid"open_modules",make_listmake_string!Clflags.open_modules;lid"for_package",make_optionmake_string!Clflags.for_package;lid"debug",make_bool!Clflags.debug;lid"use_threads",make_bool!Clflags.use_threads;lid"use_vmthreads",make_boolfalse;lid"recursive_types",make_bool!Clflags.recursive_types;lid"principal",make_bool!Clflags.principal;lid"transparent_modules",make_bool!Clflags.transparent_modules;lid"unboxed_types",make_bool (Migrate_parsetree_compiler_functions.get_unboxed_types());get_cookies()]inmkfieldsletget_fields=function|PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(fields,None)},[])}]->fields|_->raise_errorf"Internal error: invalid [@@@ocaml.ppx.context] syntax"letrestorefields=letfieldnamepayload=letrecget_string=function|{pexp_desc=Pexp_constant(Pconst_string(str,_,None))}->str|_->raise_errorf"Internal error: invalid [@@@ocaml.ppx.context \
{ %s }] string syntax"nameandget_boolpexp=matchpexpwith|{pexp_desc=Pexp_construct({txt=Longident.Lident"true"},None)}->true|{pexp_desc=Pexp_construct({txt=Longident.Lident"false"},None)}->false|_->raise_errorf"Internal error: invalid [@@@ocaml.ppx.context \
{ %s }] bool syntax"nameandget_listelem=function|{pexp_desc=Pexp_construct({txt=Longident.Lident"::"},Some{pexp_desc=Pexp_tuple[exp;rest]})}->elemexp::get_list elemrest|{pexp_desc =Pexp_construct({txt=Longident.Lident"[]"},None)}->[]|_->raise_errorf"Internal error: invalid [@@@ocaml.ppx.context \
{ %s }] list syntax"nameandget_pairf1f2=function|{pexp_desc =Pexp_tuple [e1;e2]}->(f1e1,f2e2)|_->raise_errorf"Internal error: invalid [@@@ocaml.ppx.context \
{ %s }] pair syntax"nameandget_optionelem=function|{pexp_desc =Pexp_construct({txt=Longident.Lident"Some"},Someexp)}->Some(elemexp)|{pexp_desc=Pexp_construct({txt=Longident.Lident"None"},None)}->None|_->raise_errorf"Internal error: invalid [@@@ocaml.ppx.context \
{ %s }] option syntax"nameinmatchnamewith|"tool_name"->tool_name_ref:=get_stringpayload|"include_dirs"->Clflags.include_dirs:=get_listget_stringpayload|"load_path"->Migrate_parsetree_compiler_functions.load_path_init(get_listget_stringpayload)|"open_modules" ->Clflags.open_modules:=get_listget_stringpayload|"for_package"->Clflags.for_package:=get_optionget_stringpayload|"debug"->Clflags.debug:=get_boolpayload|"use_threads" ->Clflags.use_threads:=get_boolpayload|"use_vmthreads"->ifget_boolpayloadthenraise_errorf"Internal error: vmthreads not supported after 4.09.0"|"recursive_types"->Clflags.recursive_types:=get_boolpayload|"principal"->Clflags.principal:=get_boolpayload|"transparent_modules" ->Clflags.transparent_modules:=get_boolpayload|"unboxed_types"->Migrate_parsetree_compiler_functions.set_unboxed_types(get_boolpayload)|"cookies"->let l=get_list(get_pairget_string(funx->x))payloadincookies:=List.fold_left(funs(k,v)->String.Map.addkvs)String.Map.emptyl|_->()inList.iter(function({txt=Lidentname},x)->field namex|_->())fieldsletupdate_cookiesfields=letfields=List.filter(function ({txt=Lident"cookies"},_)->false|_->true)fieldsinfields@[get_cookies()]endletppx_context =PpxContext.makeletextension_of_exnexn=extension_of_error(Locations.location_error_of_exnexn)letapply_lazy~source~targetmapper =letimplemast=let fields,ast=matchastwith|{pstr_desc =Pstr_attribute({attr_name={txt="ocaml.ppx.context"};attr_payload=x})}::l->PpxContext.get_fieldsx,l|_->[],astinPpxContext.restorefields;letast=tryletmapper=mapper()inmapper.structure mapper astwithexn->[{pstr_desc =Pstr_extension(extension_of_exnexn,[]);pstr_loc=Location.none}]inletfields=PpxContext.update_cookiesfieldsinStr.attribute(PpxContext.mkfields)::astinletifaceast=letfields,ast=matchastwith|{psig_desc =Psig_attribute({attr_name={txt="ocaml.ppx.context"};attr_payload=x;attr_loc=_})}::l->PpxContext.get_fieldsx,l|_->[],astinPpxContext.restorefields;letast=tryletmapper=mapper()inmapper.signature mapper astwithexn->[{psig_desc =Psig_extension(extension_of_exnexn,[]);psig_loc=Location.none}]inletfields=PpxContext.update_cookiesfieldsinSig.attribute(PpxContext.mkfields)::astinletic=open_in_binsourceinletmagic=really_input_string ic(String.lengthConfig.ast_impl_magic_number)inletrewritetransform=Location.input_name:=input_value ic;letast=input_valueicinclose_inic;letast=transformastinletoc=open_out_bintargetinoutput_stringocmagic;output_valueoc!Location.input_name;output_value ocast;close_outocandfail()=close_inic;failwith"Ast_mapper: OCamlversion mismatch or malformed input";inifmagic=Config.ast_impl_magic_numberthenrewrite(implem:structure ->structure)elseifmagic=Config.ast_intf_magic_numberthenrewrite(iface:signature->signature)elsefail()letdrop_ppx_context_str~restore=function|{pstr_desc=Pstr_attribute{attr_name={Location.txt="ocaml.ppx.context"};attr_payload=a;attr_loc=_}}::items->ifrestorethenPpxContext.restore(PpxContext.get_fieldsa);items|items->itemsletdrop_ppx_context_sig~restore=function|{psig_desc=Psig_attribute{attr_name={Location.txt="ocaml.ppx.context"};attr_payload=a;attr_loc=_}}::items->ifrestorethenPpxContext.restore(PpxContext.get_fieldsa);items|items->itemsletadd_ppx_context_str~tool_nameast=Ast_helper.Str.attribute (ppx_context ~tool_name())::astletadd_ppx_context_sig~tool_nameast=Ast_helper.Sig.attribute (ppx_context ~tool_name())::astletapply~source~targetmapper=apply_lazy~source~target (fun()->mapper)letrun_mainmapper=tryleta=Sys.argv inletn=Array.lengthainifn>2thenletmapper()=trymapper(Array.to_list(Array.suba1(n-3)))withexn->(* PR#6463 *)letf__=raiseexnin{default_mapperwithstructure=f;signature=f}inapply_lazy~source:a.(n-2)~target:a.(n-1)mapperelsebeginPrintf.eprintf "Usage: %s [extra_args] <infile> <outfile>\n%!"Sys.executable_name;exit2endwithexn ->prerr_endline (Printexc.to_stringexn);exit2letregister_function =ref(fun_namef->run_mainf)letregisternamef=!register_functionnamefendmodule Type_immediacy=structtype t(*IF_CURRENT = Type_immediacy.t *)=|Unknown|Always|Always_on_64bitsendmoduleOutcometree=struct(* Module [Outcometree]: results displayed by the toplevel *)(* These types represent messages that the toplevel displays as normal
results or errors. The real displaying is customisable using the hooks:
[Toploop.print_out_value]
[Toploop.print_out_type]
[Toploop.print_out_sig_item]
[Toploop.print_out_phrase] *)(** An [out_name] is a string representation of an identifier which can be
rewritten on the fly to avoid name collisions *)typeout_name(*IF_CURRENT = Outcometree.out_name *)={mutableprinted_name:string}typeout_ident(*IF_CURRENT = Outcometree.out_ident *)=|Oide_applyofout_ident*out_ident|Oide_dotofout_ident*string|Oide_identofout_nametypeout_string(*IF_CURRENT = Outcometree.out_string *)=|Ostr_string|Ostr_bytestypeout_attribute (*IF_CURRENT = Outcometree.out_attribute *)={oattr_name:string}typeout_value(*IF_CURRENT = Outcometree.out_value *)=|Oval_arrayofout_valuelist|Oval_charofchar|Oval_constr ofout_ident*out_valuelist|Oval_ellipsis|Oval_float offloat|Oval_intofint|Oval_int32ofint32|Oval_int64ofint64|Oval_nativeint ofnativeint|Oval_listofout_valuelist|Oval_printerof(Format.formatter ->unit)|Oval_recordof(out_ident*out_value)list|Oval_stringofstring*int*out_string (* string, size-to-print, kind *)|Oval_stuffofstring|Oval_tupleofout_valuelist|Oval_variantofstring*out_valueoptiontypeout_type(*IF_CURRENT = Outcometree.out_type *)=|Otyp_abstract|Otyp_open|Otyp_aliasofout_type *string|Otyp_arrowofstring*out_type*out_type|Otyp_classofbool*out_ident*out_typelist|Otyp_constr ofout_ident*out_typelist|Otyp_manifestofout_type*out_type|Otyp_objectof(string *out_type)list*booloption|Otyp_recordof(string *bool*out_type)list|Otyp_stuffofstring|Otyp_sum of(string*out_typelist*out_typeoption)list|Otyp_tuple ofout_type list|Otyp_varofbool*string|Otyp_variantofbool*out_variant*bool*(stringlist)option|Otyp_polyofstring list *out_type|Otyp_moduleofout_ident*string list*out_typelist|Otyp_attributeofout_type*out_attributeandout_variant(*IF_CURRENT = Outcometree.out_variant *) =|Ovar_fieldsof(string*bool*out_typelist)list|Ovar_typ ofout_typetype out_class_type (*IF_CURRENT = Outcometree.out_class_type *) =|Octy_constrofout_ident*out_typelist|Octy_arrowofstring*out_type*out_class_type|Octy_signature ofout_typeoption *out_class_sig_itemlistandout_class_sig_item(*IF_CURRENT = Outcometree.out_class_sig_item *) =|Ocsg_constraintofout_type*out_type|Ocsg_methodofstring *bool*bool*out_type|Ocsg_valueofstring*bool*bool *out_typetypeout_module_type(*IF_CURRENT = Outcometree.out_module_type *) =|Omty_abstract|Omty_functorof(stringoption*out_module_type)option*out_module_type|Omty_identofout_ident|Omty_signatureofout_sig_itemlist|Omty_aliasofout_identandout_sig_item (*IF_CURRENT = Outcometree.out_sig_item *) =|Osig_classofbool*string*(string*(bool*bool))list *out_class_type *out_rec_status|Osig_class_type ofbool*string*(string*(bool*bool))list *out_class_type *out_rec_status|Osig_typext ofout_extension_constructor*out_ext_status|Osig_modtypeofstring*out_module_type|Osig_moduleofstring*out_module_type*out_rec_status|Osig_typeofout_type_decl *out_rec_status|Osig_valueofout_val_decl|Osig_ellipsisandout_type_decl (*IF_CURRENT = Outcometree.out_type_decl *) ={otype_name:string;otype_params:(string*(bool*bool))list;otype_type:out_type;otype_private:Asttypes.private_flag;otype_immediate:Type_immediacy.t;otype_unboxed:bool;otype_cstrs:(out_type*out_type)list}andout_extension_constructor(*IF_CURRENT = Outcometree.out_extension_constructor *) ={oext_name:string;oext_type_name:string;oext_type_params:stringlist;oext_args:out_typelist;oext_ret_type:out_typeoption;oext_private:Asttypes.private_flag}andout_type_extension(*IF_CURRENT = Outcometree.out_type_extension *) ={otyext_name:string;otyext_params:stringlist;otyext_constructors:(string *out_typelist*out_typeoption)list;otyext_private:Asttypes.private_flag}andout_val_decl(*IF_CURRENT = Outcometree.out_val_decl *) ={oval_name:string;oval_type:out_type;oval_prims:stringlist;oval_attributes:out_attributelist}andout_rec_status(*IF_CURRENT = Outcometree.out_rec_status *) =|Orec_not|Orec_first|Orec_nextandout_ext_status(*IF_CURRENT = Outcometree.out_ext_status *) =|Oext_first|Oext_next|Oext_exceptiontypeout_phrase(*IF_CURRENT = Outcometree.out_phrase *) =|Ophr_evalofout_value*out_type|Ophr_signatureof(out_sig_item*out_valueoption)list|Ophr_exception of(exn*out_value)endmoduleConfig=structletast_impl_magic_number ="Caml1999M028"letast_intf_magic_number ="Caml1999N028"endletmap_signature mapper=mapper.Ast_mapper.signaturemapperletmap_structure mapper=mapper.Ast_mapper.structuremapperletshallow_identity=letid_x=xin{Ast_mapper.structure=id;structure_item=id;module_expr=id;signature=id;signature_item=id;module_type=id;with_constraint=id;class_declaration=id;class_expr=id;class_field=id;class_structure=id;class_type=id;class_type_field=id;class_signature=id;class_type_declaration=id;class_description=id;type_declaration=id;type_kind=id;typ=id;type_extension=id;extension_constructor=id;value_description=id;pat=id;expr=id;module_declaration=id;module_type_declaration=id;module_binding=id;open_description=id;include_description=id;include_declaration=id;value_binding=id;constructor_declaration=id;label_declaration=id;cases=id;case=id;location=id;extension=id;attribute=id;attributes=id;payload=id;binding_op=id;module_substitution=id;open_declaration=id;type_exception=id;constant=id;}letfailing_mapper=letfail__=invalid_arg"failing_mapper: this mapper function should never get called"in{Ast_mapper.structure=fail;structure_item=fail;module_expr=fail;signature=fail;signature_item=fail;module_type=fail;with_constraint=fail;class_declaration=fail;class_expr=fail;class_field=fail;class_structure=fail;class_type=fail;class_type_field=fail;class_signature=fail;class_type_declaration=fail;class_description=fail;type_declaration=fail;type_kind=fail;typ=fail;type_extension=fail;extension_constructor=fail;value_description=fail;pat=fail;expr=fail;module_declaration=fail;module_type_declaration=fail;module_binding=fail;open_description=fail;include_description=fail;include_declaration=fail;value_binding=fail;constructor_declaration=fail;label_declaration=fail;cases=fail;case=fail;location=fail;extension=fail;attribute=fail;attributes=fail;payload=fail;binding_op=fail;module_substitution=fail;open_declaration=fail;type_exception=fail;constant=fail;}letmake_top_mapper~signature~structure={failing_mapper withAst_mapper.signature=(fun_x->signaturex);structure=(fun_x->structurex)}