1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201(**************************************************************************)(* *)(* 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_stringofstring*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|NoVariancetypeinjectivity(*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.
*)|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*patternoption(* C None
C P Some P
C (P1, ..., Pn) Some (Ppat_tuple [P1; ...; Pn])
*)|Ppat_variantoflabel*patternoption(* `A (None)
`A P (Some P)
*)|Ppat_recordof(Longident.tloc*pattern)list*closed_flag(* { l1=P1; ...; ln=Pn } (flag = Closed)
{ l1=P1; ...; ln=Pn; _} (flag = Open)
Invariant: n > 0
*)|Ppat_arrayofpatternlist(* [| P1; ...; Pn |] *)|Ppat_orofpattern*pattern(* P1 | P2 *)|Ppat_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_declarationlist|Ptype_recordoflabel_declarationlist(* Invariant: non-empty list *)|Ptype_openandlabel_declaration (*IF_CURRENT = Parsetree.label_declaration *)={pld_name:stringloc;pld_mutable:mutable_flag;pld_type:core_type;pld_loc:Location.t;pld_attributes:attributes;(* l : T [@id1] [@id2] *)}(* { ...; l: T; ... } (mutable=Immutable)
{ ...; mutable l: T; ... } (mutable=Mutable)
Note: T can be a Ptyp_poly.
*)andconstructor_declaration(*IF_CURRENT = Parsetree.constructor_declaration *)={pcd_name:stringloc;pcd_args:constructor_arguments;pcd_res:core_type option;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_declofconstructor_arguments*core_typeoption(*
| C of T1 * ... * Tn ([T1; ...; Tn], None)
| C: T0 ([], Some T0)
| C: T1 * ... * Tn -> T0 ([T1; ...; Tn], Some T0)
*)|Pext_rebindofLongident.tloc(*
| C = D
*)(** {1 Class language} *)(* Type expressions for the class language *)andclass_type(*IF_CURRENT = Parsetree.class_type *)={pcty_desc:class_type_desc;pcty_loc:Location.t;pcty_attributes:attributes;(* ... [@id1] [@id2] *)}andclass_type_desc(*IF_CURRENT = Parsetree.class_type_desc *) =|Pcty_constrofLongident.tloc*core_typelist(* c
['a1, ..., 'an] c *)|Pcty_signatureofclass_signature(* object ... end *)|Pcty_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_fieldlist;}(* object('selfpat) ... end
object ... end (self = Ptyp_any)
*)andclass_type_field(*IF_CURRENT = Parsetree.class_type_field *)={pctf_desc:class_type_field_desc;pctf_loc:Location.t;pctf_attributes:attributes;(* ... [@@id1] [@@id2] *)}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_fieldlist;}(* object(selfpat) ... end
object ... end (self = Ppat_any)
*)andclass_field(*IF_CURRENT = Parsetree.class_field *)={pcf_desc:class_field_desc;pcf_loc:Location.t;pcf_attributes:attributes;(* ... [@@id1] [@@id2] *)}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_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_typesubst ofLongident.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_argumentoption;pdir_loc:Location.t;}anddirective_argument (*IF_CURRENT = Parsetree.directive_argument *) ={pdira_desc:directive_argument_desc;pdira_loc:Location.t;}anddirective_argument_desc(*IF_CURRENT = Parsetree.directive_argument_desc *) =|Pdir_stringofstring|Pdir_intofstring*charoption|Pdir_identofLongident.t|Pdir_boolofboolendmodule Docstrings:sig(** (Re)Initialise all docstring state *)valinit:unit->unit(** Emit warnings for unattached and ambiguous docstrings *)valwarn_bad_docstrings:unit->unit(** {2 Docstrings} *)(** Documentation comments *)typedocstring(** Create a docstring *)valdocstring:string->Location.t->docstring(** Register a docstring *)valregister:docstring ->unit(** Get the text of a docstring *)valdocstring_body:docstring->string(** Get the location of a docstring *)valdocstring_loc:docstring ->Location.t(** {2 Set functions}
These functions are used by the lexer to associate docstrings to
the locations of tokens. *)(** Docstrings immediately preceding a token *)valset_pre_docstrings:Lexing.position->docstringlist->unit(** Docstrings immediately following a token *)valset_post_docstrings:Lexing.position->docstringlist->unit(** Docstrings not immediately adjacent to a token *)valset_floating_docstrings:Lexing.position->docstringlist->unit(** Docstrings immediately following the token which precedes this one *)valset_pre_extra_docstrings:Lexing.position->docstringlist->unit(** Docstrings immediately preceding the token which follows this one *)valset_post_extra_docstrings:Lexing.position->docstringlist->unit(** {2 Items}
The {!docs} type represents documentation attached to an item. *)typedocs={docs_pre:docstringoption;docs_post:docstringoption;}valempty_docs:docsvaldocs_attr:docstring->Parsetree.attribute(** Convert item documentation to attributes and add them to an
attribute list *)valadd_docs_attrs:docs->Parsetree.attributes->Parsetree.attributes(** Fetch the item documentation for the current symbol. This also
marks this documentation (for ambiguity warnings). *)valsymbol_docs:unit->docsvalsymbol_docs_lazy:unit->docsLazy.t(** Fetch the item documentation for the symbols between two
positions. This also marks this documentation (for ambiguity
warnings). *)valrhs_docs:int->int->docsvalrhs_docs_lazy:int->int->docsLazy.t(** Mark the itemdocumentation 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.tval text_attr :docstring->Parsetree.attribute(** Convert text to attributes and add them to an attribute list *)valadd_text_attrs:text->Parsetree.attributes->Parsetree.attributes(** Fetch the text preceding the current symbol. *)valsymbol_text:unit->textvalsymbol_text_lazy:unit->textLazy.t(** Fetch the text preceding the symbol at the given position. *)valrhs_text:int->textvalrhs_text_lazy:int->textLazy.t(** {2 Extra text}
There may be additional text attached to the delimiters of a block
(e.g. [struct] and [end]). This is fetched by the following
functions, which are applied to the contents of the block rather
than the delimiters. *)(** Fetch additional text preceding the current symbol *)valsymbol_pre_extra_text:unit->text(** Fetch additional text following the current symbol *)valsymbol_post_extra_text:unit->text(** Fetch additional text preceding the symbol at the given position *)valrhs_pre_extra_text:int->text(** Fetch additional text following the symbol at the given position *)valrhs_post_extra_text:int->text(** Fetch text following the symbol at the given position *)valrhs_post_text:int->textmoduleWithMenhir:sig(** Fetch the item documentation for the current symbol. This also
marks this documentation (for ambiguity warnings). *)valsymbol_docs:Lexing.position*Lexing.position->docsvalsymbol_docs_lazy:Lexing.position*Lexing.position->docsLazy.t(** Fetch the item documentation for the symbols between two
positions. This also marks this documentation (for ambiguity
warnings). *)valrhs_docs:Lexing.position->Lexing.position->docsvalrhs_docs_lazy:Lexing.position->Lexing.position->docsLazy.t(** Mark the item documentation for the current symbol (for ambiguity
warnings). *)valmark_symbol_docs:Lexing.position*Lexing.position->unit(** Mark as associated the item documentation for the symbols between
two positions (for ambiguity warnings) *)valmark_rhs_docs:Lexing.position->Lexing.position->unit(** Fetch the field info for the current symbol. *)valsymbol_info:Lexing.position->info(** Fetch the field info following the symbol at a given position. *)valrhs_info:Lexing.position->info(** Fetch the text preceding the current symbol. *)valsymbol_text:Lexing.position->textvalsymbol_text_lazy:Lexing.position->textLazy.t(** Fetchthe text preceding the symbol at the given position. *)valrhs_text:Lexing.position->textvalrhs_text_lazy:Lexing.position->textLazy.t(** {3 Extratext}
There may be additional text attached to the delimiters of a block
(e.g. [struct] and [end]). This is fetched by the following
functions, which are applied to the contents of the block rather
than the delimiters. *)(** Fetch additional text preceding the current symbol *)valsymbol_pre_extra_text:Lexing.position->text(** Fetch additional text following the current symbol *)valsymbol_post_extra_text:Lexing.position->text(** Fetch additional text preceding the symbol at the given position *)valrhs_pre_extra_text:Lexing.position->text(** Fetch additional text following the symbol at the given position *)valrhs_post_extra_text:Lexing.position->text(** Fetch text following the symbol at the given position *)valrhs_post_text:Lexing.position->textendend=struct(**************************************************************************)(* *)(* OCaml *)(* *)(* Leo White *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* 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. *)(* *)(**************************************************************************)openLocation(* 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:docstringlistref=ref[](* Warn for unused and ambiguous docstrings *)letwarn_bad_docstrings()=ifWarnings.is_active(Migrate_parsetree_compiler_functions.bad_docstringtrue)thenbeginList.iter(funds->matchds.ds_attachedwith|Info ->()|Unattached->prerr_warningds.ds_loc(Migrate_parsetree_compiler_functions.bad_docstringtrue)|Docs->matchds.ds_associatedwith|Zero|One->()|Many->prerr_warningds.ds_loc(Migrate_parsetree_compiler_functions.bad_docstringfalse))(List.rev!docstrings)end(* Docstring constructors and destructors *)letdocstringbodyloc=letds={ds_body=body;ds_loc=loc;ds_attached=Unattached;ds_associated=Zero;}indsletregisterds=docstrings:=ds::!docstringsletdocstring_bodyds=ds.ds_bodyletdocstring_locds=ds.ds_loc(* Docstringsattached 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_body inletloc=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=match docs.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_body inletloc=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=letfdsl =List.filter(function{ds_body=""}->false|_->true)dslin(List.maptext_attr fdsl)@attrs(* Find the first non-info docstring in a list, attach itand return it *)letget_docstring~infodsl=letrecloop=function|[]->None|{ds_attached=Info;_}::rest ->looprest|ds::_->ds.ds_attached<-ifinfothenInfoelse Docs;Somedsinloopdsl(* Find all the non-info docstrings in a list, attach them and return them *)letget_docstringsdsl=letrecloopacc=function|[]->List.revacc|{ds_attached=Info;_}::rest->loopaccrest|ds::rest->ds.ds_attached<-Docs;loop(ds::acc)restinloop[]dsl(* "Associate" all the docstrings in a list *)letassociate_docstringsdsl=List.iter(funds->matchds.ds_associatedwith|Zero->ds.ds_associated<-One|(One|Many)->ds.ds_associated<- Many)dsl(* Map from positions to pre docstrings *)letpre_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_pre_docstrings pos dsl=ifdsl<>[]thenHashtbl.addpre_tableposdslletget_pre_docspos=tryletdsl=Hashtbl.findpre_tableposinassociate_docstrings dsl;get_docstring ~info:falsedslwithNot_found->Nonelet mark_pre_docspos=tryletdsl=Hashtbl.findpre_tableposinassociate_docstringsdslwithNot_found->()(* Map from positions to post docstrings *)letpost_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_post_docstrings pos dsl =ifdsl <>[]thenHashtbl.addpost_tableposdslletget_post_docs pos=tryletdsl=Hashtbl.findpost_table posinassociate_docstringsdsl;get_docstring ~info:falsedslwithNot_found->Nonelet mark_post_docspos=tryletdsl=Hashtbl.findpost_tableposinassociate_docstrings dslwithNot_found->()letget_info pos=tryletdsl=Hashtbl.findpost_tableposinget_docstring ~info:truedslwithNot_found ->None(* Map from positions to floating docstrings *)letfloating_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_floating_docstrings pos dsl=if dsl<>[]thenHashtbl.addfloating_tableposdslletget_text pos=tryletdsl=Hashtbl.findfloating_tableposinget_docstrings dslwithNot_found->[]letget_post_textpos=tryletdsl =Hashtbl.findpost_tableposinget_docstringsdslwithNot_found->[](* Maps from positions to extra docstrings *)letpre_extra_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_pre_extra_docstrings pos dsl=ifdsl<>[]thenHashtbl.addpre_extra_tableposdsllet get_pre_extra_text pos=tryletdsl=Hashtbl.find pre_extra_table posinget_docstringsdslwithNot_found->[]letpost_extra_table:(Lexing.position,docstringlist)Hashtbl.t=Hashtbl.create50letset_post_extra_docstrings posdsl=ifdsl<>[]thenHashtbl.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);}let rhs_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())let rhs_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_text pos)letrhs_text pos=get_text(Parsing.rhs_start_pospos)letrhs_post_textpos=get_post_text(Parsing.rhs_end_pospos)letrhs_text_lazypos=letpos=Parsing.rhs_start_posposinlazy(get_textpos)letsymbol_pre_extra_text()=get_pre_extra_text(Parsing.symbol_start_pos())letsymbol_post_extra_text()=get_post_extra_text(Parsing.symbol_end_pos())letrhs_pre_extra_textpos=get_pre_extra_text(Parsing.rhs_start_pospos)letrhs_post_extra_textpos=get_post_extra_text(Parsing.rhs_end_pospos)endincludeWithParsingmoduleWithMenhir=structletsymbol_docs(startpos,endpos)={docs_pre=get_pre_docsstartpos;docs_post=get_post_docsendpos;}letsymbol_docs_lazy(p1,p2)=lazy{docs_pre=get_pre_docsp1;docs_post=get_post_docsp2;}letrhs_docspos1pos2={docs_pre=get_pre_docspos1;docs_post=get_post_docspos2;}letrhs_docs_lazyp1p2=lazy{docs_pre=get_pre_docsp1;docs_post=get_post_docsp2;}letmark_symbol_docs(startpos,endpos)=mark_pre_docsstartpos;mark_post_docsendpos;()letmark_rhs_docspos1pos2=mark_pre_docspos1;mark_post_docs pos2;()let symbol_info endpos=get_infoendposletrhs_infoendpos=get_infoendposletsymbol_textstartpos=get_textstartposletsymbol_text_lazystartpos=lazy(get_text startpos)letrhs_textpos=get_textposletrhs_post_textpos=get_post_textposlet rhs_text_lazypos=lazy(get_text pos)letsymbol_pre_extra_textstartpos=get_pre_extra_textstartposletsymbol_post_extra_textendpos=get_post_extra_textendposletrhs_pre_extra_textpos=get_pre_extra_text posletrhs_post_extra_textpos=get_post_extra_textposend(* (Re)Initialise all comment state *)letinit()=docstrings :=[];Hashtbl.resetpre_table;Hashtbl.resetpost_table;Hashtbl.resetfloating_table;Hashtbl.resetpre_extra_table;Hashtbl.resetpost_extra_tableendmoduleAst_helper:sigopenAsttypesopenDocstringsopenParsetreetype'awith_loc='aLocation.loctypeloc=Location.ttypelid=Longident.twith_loctypestr=stringwith_loctypestr_opt=stringoptionwith_loctypeattrs=attribute list(** {1 Default locations} *)valdefault_loc:locref(** Default value for all optional location arguments. *)val with_default_loc:loc->(unit->'a)->'a(** Set the [default_loc] within the scope of the execution
of the provided function. *)(** {1 Constants} *)moduleConst:sigvalchar:char->constantvalstring:?quotation_delimiter:string->?loc:Location.t->string->constantvalinteger:?suffix:char->string->constantvalint:?suffix:char->int->constantvalint32 :?suffix:char->int32->constantval int64:?suffix:char->int64->constantval nativeint:?suffix:char->nativeint->constantvalfloat:?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_fieldlist->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_typevalextension:?loc:loc->?attrs:attrs->extension->core_typevalforce_poly:core_type ->core_typevalvarify_constructors:strlist->core_type->core_type(** [varify_constructors newtypes te] is type expression [te], of which
any of nullary type constructor [tc] is replaced by type variable of
the same name, if [tc]'s name appears in [newtypes].
Raise [Syntaxerr.Variable_in_scope] if any type variable inside [te]
appears in [newtypes].
@since 4.05
*)end(** Patterns *)modulePat:sigvalmk:?loc:loc->?attrs:attrs->pattern_desc->patternvalattr:pattern->attribute->patternvalany:?loc:loc->?attrs:attrs->unit->patternvalvar:?loc:loc->?attrs:attrs->str->patternvalalias:?loc:loc->?attrs:attrs->pattern->str->patternvalconstant:?loc:loc->?attrs:attrs->constant->patternvalinterval:?loc:loc->?attrs:attrs->constant->constant ->patternvaltuple:?loc:loc->?attrs:attrs->patternlist->patternvalconstruct:?loc:loc->?attrs:attrs->lid->patternoption ->patternvalvariant:?loc:loc->?attrs:attrs->label->patternoption ->patternvalrecord:?loc:loc-> ?attrs:attrs->(lid*pattern)list->closed_flag->patternval array:?loc:loc ->?attrs:attrs->patternlist->patternvalor_:?loc:loc->?attrs:attrs->pattern->pattern ->patternvalconstraint_:?loc:loc-> ?attrs:attrs->pattern->core_type->patternvaltype_:?loc:loc->?attrs:attrs->lid->patternval lazy_:?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 ->expressionvaltuple:?loc:loc->?attrs:attrs->expressionlist->expressionvalconstruct:?loc:loc->?attrs:attrs->lid->expressionoption-> expressionvalvariant:?loc:loc->?attrs:attrs->label->expressionoption-> expressionvalrecord:?loc:loc->?attrs:attrs->(lid*expression)list->expression option->expressionvalfield:?loc:loc->?attrs:attrs->expression->lid->expressionvalsetfield:?loc:loc->?attrs:attrs->expression->lid->expression->expressionvalarray:?loc:loc->?attrs:attrs->expressionlist->expressionvalifthenelse:?loc:loc->?attrs:attrs->expression->expression->expressionoption->expressionvalsequence:?loc:loc->?attrs:attrs->expression->expression->expressionvalwhile_:?loc:loc->?attrs:attrs->expression->expression->expressionval for_:?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->expressionval letmodule:?loc:loc->?attrs:attrs->str_opt->module_expr->expression->expressionvalletexception:?loc:loc->?attrs:attrs->extension_constructor ->expression->expressionval assert_:?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->?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_constructorvaldecl:?loc:loc->?attrs:attrs->?docs:docs->?info:info ->?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:sigvalmk:?loc:loc->signature_item_desc->signature_itemvalvalue:?loc:loc->value_description->signature_itemvaltype_:?loc:loc->rec_flag->type_declarationlist->signature_itemvaltype_subst:?loc:loc->type_declaration list->signature_itemvaltype_extension:?loc:loc->type_extension->signature_itemvalexception_:?loc:loc->type_exception->signature_itemvalmodule_:?loc:loc->module_declaration->signature_itemvalmod_subst:?loc:loc->module_substitution->signature_itemvalrec_module:?loc:loc->module_declarationlist->signature_itemvalmodtype:?loc:loc->module_type_declaration->signature_itemvalopen_:?loc:loc->open_description->signature_itemvalinclude_:?loc:loc->include_description->signature_itemvalclass_:?loc:loc->class_descriptionlist->signature_itemvalclass_type:?loc:loc->class_type_declarationlist->signature_itemvalextension:?loc:loc->?attrs:attrs->extension->signature_itemvalattribute:?loc:loc->attribute ->signature_itemval text:text->signature_itemlistend(** Structure items *)moduleStr:sigvalmk:?loc:loc-> structure_item_desc->structure_itemvaleval:?loc:loc->?attrs:attributes->expression->structure_itemvalvalue:?loc:loc->rec_flag->value_bindinglist->structure_itemvalprimitive:?loc:loc->value_description ->structure_itemvaltype_:?loc:loc->rec_flag->type_declarationlist->structure_itemvaltype_extension:?loc:loc->type_extension->structure_itemvalexception_:?loc:loc->type_exception->structure_itemvalmodule_:?loc:loc->module_binding->structure_itemvalrec_module:?loc:loc->module_bindinglist->structure_itemvalmodtype:?loc:loc->module_type_declaration->structure_itemvalopen_:?loc:loc->open_declaration->structure_itemvalclass_:?loc:loc->class_declarationlist->structure_itemvalclass_type:?loc:loc->class_type_declarationlist->structure_itemvalinclude_:?loc:loc->include_declaration->structure_itemvalextension:?loc:loc->?attrs:attrs->extension->structure_itemvalattribute:?loc:loc->attribute ->structure_itemval text: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 *)module Mtd:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->?typ:module_type->str->module_type_declarationend(** Module bindings *)moduleMb:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->str_opt->module_expr->module_bindingend(** Opens *)moduleOpn:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?override:override_flag->'a->'aopen_infosend(** Includes *)moduleIncl:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->'a->'ainclude_infosend(** Value bindings *)moduleVb:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->pattern->expression->value_bindingend(** {1 Class language} *)(** Class type expressions *)moduleCty:sigvalmk:?loc:loc->?attrs:attrs->class_type_desc->class_typevalattr:class_type ->attribute->class_typevalconstr:?loc:loc->?attrs:attrs->lid->core_typelist ->class_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_fieldvalattr:class_field->attribute->class_fieldvalinherit_:?loc:loc->?attrs:attrs->override_flag->class_expr->stroption->class_fieldvalval_:?loc:loc->?attrs:attrs->str->mutable_flag->class_field_kind->class_fieldvalmethod_:?loc:loc->?attrs:attrs->str->private_flag->class_field_kind->class_fieldvalconstraint_:?loc:loc->?attrs:attrs->core_type->core_type ->class_fieldvalinitializer_:?loc:loc->?attrs:attrs->expression->class_fieldvalextension:?loc:loc->?attrs:attrs->extension->class_fieldvalattribute:?loc:loc->attribute->class_fieldvaltext:text->class_fieldlistvalvirtual_:core_type ->class_field_kindvalconcrete:override_flag->expression->class_field_kindend(** Classes *)moduleCi:sigvalmk:?loc:loc->?attrs:attrs->?docs:docs->?text:text->?virt:virtual_flag->?params:(core_type*(variance*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_fieldval tag:?loc:loc->?attrs:attrs->labelwith_loc->core_type->object_fieldvalinherit_:?loc:loc->core_type->object_fieldendend=structopenAsttypesopenParsetreeopenDocstringstype'awith_loc='aLocation.loctypeloc=Location.ttypelid=Longident.twith_loctypestr=stringwith_loctypestr_opt=stringoptionwith_loctypeattrs=attribute listletdefault_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)letint32 ?(suffix='l')i=integer~suffix(Int32.to_stringi)letint64 ?(suffix='L')i=integer~suffix (Int64.to_stringi)letnativeint ?(suffix='n')i=integer~suffix(Nativeint.to_stringi)letfloat?suffixf=Pconst_float(f,suffix)letcharc=Pconst_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?attrs abc=mk?loc?attrs(Ptyp_arrow (a,b,c))lettuple?loc?attrsa=mk?loc ?attrs (Ptyp_tuplea)letconstr?loc?attrsab=mk?loc?attrs (Ptyp_constr (a,b))letobject_?loc?attrsab=mk?loc?attrs(Ptyp_object(a,b))letclass_?loc?attrsab=mk?loc?attrs (Ptyp_class(a,b))letalias?loc?attrsab=mk?loc?attrs(Ptyp_alias(a,b))letvariant?loc?attrsabc=mk?loc?attrs(Ptyp_variant(a,b,c))let poly?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_field row_field_list,flag,lbl_lst_option)|Ptyp_poly(string_lst,core_type)->List.iter (funv->check_variable var_names t.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}letattrda={dwithppat_attributes=d.ppat_attributes@[a]}letany?loc?attrs()=mk?loc?attrsPpat_anyletvar?loc?attrsa=mk?loc?attrs(Ppat_vara)letalias?loc?attrs ab=mk?loc?attrs(Ppat_alias(a,b))letconstant?loc?attrsa=mk?loc ?attrs (Ppat_constanta)letinterval?loc?attrsab=mk?loc ?attrs (Ppat_interval(a,b))lettuple ?loc?attrsa=mk?loc ?attrs (Ppat_tuplea)letconstruct?loc?attrs ab=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))lettype_?loc?attrsa=mk?loc?attrs(Ppat_typea)letlazy_?loc?attrsa=mk?loc?attrs(Ppat_lazya)letunpack?loc?attrsa=mk?loc?attrs(Ppat_unpacka)letopen_?loc?attrsab=mk?loc?attrs (Ppat_open (a,b))letexception_?loc?attrsa=mk?loc?attrs (Ppat_exceptiona)letextension?loc ?attrsa=mk?loc ?attrs (Ppat_extensiona)endmoduleExp =structletmk?(loc =!default_loc)?(attrs=[])d={pexp_desc=d;pexp_loc=loc;pexp_loc_stack=[];pexp_attributes=attrs}letattrda={dwithpexp_attributes=d.pexp_attributes@[a]}letident?loc?attrsa=mk?loc?attrs(Pexp_identa)letconstant?loc?attrs a=mk?loc?attrs (Pexp_constant a)letlet_?loc?attrsabc=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 ?attrs ab=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_tuple a)letconstruct?loc?attrs ab=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))letsequence?loc?attrsab=mk?loc?attrs(Pexp_sequence(a,b))letwhile_ ?loc?attrsab=mk?loc?attrs(Pexp_while(a,b))letfor_?loc?attrsabcde=mk?loc?attrs(Pexp_for(a,b,c,d,e))letconstraint_?loc?attrsab=mk ?loc?attrs(Pexp_constraint(a,b))letcoerce?loc?attrsabc=mk?loc?attrs(Pexp_coerce(a,b,c))letsend?loc?attrsab=mk?loc?attrs(Pexp_send(a,b))letnew_?loc?attrsa=mk?loc?attrs (Pexp_new a)letsetinstvar?loc ?attrs ab=mk?loc?attrs(Pexp_setinstvar(a,b))letoverride?loc?attrsa=mk ?loc?attrs(Pexp_overridea)letletmodule?loc?attrsabc=mk?loc?attrs(Pexp_letmodule(a,b,c))letletexception?loc?attrsab=mk?loc?attrs(Pexp_letexception(a,b))let assert_?loc?attrsa=mk?loc?attrs(Pexp_asserta)letlazy_?loc?attrsa=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?attrs ab=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?attrsa=mk?loc?attrs(Pexp_extensiona)letunreachable ?loc?attrs()=mk?loc?attrsPexp_unreachableletcaselhs?guardrhs={pc_lhs=lhs;pc_guard=guard;pc_rhs=rhs;}letbinding_opoppatexploc={pbop_op=op;pbop_pat=pat;pbop_exp=exp;pbop_loc=loc;}endmoduleMty=structletmk?(loc=!default_loc)?(attrs=[])d={pmty_desc=d;pmty_loc=loc;pmty_attributes=attrs}letattrda={dwithpmty_attributes=d.pmty_attributes@[a]}letident?loc?attrsa=mk?loc?attrs(Pmty_identa)letalias?loc?attrsa=mk?loc?attrs(Pmty_aliasa)letsignature?loc?attrs a=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)endmoduleMod =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?attrs x=mk?loc?attrs (Pmod_structurex)letfunctor_?loc?attrsargbody=mk?loc?attrs(Pmod_functor(arg,body))letapply?loc?attrsm1m2=mk?loc ?attrs(Pmod_apply(m1,m2))letconstraint_ ?loc?attrs mmty=mk?loc?attrs(Pmod_constraint(m,mty))letunpack?loc?attrs e=mk ?loc?attrs(Pmod_unpacke)letextension?loc?attrsa=mk?loc?attrs(Pmod_extensiona)endmoduleSig =structletmk?(loc =!default_loc)d={psig_desc=d;psig_loc=loc}letvalue?loca=mk?loc(Psig_valuea)lettype_?locrec_flaga=mk?loc(Psig_type(rec_flag,a))lettype_subst?loca=mk?loc(Psig_typesubsta)lettype_extension?loca=mk?loc(Psig_typexta)letexception_?loca=mk?loc(Psig_exception a)letmodule_?loca=mk?loc(Psig_module a)letmod_subst?loca=mk?loc (Psig_modsubst a)letrec_module?loca=mk?loc(Psig_recmodulea)letmodtype?loca=mk?loc(Psig_modtype a)letopen_?loca=mk?loc(Psig_opena)let include_?loca=mk?loc(Psig_includea)letclass_?loca=mk?loc(Psig_classa)letclass_type?loca=mk?loc (Psig_class_type a)letextension?loc?(attrs =[])a=mk?loc (Psig_extension(a,attrs))letattribute?loca=mk?loc(Psig_attribute a)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}leteval?loc?(attrs=[])a=mk?loc(Pstr_eval(a,attrs))letvalue?loc ab=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_exception a)letmodule_?loca=mk?loc(Pstr_module a)letrec_module?loca=mk?loc(Pstr_recmodule a)letmodtype?loca=mk?loc(Pstr_modtype a)letopen_?loca=mk?loc(Pstr_opena)let class_?loca=mk?loc(Pstr_classa)letclass_type?loca=mk?loc (Pstr_class_type a)letinclude_?loca=mk?loc(Pstr_includea)letextension?loc?(attrs=[])a=mk?loc(Pstr_extension(a,attrs))letattribute?loca=mk?loc(Pstr_attribute a)lettexttxt=letf_txt=List.filter(funds->docstring_bodyds<>"")txtinList.map(funds->attribute~loc:(docstring_locds)(text_attrds))f_txtendmoduleCl=structletmk?(loc=!default_loc)?(attrs=[])d={pcl_desc=d;pcl_loc=loc;pcl_attributes =attrs;}letattrda={dwithpcl_attributes=d.pcl_attributes@[a]}letconstr?loc?attrsab=mk?loc?attrs(Pcl_constr(a,b))letstructure ?loc?attrsa=mk?loc?attrs (Pcl_structurea)letfun_?loc?attrsabcd=mk?loc ?attrs (Pcl_fun(a,b,c,d))let apply?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 ?attrs ab=mk?loc?attrs(Pcl_open(a,b))endmoduleCty=structletmk?(loc=!default_loc)?(attrs=[])d={pcty_desc=d;pcty_loc=loc;pcty_attributes =attrs;}letattrda={dwithpcty_attributes =d.pcty_attributes@[a]}letconstr?loc?attrsab=mk?loc?attrs(Pcty_constr(a,b))letsignature?loc?attrsa=mk?loc?attrs(Pcty_signaturea)letarrow?loc?attrs abc=mk?loc ?attrs (Pcty_arrow(a,b,c))letextension?loc?attrsa=mk?loc?attrs(Pcty_extensiona)letopen_?loc?attrs ab=mk?loc?attrs(Pcty_open(a,b))endmoduleCtf=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_inherit a)letval_?loc?attrsabcd=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))letextension?loc?attrsa=mk?loc?attrs(Pctf_extensiona)letattribute ?loc a=mk?loc(Pctf_attributea)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))letconstraint_?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_attrsdocs attrs;pval_loc=loc;pval_prim=prim;}endmodule Md =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=structletmk?(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;}endmodule Mb=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;}endmodule Incl=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=structletmk?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(text=[])?(virt=Concrete)?(params=[])nameexpr ={pci_virt=virt;pci_params =params;pci_name =name;pci_expr=expr;pci_attributes=add_text_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)?(args=Pcstr_tuple[])?resname={pcd_name =name;pcd_args =args;pcd_res=res;pcd_loc=loc;pcd_attributes=add_info_attrs infoattrs;}letfield?(loc=!default_loc)?(attrs=[])?(info=empty_info)?(mut=Immutable)name typ={pld_name =name;pld_mutable=mut;pld_type =typ;pld_loc=loc;pld_attributes=add_info_attrsinfoattrs;}end(** Type extensions *)moduleTe=structlet mk?(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;}let mk_exception?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)constructor={ptyexn_constructor=constructor;ptyexn_loc=loc;ptyexn_attributes=add_docs_attrsdocsattrs;}let constructor?(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)?(args=Pcstr_tuple[])?resname={pext_name =name;pext_kind=Pext_decl(args,res);pext_loc=loc;pext_attributes=add_docs_attrsdocs(add_info_attrsinfoattrs);}letrebind?(loc=!default_loc)?(attrs=[])?(docs=empty_docs)?(info=empty_info)namelid={pext_name=name;pext_kind=Pext_rebindlid;pext_loc=loc;pext_attributes =add_docs_attrsdocs(add_info_attrsinfoattrs);}endmoduleCsig=structletmkselffields={pcsig_self=self;pcsig_fields=fields;}endmoduleCstr=structlet mkselffields={pcstr_self=self;pcstr_fields=fields;}end(** Row fields *)moduleRf=structletmk?(loc=!default_loc)?(attrs=[])desc={prf_desc=desc;prf_loc=loc;prf_attributes=attrs;}lettag?loc?attrslabelconsttys=mk?loc?attrs(Rtag(label,const,tys))letinherit_?locty=mk?loc(Rinheritty)end(** Object fields *)moduleOf=structletmk?(loc=!default_loc)?(attrs=[])desc={pof_desc=desc;pof_loc =loc;pof_attributes=attrs;}lettag?loc?attrslabelty=mk?loc?attrs(Otag(label,ty))letinherit_ ?locty=mk?loc(Oinheritty)endendmodule Ast_mapper:sigopenParsetree(** {1 A generic Parsetree mapper} *)typemapper(*IF_CURRENT = Ast_mapper.mapper *)={attribute:mapper->attribute->attribute;attributes:mapper->attributelist->attributelist;binding_op:mapper->binding_op ->binding_op;case:mapper ->case->case;cases:mapper->caselist->caselist;class_declaration:mapper->class_declaration->class_declaration;class_description:mapper->class_description->class_description;class_expr:mapper->class_expr->class_expr;class_field:mapper->class_field->class_field;class_signature:mapper->class_signature->class_signature;class_structure:mapper->class_structure->class_structure;class_type:mapper->class_type->class_type;class_type_declaration:mapper->class_type_declaration->class_type_declaration;class_type_field:mapper->class_type_field->class_type_field;constant:mapper->constant->constant;constructor_declaration:mapper->constructor_declaration->constructor_declaration;expr:mapper->expression->expression;extension:mapper->extension->extension;extension_constructor:mapper->extension_constructor->extension_constructor;include_declaration:mapper->include_declaration->include_declaration;include_description:mapper->include_description->include_description;label_declaration:mapper->label_declaration->label_declaration;location:mapper->Location.t->Location.t;module_binding:mapper->module_binding->module_binding;module_declaration:mapper ->module_declaration->module_declaration;module_substitution:mapper->module_substitution->module_substitution;module_expr:mapper->module_expr->module_expr;module_type:mapper->module_type->module_type;module_type_declaration:mapper->module_type_declaration->module_type_declaration;open_declaration:mapper->open_declaration->open_declaration;open_description:mapper->open_description->open_description;pat:mapper->pattern->pattern;payload:mapper->payload->payload;signature:mapper->signature->signature;signature_item:mapper->signature_item->signature_item;structure:mapper->structure->structure;structure_item:mapper->structure_item->structure_item;typ:mapper->core_type->core_type;type_declaration:mapper->type_declaration->type_declaration;type_extension:mapper ->type_extension->type_extension;type_exception:mapper->type_exception->type_exception;type_kind:mapper->type_kind->type_kind;value_binding:mapper->value_binding->value_binding;value_description:mapper->value_description->value_description;with_constraint:mapper->with_constraint->with_constraint;}(** A mapper record implements one "method" per syntactic category,
using an open recursion style: each method takes as its first
argument the mapper to be applied to children in the syntax
tree. *)valdefault_mapper:mapper(** A default mapper, which implements a "deep identity" mapping. *)(** {1 Apply mappers to compilation units} *)valtool_name:unit->string(** Can be used within a ppx preprocessor to know which tool is
calling it ["ocamlc"], ["ocamlopt"], ["ocamldoc"], ["ocamldep"],
["ocaml"], ... Some global variables that reflect command-line
options are automatically synchronized between the calling tool
and the ppx preprocessor: {!Clflags.include_dirs},
{!Load_path}, {!Clflags.open_modules}, {!Clflags.for_package},
{!Clflags.debug}. *)valapply:source:string->target:string->mapper->unit(** Apply a mapper (parametrized by the unit name) to a dumped
parsetree found in the [source] file and put the result in the
[target] file. The [structure] or [signature] field of the mapper
is applied to the implementation or interface. *)valrun_main:(stringlist->mapper)->unit(** Entry point to call to implement a standalone -ppx rewriter from a
mapper, parametrized by the command line arguments. The current
unit name can be obtained from {!Location.input_name}. This
function implements proper error reporting for uncaught
exceptions. *)(** {1 Registration API} *)valregister_function:(string->(stringlist->mapper)->unit)refvalregister:string->(stringlist->mapper)->unit(** Apply the [register_function]. The default behavior is to run the
mapper immediately, taking arguments from the process command
line. This is to support a scenario where a mapper is linked as a
stand-alone executable.
It is possible to overwrite the [register_function] to define
"-ppx drivers", which combine several mappers in a single process.
Typically, a driver starts by defining [register_function] to a
custom implementation, then lets ppx rewriters (linked statically
or dynamically) register themselves, and then run all or some of
them. It is also possible to have -ppx drivers apply rewriters to
only specific parts of an AST.
The first argument to [register] is a symbolic name to be used by
the ppx driver. *)(** {1 Convenience functions to write mappers} *)valmap_opt:('a->'b)->'aoption->'boptionvalextension_of_error: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=structopenParsetreeopenAst_helperopenLocationmoduleString=Misc.Stdlib.Stringtypemapper(*IF_CURRENT = Ast_mapper.mapper *)={attribute:mapper->attribute->attribute;attributes:mapper->attributelist->attributelist;binding_op:mapper->binding_op->binding_op;case:mapper->case->case;cases:mapper->caselist->caselist;class_declaration:mapper->class_declaration->class_declaration;class_description:mapper->class_description->class_description;class_expr:mapper ->class_expr->class_expr;class_field:mapper->class_field->class_field;class_signature:mapper->class_signature ->class_signature;class_structure:mapper ->class_structure->class_structure;class_type:mapper->class_type->class_type;class_type_declaration:mapper->class_type_declaration->class_type_declaration;class_type_field:mapper->class_type_field->class_type_field;constant:mapper->constant->constant;constructor_declaration:mapper->constructor_declaration->constructor_declaration;expr:mapper->expression->expression;extension:mapper->extension->extension;extension_constructor:mapper->extension_constructor->extension_constructor;include_declaration:mapper->include_declaration->include_declaration;include_description:mapper->include_description->include_description;label_declaration:mapper->label_declaration->label_declaration;location:mapper->Location.t->Location.t;module_binding:mapper->module_binding ->module_binding;module_declaration:mapper->module_declaration->module_declaration;module_substitution:mapper->module_substitution->module_substitution;module_expr:mapper->module_expr->module_expr;module_type:mapper->module_type->module_type;module_type_declaration:mapper ->module_type_declaration->module_type_declaration;open_declaration:mapper->open_declaration->open_declaration;open_description:mapper->open_description->open_description;pat:mapper->pattern->pattern;payload:mapper->payload->payload;signature:mapper->signature->signature;signature_item:mapper->signature_item->signature_item;structure:mapper->structure ->structure;structure_item:mapper->structure_item->structure_item;typ:mapper->core_type->core_type;type_declaration:mapper->type_declaration ->type_declaration;type_extension:mapper->type_extension->type_extension;type_exception:mapper->type_exception->type_exception;type_kind:mapper->type_kind ->type_kind;value_binding:mapper->value_binding->value_binding;value_description:mapper->value_description->value_description;with_constraint:mapper->with_constraint->with_constraint;}letmap_fstf(x,y)=(fx,y)letmap_sndf(x,y)=(x,fy)letmap_tuplef1f2(x,y)=(f1x,f2y)letmap_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.typsubt)|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(ctl,cto)->Pext_decl(map_constructor_arguments subctl,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_locinletattrs=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_typesubst(lid,d)->Pwith_typesubst(map_locsublid,sub.type_declarationsubd)|Pwith_modsubst(s,lid)->Pwith_modsubst(map_locsubs,map_locsublid)letmap_signature_itemsub{psig_desc=desc;psig_loc=loc}=letopenSiginletloc=sub.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_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~attrsc1c2|Ppat_tuplepl->tuple~loc ~attrs(List.map (sub.patsub)pl)|Ppat_construct(l,p)->construct ~loc~attrs(map_locsubl)(map_opt(sub.patsub)p)|Ppat_variant(l,p)->variant~loc~attrsl(map_opt(sub.patsub)p)|Ppat_record(lpl,cf)->record~loc ~attrs(List.map(map_tuple(map_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.attributesthispopen_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.attributesthispopen_attributes));include_description=(funthis{pincl_mod;pincl_attributes;pincl_loc}->Incl.mk(this.module_typethispincl_mod)~loc:(this.locationthis pincl_loc)~attrs:(this.attributesthispincl_attributes));include_declaration=(funthis{pincl_mod;pincl_attributes;pincl_loc}->Incl.mk(this.module_exprthispincl_mod)~loc:(this.locationthis pincl_loc)~attrs:(this.attributesthispincl_attributes));value_binding=(funthis{pvb_pat;pvb_expr;pvb_attributes;pvb_loc}->Vb.mk(this.patthispvb_pat)(this.exprthispvb_expr)~loc:(this.locationthispvb_loc)~attrs:(this.attributesthispvb_attributes));constructor_declaration=(funthis{pcd_name;pcd_args;pcd_res;pcd_loc;pcd_attributes}->Type.constructor(map_loc thispcd_name)~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.signaturethisx)|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_stringpayload|"include_dirs"->Clflags.include_dirs:=get_listget_stringpayload|"load_path"->Migrate_parsetree_compiler_functions.load_path_init(get_listget_stringpayload)|"open_modules"->Clflags.open_modules :=get_listget_stringpayload|"for_package"->Clflags.for_package :=get_option get_stringpayload|"debug"->Clflags.debug:=get_bool payload|"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_pair get_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)inletrewritetransform=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_main mapper=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_main f)let registernamef=!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_sumof(string*out_typelist*out_typeoption)list|Otyp_tupleofout_typelist|Otyp_varofbool*string|Otyp_variantofbool *out_variant*bool*(string list)option|Otyp_polyofstring list*out_type|Otyp_module ofout_ident *stringlist*out_typelist|Otyp_attributeofout_type*out_attributeandout_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_arrowofstring*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_typextofout_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:(string*out_typelist*out_type option)list;otyext_private:Asttypes.private_flag}andout_val_decl(*IF_CURRENT = Outcometree.out_val_decl *)={oval_name:string;oval_type:out_type;oval_prims:stringlist;oval_attributes:out_attributelist}andout_rec_status(*IF_CURRENT = Outcometree.out_rec_status *) =|Orec_not|Orec_first|Orec_nextandout_ext_status(*IF_CURRENT = Outcometree.out_ext_status *) =|Oext_first|Oext_next|Oext_exceptiontypeout_phrase(*IF_CURRENT = Outcometree.out_phrase *)=|Ophr_evalofout_value*out_type|Ophr_signatureof(out_sig_item*out_valueoption)list|Ophr_exceptionof(exn*out_value)endmodule Config =structletast_impl_magic_number="Caml1999M029"letast_intf_magic_number="Caml1999N029"endletmap_signaturemapper=mapper.Ast_mapper.signaturemapperlet map_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)}