1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Abstract syntax tree produced by parsing *)
|
|
|
|
|
|
|
|
open Asttypes
|
|
|
|
|
2013-02-28 08:51:59 -08:00
|
|
|
(* Extension points *)
|
|
|
|
|
2013-03-01 04:44:04 -08:00
|
|
|
type attribute = string * expression
|
2013-02-28 08:51:59 -08:00
|
|
|
|
|
|
|
and extension = string * expression
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Type expressions for the core language *)
|
|
|
|
|
2013-02-28 08:51:59 -08:00
|
|
|
and core_type =
|
1995-05-04 03:15:53 -07:00
|
|
|
{ ptyp_desc: core_type_desc;
|
|
|
|
ptyp_loc: Location.t }
|
|
|
|
|
2010-01-22 04:48:24 -08:00
|
|
|
and core_type_desc =
|
1997-02-11 10:24:47 -08:00
|
|
|
Ptyp_any
|
|
|
|
| Ptyp_var of string
|
1999-11-30 08:07:38 -08:00
|
|
|
| Ptyp_arrow of label * core_type * core_type
|
1995-05-04 03:15:53 -07:00
|
|
|
| Ptyp_tuple of core_type list
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ptyp_constr of Longident.t loc * core_type list
|
1997-03-07 14:26:29 -08:00
|
|
|
| Ptyp_object of core_field_type list
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ptyp_class of Longident.t loc * core_type list * label list
|
1997-03-07 14:26:29 -08:00
|
|
|
| Ptyp_alias of core_type * string
|
2001-09-25 02:54:18 -07:00
|
|
|
| Ptyp_variant of row_field list * bool * label list option
|
2002-04-18 00:27:47 -07:00
|
|
|
| Ptyp_poly of string list * core_type
|
2009-10-26 03:53:16 -07:00
|
|
|
| Ptyp_package of package_type
|
2013-03-01 04:44:04 -08:00
|
|
|
| Ptyp_attribute of (core_type * attribute)
|
2013-02-28 08:51:59 -08:00
|
|
|
| Ptyp_extension of extension
|
2009-10-26 03:53:16 -07:00
|
|
|
|
2012-05-30 07:52:37 -07:00
|
|
|
|
|
|
|
and package_type = Longident.t loc * (Longident.t loc * core_type) list
|
1996-04-22 04:15:41 -07:00
|
|
|
|
|
|
|
and core_field_type =
|
|
|
|
{ pfield_desc: core_field_desc;
|
|
|
|
pfield_loc: Location.t }
|
|
|
|
|
|
|
|
and core_field_desc =
|
1996-05-16 09:10:16 -07:00
|
|
|
Pfield of string * core_type
|
1996-04-22 04:15:41 -07:00
|
|
|
| Pfield_var
|
1995-05-04 03:15:53 -07:00
|
|
|
|
2001-09-25 02:54:18 -07:00
|
|
|
and row_field =
|
|
|
|
Rtag of label * bool * core_type list
|
|
|
|
| Rinherit of core_type
|
|
|
|
|
2009-08-27 01:19:08 -07:00
|
|
|
(* Type expressions for the class language *)
|
1998-06-24 12:22:26 -07:00
|
|
|
|
2013-02-28 08:51:59 -08:00
|
|
|
and 'a class_infos =
|
1998-06-24 12:22:26 -07:00
|
|
|
{ pci_virt: virtual_flag;
|
2012-05-30 07:52:37 -07:00
|
|
|
pci_params: string loc list * Location.t;
|
|
|
|
pci_name: string loc;
|
1998-06-24 12:22:26 -07:00
|
|
|
pci_expr: 'a;
|
2000-09-07 03:57:32 -07:00
|
|
|
pci_variance: (bool * bool) list;
|
1998-06-24 12:22:26 -07:00
|
|
|
pci_loc: Location.t }
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Value expressions for the core language *)
|
|
|
|
|
2013-02-28 08:51:59 -08:00
|
|
|
and pattern =
|
1995-05-04 03:15:53 -07:00
|
|
|
{ ppat_desc: pattern_desc;
|
|
|
|
ppat_loc: Location.t }
|
|
|
|
|
|
|
|
and pattern_desc =
|
|
|
|
Ppat_any
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ppat_var of string loc
|
|
|
|
| Ppat_alias of pattern * string loc
|
1995-05-04 03:15:53 -07:00
|
|
|
| Ppat_constant of constant
|
|
|
|
| Ppat_tuple of pattern list
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ppat_construct of Longident.t loc * pattern option * bool
|
1999-11-30 08:07:38 -08:00
|
|
|
| Ppat_variant of label * pattern option
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ppat_record of (Longident.t loc * pattern) list * closed_flag
|
1998-04-06 02:16:54 -07:00
|
|
|
| Ppat_array of pattern list
|
1995-05-04 03:15:53 -07:00
|
|
|
| Ppat_or of pattern * pattern
|
|
|
|
| Ppat_constraint of pattern * core_type
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ppat_type of Longident.t loc
|
2008-07-09 06:03:38 -07:00
|
|
|
| Ppat_lazy of pattern
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ppat_unpack of string loc
|
2013-03-04 05:52:23 -08:00
|
|
|
| Ppat_attribute of (pattern * attribute)
|
|
|
|
| Ppat_extension of extension
|
1995-05-04 03:15:53 -07:00
|
|
|
|
2013-02-28 08:51:59 -08:00
|
|
|
and expression =
|
1995-05-04 03:15:53 -07:00
|
|
|
{ pexp_desc: expression_desc;
|
|
|
|
pexp_loc: Location.t }
|
|
|
|
|
|
|
|
and expression_desc =
|
2012-05-30 07:52:37 -07:00
|
|
|
Pexp_ident of Longident.t loc
|
1995-05-04 03:15:53 -07:00
|
|
|
| Pexp_constant of constant
|
|
|
|
| Pexp_let of rec_flag * (pattern * expression) list * expression
|
1999-11-30 08:07:38 -08:00
|
|
|
| Pexp_function of label * expression option * (pattern * expression) list
|
|
|
|
| Pexp_apply of expression * (label * expression) list
|
1995-05-04 03:15:53 -07:00
|
|
|
| Pexp_match of expression * (pattern * expression) list
|
|
|
|
| Pexp_try of expression * (pattern * expression) list
|
|
|
|
| Pexp_tuple of expression list
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pexp_construct of Longident.t loc * expression option * bool
|
1999-11-30 08:07:38 -08:00
|
|
|
| Pexp_variant of label * expression option
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pexp_record of (Longident.t loc * expression) list * expression option
|
|
|
|
| Pexp_field of expression * Longident.t loc
|
|
|
|
| Pexp_setfield of expression * Longident.t loc * expression
|
1995-05-04 03:15:53 -07:00
|
|
|
| Pexp_array of expression list
|
|
|
|
| Pexp_ifthenelse of expression * expression * expression option
|
|
|
|
| Pexp_sequence of expression * expression
|
|
|
|
| Pexp_while of expression * expression
|
2012-12-08 12:55:42 -08:00
|
|
|
| Pexp_for of
|
|
|
|
string loc * expression * expression * direction_flag * expression
|
1996-04-22 04:15:41 -07:00
|
|
|
| Pexp_constraint of expression * core_type option * core_type option
|
1995-05-04 03:15:53 -07:00
|
|
|
| Pexp_when of expression * expression
|
1996-05-16 09:10:16 -07:00
|
|
|
| Pexp_send of expression * string
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pexp_new of Longident.t loc
|
|
|
|
| Pexp_setinstvar of string loc * expression
|
|
|
|
| Pexp_override of (string loc * expression) list
|
|
|
|
| Pexp_letmodule of string loc * module_expr * expression
|
2000-12-04 07:37:05 -08:00
|
|
|
| Pexp_assert of expression
|
|
|
|
| Pexp_assertfalse
|
2002-01-20 09:39:10 -08:00
|
|
|
| Pexp_lazy of expression
|
2002-04-18 00:27:47 -07:00
|
|
|
| Pexp_poly of expression * core_type option
|
2003-11-25 00:46:45 -08:00
|
|
|
| Pexp_object of class_structure
|
2009-10-06 05:51:42 -07:00
|
|
|
| Pexp_newtype of string * expression
|
2010-10-21 16:59:33 -07:00
|
|
|
| Pexp_pack of module_expr
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pexp_open of Longident.t loc * expression
|
2013-03-01 04:44:04 -08:00
|
|
|
| Pexp_attribute of (expression * attribute)
|
2013-02-28 08:51:59 -08:00
|
|
|
| Pexp_extension of extension
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
(* Value descriptions *)
|
|
|
|
|
1998-02-26 04:54:44 -08:00
|
|
|
and value_description =
|
1995-05-04 03:15:53 -07:00
|
|
|
{ pval_type: core_type;
|
2012-05-30 07:52:37 -07:00
|
|
|
pval_prim: string list;
|
2012-12-10 05:15:22 -08:00
|
|
|
pval_loc: Location.t
|
2012-05-30 07:52:37 -07:00
|
|
|
}
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
(* Type declarations *)
|
|
|
|
|
1998-02-26 04:54:44 -08:00
|
|
|
and type_declaration =
|
2012-05-30 07:52:37 -07:00
|
|
|
{ ptype_params: string loc option list;
|
1998-06-24 12:22:26 -07:00
|
|
|
ptype_cstrs: (core_type * core_type * Location.t) list;
|
1995-05-04 03:15:53 -07:00
|
|
|
ptype_kind: type_kind;
|
2007-10-09 03:29:37 -07:00
|
|
|
ptype_private: private_flag;
|
1995-09-26 13:23:29 -07:00
|
|
|
ptype_manifest: core_type option;
|
2000-09-07 03:57:32 -07:00
|
|
|
ptype_variance: (bool * bool) list;
|
2013-03-01 04:44:04 -08:00
|
|
|
ptype_attributes: attribute list;
|
1995-05-04 03:15:53 -07:00
|
|
|
ptype_loc: Location.t }
|
|
|
|
|
|
|
|
and type_kind =
|
2000-09-07 03:57:32 -07:00
|
|
|
Ptype_abstract
|
2010-11-11 02:02:56 -08:00
|
|
|
| Ptype_variant of
|
2012-05-30 07:52:37 -07:00
|
|
|
(string loc * core_type list * core_type option * Location.t) list
|
2004-10-06 06:06:11 -07:00
|
|
|
| Ptype_record of
|
2012-05-30 07:52:37 -07:00
|
|
|
(string loc * mutable_flag * core_type * Location.t) list
|
1995-05-04 03:15:53 -07:00
|
|
|
|
1998-02-26 04:54:44 -08:00
|
|
|
and exception_declaration = core_type list
|
1995-05-04 03:15:53 -07:00
|
|
|
|
1996-04-22 04:15:41 -07:00
|
|
|
(* Type expressions for the class language *)
|
|
|
|
|
1998-02-26 04:54:44 -08:00
|
|
|
and class_type =
|
1998-06-24 12:22:26 -07:00
|
|
|
{ pcty_desc: class_type_desc;
|
1996-04-22 04:15:41 -07:00
|
|
|
pcty_loc: Location.t }
|
|
|
|
|
1998-06-24 12:22:26 -07:00
|
|
|
and class_type_desc =
|
2012-05-30 07:52:37 -07:00
|
|
|
Pcty_constr of Longident.t loc * core_type list
|
1998-06-24 12:22:26 -07:00
|
|
|
| Pcty_signature of class_signature
|
1999-11-30 08:07:38 -08:00
|
|
|
| Pcty_fun of label * core_type * class_type
|
1998-06-24 12:22:26 -07:00
|
|
|
|
2012-05-30 07:52:37 -07:00
|
|
|
and class_signature = {
|
2012-12-10 05:15:22 -08:00
|
|
|
pcsig_self: core_type;
|
|
|
|
pcsig_fields: class_type_field list;
|
|
|
|
pcsig_loc: Location.t;
|
2012-05-30 07:52:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
and class_type_field = {
|
2012-12-10 05:15:22 -08:00
|
|
|
pctf_desc: class_type_field_desc;
|
|
|
|
pctf_loc: Location.t;
|
2012-05-30 07:52:37 -07:00
|
|
|
}
|
1998-06-24 12:22:26 -07:00
|
|
|
|
2012-05-30 07:52:37 -07:00
|
|
|
and class_type_field_desc =
|
1998-06-24 12:22:26 -07:00
|
|
|
Pctf_inher of class_type
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pctf_val of (string * mutable_flag * virtual_flag * core_type)
|
|
|
|
| Pctf_virt of (string * private_flag * core_type)
|
|
|
|
| Pctf_meth of (string * private_flag * core_type)
|
|
|
|
| Pctf_cstr of (core_type * core_type)
|
1998-06-24 12:22:26 -07:00
|
|
|
|
|
|
|
and class_description = class_type class_infos
|
|
|
|
|
|
|
|
and class_type_declaration = class_type class_infos
|
|
|
|
|
|
|
|
(* Value expressions for the class language *)
|
|
|
|
|
|
|
|
and class_expr =
|
|
|
|
{ pcl_desc: class_expr_desc;
|
1996-04-22 04:15:41 -07:00
|
|
|
pcl_loc: Location.t }
|
|
|
|
|
1998-06-24 12:22:26 -07:00
|
|
|
and class_expr_desc =
|
2012-05-30 07:52:37 -07:00
|
|
|
Pcl_constr of Longident.t loc * core_type list
|
1998-06-24 12:22:26 -07:00
|
|
|
| Pcl_structure of class_structure
|
1999-11-30 08:07:38 -08:00
|
|
|
| Pcl_fun of label * expression option * pattern * class_expr
|
|
|
|
| Pcl_apply of class_expr * (label * expression) list
|
1998-06-24 12:22:26 -07:00
|
|
|
| Pcl_let of rec_flag * (pattern * expression) list * class_expr
|
|
|
|
| Pcl_constraint of class_expr * class_type
|
|
|
|
|
2012-05-30 07:52:37 -07:00
|
|
|
and class_structure = {
|
2012-12-10 05:15:22 -08:00
|
|
|
pcstr_pat: pattern;
|
|
|
|
pcstr_fields: class_field list;
|
2012-05-30 07:52:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
and class_field = {
|
2012-12-10 05:15:22 -08:00
|
|
|
pcf_desc: class_field_desc;
|
|
|
|
pcf_loc: Location.t;
|
2012-05-30 07:52:37 -07:00
|
|
|
}
|
1998-06-24 12:22:26 -07:00
|
|
|
|
2012-05-30 07:52:37 -07:00
|
|
|
and class_field_desc =
|
2010-04-07 20:58:41 -07:00
|
|
|
Pcf_inher of override_flag * class_expr * string option
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pcf_valvirt of (string loc * mutable_flag * core_type)
|
|
|
|
| Pcf_val of (string loc * mutable_flag * override_flag * expression)
|
2012-12-08 12:55:42 -08:00
|
|
|
| Pcf_virt of (string loc * private_flag * core_type)
|
|
|
|
| Pcf_meth of (string loc * private_flag * override_flag * expression)
|
2012-12-10 05:15:22 -08:00
|
|
|
| Pcf_constr of (core_type * core_type)
|
|
|
|
| Pcf_init of expression
|
1998-06-24 12:22:26 -07:00
|
|
|
|
|
|
|
and class_declaration = class_expr class_infos
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Type expressions for the module language *)
|
|
|
|
|
1998-02-26 04:54:44 -08:00
|
|
|
and module_type =
|
1995-05-04 03:15:53 -07:00
|
|
|
{ pmty_desc: module_type_desc;
|
|
|
|
pmty_loc: Location.t }
|
|
|
|
|
|
|
|
and module_type_desc =
|
2012-05-30 07:52:37 -07:00
|
|
|
Pmty_ident of Longident.t loc
|
1995-05-04 03:15:53 -07:00
|
|
|
| Pmty_signature of signature
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pmty_functor of string loc * module_type * module_type
|
|
|
|
| Pmty_with of module_type * (Longident.t loc * with_constraint) list
|
2010-04-02 05:53:33 -07:00
|
|
|
| Pmty_typeof of module_expr
|
2013-03-04 06:11:15 -08:00
|
|
|
| Pmty_attribute of (module_type * attribute)
|
|
|
|
| Pmty_extension of extension
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
and signature = signature_item list
|
|
|
|
|
|
|
|
and signature_item =
|
1995-10-05 08:18:49 -07:00
|
|
|
{ psig_desc: signature_item_desc;
|
|
|
|
psig_loc: Location.t }
|
|
|
|
|
|
|
|
and signature_item_desc =
|
2012-05-30 07:52:37 -07:00
|
|
|
Psig_value of string loc * value_description
|
|
|
|
| Psig_type of (string loc * type_declaration) list
|
|
|
|
| Psig_exception of string loc * exception_declaration
|
|
|
|
| Psig_module of string loc * module_type
|
|
|
|
| Psig_recmodule of (string loc * module_type) list
|
|
|
|
| Psig_modtype of string loc * modtype_declaration
|
|
|
|
| Psig_open of Longident.t loc
|
1995-05-04 03:15:53 -07:00
|
|
|
| Psig_include of module_type
|
1998-06-24 12:22:26 -07:00
|
|
|
| Psig_class of class_description list
|
|
|
|
| Psig_class_type of class_type_declaration list
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
and modtype_declaration =
|
|
|
|
Pmodtype_abstract
|
|
|
|
| Pmodtype_manifest of module_type
|
|
|
|
|
1995-10-01 06:39:43 -07:00
|
|
|
and with_constraint =
|
|
|
|
Pwith_type of type_declaration
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pwith_module of Longident.t loc
|
2010-04-17 07:45:12 -07:00
|
|
|
| Pwith_typesubst of type_declaration
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pwith_modsubst of Longident.t loc
|
1995-10-01 06:39:43 -07:00
|
|
|
|
2011-10-28 14:26:01 -07:00
|
|
|
(* Value expressions for the module language *)
|
1995-05-04 03:15:53 -07:00
|
|
|
|
1998-02-26 04:54:44 -08:00
|
|
|
and module_expr =
|
1995-05-04 03:15:53 -07:00
|
|
|
{ pmod_desc: module_expr_desc;
|
|
|
|
pmod_loc: Location.t }
|
|
|
|
|
|
|
|
and module_expr_desc =
|
2012-05-30 07:52:37 -07:00
|
|
|
Pmod_ident of Longident.t loc
|
1995-05-04 03:15:53 -07:00
|
|
|
| Pmod_structure of structure
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pmod_functor of string loc * module_type * module_expr
|
1995-05-04 03:15:53 -07:00
|
|
|
| Pmod_apply of module_expr * module_expr
|
|
|
|
| Pmod_constraint of module_expr * module_type
|
2010-10-21 16:59:33 -07:00
|
|
|
| Pmod_unpack of expression
|
2013-03-04 04:54:57 -08:00
|
|
|
| Pmod_attribute of (module_expr * attribute)
|
|
|
|
| Pmod_extension of extension
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
and structure = structure_item list
|
|
|
|
|
|
|
|
and structure_item =
|
1995-10-05 08:18:49 -07:00
|
|
|
{ pstr_desc: structure_item_desc;
|
|
|
|
pstr_loc: Location.t }
|
|
|
|
|
|
|
|
and structure_item_desc =
|
1995-05-04 03:15:53 -07:00
|
|
|
Pstr_eval of expression
|
|
|
|
| Pstr_value of rec_flag * (pattern * expression) list
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pstr_primitive of string loc * value_description
|
|
|
|
| Pstr_type of (string loc * type_declaration) list
|
|
|
|
| Pstr_exception of string loc * exception_declaration
|
|
|
|
| Pstr_exn_rebind of string loc * Longident.t loc
|
|
|
|
| Pstr_module of string loc * module_expr
|
|
|
|
| Pstr_recmodule of (string loc * module_type * module_expr) list
|
|
|
|
| Pstr_modtype of string loc * module_type
|
2013-03-04 04:54:57 -08:00
|
|
|
| Pstr_open of Longident.t loc * attribute list
|
1998-06-24 12:22:26 -07:00
|
|
|
| Pstr_class of class_declaration list
|
|
|
|
| Pstr_class_type of class_type_declaration list
|
2013-03-04 04:54:57 -08:00
|
|
|
| Pstr_include of module_expr * attribute list
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
(* Toplevel phrases *)
|
|
|
|
|
|
|
|
type toplevel_phrase =
|
|
|
|
Ptop_def of structure
|
|
|
|
| Ptop_dir of string * directive_argument
|
|
|
|
|
|
|
|
and directive_argument =
|
|
|
|
Pdir_none
|
|
|
|
| Pdir_string of string
|
|
|
|
| Pdir_int of int
|
|
|
|
| Pdir_ident of Longident.t
|
1999-12-03 02:26:08 -08:00
|
|
|
| Pdir_bool of bool
|