123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943(**************************************************************************)(* *)(* OCaml Migrate Parsetree *)(* *)(* Frédéric Bour *)(* 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 2017 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. *)(* *)(**************************************************************************)(* Ast ported on Mon Oct 2 11:25:57 CEST 2017
OCaml trunk was:
commit 65940a2c6be43c42f75c6c6b255974f7e6de03ca (HEAD -> 4.06, origin/4.06)
Author: Christophe Raffalli <christophe@raffalli.eu>
Date: Sun Oct 1 18:27:07 2017 +0200
fixed position of last optional last semicolumn in sequence (#1387)
*)moduleAsttypes=struct(** Auxiliary AST types used by parsetree and typedtree. *)typeconstant(*IF_CURRENT = Asttypes.constant *)=Const_intofint|Const_charofchar|Const_stringofstring*stringoption|Const_float ofstring|Const_int32ofint32|Const_int64ofint64|Const_nativeintof nativeinttyperec_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|InvariantendmoduleParsetree=struct(** Abstract syntax tree produced by parsing *)openAsttypestypeconstant(*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_string ofstring*stringoption(* "constant"
{delim|other constant|delim}
*)|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.
*)(** {2 Extension points} *)typeattribute=stringloc*payload(* [@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 *)|PPatof pattern*expressionoption(* ? P or ? P when E *)(** {2 Core language} *)(* Type expressions *)andcore_type(*IF_CURRENT = Parsetree.core_type *)={ptyp_desc:core_type_desc;ptyp_loc:Location.t;ptyp_attributes:attributes;(* ... [@id1] [@id2] *)}andcore_type_desc(*IF_CURRENT = Parsetree.core_type_desc *)=|Ptyp_any(* _ *)|Ptyp_varofstring(* 'a *)|Ptyp_arrowofarg_label*core_type*core_type(* T1 -> T2 Simple
~l:T1 -> T2 Labelled
?l:T1 -> T2 Optional
*)|Ptyp_tupleofcore_typelist(* T1 * ... * Tn
Invariant: n >= 2
*)|Ptyp_constrofLongident.tloc*core_typelist(* tconstr
T tconstr
(T1, ..., Tn) tconstr
*)|Ptyp_objectofobject_fieldlist*closed_flag(* < l1:T1; ...; ln:Tn > (flag = Closed)
< l1:T1; ...; ln:Tn; .. > (flag = Open)
*)|Ptyp_classofLongident.tloc*core_typelist(* #tconstr
T #tconstr
(T1, ..., Tn) #tconstr
*)|Ptyp_aliasofcore_type*string(* T as 'a *)|Ptyp_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 *)=|Rtagoflabelloc*attributes*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 2nd 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)
- TODO: switch to a record representation, and keep location
*)|Rinheritofcore_type(* [ T ] *)andobject_field(*IF_CURRENT = Parsetree.object_field *)=|Otagoflabelloc*attributes*core_type|Oinherit ofcore_type(* Patterns *)and pattern(*IF_CURRENT = Parsetree.pattern *)={ppat_desc:pattern_desc;ppat_loc:Location.t;ppat_attributes:attributes;(* ... [@id1] [@id2] *)}andpattern_desc(*IF_CURRENT = Parsetree.pattern_desc *)=|Ppat_any(* _ *)|Ppat_varofstringloc(* x *)|Ppat_aliasofpattern*stringloc(* P as 'a *)|Ppat_constantofconstant(* 1, 'a', "true", 1.0, 1l, 1L, 1n *)|Ppat_intervalofconstant*constant(* 'a'..'z'
Other forms of interval are recognized by the parser
but rejected by the type-checker. *)|Ppat_tupleofpatternlist(* (P1, ..., Pn)
Invariant: n >= 2
*)|Ppat_constructofLongident.tloc*patternoption(* C None
C P Some P
C (P1, ..., Pn) Some (Ppat_tuple [P1; ...; Pn])
*)|Ppat_variantoflabel*patternoption(* `A (None)
`A P (Some P)
*)|Ppat_recordof(Longident.tloc*pattern)list*closed_flag(* { l1=P1; ...; ln=Pn } (flag = Closed)
{ l1=P1; ...; ln=Pn; _} (flag = Open)
Invariant: n > 0
*)|Ppat_arrayofpatternlist(* [| P1; ...; Pn |] *)|Ppat_orofpattern*pattern(* P1 | P2 *)|Ppat_constraintofpattern*core_type(* (P : T) *)|Ppat_typeofLongident.tloc(* #tconst *)|Ppat_lazyofpattern(* lazy P *)|Ppat_unpackofstringloc(* (module P)
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_attributes:attributes;(* ... [@id1] [@id2] *)}andexpression_desc(*IF_CURRENT = Parsetree.expression_desc *)=|Pexp_identofLongident.tloc(* x
M.x
*)|Pexp_constantofconstant(* 1, 'a', "true", 1.0, 1l, 1L, 1n *)|Pexp_letofrec_flag*value_bindinglist*expression(* let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive)
let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive)
*)|Pexp_functionofcaselist(* function P1 -> E1 | ... | Pn -> En *)|Pexp_funofarg_label*expressionoption*pattern*expression(* fun P -> E1 (Simple, None)
fun ~l:P -> E1 (Labelled l, None)
fun ?l:P -> E1 (Optional l, None)
fun ?l:(P = E0) -> E1 (Optional l, Some E0)
Notes:
- If E0 is provided, only Optional is allowed.
- "fun P1 P2 .. Pn -> E1" is represented as nested Pexp_fun.
- "let f P = E" is represented using Pexp_fun.
*)|Pexp_applyofexpression*(arg_label*expression)list(* E0 ~l1:E1 ... ~ln:En
li can be empty (non labeled argument) or start with '?'
(optional argument).
Invariant: n > 0
*)|Pexp_matchofexpression*caselist(* match E0 with P1 -> E1 | ... | Pn -> En *)|Pexp_tryofexpression*caselist(* try E0 with P1 -> E1 | ... | Pn -> En *)|Pexp_tupleofexpressionlist(* (E1, ..., En)
Invariant: n >= 2
*)|Pexp_constructofLongident.tloc*expressionoption(* C None
C E Some E
C (E1, ..., En) Some (Pexp_tuple[E1;...;En])
*)|Pexp_variantoflabel*expressionoption(* `A (None)
`A E (Some E)
*)|Pexp_recordof(Longident.tloc*expression)list*expressionoption(* { l1=P1; ...; ln=Pn } (None)
{ E0 with l1=P1; ...; ln=Pn } (Some E0)
Invariant: n > 0
*)|Pexp_fieldofexpression*Longident.tloc(* E.l *)|Pexp_setfieldofexpression*Longident.tloc*expression(* E1.l <- E2 *)|Pexp_arrayofexpressionlist(* [| E1; ...; En |] *)|Pexp_ifthenelseofexpression*expression*expression option(* if E1 then E2 else E3 *)|Pexp_sequenceofexpression*expression(* E1; E2 *)|Pexp_whileofexpression*expression(* while E1 do E2 done *)|Pexp_forofpattern*expression*expression*direction_flag *expression(* for i = E1 to E2 do E3 done (flag = Upto)
for i = E1 downto E2 do E3 done (flag = Downto)
*)|Pexp_constraintofexpression*core_type(* (E : T) *)|Pexp_coerceofexpression*core_typeoption*core_type(* (E :> T) (None, T)
(E : T0 :> T) (Some T0, T)
*)|Pexp_sendofexpression*labelloc(* E # m *)|Pexp_newofLongident.tloc(* new M.c *)|Pexp_setinstvaroflabelloc*expression(* x <- 2 *)|Pexp_overrideof(labelloc*expression)list(* {< x1 = E1; ...; Xn = En >} *)|Pexp_letmoduleofstringloc*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_openofoverride_flag*Longident.tloc*expression(* M.(E)
let open M in E
let! open M in E *)|Pexp_extensionofextension(* [%id] *)|Pexp_unreachable(* . *)and case(*IF_CURRENT = Parsetree.case *)=(* (P -> E) or (P when E0 -> E) *){pc_lhs:pattern;pc_guard:expression option;pc_rhs:expression;}(* Value descriptions *)andvalue_description(*IF_CURRENT = Parsetree.value_description *)={pval_name:stringloc;pval_type:core_type;pval_prim:stringlist;pval_attributes:attributes;(* ... [@@id1] [@@id2] *)pval_loc:Location.t;}(*
val x: T (prim = [])
external x: T = "s1" ... "sn" (prim = ["s1";..."sn"])
*)(* Type declarations *)andtype_declaration(*IF_CURRENT = Parsetree.type_declaration *)={ptype_name:stringloc;ptype_params:(core_type*variance)list;(* ('a1,...'an) t; None represents _*)ptype_cstrs:(core_type*core_type*Location.t)list;(* ... constraint T1=T1' ... constraint Tn=Tn' *)ptype_kind:type_kind;ptype_private:private_flag;(* = private ... *)ptype_manifest:core_typeoption;(* = T *)ptype_attributes:attributes;(* ... [@@id1] [@@id2] *)ptype_loc:Location.t;}(*
type t (abstract, no manifest)
type t = T0 (abstract, manifest=T0)
type t = C of T | ... (variant, no manifest)
type t = T0 = C of T | ... (variant, manifest=T0)
type t = {l: T; ...} (record, no manifest)
type t = T0 = {l : T; ...} (record, manifest=T0)
type t = .. (open, no manifest)
*)andtype_kind(*IF_CURRENT = Parsetree.type_kind *)=|Ptype_abstract|Ptype_variantofconstructor_declarationlist(* Invariant: non-empty list *)|Ptype_recordoflabel_declarationlist(* Invariant: non-empty list *)|Ptype_openandlabel_declaration(*IF_CURRENT = Parsetree.label_declaration *)={pld_name:stringloc;pld_mutable:mutable_flag;pld_type:core_type;pld_loc:Location.t;pld_attributes:attributes;(* l : T [@id1] [@id2] *)}(* { ...; l: T; ... } (mutable=Immutable)
{ ...; mutable l: T; ... } (mutable=Mutable)
Note: T can be a Ptyp_poly.
*)andconstructor_declaration(*IF_CURRENT = Parsetree.constructor_declaration *)={pcd_name:stringloc;pcd_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)list;ptyext_constructors:extension_constructorlist;ptyext_private:private_flag;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] *)}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
*)(** {2 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_openofoverride_flag*Longident.tloc*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)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_openofoverride_flag*Longident.tloc*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_methodof(labelloc*private_flag*class_field_kind)(* method x = E (E can be a Pexp_poly)
method virtual x: T (T can be a Ptyp_poly)
*)|Pcf_constraintof(core_type*core_type)(* constraint T1 = T2 *)|Pcf_initializerofexpression(* initializer E *)|Pcf_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(** {2 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_functorofstringloc*module_typeoption *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) *)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_typextoftype_extension(* type t1 += ... *)|Psig_exceptionofextension_constructor(* exception C of T *)|Psig_moduleofmodule_declaration(* module X : MT *)|Psig_recmoduleofmodule_declarationlist(* module rec X1 : MT1 and ... and Xn : MTn *)|Psig_modtypeofmodule_type_declaration(* module type S = MT
module type S *)|Psig_openofopen_description(* open X *)|Psig_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:stringloc;pmd_type:module_type;pmd_attributes:attributes;(* ... [@@id1] [@@id2] *)pmd_loc:Location.t;}(* S : MT *)andmodule_type_declaration(*IF_CURRENT = Parsetree.module_type_declaration *)={pmtd_name:stringloc;pmtd_type:module_typeoption;pmtd_attributes:attributes;(* ... [@@id1] [@@id2] *)pmtd_loc:Location.t;}(* S = MT
S (abstract module type declaration, pmtd_type = None)
*)andopen_description(*IF_CURRENT = Parsetree.open_description *)={popen_lid:Longident.tloc;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
*)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 *)and include_declaration=module_exprinclude_infos(* include ME *)and with_constraint(*IF_CURRENT = Parsetree.with_constraint *)=|Pwith_typeofLongident.tloc*type_declaration(* with type X.t = ...
Note: the last component of the longident must match
the name of the type_declaration. *)|Pwith_moduleofLongident.tloc*Longident.tloc(* with module X.Y = Z *)|Pwith_typesubstofLongident.tloc*type_declaration(* with type X.t := ..., same format as [Pwith_type] *)|Pwith_modsubstofLongident.tloc*Longident.tloc(* with module X.Y := Z *)(* Value expressions for the module language *)andmodule_expr(*IF_CURRENT = Parsetree.module_expr *)={pmod_desc:module_expr_desc;pmod_loc:Location.t;pmod_attributes:attributes;(* ... [@id1] [@id2] *)}andmodule_expr_desc(*IF_CURRENT = Parsetree.module_expr_desc *)=|Pmod_identofLongident.tloc(* X *)|Pmod_structureofstructure(* struct ... end *)|Pmod_functorofstringloc*module_typeoption *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_bindinglist(* let P1 = E1 and ... and Pn = EN (flag = Nonrecursive)
let rec P1 = E1 and ... and Pn = EN (flag = Recursive)
*)|Pstr_primitiveofvalue_description(* val x: T
external x: T = "s1" ... "sn" *)|Pstr_typeofrec_flag*type_declarationlist(* type t1 = ... and ... and tn = ... *)|Pstr_typextoftype_extension(* type t1 += ... *)|Pstr_exceptionofextension_constructor(* 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_description(* 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:stringloc;pmb_expr:module_expr;pmb_attributes:attributes;pmb_loc:Location.t;}(* X = ME *)(** {2 Toplevel} *)(* Toplevel phrases *)typetoplevel_phrase(*IF_CURRENT = Parsetree.toplevel_phrase *)=|Ptop_defofstructure|Ptop_dirofstring *directive_argument(* #use, #load ... *)anddirective_argument(*IF_CURRENT = Parsetree.directive_argument *)=|Pdir_none|Pdir_stringofstring|Pdir_intofstring *charoption|Pdir_ident ofLongident.t|Pdir_boolofboolendmoduleConfig=structletast_impl_magic_number="Caml1999M022"letast_intf_magic_number="Caml1999N022"end