module Parsetree:sig..end
由解析生成的抽象语法树
警告:此模块不稳定,并且是 compiler-libs 的一部分。
type constant =
| |
Pconst_integer of |
(* | 整数常量,例如 解析器接受后缀 | *) |
| |
Pconst_char of |
(* | 字符,例如 | *) |
| |
Pconst_string of |
(* | 常量字符串,例如 位置跨越字符串的内容,不包括分隔符。 | *) |
| |
Pconst_float of |
(* | 浮点数常量,例如 解析器接受后缀 | *) |
typelocation_stack =Location.t list
type attribute = {
|
attr_name : |
|
attr_payload : |
|
attr_loc : |
}
属性,例如 [@id ARG] 和 [@@id ARG]。
在 AST 中传递的元数据容器。编译器忽略未知属性。
typeextension =string Asttypes.loc * payload
扩展点,例如 [%id ARG] and [%%id ARG]。
子语言占位符——被类型检查器拒绝。
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 |
(* | 类型变量,例如 | *) |
| |
Ptyp_arrow of |
(* | *) |
|
| |
Ptyp_tuple of |
(* |
不变式: | *) |
| |
Ptyp_constr of |
(* |
| *) |
| |
Ptyp_object of |
(* | *) |
|
| |
Ptyp_class of |
(* |
| *) |
| |
Ptyp_alias of |
(* |
| *) |
| |
Ptyp_variant of |
(* | *) |
|
| |
Ptyp_poly of |
(* |
只能出现在以下上下文中
| *) |
| |
Ptyp_package of |
(* |
| *) |
| |
Ptyp_open of |
(* |
| *) |
| |
Ptyp_extension of |
(* |
| *) |
typepackage_type =Longident.t Asttypes.loc *
(Longident.t Asttypes.loc * core_type) list
作为 Parsetree.package_type 类型的值
(S, []) 代表 (module S),(S, [(t1, T1) ; ... ; (tn, Tn)]) 代表 (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 |
(* | 模式 | *) |
| |
Ppat_var of |
(* | 变量模式,例如 | *) |
| |
Ppat_alias of |
(* | 别名模式,例如 | *) |
| |
Ppat_constant of |
(* | 模式,例如 | *) |
| |
Ppat_interval of |
(* | 模式,例如 解析器识别其他形式的区间,但类型检查器会拒绝。 | *) |
| |
Ppat_tuple of |
(* | 模式 不变式: | *) |
| |
Ppat_construct of |
(* |
| *) |
| |
Ppat_variant of |
(* |
| *) |
| |
Ppat_record of |
(* | *) |
|
| |
Ppat_array of |
(* | 模式 | *) |
| |
Ppat_or of |
(* | 模式 | *) |
| |
Ppat_constraint of |
(* | 模式 | *) |
| |
Ppat_type of |
(* | 模式 | *) |
| |
Ppat_lazy of |
(* | 模式 | *) |
| |
Ppat_unpack of |
(* |
注意: | *) |
| |
Ppat_exception of |
(* | 模式 | *) |
| |
Ppat_extension of |
(* | 模式 | *) |
| |
Ppat_open of |
(* | 模式 | *) |
type expression = {
|
pexp_desc : |
|||
|
pexp_loc : |
|||
|
pexp_loc_stack : |
|||
|
pexp_attributes : |
(* |
| *) |
}
type expression_desc =
| |
Pexp_ident of |
(* | 标识符,例如 | *) |
| |
Pexp_constant of |
(* | 常量表达式,例如 | *) |
| |
Pexp_let of |
(* |
| *) |
| |
Pexp_function of |
(* |
函数必须有参数。 | *) |
| |
Pexp_apply of |
(* | *) |
|
| |
Pexp_match of |
(* |
| *) |
| |
Pexp_try of |
(* |
| *) |
| |
Pexp_tuple of |
(* | 表达式 不变式: | *) |
| |
Pexp_construct of |
(* |
| *) |
| |
Pexp_variant of |
(* |
| *) |
| |
Pexp_record of |
(* |
不变式: | *) |
| |
Pexp_field of |
(* |
| *) |
| |
Pexp_setfield of |
(* |
| *) |
| |
Pexp_array of |
(* |
| *) |
| |
Pexp_ifthenelse of |
(* |
| *) |
| |
Pexp_sequence of |
(* |
| *) |
| |
Pexp_while 的 类型 为 |
(* |
| *) |
| |
Pexp_for 的 类型 为 |
(* | *) |
|
| |
Pexp_constraint 的 类型 为 |
(* |
| *) |
| |
Pexp_coerce 的 类型 为 |
(* |
| *) |
| |
Pexp_send 的 类型 为 |
(* |
| *) |
| |
Pexp_new 的 类型 为 |
(* |
| *) |
| |
Pexp_setinstvar 的 类型 为 |
(* |
| *) |
| |
Pexp_override 的 类型 为 |
(* |
| *) |
| |
Pexp_letmodule 的 类型 为 |
(* |
| *) |
| |
Pexp_letexception 的 类型 为 |
(* |
| *) |
| |
Pexp_assert 的 类型 为 |
(* |
注意: | *) |
| |
Pexp_lazy 的 类型 为 |
(* |
| *) |
| |
Pexp_poly 的 类型 为 |
(* | 用于 方法体。 只能 用作 | *) |
| |
Pexp_object 的 类型 为 |
(* |
| *) |
| |
Pexp_newtype 的 类型 为 |
(* |
| *) |
| |
Pexp_pack 的 类型 为 |
(* |
| *) |
| |
Pexp_open 的 类型 为 |
(* | -
| *) |
| |
Pexp_letop 的 类型 为 |
(* | -
| *) |
| |
Pexp_extension 的 类型 为 |
(* |
| *) |
| |
Pexp_unreachable |
(* |
| *) |
type case = {
|
pc_lhs : |
|
pc_guard : |
|
pc_rhs : |
}
类型 Parsetree.case 的值 表示 (P -> E) 或 (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 的 类型 为 |
(* |
注意:如果 提供了 | *) |
| |
Pparam_newtype 的 类型 为 |
(* |
多个参数
这里,第一个位置 | *) |
type function_param = {
|
pparam_loc : |
|
pparam_desc : |
}
type function_body =
| |
Pfunction_body of |
|||
| |
Pfunction_cases of |
(* | 在 | *) |
请参阅 Pexp_function 上的注释。
type type_constraint =
| |
Pconstraint of |
|||
| |
Pcoerce of |
(* | 请参阅 | *) |
type value_description = {
|
pval_name : |
|||
|
pval_type : |
|||
|
pval_prim : |
|||
|
pval_attributes : |
(* |
| *) |
|
pval_loc : |
}
类型 Parsetree.value_description 的值表示
type type_declaration = {
|
ptype_name : |
|||
|
ptype_params : |
(* |
| *) |
|
ptype_cstrs : |
(* |
| *) |
|
ptype_kind : |
|||
|
ptype_private : |
(* | 用于 | *) |
|
ptype_manifest : |
(* | 表示 | *) |
|
ptype_attributes : |
(* |
| *) |
|
ptype_loc : |
}
以下是类型声明及其表示,适用于各种 ptype_kind 和 ptype_manifest 值
type t 当 type_kind 为 Ptype_abstract 且 manifest 为 None 时type t = T0 当 type_kind 为 Ptype_abstract 且 manifest 为 Some T0 时type t = C of T | ... 当 type_kind 为 Ptype_variant 且 manifest 为 None 时type t = T0 = C of T | ... 当 type_kind 为 Ptype_variant 且 manifest 为 Some T0 时type t = {l: T; ...} 当 type_kind 为 Ptype_record 且 manifest 为 None 时type t = T0 = {l : T; ...} 当 type_kind 为 Ptype_record 且 manifest 为 Some T0 时type t = .. 当 type_kind 为 Ptype_open 且 manifest 为 None 时。type type_kind =
| |
Ptype_abstract |
|||
| |
Ptype_variant of |
|||
| |
Ptype_record of |
(* | 不变式:非空列表 | *) |
| |
Ptype_open |
type label_declaration = {
|
pld_name : |
|||
|
pld_mutable : |
|||
|
pld_type : |
|||
|
pld_loc : |
|||
|
pld_attributes : |
(* |
| *) |
}
- { ...; l: T; ... } 当 pld_mutable 为 Immutable 时
{ ...; mutable l: T; ... } 当 pld_mutable 为 Mutable 时。注意:T 可以是 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 |
(* | 类型
| *) |
type type_extension = {
|
ptyext_path : |
|||
|
ptyext_params : |
|||
|
ptyext_constructors : |
|||
|
ptyext_private : |
|||
|
ptyext_loc : |
|||
|
ptyext_attributes : |
(* | ... | *) |
}
扩展和类型扩展构造函数的定义,用于扩展和类型扩展和。 t (type t += ...)。
type extension_constructor = {
|
pext_name : |
|||
|
pext_kind : |
|||
|
pext_loc : |
|||
|
pext_attributes : |
(* |
| *) |
}
type type_exception = {
|
ptyexn_constructor : |
|||
|
ptyexn_loc : |
|||
|
ptyexn_attributes : |
(* |
| *) |
}
定义一个新的异常 (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 : |
}
类型 class_signature 的值表示
object('selfpat) ... endobject ... end 当 pcsig_self 为 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 |
(* |
注意: | *) |
| |
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 : |
(* |
| *) |
}
类型 class_expr class_infos 的值表示
class c = ...class ['a1,...,'an] c = ...class virtual c = ...它们也用于“类类型”声明。
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 |
(* |
不变式: | *) |
| |
Pcl_let of |
(* |
| *) |
| |
Pcl_constraint 的 |
(* |
| *) |
| |
Pcl_extension 的 |
(* |
| *) |
| |
Pcl_open 的 |
(* |
| *) |
type class_structure = {
|
pcstr_self : |
|
pcstr_fields : |
}
Parsetree.class_structure 类型的 值 表示
object(selfpat) ... endobject ... end 当 pcstr_self 为 Ppat_any 时type class_field = {
|
pcf_desc : |
|||
|
pcf_loc : |
|||
|
pcf_attributes : |
(* |
| *) |
}
type class_field_desc =
| |
Pcf_inherit 的 |
(* | *) |
|
| |
Pcf_val 的 |
(* |
| *) |
| |
Pcf_method 的 |
(* | *) |
|
| |
Pcf_constraint 的 |
(* |
| *) |
| |
Pcf_initializer 的 |
(* |
| *) |
| |
Pcf_attribute 的 |
(* |
| *) |
| |
Pcf_extension 的 |
(* |
| *) |
type class_field_kind =
| |
Cfk_virtual 的 |
| |
Cfk_concrete 的 |
typeclass_declaration =class_expr class_infos
type module_type = {
|
pmty_desc : |
|||
|
pmty_loc : |
|||
|
pmty_attributes : |
(* |
| *) |
}
type module_type_desc =
| |
Pmty_ident 的 |
(* |
| *) |
| |
Pmty_signature 的 |
(* |
| *) |
| |
Pmty_functor 的 |
(* |
| *) |
| |
Pmty_with 的 |
(* |
| *) |
| |
Pmty_typeof 的 |
(* |
| *) |
| |
Pmty_extension 的 |
(* |
| *) |
| |
Pmty_alias 的 |
(* |
| *) |
type functor_parameter =
| |
单元 |
(* |
| *) |
| |
Named 的 |
(* |
| *) |
typesignature =signature_item list
type signature_item = {
|
psig_desc : |
|
psig_loc : |
}
type signature_item_desc =
| |
Psig_value 是 |
(* | -
| *) |
| |
Psig_type 是 |
(* |
| *) |
| |
Psig_typesubst 是 |
(* |
| *) |
| |
Psig_typext 是 |
(* |
| *) |
| |
Psig_exception 是 |
(* |
| *) |
| |
Psig_module 是 |
(* |
| *) |
| |
Psig_modsubst 是 |
(* |
| *) |
| |
Psig_recmodule 是 |
(* |
| *) |
| |
Psig_modtype 是 |
(* |
| *) |
| |
Psig_modtypesubst 是 |
(* |
| *) |
| |
Psig_open 是 |
(* |
| *) |
| |
Psig_include 是 |
(* |
| *) |
| |
Psig_class 是 |
(* |
| *) |
| |
Psig_class_type 是 |
(* |
| *) |
| |
Psig_attribute 是 |
(* |
| *) |
| |
Psig_extension 是 |
(* |
| *) |
type module_declaration = {
|
pmd_name : |
|||
|
pmd_type : |
|||
|
pmd_attributes : |
(* |
| *) |
|
pmd_loc : |
}
module_declaration 类型的 值 表示 S : MT
type module_substitution = {
|
pms_name : |
|||
|
pms_manifest : |
|||
|
pms_attributes : |
(* |
| *) |
|
pms_loc : |
}
module_substitution 类型的 值 表示 S := M
type module_type_declaration = {
|
pmtd_name : |
|||
|
pmtd_type : |
|||
|
pmtd_attributes : |
(* |
| *) |
|
pmtd_loc : |
}
module_type_declaration 类型的 值 表示
S = MT,S 用于抽象模块类型声明,当 pmtd_type 为 None 时。type 'a open_infos = {
|
popen_expr : |
|
popen_override : |
|
popen_loc : |
|
popen_attributes : |
}
'a open_infos 类型的 值 表示
open! X 当 popen_override 为 Override 时(抑制“使用的标识符隐藏”警告)open X 当 popen_override 为 Fresh 时typeopen_description =Longident.t Asttypes.loc open_infos
open_description 类型的 值 表示
open M.Nopen M(N).Otypeopen_declaration =module_expr open_infos
open_declaration 类型的 值 表示
open M.Nopen M(N).Oopen struct ... endtype 'a include_infos = {
|
pincl_mod : |
|
pincl_loc : |
|
pincl_attributes : |
}
typeinclude_description =module_type include_infos
include_description 类型的 值 表示 include MT
typeinclude_declaration =module_expr include_infos
include_declaration 类型的 值 表示 include ME
type with_constraint =
| |
Pwith_type 是 |
(* |
注意:longident 的最后一个组件必须与 type_declaration 的名称匹配。 | *) |
| |
Pwith_module 是 |
(* |
| *) |
| |
Pwith_modtype 是 |
(* |
| *) |
| |
Pwith_modtypesubst 是 |
(* |
| *) |
| |
Pwith_typesubst 是 |
(* |
| *) |
| |
Pwith_modsubst 是 |
(* |
| *) |
type module_expr = {
|
pmod_desc : |
|||
|
pmod_loc : |
|||
|
pmod_attributes : |
(* |
| *) |
}
type module_expr_desc =
| |
Pmod_ident 是 |
(* |
| *) |
| |
Pmod_structure 是 |
(* |
| *) |
| |
Pmod_functor 是 |
(* |
| *) |
| |
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 : |
}
module_binding 类型的的值表示 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 |