module Parsetree:sig
..end
Abstract syntax tree produced by parsing
Warning: this module is unstable and part of compiler-libs.
type
constant =
| |
Pconst_integer of |
(* | Integer constants such as Suffixes | *) |
| |
Pconst_char of |
(* | Character such as | *) |
| |
Pconst_string of |
(* | Constant string such as The location span the content of the string, without the delimiters. | *) |
| |
Pconst_float of |
(* | Float constant such as Suffixes | *) |
typelocation_stack =
Location.t list
type
attribute = {
|
attr_name : |
|
attr_payload : |
|
attr_loc : |
}
Attributes such as [@id ARG]
and [@@id ARG]
.
Metadata containers passed around within the AST. The compiler ignores unknown attributes.
typeextension =
string Asttypes.loc * payload
Extension points such as [%id ARG] and [%%id ARG]
.
Sub-language placeholder -- rejected by the typechecker.
typeattributes =
attribute list
type
payload =
| |
PStr of |
|||
| |
PSig of |
(* |
| *) |
| |
PTyp of |
(* |
| *) |
| |
PPat of |
(* |
| *) |
type
core_type = {
|
ptyp_desc : |
|||
|
ptyp_loc : |
|||
|
ptyp_loc_stack : |
|||
|
ptyp_attributes : |
(* |
| *) |
}
type
core_type_desc =
| |
Ptyp_any |
(* |
| *) |
| |
Ptyp_var of |
(* | A type variable such as | *) |
| |
Ptyp_arrow of |
(* | *) |
|
| |
Ptyp_tuple of |
(* |
Invariant: | *) |
| |
Ptyp_constr of |
(* |
| *) |
| |
Ptyp_object of |
(* | *) |
|
| |
Ptyp_class of |
(* |
| *) |
| |
Ptyp_alias of |
(* |
| *) |
| |
Ptyp_variant of |
(* | *) |
|
| |
Ptyp_poly of |
(* |
Can only appear in the following context:
| *) |
| |
Ptyp_package of |
(* |
| *) |
| |
Ptyp_open of |
(* |
| *) |
| |
Ptyp_extension of |
(* |
| *) |
typepackage_type =
Longident.t Asttypes.loc *
(Longident.t Asttypes.loc * core_type) list
As Parsetree.package_type
typed values:
(S, [])
represents (module S)
,(S, [(t1, T1) ; ... ; (tn, Tn)])
represents (module S with type t1 = T1 and ... and tn = Tn)
.type
row_field = {
|
prf_desc : |
|
prf_loc : |
|
prf_attributes : |
}
type
row_field_desc =
| |
Rtag of |
(* |
| *) |
| |
Rinherit of |
(* |
| *) |
type
object_field = {
|
pof_desc : |
|
pof_loc : |
|
pof_attributes : |
}
type
object_field_desc =
| |
Otag of |
| |
Oinherit of |
type
pattern = {
|
ppat_desc : |
|||
|
ppat_loc : |
|||
|
ppat_loc_stack : |
|||
|
ppat_attributes : |
(* |
| *) |
}
type
pattern_desc =
| |
Ppat_any |
(* | The pattern | *) |
| |
Ppat_var of |
(* | A variable pattern such as | *) |
| |
Ppat_alias of |
(* | An alias pattern such as | *) |
| |
Ppat_constant of |
(* | Patterns such as | *) |
| |
Ppat_interval of |
(* | Patterns such as Other forms of interval are recognized by the parser but rejected by the type-checker. | *) |
| |
Ppat_tuple of |
(* | Patterns Invariant: | *) |
| |
Ppat_construct of |
(* |
| *) |
| |
Ppat_variant of |
(* |
| *) |
| |
Ppat_record of |
(* | *) |
|
| |
Ppat_array of |
(* | Pattern | *) |
| |
Ppat_or of |
(* | Pattern | *) |
| |
Ppat_constraint of |
(* | Pattern | *) |
| |
Ppat_type of |
(* | Pattern | *) |
| |
Ppat_lazy of |
(* | Pattern | *) |
| |
Ppat_unpack of |
(* |
Note: | *) |
| |
Ppat_exception of |
(* | Pattern | *) |
| |
Ppat_extension of |
(* | Pattern | *) |
| |
Ppat_open of |
(* | Pattern | *) |
type
expression = {
|
pexp_desc : |
|||
|
pexp_loc : |
|||
|
pexp_loc_stack : |
|||
|
pexp_attributes : |
(* |
| *) |
}
type
expression_desc =
| |
Pexp_ident of |
(* | Identifiers such as | *) |
| |
Pexp_constant of |
(* | Expressions constant such as | *) |
| |
Pexp_let of |
(* |
| *) |
| |
Pexp_function of |
(* |
A function must have parameters. | *) |
| |
Pexp_apply of |
(* | *) |
|
| |
Pexp_match of |
(* |
| *) |
| |
Pexp_try of |
(* |
| *) |
| |
Pexp_tuple of |
(* | Expressions Invariant: | *) |
| |
Pexp_construct of |
(* |
| *) |
| |
Pexp_variant of |
(* |
| *) |
| |
Pexp_record of |
(* |
Invariant: | *) |
| |
Pexp_field of |
(* |
| *) |
| |
Pexp_setfield of |
(* |
| *) |
| |
Pexp_array of |
(* |
| *) |
| |
Pexp_ifthenelse of |
(* |
| *) |
| |
Pexp_sequence of |
(* |
| *) |
| |
Pexp_while of |
(* |
| *) |
| |
Pexp_for of |
(* | *) |
|
| |
Pexp_constraint of |
(* |
| *) |
| |
Pexp_coerce of |
(* |
| *) |
| |
Pexp_send of |
(* |
| *) |
| |
Pexp_new of |
(* |
| *) |
| |
Pexp_setinstvar of |
(* |
| *) |
| |
Pexp_override of |
(* |
| *) |
| |
Pexp_letmodule of |
(* |
| *) |
| |
Pexp_letexception of |
(* |
| *) |
| |
Pexp_assert of |
(* |
Note: | *) |
| |
Pexp_lazy of |
(* |
| *) |
| |
Pexp_poly of |
(* | Used for method bodies. Can only be used as the expression under
| *) |
| |
Pexp_object of |
(* |
| *) |
| |
Pexp_newtype of |
(* |
| *) |
| |
Pexp_pack of |
(* |
| *) |
| |
Pexp_open of |
(* | -
| *) |
| |
Pexp_letop of |
(* | -
| *) |
| |
Pexp_extension of |
(* |
| *) |
| |
Pexp_unreachable |
(* |
| *) |
type
case = {
|
pc_lhs : |
|
pc_guard : |
|
pc_rhs : |
}
Values of type Parsetree.case
represents (P -> E)
or (P when E0 -> E)
type
letop = {
|
let_ : |
|
ands : |
|
body : |
}
type
binding_op = {
|
pbop_op : |
|
pbop_pat : |
|
pbop_exp : |
|
pbop_loc : |
}
type
function_param_desc =
| |
Pparam_val of |
(* |
Note: If | *) |
| |
Pparam_newtype of |
(* |
Multiple parameters
Here, the first loc | *) |
type
function_param = {
|
pparam_loc : |
|
pparam_desc : |
}
type
function_body =
| |
Pfunction_body of |
|||
| |
Pfunction_cases of |
(* | In | *) |
See the comment on Pexp_function
.
type
type_constraint =
| |
Pconstraint of |
|||
| |
Pcoerce of |
(* | See the comment on | *) |
type
value_description = {
|
pval_name : |
|||
|
pval_type : |
|||
|
pval_prim : |
|||
|
pval_attributes : |
(* |
| *) |
|
pval_loc : |
}
Values of type Parsetree.value_description
represents:
type
type_declaration = {
|
ptype_name : |
|||
|
ptype_params : |
(* |
| *) |
|
ptype_cstrs : |
(* |
| *) |
|
ptype_kind : |
|||
|
ptype_private : |
(* | for | *) |
|
ptype_manifest : |
(* | represents | *) |
|
ptype_attributes : |
(* |
| *) |
|
ptype_loc : |
}
Here are type declarations and their representation,
for various ptype_kind
and ptype_manifest
values:
type t
when type_kind
is Ptype_abstract
,
and manifest
is None
,type t = T0
when type_kind
is Ptype_abstract
,
and manifest
is Some T0
,type t = C of T | ...
when type_kind
is Ptype_variant
,
and manifest
is None
,type t = T0 = C of T | ...
when type_kind
is Ptype_variant
,
and manifest
is Some T0
,type t = {l: T; ...}
when type_kind
is Ptype_record
,
and manifest
is None
,type t = T0 = {l : T; ...}
when type_kind
is Ptype_record
,
and manifest
is Some T0
,type t = ..
when type_kind
is Ptype_open
,
and manifest
is None
.type
type_kind =
| |
Ptype_abstract |
|||
| |
Ptype_variant of |
|||
| |
Ptype_record of |
(* | Invariant: non-empty list | *) |
| |
Ptype_open |
type
label_declaration = {
|
pld_name : |
|||
|
pld_mutable : |
|||
|
pld_type : |
|||
|
pld_loc : |
|||
|
pld_attributes : |
(* |
| *) |
}
- { ...; l: T; ... }
when pld_mutable
is Immutable
,
{ ...; mutable l: T; ... }
when pld_mutable
is Mutable
.Note: T
can be a Ptyp_poly
.
type
constructor_declaration = {
|
pcd_name : |
|||
|
pcd_vars : |
|||
|
pcd_args : |
|||
|
pcd_res : |
|||
|
pcd_loc : |
|||
|
pcd_attributes : |
(* |
| *) |
}
type
constructor_arguments =
| |
Pcstr_tuple of |
|||
| |
Pcstr_record of |
(* | Values of type
| *) |
type
type_extension = {
|
ptyext_path : |
|||
|
ptyext_params : |
|||
|
ptyext_constructors : |
|||
|
ptyext_private : |
|||
|
ptyext_loc : |
|||
|
ptyext_attributes : |
(* | ... | *) |
}
Definition of new extensions constructors for the extensive sum type t
(type t += ...
).
type
extension_constructor = {
|
pext_name : |
|||
|
pext_kind : |
|||
|
pext_loc : |
|||
|
pext_attributes : |
(* |
| *) |
}
type
type_exception = {
|
ptyexn_constructor : |
|||
|
ptyexn_loc : |
|||
|
ptyexn_attributes : |
(* |
| *) |
}
Definition of a new exception (exception E
).
type
extension_constructor_kind =
| |
Pext_decl of |
(* |
| *) |
| |
Pext_rebind of |
(* |
| *) |
type
class_type = {
|
pcty_desc : |
|||
|
pcty_loc : |
|||
|
pcty_attributes : |
(* |
| *) |
}
type
class_type_desc =
| |
Pcty_constr of |
(* | -
| *) |
| |
Pcty_signature of |
(* |
| *) |
| |
Pcty_arrow of |
(* |
| *) |
| |
Pcty_extension of |
(* |
| *) |
| |
Pcty_open of |
(* |
| *) |
type
class_signature = {
|
pcsig_self : |
|
pcsig_fields : |
}
Values of type class_signature
represents:
object('selfpat) ... end
object ... end
when pcsig_self
is Ptyp_any
type
class_type_field = {
|
pctf_desc : |
|||
|
pctf_loc : |
|||
|
pctf_attributes : |
(* |
| *) |
}
type
class_type_field_desc =
| |
Pctf_inherit of |
(* |
| *) |
| |
Pctf_val of |
(* |
| *) |
| |
Pctf_method of |
(* |
Note: | *) |
| |
Pctf_constraint of |
(* |
| *) |
| |
Pctf_attribute of |
(* |
| *) |
| |
Pctf_extension of |
(* |
| *) |
type 'a
class_infos = {
|
pci_virt : |
|||
|
pci_params : |
|||
|
pci_name : |
|||
|
pci_expr : |
|||
|
pci_loc : |
|||
|
pci_attributes : |
(* |
| *) |
}
Values of type class_expr class_infos
represents:
class c = ...
class ['a1,...,'an] c = ...
class virtual c = ...
They are also used for "class type" declaration.
typeclass_description =
class_type class_infos
typeclass_type_declaration =
class_type class_infos
type
class_expr = {
|
pcl_desc : |
|||
|
pcl_loc : |
|||
|
pcl_attributes : |
(* |
| *) |
}
type
class_expr_desc =
| |
Pcl_constr of |
(* |
| *) |
| |
Pcl_structure of |
(* |
| *) |
| |
Pcl_fun of |
(* |
| *) |
| |
Pcl_apply of |
(* |
Invariant: | *) |
| |
Pcl_let of |
(* |
| *) |
| |
Pcl_constraint of |
(* |
| *) |
| |
Pcl_extension of |
(* |
| *) |
| |
Pcl_open of |
(* |
| *) |
type
class_structure = {
|
pcstr_self : |
|
pcstr_fields : |
}
Values of type Parsetree.class_structure
represents:
object(selfpat) ... end
object ... end
when pcstr_self
is Ppat_any
type
class_field = {
|
pcf_desc : |
|||
|
pcf_loc : |
|||
|
pcf_attributes : |
(* |
| *) |
}
type
class_field_desc =
| |
Pcf_inherit of |
(* | *) |
|
| |
Pcf_val of |
(* |
| *) |
| |
Pcf_method of |
(* | *) |
|
| |
Pcf_constraint of |
(* |
| *) |
| |
Pcf_initializer of |
(* |
| *) |
| |
Pcf_attribute of |
(* |
| *) |
| |
Pcf_extension of |
(* |
| *) |
type
class_field_kind =
| |
Cfk_virtual of |
| |
Cfk_concrete of |
typeclass_declaration =
class_expr class_infos
type
module_type = {
|
pmty_desc : |
|||
|
pmty_loc : |
|||
|
pmty_attributes : |
(* |
| *) |
}
type
module_type_desc =
| |
Pmty_ident of |
(* |
| *) |
| |
Pmty_signature of |
(* |
| *) |
| |
Pmty_functor of |
(* |
| *) |
| |
Pmty_with of |
(* |
| *) |
| |
Pmty_typeof of |
(* |
| *) |
| |
Pmty_extension of |
(* |
| *) |
| |
Pmty_alias of |
(* |
| *) |
type
functor_parameter =
| |
Unit |
(* |
| *) |
| |
Named of |
(* |
| *) |
typesignature =
signature_item list
type
signature_item = {
|
psig_desc : |
|
psig_loc : |
}
type
signature_item_desc =
| |
Psig_value of |
(* | -
| *) |
| |
Psig_type of |
(* |
| *) |
| |
Psig_typesubst of |
(* |
| *) |
| |
Psig_typext of |
(* |
| *) |
| |
Psig_exception of |
(* |
| *) |
| |
Psig_module of |
(* |
| *) |
| |
Psig_modsubst of |
(* |
| *) |
| |
Psig_recmodule of |
(* |
| *) |
| |
Psig_modtype of |
(* |
| *) |
| |
Psig_modtypesubst of |
(* |
| *) |
| |
Psig_open of |
(* |
| *) |
| |
Psig_include of |
(* |
| *) |
| |
Psig_class of |
(* |
| *) |
| |
Psig_class_type of |
(* |
| *) |
| |
Psig_attribute of |
(* |
| *) |
| |
Psig_extension of |
(* |
| *) |
type
module_declaration = {
|
pmd_name : |
|||
|
pmd_type : |
|||
|
pmd_attributes : |
(* |
| *) |
|
pmd_loc : |
}
Values of type module_declaration
represents S : MT
type
module_substitution = {
|
pms_name : |
|||
|
pms_manifest : |
|||
|
pms_attributes : |
(* |
| *) |
|
pms_loc : |
}
Values of type module_substitution
represents S := M
type
module_type_declaration = {
|
pmtd_name : |
|||
|
pmtd_type : |
|||
|
pmtd_attributes : |
(* |
| *) |
|
pmtd_loc : |
}
Values of type module_type_declaration
represents:
S = MT
,S
for abstract module type declaration,
when pmtd_type
is None
.type 'a
open_infos = {
|
popen_expr : |
|
popen_override : |
|
popen_loc : |
|
popen_attributes : |
}
Values of type 'a open_infos
represents:
open! X
when popen_override
is Override
(silences the "used identifier shadowing" warning)open X
when popen_override
is Fresh
typeopen_description =
Longident.t Asttypes.loc open_infos
Values of type open_description
represents:
open M.N
open M(N).O
typeopen_declaration =
module_expr open_infos
Values of type open_declaration
represents:
open M.N
open M(N).O
open struct ... end
type 'a
include_infos = {
|
pincl_mod : |
|
pincl_loc : |
|
pincl_attributes : |
}
typeinclude_description =
module_type include_infos
Values of type include_description
represents include MT
typeinclude_declaration =
module_expr include_infos
Values of type include_declaration
represents include ME
type
with_constraint =
| |
Pwith_type of |
(* |
Note: the last component of the longident must match the name of the type_declaration. | *) |
| |
Pwith_module of |
(* |
| *) |
| |
Pwith_modtype of |
(* |
| *) |
| |
Pwith_modtypesubst of |
(* |
| *) |
| |
Pwith_typesubst of |
(* |
| *) |
| |
Pwith_modsubst of |
(* |
| *) |
type
module_expr = {
|
pmod_desc : |
|||
|
pmod_loc : |
|||
|
pmod_attributes : |
(* |
| *) |
}
type
module_expr_desc =
| |
Pmod_ident of |
(* |
| *) |
| |
Pmod_structure of |
(* |
| *) |
| |
Pmod_functor of |
(* |
| *) |
| |
Pmod_apply of |
(* |
| *) |
| |
Pmod_apply_unit of |
(* |
| *) |
| |
Pmod_constraint of |
(* |
| *) |
| |
Pmod_unpack of |
(* |
| *) |
| |
Pmod_extension of |
(* |
| *) |
typestructure =
structure_item list
type
structure_item = {
|
pstr_desc : |
|
pstr_loc : |
}
type
structure_item_desc =
| |
Pstr_eval of |
(* |
| *) |
| |
Pstr_value of |
(* |
| *) |
| |
Pstr_primitive of |
(* | -
| *) |
| |
Pstr_type of |
(* |
| *) |
| |
Pstr_typext of |
(* |
| *) |
| |
Pstr_exception of |
(* | -
| *) |
| |
Pstr_module of |
(* |
| *) |
| |
Pstr_recmodule of |
(* |
| *) |
| |
Pstr_modtype of |
(* |
| *) |
| |
Pstr_open of |
(* |
| *) |
| |
Pstr_class of |
(* |
| *) |
| |
Pstr_class_type of |
(* |
| *) |
| |
Pstr_include of |
(* |
| *) |
| |
Pstr_attribute of |
(* |
| *) |
| |
Pstr_extension of |
(* |
| *) |
type
value_constraint =
| |
Pvc_constraint of |
|||||||
| |
Pvc_coercion of |
(* | -
| *) |
type
value_binding = {
|
pvb_pat : |
|
pvb_expr : |
|
pvb_constraint : |
|
pvb_attributes : |
|
pvb_loc : |
}
let pat : type_constraint = exp
type
module_binding = {
|
pmb_name : |
|
pmb_expr : |
|
pmb_attributes : |
|
pmb_loc : |
}
Values of type module_binding
represents module X = ME
type
toplevel_phrase =
| |
Ptop_def of |
|||
| |
Ptop_dir of |
(* |
| *) |
type
toplevel_directive = {
|
pdir_name : |
|
pdir_arg : |
|
pdir_loc : |
}
type
directive_argument = {
|
pdira_desc : |
|
pdira_loc : |
}
type
directive_argument_desc =
| |
Pdir_string of |
| |
Pdir_int of |
| |
Pdir_ident of |
| |
Pdir_bool of |