12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280(**************************************************************************)(* *)(* 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. *)(* *)(**************************************************************************)openAst_409_helpermoduleAsttypes=structtypeconstant(*IF_CURRENT = Asttypes.constant *)=Const_intofint|Const_charofchar|Const_string ofstring*Location.t*stringoption|Const_floatofstring|Const_int32 ofint32|Const_int64ofint64|Const_nativeint ofnativeinttyperec_flag(*IF_CURRENT = Asttypes.rec_flag *) =Nonrecursive |Recursivetypedirection_flag(*IF_CURRENT = Asttypes.direction_flag *)=Upto|Downto(* Order matters, used in polymorphic 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|NoVariancetype injectivity(*IF_CURRENT = Asttypes.injectivity *)=|Injective|NoInjectivityendmoduleParsetree=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*string option(* "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} *)typeattribute(*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_arrow ofarg_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_variantofrow_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.
- As the pval_type field of a value_description.
*)|Ptyp_packageofpackage_type(* (module S) *)|Ptyp_extensionofextension(* [%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_alias ofpattern*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*(stringloclist*pattern)option(* C None
C P Some ([], P)
C (P1, ..., Pn) Some ([], Ppat_tuple [P1; ...; Pn])
C (type a b) P Some ([a; b], P)
*)|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_constraintofpattern*core_type(* (P : T) *)|Ppat_typeofLongident.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_try ofexpression*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_array ofexpression list(* [| E1; ...; En |] *)|Pexp_ifthenelseofexpression *expression*expressionoption(* if E1 then E2 else E3 *)|Pexp_sequence ofexpression *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_packofmodule_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*injectivity))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_declaration list|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_vars:stringloclist;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_declarationlist(*
| 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*injectivity))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] *)}andextension_constructor_kind(*IF_CURRENT = Parsetree.extension_constructor_kind *) =Pext_declofstringloclist*constructor_arguments*core_typeoption(*
| C of T1 * ... * Tn ([], [T1; ...; Tn], None)
| C: T0 ([], [], Some T0)
| C: T1 * ... * Tn -> T0 ([], [T1; ...; Tn], Some T0)
| C: 'a... . T1... -> T0 (['a;...]; [T1;...], 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_arrowofarg_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_field list;}(* 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] *)}andclass_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*injectivity))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_funofarg_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_field list;}(* 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] *)}andclass_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_method of(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_attributeofattribute(* [@@@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_typeofofmodule_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_moduleofmodule_declaration(* module X = M
module X : MT *)|Psig_modsubstofmodule_substitution(* module X := M *)|Psig_recmoduleofmodule_declaration list(* module rec X1 : MT1 and ... and Xn : MTn *)|Psig_modtypeofmodule_type_declaration(* module type S = MT
module type S *)|Psig_modtypesubstofmodule_type_declaration(* module type S := ... *)|Psig_openofopen_description(* open X *)|Psig_includeofinclude_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;}and module_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_modtype ofLongident.tloc*module_type(* with module type X.Y = Z *)|Pwith_modtypesubst ofLongident.tloc*module_type(* with module type X.Y := sig end *)|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_functoroffunctor_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_valueofrec_flag*value_binding list(* 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_recmoduleofmodule_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_attributeofattribute(* [@@@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_argument option;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_boolofboolendmodule Docstrings:sig(** Documentation comments
{b Warning:} this module is unstable and part of
{{!Compiler_libs}compiler-libs}.
*)(** (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 *)val symbol_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 ->docs Lazy.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 *)val symbol_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;mutableds_attached:ds_attached;mutableds_associated:ds_associated;}(* List of docstrings *)letdocstrings:docstringlist ref =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_docstringtrue))(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_loc ds=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=letopenParsetreeinletbody=ds.ds_bodyinletloc=ds.ds_locinletexp={pexp_desc=Pexp_constant(Pconst_string(body,loc,None));pexp_loc=loc;pexp_loc_stack=[];pexp_attributes=[];}inletitem={pstr_desc=Pstr_eval(exp,[]);pstr_loc=loc}in{attr_name=doc_loc;attr_payload =PStr[item];attr_loc=loc}letadd_docs_attrsdocsattrs=letattrs=matchdocs.docs_prewith|None |Some{ds_body="";_}->attrs|Someds->docs_attrds::attrsinletattrs=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 not attached to a specific item*)typetext=docstringlistletempty_text=[]letempty_text_lazy=lazy[]lettext_loc={txt="ocaml.text";loc=Location.none}lettext_attrds=letopenParsetreeinletbody=ds.ds_bodyinletloc=ds.ds_locinletexp={pexp_desc=Pexp_constant(Pconst_string(body,loc,None));pexp_loc=loc;pexp_loc_stack=[];pexp_attributes=[];}inletitem={pstr_desc=Pstr_eval(exp,[]);pstr_loc=loc}in{attr_name=text_loc;attr_payload=PStr[item];attr_loc=loc}letadd_text_attrsdslattrs=let fdsl=List.filter(function{ds_body=""}->false|_->true)dslin(List.maptext_attrfdsl)@attrs(* Find the first non-info docstring in a list, attachit and return it *)letget_docstring~infodsl=letrecloop=function|[]->None|{ds_attached =Info;_}::rest->looprest|ds::_->ds.ds_attached<-ifinfo thenInfoelseDocs;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_associated with|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.find pre_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_docs pos =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.create 50letset_floating_docstringsposdsl=ifdsl<>[]then Hashtbl.addfloating_tableposdsllet get_textpos=tryletdsl =Hashtbl.findfloating_tableposinget_docstringsdslwithNot_found ->[]letget_post_text pos=tryletdsl=Hashtbl.findpost_tableposinget_docstringsdslwithNot_found->[](* Maps from positions to extra docstrings *)letpre_extra_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create 50letset_pre_extra_docstringsposdsl=ifdsl<>[]thenHashtbl.addpre_extra_tableposdsllet get_pre_extra_textpos=tryletdsl=Hashtbl.findpre_extra_tableposinget_docstringsdslwithNot_found ->[]letpost_extra_table :(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create 50letset_post_extra_docstringsposdsl=ifdsl<>[]then Hashtbl.addpost_extra_tableposdslletget_post_extra_textpos=tryletdsl=Hashtbl.findpost_extra_tableposinget_docstringsdslwithNot_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_docsp1;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)let rhs_textpos=get_text(Parsing.rhs_start_pospos)letrhs_post_textpos=get_post_text(Parsing.rhs_end_pospos)letrhs_text_lazy pos=letpos=Parsing.rhs_start_pos posinlazy(get_text pos)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=structlet symbol_docs (startpos,endpos)={docs_pre=get_pre_docsstartpos;docs_post=get_post_docs endpos;}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_docs pos2;}letrhs_docs_lazyp1p2=lazy{docs_pre=get_pre_docsp1;docs_post=get_post_docsp2;}letmark_symbol_docs(startpos,endpos)=mark_pre_docsstartpos;mark_post_docs endpos;()letmark_rhs_docspos1pos2 =mark_pre_docspos1;mark_post_docspos2;()letsymbol_infoendpos=get_infoendposletrhs_infoendpos=get_info endposletsymbol_textstartpos=get_textstartposletsymbol_text_lazy startpos=lazy (get_textstartpos)letrhs_textpos=get_text posletrhs_post_textpos=get_post_textposletrhs_text_lazypos=lazy(get_textpos)letsymbol_pre_extra_textstartpos=get_pre_extra_textstartposletsymbol_post_extra_text endpos=get_post_extra_textendposletrhs_pre_extra_textpos=get_pre_extra_textposlet rhs_post_extra_textpos=get_post_extra_textposend(* (Re)Initialise allcomment state *)letinit()=docstrings :=[];Hashtbl.resetpre_table;Hashtbl.resetpost_table;Hashtbl.resetfloating_table;Hashtbl.resetpre_extra_table;Hashtbl.reset post_extra_tableendmoduleAst_helper:sig(** Helpers to produce Parsetree fragments
{b Warning} This module is unstable and part of
{{!Compiler_libs}compiler-libs}.
*)openAsttypesopenDocstringsopenParsetreetype'awith_loc='aLocation.loctypeloc=Location.ttypelid=Longident.twith_loctype str=stringwith_loctypestr_opt=stringoption with_loctypeattrs=attributelist(** {1 Default locations} *)valdefault_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->constantval int32:?suffix:char->int32->constantvalint64:?suffix:char->int64->constantvalnativeint:?suffix:char->nativeint->constantval float:?suffix:char->string->constantend(** {1 Attributes} *)moduleAttr:sigvalmk:?loc:loc ->str->payload->attributeend(** {1 Core language} *)(** Type expressions *)moduleTyp:sigvalmk:?loc:loc->?attrs:attrs->core_type_desc->core_typevalattr: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_typevalconstr:?loc:loc->?attrs:attrs->lid-> core_typelist ->core_typevalobject_:?loc:loc->?attrs:attrs->object_field list->closed_flag->core_typevalclass_:?loc:loc->?attrs:attrs->lid->core_typelist ->core_typevalalias:?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_typevalpackage:?loc:loc->?attrs:attrs->lid->(lid*core_type)list->core_typeval extension:?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->(strlist*pattern)option->patternval variant:?loc:loc->?attrs:attrs->label->patternoption->patternvalrecord:?loc:loc->?attrs:attrs->(lid*pattern)list ->closed_flag->patternvalarray:?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_binding list->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 ->expressionval tuple:?loc:loc->?attrs:attrs->expression list->expressionvalconstruct:?loc:loc-> ?attrs:attrs->lid->expressionoption->expressionvalvariant:?loc:loc->?attrs:attrs->label->expressionoption->expressionvalrecord:?loc:loc->?attrs:attrs->(lid*expression)list->expressionoption->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_type option->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 *injectivity))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->?vars:strlist->?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 *)moduleTe:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?params:(core_type*(variance *injectivity))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_constructorval decl:?loc:loc->?attrs:attrs->?docs:docs->?info:info->?vars:strlist->?args:constructor_arguments->?res:core_type->str->extension_constructorvalrebind:?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:sigval mk:?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_itemvalmodtype_subst:?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_itemvalattribute:?loc:loc->attribute->signature_itemvaltext:text->signature_itemlistend(** Structure items *)moduleStr:sigval mk:?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_itemvalattribute:?loc:loc->attribute->structure_itemvaltext:text->structure_itemlistend(** Module declarations *)moduleMd:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->str_opt->module_type->module_declarationend(** Module substitutions *)moduleMs: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 *)module Mb:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->str_opt->module_expr->module_bindingend(** Opens *)module Opn: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_typevalsignature:?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 *)moduleCtf: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_exprvalstructure:?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_fieldval attr: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*injectivity))list->str->'a->'aclass_infosend(** Class signatures *)moduleCsig:sigvalmk:core_type->class_type_fieldlist->class_signatureend(** Class structures *)moduleCstr:sigvalmk:pattern->class_fieldlist->class_structureend(** Row fields *)moduleRf:sigvalmk:?loc:loc->?attrs:attrs->row_field_desc->row_fieldvaltag:?loc:loc->?attrs:attrs->labelwith_loc ->bool->core_typelist->row_fieldvalinherit_:?loc:loc->core_type ->row_fieldend(** Object fields *)moduleOf: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=struct(** Helpers to produce Parsetree fragments *)openAsttypesopenParsetreeopenDocstringstype'awith_loc='aLocation.loctypeloc=Location.ttypelid=Longident.twith_loctype str=stringwith_loctypestr_opt=stringoption with_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(string_of_inti)let int32?(suffix='l')i=integer~suffix (Int32.to_string i)letint64?(suffix='L')i=integer~suffix(Int64.to_stringi)letnativeint?(suffix='n')i=integer~suffix(Nativeint.to_stringi)let float?suffixf=Pconst_float(f,suffix)letcharc=Pconst_charcletstring?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=structletmk ?(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?attrsabc=mk?loc?attrs (Ptyp_arrow (a,b,c))let tuple?loc?attrsa=mk?loc?attrs(Ptyp_tuplea)letconstr?loc?attrs ab=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_polyt=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_namesinletrecloopt=letdesc=matcht.ptyp_desc with|Ptyp_any->Ptyp_any|Ptyp_varx->check_variablevar_namest.ptyp_locx;Ptyp_varx|Ptyp_arrow (label,core_type,core_type')->Ptyp_arrow(label,loopcore_type,loopcore_type')|Ptyp_tuplelst->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.maploop_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)|Rinheritt->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}let attrda={dwithppat_attributes=d.ppat_attributes@[a]}letany?loc?attrs()=mk?loc?attrsPpat_anyletvar?loc?attrsa=mk?loc?attrs(Ppat_vara)letalias?loc?attrsab=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))letvariant?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?attrsab=mk?loc?attrs(Ppat_or (a,b))letconstraint_?loc?attrsab=mk?loc?attrs(Ppat_constraint(a,b))let type_?loc?attrsa=mk?loc?attrs(Ppat_typea)letlazy_?loc?attrsa=mk?loc?attrs(Ppat_lazy a)letunpack?loc?attrsa=mk?loc?attrs(Ppat_unpack a)letopen_?loc?attrs ab=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}let attrda={dwithpexp_attributes=d.pexp_attributes@[a]}letident?loc?attrsa=mk?loc?attrs(Pexp_identa)letconstant?loc?attrsa=mk?loc?attrs(Pexp_constanta)letlet_?loc?attrs abc=mk?loc ?attrs (Pexp_let(a,b,c))letfun_?loc?attrsabcd=mk ?loc?attrs(Pexp_fun(a,b,c,d))letfunction_?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))letvariant?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))let sequence?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))let coerce?loc?attrsabc=mk?loc?attrs(Pexp_coerce(a,b,c))letsend?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))let override?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_asserta)letlazy_?loc?attrs a=mk?loc?attrs (Pexp_lazy a)letpoly?loc?attrsab=mk?loc?attrs(Pexp_poly (a,b))letobject_?loc?attrsa=mk?loc ?attrs (Pexp_objecta)letnewtype?loc?attrsab=mk?loc?attrs(Pexp_newtype(a,b))letpack ?loc?attrsa=mk?loc ?attrs (Pexp_packa)letopen_?loc?attrsab=mk?loc?attrs (Pexp_open (a,b))letletop ?loc ?attrslet_andsbody=mk?loc?attrs(Pexp_letop{let_;ands;body})letextension?loc?attrs a=mk?loc?attrs(Pexp_extensiona)letunreachable?loc?attrs()=mk ?loc?attrsPexp_unreachableletcaselhs?guard rhs ={pc_lhs =lhs;pc_guard=guard;pc_rhs=rhs;}letbinding_op oppatexploc={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_alias a)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_typeofa)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))let apply ?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_unpacke)letextension?loc?attrsa=mk?loc?attrs(Pmod_extensiona)endmodule Sig=structletmk?(loc=!default_loc)d={psig_desc =d;psig_loc=loc}let value?loca=mk?loc(Psig_valuea)lettype_?loc rec_flaga=mk?loc(Psig_type(rec_flag,a))lettype_subst?loca=mk?loc(Psig_typesubsta)lettype_extension?loca=mk?loc(Psig_typexta)letexception_?loca=mk?loc(Psig_exceptiona)letmodule_?loca=mk?loc(Psig_modulea)letmod_subst?loca=mk?loc(Psig_modsubsta)letrec_module?loca=mk ?loc(Psig_recmodulea)letmodtype?loca=mk?loc(Psig_modtypea)letmodtype_subst?loca=mk?loc(Psig_modtypesubsta)letopen_?loca=mk?loc(Psig_opena)letinclude_?loca=mk?loc(Psig_includea)letclass_?loca=mk?loc (Psig_class a)letclass_type?loca=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<>"")txtinList.map(funds ->attribute~loc:(docstring_locds)(text_attrds))f_txtendmoduleStr=structletmk?(loc=!default_loc)d={pstr_desc =d;pstr_loc=loc}let eval?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_?loca=mk?loc(Pstr_exceptiona)letmodule_?loca=mk?loc(Pstr_modulea)letrec_module?loca=mk?loc(Pstr_recmodulea)letmodtype?loca=mk?loc(Pstr_modtypea)letopen_?loca=mk?loc(Pstr_opena)letclass_?loca=mk?loc(Pstr_classa)letclass_type?loca=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<>"")txtinList.map(funds ->attribute~loc:(docstring_locds)(text_attrds))f_txtendmoduleCl=structlet mk?(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?attrs abcd=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))letextension?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={dwith pcty_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))let extension?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?attrsa=mk?loc?attrs(Pctf_inherita)letval_?loc ?attrs abcd=mk?loc?attrs (Pctf_val(a,b,c,d))letmethod_?loc?attrsabcd=mk?loc?attrs(Pctf_method(a,b,c,d))letconstraint_?loc?attrsab=mk?loc?attrs(Pctf_constraint(a,b))let extension?loc?attrsa=mk?loc ?attrs(Pctf_extensiona)letattribute?loca=mk?loc(Pctf_attribute a)lettexttxt=letf_txt =List.filter(funds->docstring_bodyds<>"")txtinList.map(funds ->attribute~loc:(docstring_locds)(text_attrds))f_txtletattrda={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?attrsabc=mk?loc?attrs (Pcf_inherit (a,b,c))letval_?loc?attrsabc=mk?loc?attrs(Pcf_val(a,b,c))letmethod_?loc?attrsabc=mk ?loc?attrs(Pcf_method(a,b,c))let constraint_?loc?attrsab=mk?loc?attrs(Pcf_constraint(a,b))letinitializer_?loc?attrsa=mk?loc?attrs(Pcf_initializera)letextension ?loc?attrsa=mk?loc?attrs(Pcf_extensiona)letattribute?loca=mk?loc(Pcf_attributea)lettexttxt=letf_txt=List.filter(funds->docstring_bodyds<>"")txtinList.map(funds ->attribute~loc:(docstring_locds)(text_attrds))f_txtletvirtual_ct=Cfk_virtualctletconcreteoe=Cfk_concrete (o,e)letattrda={dwithpcf_attributes=d.pcf_attributes@[a]}endmoduleVal=structletmk?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(prim=[])nametyp={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_attrstext(add_docs_attrsdocsattrs);pmd_loc=loc;}endmoduleMs=structlet mk?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])namesyn={pms_name=name;pms_manifest =syn;pms_attributes=add_text_attrstext(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_attrstext(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=[])patexpr ={pvb_pat =pat;pvb_expr=expr;pvb_attributes=add_text_attrstext(add_docs_attrsdocsattrs);pvb_loc=loc;}endmoduleCi=structlet mk?(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_attrstext(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)?(vars=[])?(args =Pcstr_tuple[])?res name={pcd_name=name;pcd_vars=vars;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)namekind={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)?(vars=[])?(args=Pcstr_tuple[])?resname={pext_name=name;pext_kind=Pext_decl(vars,args,res);pext_loc=loc;pext_attributes=add_docs_attrsdocs(add_info_attrsinfoattrs);}letrebind?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(info=empty_info)namelid={pext_name=name;pext_kind =Pext_rebind lid;pext_loc=loc;pext_attributes=add_docs_attrsdocs (add_info_attrsinfoattrs);}endmoduleCsig=structletmkselffields={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;}let tag?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;}let tag?loc?attrslabelty=mk?loc?attrs(Otag(label,ty))let inherit_?locty=mk?loc(Oinherit ty)endendmoduleAst_mapper:sig(** The interface of a -ppx rewriter
A -ppx rewriter is a program that accepts a serialized abstract syntax
tree and outputs another, possibly modified, abstract syntax tree.
This module encapsulates the interface between the compiler and
the -ppx rewriters, handling such details as the serialization format,
forwarding of command-line flags, and storing state.
{!mapper} enables AST rewriting using open recursion.
A typical mapper would be based on {!default_mapper}, a deep
identity mapper, and will fall back on it for handling the syntax it
does not modify. For example:
{[
open Asttypes
open Parsetree
open Ast_mapper
let test_mapper argv =
{ default_mapper with
expr = fun mapper expr ->
match expr with
| { pexp_desc = Pexp_extension ({ txt = "test" }, PStr [])} ->
Ast_helper.Exp.constant (Const_int 42)
| other -> default_mapper.expr mapper other; }
let () =
register "ppx_test" test_mapper]}
This -ppx rewriter, which replaces [[%test]] in expressions with
the constant [42], can be compiled using
[ocamlc -o ppx_test -I +compiler-libs ocamlcommon.cma ppx_test.ml].
{b Warning:} this module is unstable and part of
{{!Compiler_libs}compiler-libs}.
*)openParsetree(** {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: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. *)(** {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=struct(* A generic Parsetree mapping class *)(*
[@@@ocaml.warning "+9"]
(* Ensure that record patterns don't miss any field. *)
*)openParsetreeopenAst_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_tuple3f1f2f3(x,y,z)=(f1x,f2y,f3z)letmap_optf=function None-> None|Somex->Some(fx)letmap_locsub{loc;txt}={loc=sub.locationsubloc;txt}moduleC=struct(* Constants *)letmapsubc=match cwith|Pconst_integer_|Pconst_char_|Pconst_float_->c|Pconst_string(s,loc,quotation_delimiter)->letloc=sub.locationsubloc inConst.string~loc?quotation_delimitersendmodule T=struct(* Type expressions for the corelanguage *)letrow_fieldsub{prf_desc;prf_loc;prf_attributes;}=letloc =sub.locationsubprf_locinletattrs=sub.attributessubprf_attributesinletdesc=matchprf_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_locinletattrs=sub.attributessubpof_attributesinletdesc=matchpof_descwith|Otag(l,t)->Otag(map_locsubl,sub.typsubt)|Oinheritt->Oinherit(sub.typsubt)inOf.mk~loc~attrsdescletmapsub {ptyp_desc=desc;ptyp_loc=loc;ptyp_attributes=attrs}=letopenTypinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatchdescwith|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.typ subt)|Ptyp_package(lid,l)->package~loc ~attrs(map_locsublid)(List.map(map_tuple(map_locsub)(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.attributessubptype_attributesinType.mk~loc~attrs (map_loc subptype_name)~params:(List.map(map_fst(sub.typsub))ptype_params)~priv:ptype_private~cstrs:(List.map(map_tuple3(sub.typsub)(sub.typsub)(sub.location sub))ptype_cstrs)~kind:(sub.type_kindsub ptype_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.typ sub)l)|Pcstr_recordl->Pcstr_record(List.map(sub.label_declarationsub)l)letmap_type_extensionsub{ptyext_path;ptyext_params;ptyext_constructors;ptyext_private;ptyext_loc;ptyext_attributes}=letloc=sub.locationsubptyext_locinletattrs =sub.attributessubptyext_attributesinTe.mk~loc~attrs(map_locsubptyext_path)(List.map(sub.extension_constructorsub)ptyext_constructors)~params:(List.map(map_fst(sub.typ sub))ptyext_params)~priv:ptyext_privateletmap_type_exceptionsub{ptyexn_constructor;ptyexn_loc;ptyexn_attributes}=letloc=sub.locationsubptyexn_loc inletattrs =sub.attributessubptyexn_attributesinTe.mk_exception~loc~attrs(sub.extension_constructorsubptyexn_constructor)letmap_extension_constructor_kindsub=functionPext_decl(vars,ctl,cto)->Pext_decl(List.map(map_locsub)vars,map_constructor_argumentssubctl,map_opt(sub.typsub)cto)|Pext_rebindli->Pext_rebind(map_loc subli)letmap_extension_constructorsub{pext_name;pext_kind;pext_loc;pext_attributes}=letloc=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.attributessubattrsinmatchdescwith|Pcty_constr (lid,tys)->constr~loc~attrs (map_locsublid)(List.map (sub.typsub)tys)|Pcty_signature x->signature~loc~attrs (sub.class_signaturesubx)|Pcty_arrow(lab,t,ct)->arrow~loc~attrslab(sub.typsubt)(sub.class_typesubct)|Pcty_extensionx->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}=letopenCtfinlet loc=sub.locationsublocinletattrs=sub.attributessubattrsinmatchdescwith|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_fieldsub)pcsig_fields)endletmap_functor_paramsub=function|Unit->Unit|Named(s,mt)->Named(map_locsubs,sub.module_typesubmt)moduleMT=struct(* Type expressions for the modulelanguage *)letmapsub{pmty_desc=desc;pmty_loc=loc;pmty_attributes=attrs}=letopenMtyinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatchdescwith|Pmty_idents->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_type submt)(List.map(sub.with_constraintsub)l)|Pmty_typeof me->typeof_~loc~attrs(sub.module_exprsubme)|Pmty_extensionx->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_loc sublid,map_locsublid2)|Pwith_modtype(lid,mty)->Pwith_modtype(map_loc sublid,sub.module_typesub mty)|Pwith_typesubst(lid,d)->Pwith_typesubst(map_locsublid,sub.type_declarationsubd)|Pwith_modsubst(s,lid)->Pwith_modsubst(map_locsubs,map_locsublid)|Pwith_modtypesubst(lid,mty)->Pwith_modtypesubst(map_locsublid,sub.module_typesubmty)letmap_signature_itemsub{psig_desc =desc;psig_loc=loc}=letopenSiginletloc=sub.location sublocinmatchdescwith|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_exceptioned->exception_~loc(sub.type_exceptionsubed)|Psig_modulex->module_~loc (sub.module_declarationsub x)|Psig_modsubstx->mod_subst~loc(sub.module_substitutionsubx)|Psig_recmodulel->rec_module~loc(List.map(sub.module_declarationsub)l)|Psig_modtypex->modtype~loc (sub.module_type_declarationsubx)|Psig_modtypesubstx->modtype_subst~loc(sub.module_type_declarationsubx)|Psig_openx->open_~loc(sub.open_descriptionsubx)|Psig_includex->include_~loc(sub.include_descriptionsubx)|Psig_classl->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.attributessubattrsinmatchdescwith|Pmod_identx->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~loc r(List.map (sub.value_binding sub)vbs)|Pstr_primitivevd->primitive~loc(sub.value_descriptionsubvd)|Pstr_type(rf,l)->type_~loc rf(List.map(sub.type_declaration sub)l)|Pstr_typextte-> type_extension~loc(sub.type_extensionsubte)|Pstr_exceptioned->exception_~loc(sub.type_exceptionsubed)|Pstr_modulex->module_~loc (sub.module_bindingsubx)|Pstr_recmodulel->rec_module~loc (List.map(sub.module_binding sub)l)|Pstr_modtypex->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.attributessubattrsinmatchdescwith|Pexp_identx->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~attrslab(map_opt(sub.exprsub)def)(sub.patsubp)(sub.expr sube)|Pexp_functionpel ->function_~loc~attrs(sub.casessubpel)|Pexp_apply(e,l)->apply~loc~attrs(sub.expr sube)(List.map(map_snd(sub.exprsub))l)|Pexp_match (e,pel)->match_~loc ~attrs(sub.exprsube)(sub.casessubpel)|Pexp_try(e,pel)->try_~loc~attrs (sub.exprsube)(sub.casessubpel)|Pexp_tupleel->tuple ~loc~attrs(List.map(sub.exprsub)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_loc sublid)(sub.exprsube2)|Pexp_arrayel->array~loc ~attrs(List.map (sub.expr sub)el)|Pexp_ifthenelse(e1,e2,e3)->ifthenelse~loc ~attrs(sub.exprsube1)(sub.exprsube2)(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.exprsube2)|Pexp_for(p,e1,e2,d,e3)->for_ ~loc~attrs(sub.patsubp)(sub.expr sube1)(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_newlid->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_locsub)(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.expr sube)|Pexp_lazye->lazy_~loc~attrs(sub.expr sub e)|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_loc subs)(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_patinletexp=sub.expr subpbop_expinletloc=sub.locationsubpbop_locinbinding_opoppatexplocendmoduleP=struct(* Patterns *)letmapsub{ppat_desc=desc;ppat_loc=loc;ppat_attributes=attrs}=letopenPatinletloc=sub.locationsublocinletattrs=sub.attributessubattrsinmatchdescwith|Ppat_any -> any~loc~attrs()|Ppat_vars-> var~loc~attrs(map_locsubs)|Ppat_alias(p,s)->alias~loc~attrs(sub.patsubp)(map_locsubs)|Ppat_constantc-> constant~loc~attrs(sub.constantsubc)|Ppat_interval(c1,c2)->interval~loc~attrs (sub.constantsubc1)(sub.constantsubc2)|Ppat_tuplepl->tuple~loc~attrs (List.map(sub.patsub)pl)|Ppat_construct(l,p)->construct ~loc~attrs(map_locsubl)(map_opt(fun(vl,p)->List.map(map_locsub)vl,sub.patsubp)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_locsub)(sub.patsub))lpl)cf|Ppat_arraypl->array~loc~attrs(List.map(sub.pat sub)pl)|Ppat_or(p1,p2)->or_~loc~attrs(sub.pat subp1)(sub.patsubp2)|Ppat_constraint(p,t)->constraint_~loc~attrs (sub.patsubp)(sub.typsubt)|Ppat_types->type_ ~loc ~attrs (map_locsubs)|Ppat_lazyp->lazy_~loc~attrs(sub.patsubp)|Ppat_unpacks->unpack~loc~attrs(map_loc subs)|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.attributessubattrsinmatchdescwith|Pcl_constr(lid,tys)->constr~loc~attrs (map_locsublid)(List.map (sub.typsub)tys)|Pcl_structure s->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_expr subce)(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_typesubct)|Pcl_extensionx->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.attributessubattrsinmatchdescwith|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_kindsubk)|Pcf_method(s,p,k)->method_~loc~attrs(map_locsubs)p(map_kindsubk)|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_locinletattrs=sub.attributessubpci_attributesinCi.mk~loc~attrs~virt:pci_virt~params:(List.map(map_fst(sub.typsub))pl)(map_loc subpci_name)(fpci_expr)end(* Now, a generic AST mapper, to be extendedto 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_locthispval_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_typethis)pmtd_type)~attrs:(this.attributesthispmtd_attributes)~loc:(this.locationthispmtd_loc));module_binding=(funthis{pmb_name;pmb_expr;pmb_attributes;pmb_loc}->Mb.mk(map_locthispmb_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_expr thispopen_expr)~override:popen_override~loc:(this.location thispopen_loc)~attrs:(this.attributesthis popen_attributes));open_description=(funthis{popen_expr;popen_override;popen_attributes;popen_loc}->Opn.mk (map_locthispopen_expr)~override:popen_override~loc:(this.location thispopen_loc)~attrs:(this.attributesthis popen_attributes));include_description=(funthis{pincl_mod;pincl_attributes;pincl_loc}->Incl.mk(this.module_typethispincl_mod)~loc:(this.locationthispincl_loc)~attrs:(this.attributesthis pincl_attributes));include_declaration=(funthis{pincl_mod;pincl_attributes;pincl_loc}->Incl.mk(this.module_exprthispincl_mod)~loc:(this.locationthispincl_loc)~attrs:(this.attributesthis pincl_attributes));value_binding=(funthis{pvb_pat;pvb_expr;pvb_attributes;pvb_loc}->Vb.mk(this.patthispvb_pat)(this.exprthispvb_expr)~loc:(this.location thispvb_loc)~attrs:(this.attributesthispvb_attributes));constructor_declaration=(funthis{pcd_name;pcd_vars;pcd_args;pcd_res;pcd_loc;pcd_attributes}->Type.constructor(map_loc thispcd_name)~vars:(List.map(map_locthis)pcd_vars)~args:(T.map_constructor_argumentsthispcd_args)?res:(map_opt(this.typthis)pcd_res)~loc:(this.locationthispcd_loc)~attrs:(this.attributesthispcd_attributes));label_declaration=(fun this{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.signaturethis x)|PTypx->PTyp(this.typthisx)|PPat(x,g)->PPat(this.patthisx,map_opt(this.exprthis)g));}letextension_of_errorerror=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)))]))letcookies=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=matchoptwith|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.recordfields None)];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());lid"unsafe_string",make_bool!Clflags.unsafe_string;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_listelemrest|{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_string payload|"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_bool payload|"transparent_modules"->Clflags.transparent_modules :=get_boolpayload|"unboxed_types"->Migrate_parsetree_compiler_functions.set_unboxed_types(get_boolpayload)|"unsafe_string"->Clflags.unsafe_string:=get_boolpayload|"cookies"->letl=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)->fieldnamex|_->())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)let apply_lazy~source~targetmapper=letimplemast=letfields,ast=match astwith|{pstr_desc=Pstr_attribute({attr_name={txt="ocaml.ppx.context"};attr_payload=x})}::l->PpxContext.get_fieldsx,l|_->[],astinPpxContext.restorefields;letast=tryletmapper=mapper()inmapper.structuremapperastwith exn->[{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.signaturemapperastwith exn->[{psig_desc=Psig_extension(extension_of_exnexn,[]);psig_loc=Location.none}]inletfields=PpxContext.update_cookiesfieldsinSig.attribute(PpxContext.mkfields)::astinletic=open_in_binsourceinletmagic=really_input_stringic(String.lengthConfig.ast_impl_magic_number)inletrewrite transform=Location.input_name:=input_valueic;let ast=input_value icinclose_inic;let ast=transformastinletoc=open_out_bintargetinoutput_stringocmagic;output_valueoc!Location.input_name;output_valueocast;close_outocandfail()=close_inic;failwith "Ast_mapper: OCaml version 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.argvinletn=Array.length ainifn>2thenlet mapper()=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_functionnamefendmoduleType_immediacy=structtypet(*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_constrofout_ident*out_valuelist|Oval_ellipsis|Oval_floatoffloat|Oval_int ofint|Oval_int32ofint32|Oval_int64ofint64|Oval_nativeintofnativeint|Oval_listofout_valuelist|Oval_printerof(Format.formatter->unit)|Oval_record of(out_ident*out_value)list|Oval_string ofstring*int*out_string(* string, size-to-print, kind *)|Oval_stuff ofstring|Oval_tupleofout_valuelist|Oval_variantofstring*out_valueoptiontypeout_type_param =string*(Asttypes.variance*Asttypes.injectivity)typeout_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_type list|Otyp_constr ofout_ident*out_type list|Otyp_manifest ofout_type*out_type|Otyp_objectof(string*out_type)list*booloption|Otyp_recordof(string*bool*out_type)list|Otyp_stuffofstring|Otyp_sumofout_constructorlist|Otyp_tupleofout_type list|Otyp_varofbool*string|Otyp_variantofbool *out_variant*bool*(string list)option|Otyp_polyofstring list*out_type|Otyp_module ofout_ident *(string*out_type)list|Otyp_attributeofout_type*out_attributeandout_constructor (*IF_CURRENT = Outcometree.out_constructor *)={ocstr_name:string;ocstr_args:out_typelist;ocstr_return_type:out_typeoption;}andout_variant (*IF_CURRENT = Outcometree.out_variant *)=|Ovar_fieldsof(string*bool*out_typelist)list|Ovar_typofout_typetypeout_class_type(*IF_CURRENT = Outcometree.out_class_type *) =|Octy_constrofout_ident*out_typelist|Octy_arrow ofstring*out_type*out_class_type|Octy_signature ofout_typeoption*out_class_sig_item listandout_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_signature ofout_sig_item list|Omty_aliasofout_identandout_sig_item(*IF_CURRENT = Outcometree.out_sig_item *)=|Osig_classofbool*string*out_type_paramlist*out_class_type*out_rec_status|Osig_class_type ofbool*string*out_type_paramlist*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_value ofout_val_decl|Osig_ellipsisandout_type_decl (*IF_CURRENT = Outcometree.out_type_decl *) ={otype_name:string;otype_params:out_type_paramlist;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_type option;oext_private:Asttypes.private_flag}andout_type_extension(*IF_CURRENT = Outcometree.out_type_extension *) ={otyext_name:string;otyext_params:stringlist;otyext_constructors:out_constructorlist;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_exceptiontype out_phrase(*IF_CURRENT = Outcometree.out_phrase *)=|Ophr_evalofout_value*out_type|Ophr_signatureof(out_sig_item*out_valueoption)list|Ophr_exceptionof(exn*out_value)endmodule Config =structletast_impl_magic_number="Caml1999M031"letast_intf_magic_number="Caml1999N031"endletmap_signaturemapper=mapper.Ast_mapper.signaturemapperletmap_structuremapper=mapper.Ast_mapper.structuremapperletshallow_identity=let id_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=let fail__=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_mapperwithAst_mapper.signature =(fun_x->signaturex);structure=(fun_x->structurex)}