1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the Q Public License version 1.0. *)
11 (***********************************************************************)
15 (* Abstract syntax tree produced by parsing *)
19 (* Type expressions for the core language *)
22 { ptyp_desc
: core_type_desc
;
23 ptyp_loc
: Location.t
}
28 | Ptyp_arrow
of label
* core_type
* core_type
29 | Ptyp_tuple
of core_type list
30 | Ptyp_constr
of Longident.t
* core_type list
31 | Ptyp_object
of core_field_type list
32 | Ptyp_class
of Longident.t
* core_type list
* label list
33 | Ptyp_alias
of core_type
* string
34 | Ptyp_variant
of row_field list
* bool * label list
option
35 | Ptyp_poly
of string list
* core_type
38 { pfield_desc
: core_field_desc
;
39 pfield_loc
: Location.t
}
42 Pfield
of string * core_type
46 Rtag
of label
* bool * core_type list
47 | Rinherit
of core_type
49 (* XXX Type expressions for the class language *)
52 { pci_virt
: virtual_flag
;
53 pci_params
: string list
* Location.t
;
56 pci_variance
: (bool * bool) list
;
59 (* Value expressions for the core language *)
62 { ppat_desc
: pattern_desc
;
63 ppat_loc
: Location.t
}
68 | Ppat_alias
of pattern
* string
69 | Ppat_constant
of constant
70 | Ppat_tuple
of pattern list
71 | Ppat_construct
of Longident.t
* pattern
option * bool
72 | Ppat_variant
of label
* pattern
option
73 | Ppat_record
of (Longident.t
* pattern
) list
74 | Ppat_array
of pattern list
75 | Ppat_or
of pattern
* pattern
76 | Ppat_constraint
of pattern
* core_type
77 | Ppat_type
of Longident.t
80 { pexp_desc
: expression_desc
;
81 pexp_loc
: Location.t
}
84 Pexp_ident
of Longident.t
85 | Pexp_constant
of constant
86 | Pexp_let
of rec_flag
* (pattern
* expression
) list
* expression
87 | Pexp_function
of label
* expression
option * (pattern
* expression
) list
88 | Pexp_apply
of expression
* (label
* expression
) list
89 | Pexp_match
of expression
* (pattern
* expression
) list
90 | Pexp_try
of expression
* (pattern
* expression
) list
91 | Pexp_tuple
of expression list
92 | Pexp_construct
of Longident.t
* expression
option * bool
93 | Pexp_variant
of label
* expression
option
94 | Pexp_record
of (Longident.t
* expression
) list
* expression
option
95 | Pexp_field
of expression
* Longident.t
96 | Pexp_setfield
of expression
* Longident.t
* expression
97 | Pexp_array
of expression list
98 | Pexp_ifthenelse
of expression
* expression
* expression
option
99 | Pexp_sequence
of expression
* expression
100 | Pexp_while
of expression
* expression
101 | Pexp_for
of string * expression
* expression
* direction_flag
* expression
102 | Pexp_constraint
of expression
* core_type
option * core_type
option
103 | Pexp_when
of expression
* expression
104 | Pexp_send
of expression
* string
105 | Pexp_new
of Longident.t
106 | Pexp_setinstvar
of string * expression
107 | Pexp_override
of (string * expression
) list
108 | Pexp_letmodule
of string * module_expr
* expression
109 | Pexp_assert
of expression
111 | Pexp_lazy
of expression
112 | Pexp_poly
of expression
* core_type
option
113 | Pexp_object
of class_structure
115 (* Value descriptions *)
117 and value_description
=
118 { pval_type
: core_type
;
119 pval_prim
: string list
}
121 (* Type declarations *)
123 and type_declaration
=
124 { ptype_params
: string list
;
125 ptype_cstrs
: (core_type
* core_type
* Location.t
) list
;
126 ptype_kind
: type_kind
;
127 ptype_manifest
: core_type
option;
128 ptype_variance
: (bool * bool) list
;
129 ptype_loc
: Location.t
}
133 | Ptype_variant
of (string * core_type list
* Location.t
) list
* private_flag
135 (string * mutable_flag
* core_type
* Location.t
) list
* private_flag
138 and exception_declaration
= core_type list
140 (* Type expressions for the class language *)
143 { pcty_desc
: class_type_desc
;
144 pcty_loc
: Location.t
}
146 and class_type_desc
=
147 Pcty_constr
of Longident.t
* core_type list
148 | Pcty_signature
of class_signature
149 | Pcty_fun
of label
* core_type
* class_type
151 and class_signature
= core_type
* class_type_field list
153 and class_type_field
=
154 Pctf_inher
of class_type
155 | Pctf_val
of (string * mutable_flag
* virtual_flag
* core_type
* Location.t
)
156 | Pctf_virt
of (string * private_flag
* core_type
* Location.t
)
157 | Pctf_meth
of (string * private_flag
* core_type
* Location.t
)
158 | Pctf_cstr
of (core_type
* core_type
* Location.t
)
160 and class_description
= class_type class_infos
162 and class_type_declaration
= class_type class_infos
164 (* Value expressions for the class language *)
167 { pcl_desc
: class_expr_desc
;
168 pcl_loc
: Location.t
}
170 and class_expr_desc
=
171 Pcl_constr
of Longident.t
* core_type list
172 | Pcl_structure
of class_structure
173 | Pcl_fun
of label
* expression
option * pattern
* class_expr
174 | Pcl_apply
of class_expr
* (label
* expression
) list
175 | Pcl_let
of rec_flag
* (pattern
* expression
) list
* class_expr
176 | Pcl_constraint
of class_expr
* class_type
178 and class_structure
= pattern
* class_field list
181 Pcf_inher
of class_expr
* string option
182 | Pcf_valvirt
of (string * mutable_flag
* core_type
* Location.t
)
183 | Pcf_val
of (string * mutable_flag
* expression
* Location.t
)
184 | Pcf_virt
of (string * private_flag
* core_type
* Location.t
)
185 | Pcf_meth
of (string * private_flag
* expression
* Location.t
)
186 | Pcf_cstr
of (core_type
* core_type
* Location.t
)
187 | Pcf_let
of rec_flag
* (pattern
* expression
) list
* Location.t
188 | Pcf_init
of expression
190 and class_declaration
= class_expr class_infos
192 (* Type expressions for the module language *)
195 { pmty_desc
: module_type_desc
;
196 pmty_loc
: Location.t
}
198 and module_type_desc
=
199 Pmty_ident
of Longident.t
200 | Pmty_signature
of signature
201 | Pmty_functor
of string * module_type
* module_type
202 | Pmty_with
of module_type
* (Longident.t
* with_constraint
) list
204 and signature
= signature_item list
207 { psig_desc
: signature_item_desc
;
208 psig_loc
: Location.t
}
210 and signature_item_desc
=
211 Psig_value
of string * value_description
212 | Psig_type
of (string * type_declaration
) list
213 | Psig_exception
of string * exception_declaration
214 | Psig_module
of string * module_type
215 | Psig_recmodule
of (string * module_type
) list
216 | Psig_modtype
of string * modtype_declaration
217 | Psig_open
of Longident.t
218 | Psig_include
of module_type
219 | Psig_class
of class_description list
220 | Psig_class_type
of class_type_declaration list
222 and modtype_declaration
=
224 | Pmodtype_manifest
of module_type
226 and with_constraint
=
227 Pwith_type
of type_declaration
228 | Pwith_module
of Longident.t
230 (* Value expressions for the module language *)
233 { pmod_desc
: module_expr_desc
;
234 pmod_loc
: Location.t
}
236 and module_expr_desc
=
237 Pmod_ident
of Longident.t
238 | Pmod_structure
of structure
239 | Pmod_functor
of string * module_type
* module_expr
240 | Pmod_apply
of module_expr
* module_expr
241 | Pmod_constraint
of module_expr
* module_type
243 and structure
= structure_item list
246 { pstr_desc
: structure_item_desc
;
247 pstr_loc
: Location.t
}
249 and structure_item_desc
=
250 Pstr_eval
of expression
251 | Pstr_value
of rec_flag
* (pattern
* expression
) list
252 | Pstr_primitive
of string * value_description
253 | Pstr_type
of (string * type_declaration
) list
254 | Pstr_exception
of string * exception_declaration
255 | Pstr_exn_rebind
of string * Longident.t
256 | Pstr_module
of string * module_expr
257 | Pstr_recmodule
of (string * module_type
* module_expr
) list
258 | Pstr_modtype
of string * module_type
259 | Pstr_open
of Longident.t
260 | Pstr_class
of class_declaration list
261 | Pstr_class_type
of class_type_declaration list
262 | Pstr_include
of module_expr
264 (* Toplevel phrases *)
266 type toplevel_phrase
=
267 Ptop_def
of structure
268 | Ptop_dir
of string * directive_argument
270 and directive_argument
=
272 | Pdir_string
of string
274 | Pdir_ident
of Longident.t