ocaml-base-compiler
-
dynlink
-
ocamlbytecomp
-
ocamlcommon
-
ocamlmiddleend
-
ocamloptcomp
-
odoc_info
-
stdlib
-
str
-
unix
Library
Module
Module type
Parameter
Class
Class type
By comparison with Parsetree
:
- Every
Longindent
.t is accompanied by a resolvedPath.t
.
Extension points
type attribute = Parsetree.attribute
type attributes = attribute list
Core language
type _ pattern_category =
| Value : value pattern_category |
| Computation : computation pattern_category |
type pattern = value general_pattern
and 'k general_pattern = 'k pattern_desc pattern_data
and 'a pattern_data = {
pat_desc : 'a; |
pat_loc : Location.t; |
pat_extra : (pat_extra * Location.t * attributes) list; |
pat_type : Types.type_expr; |
pat_env : Env.t; |
pat_attributes : attributes; |
}
and pat_extra =
| Tpat_constraint of core_type | (* P : T |
| Tpat_type of Path.t * Longident.t Asttypes.loc | (* #tconst where |
| Tpat_open of Path.t * Longident.t Asttypes.loc * Env.t | |
| Tpat_unpack | (* (module P) |
and 'k pattern_desc =
| Tpat_any : value pattern_desc | (* _ *) |
| Tpat_var : Ident.t * string Asttypes.loc -> value pattern_desc | (* x *) |
| Tpat_alias : value general_pattern
* Ident.t
* string Asttypes.loc -> value pattern_desc | (* P as a *) |
| Tpat_constant : Asttypes.constant -> value pattern_desc | (* 1, 'a', "true", 1.0, 1l, 1L, 1n *) |
| Tpat_tuple : value general_pattern list -> value pattern_desc | (* (P1, ..., Pn) Invariant: n >= 2 *) |
| Tpat_construct : Longident.t Asttypes.loc
* Types.constructor_description
* value general_pattern list
* (Ident.t Asttypes.loc list * core_type) option -> value pattern_desc | (* C (, None) C P ( |
| Tpat_variant : Asttypes.label
* value general_pattern option
* Types.row_desc ref -> value pattern_desc | (* `A (None) `A P (Some P) See |
| Tpat_record : (Longident.t Asttypes.loc
* Types.label_description
* value general_pattern)
list
* Asttypes.closed_flag -> value pattern_desc | (*
Invariant: n > 0 *) |
| Tpat_array : value general_pattern list -> value pattern_desc | (*
|
| Tpat_lazy : value general_pattern -> value pattern_desc | (* lazy P *) |
| Tpat_value : tpat_value_argument -> computation pattern_desc | (* P Invariant: Tpat_value pattern should not carry pat_attributes or pat_extra metadata coming from user syntax, which must be on the inner pattern node -- to facilitate searching for a certain value pattern constructor with a specific attributed. To enforce this restriction, we made the argument of the Tpat_value constructor a private synonym of |
| Tpat_exception : value general_pattern -> computation pattern_desc | (* exception P *) |
| Tpat_or : 'k general_pattern
* 'k general_pattern
* Types.row_desc option -> 'k pattern_desc | (* P1 | P2
|
and tpat_value_argument = private value general_pattern
and expression = {
exp_desc : expression_desc; |
exp_loc : Location.t; |
exp_extra : (exp_extra * Location.t * attributes) list; |
exp_type : Types.type_expr; |
exp_env : Env.t; |
exp_attributes : attributes; |
}
and expression_desc =
| Texp_ident of Path.t * Longident.t Asttypes.loc * Types.value_description | (* x M.x *) | ||||
| Texp_constant of Asttypes.constant | (* 1, 'a', "true", 1.0, 1l, 1L, 1n *) | ||||
| Texp_let of Asttypes.rec_flag * value_binding list * expression | (* let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive) let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive) *) | ||||
| Texp_function of {
} | (*
partial = | ||||
| Texp_apply of expression * (Asttypes.arg_label * expression option) list | (* E0 ~l1:E1 ... ~ln:En The expression can be None if the expression is abstracted over this argument. It currently appears when a label is applied. For example: let f x ~y = x + y in f ~y:3 The resulting typedtree for the application is: Texp_apply (Texp_ident "f/1037", | ||||
| Texp_match of expression * computation case list * partial | (* match E0 with | P1 -> E1 | P2 | exception P3 -> E2 | exception P4 -> E3
| ||||
| Texp_try of expression * value case list | (* try E with P1 -> E1 | ... | PN -> EN *) | ||||
| Texp_tuple of expression list | (* (E1, ..., EN) *) | ||||
| Texp_construct of Longident.t Asttypes.loc
* Types.constructor_description
* expression list | (* C C E | ||||
| Texp_variant of Asttypes.label * expression option | |||||
| Texp_record of {
} | (*
Invariant: n > 0 If the type is | ||||
| Texp_field of expression * Longident.t Asttypes.loc * Types.label_description | |||||
| Texp_setfield of expression
* Longident.t Asttypes.loc
* Types.label_description
* expression | |||||
| Texp_array of expression list | |||||
| Texp_ifthenelse of expression * expression * expression option | |||||
| Texp_sequence of expression * expression | |||||
| Texp_while of expression * expression | |||||
| Texp_for of Ident.t
* Parsetree.pattern
* expression
* expression
* Asttypes.direction_flag
* expression | |||||
| Texp_send of expression * meth | |||||
| Texp_new of Path.t * Longident.t Asttypes.loc * Types.class_declaration | |||||
| Texp_instvar of Path.t * Path.t * string Asttypes.loc | |||||
| Texp_setinstvar of Path.t * Path.t * string Asttypes.loc * expression | |||||
| Texp_override of Path.t * (Ident.t * string Asttypes.loc * expression) list | |||||
| Texp_letmodule of Ident.t option
* string option Asttypes.loc
* Types.module_presence
* module_expr
* expression | |||||
| Texp_letexception of extension_constructor * expression | |||||
| Texp_assert of expression | |||||
| Texp_lazy of expression | |||||
| Texp_object of class_structure * string list | |||||
| Texp_pack of module_expr | |||||
| Texp_letop of {
} | |||||
| Texp_unreachable | |||||
| Texp_extension_constructor of Longident.t Asttypes.loc * Path.t | |||||
| Texp_open of open_declaration * expression | (* let open |
and record_label_definition =
| Kept of Types.type_expr |
| Overridden of Longident.t Asttypes.loc * expression |
and binding_op = {
bop_op_path : Path.t; |
bop_op_name : string Asttypes.loc; |
bop_op_val : Types.value_description; |
bop_op_type : Types.type_expr; |
bop_exp : expression; |
bop_loc : Location.t; |
}
and class_expr = {
cl_desc : class_expr_desc; |
cl_loc : Location.t; |
cl_type : Types.class_type; |
cl_env : Env.t; |
cl_attributes : attributes; |
}
and class_expr_desc =
| Tcl_ident of Path.t * Longident.t Asttypes.loc * core_type list |
| Tcl_structure of class_structure |
| Tcl_fun of Asttypes.arg_label
* pattern
* (Ident.t * expression) list
* class_expr
* partial |
| Tcl_apply of class_expr * (Asttypes.arg_label * expression option) list |
| Tcl_let of Asttypes.rec_flag
* value_binding list
* (Ident.t * expression) list
* class_expr |
| Tcl_constraint of class_expr
* class_type option
* string list
* string list
* Types.MethSet.t |
| Tcl_open of open_description * class_expr |
and class_structure = {
cstr_self : pattern; |
cstr_fields : class_field list; |
cstr_type : Types.class_signature; |
cstr_meths : Ident.t Types.Meths.t; |
}
and class_field_kind =
| Tcfk_virtual of core_type |
| Tcfk_concrete of Asttypes.override_flag * expression |
and class_field_desc =
| Tcf_inherit of Asttypes.override_flag
* class_expr
* string option
* (string * Ident.t) list
* (string * Ident.t) list |
| Tcf_val of string Asttypes.loc
* Asttypes.mutable_flag
* Ident.t
* class_field_kind
* bool |
| Tcf_method of string Asttypes.loc * Asttypes.private_flag * class_field_kind |
| Tcf_constraint of core_type * core_type |
| Tcf_initializer of expression |
| Tcf_attribute of attribute |
and module_expr = {
mod_desc : module_expr_desc; |
mod_loc : Location.t; |
mod_type : Types.module_type; |
mod_env : Env.t; |
mod_attributes : attributes; |
}
and module_type_constraint =
| Tmodtype_implicit | (* The module type constraint has been synthesized during typechecking. *) |
| Tmodtype_explicit of module_type | (* The module type was in the source file. *) |
Annotations for Tmod_constraint
.
and module_expr_desc =
| Tmod_ident of Path.t * Longident.t Asttypes.loc | |
| Tmod_structure of structure | |
| Tmod_functor of functor_parameter * module_expr | |
| Tmod_apply of module_expr * module_expr * module_coercion | |
| Tmod_constraint of module_expr
* Types.module_type
* module_type_constraint
* module_coercion | (* ME (constraint = Tmodtype_implicit) (ME : MT) (constraint = Tmodtype_explicit MT) *) |
| Tmod_unpack of expression * Types.module_type |
and structure_item_desc =
| Tstr_eval of expression * attributes |
| Tstr_value of Asttypes.rec_flag * value_binding list |
| Tstr_primitive of value_description |
| Tstr_type of Asttypes.rec_flag * type_declaration list |
| Tstr_typext of type_extension |
| Tstr_exception of type_exception |
| Tstr_module of module_binding |
| Tstr_recmodule of module_binding list |
| Tstr_modtype of module_type_declaration |
| Tstr_open of open_declaration |
| Tstr_class of (class_declaration * string list) list |
| Tstr_class_type of (Ident.t * string Asttypes.loc * class_type_declaration)
list |
| Tstr_include of include_declaration |
| Tstr_attribute of attribute |
and module_binding = {
mb_id : Ident.t option; |
mb_name : string option Asttypes.loc; |
mb_presence : Types.module_presence; |
mb_expr : module_expr; |
mb_attributes : attributes; |
mb_loc : Location.t; |
}
and value_binding = {
vb_pat : pattern; |
vb_expr : expression; |
vb_attributes : attributes; |
vb_loc : Location.t; |
}
and module_coercion =
| Tcoerce_none |
| Tcoerce_structure of (int * module_coercion) list
* (Ident.t * int * module_coercion) list |
| Tcoerce_functor of module_coercion * module_coercion |
| Tcoerce_primitive of primitive_coercion |
| Tcoerce_alias of Env.t * Path.t * module_coercion |
and module_type = {
mty_desc : module_type_desc; |
mty_type : Types.module_type; |
mty_env : Env.t; |
mty_loc : Location.t; |
mty_attributes : attributes; |
}
and module_type_desc =
| Tmty_ident of Path.t * Longident.t Asttypes.loc |
| Tmty_signature of signature |
| Tmty_functor of functor_parameter * module_type |
| Tmty_with of module_type
* (Path.t * Longident.t Asttypes.loc * with_constraint) list |
| Tmty_typeof of module_expr |
| Tmty_alias of Path.t * Longident.t Asttypes.loc |
and primitive_coercion = {
pc_desc : Primitive.description; |
pc_type : Types.type_expr; |
pc_env : Env.t; |
pc_loc : Location.t; |
}