1Parsetree(3)                     OCaml library                    Parsetree(3)
2
3
4

NAME

6       Parsetree - Abstract syntax tree produced by parsing
7

Module

9       Module   Parsetree
10

Documentation

12       Module Parsetree
13        : sig end
14
15
16       Abstract syntax tree produced by parsing
17
18
19
20
21
22       type constant =
23        | Pconst_integer of string * char option
24        | Pconst_char of char
25        | Pconst_string of string * string option
26        | Pconst_float of string * char option
27
28
29
30
31
32
33       === Extension points ===
34
35
36       type attribute = string Asttypes.loc * payload
37
38
39
40
41       type extension = string Asttypes.loc * payload
42
43
44
45
46       type attributes = attribute list
47
48
49
50
51       type payload =
52        | PStr of structure
53        | PSig of signature
54        | PTyp of core_type
55        | PPat of pattern * expression option
56
57
58
59
60
61
62       === Core language ===
63
64
65       type core_type = {
66        ptyp_desc : core_type_desc ;
67        ptyp_loc : Location.t ;
68        ptyp_attributes : attributes ;
69        }
70
71
72
73
74       type core_type_desc =
75        | Ptyp_any
76        | Ptyp_var of string
77        | Ptyp_arrow of Asttypes.arg_label * core_type * core_type
78        | Ptyp_tuple of core_type list
79        | Ptyp_constr of Longident.t Asttypes.loc * core_type list
80        | Ptyp_object of object_field list * Asttypes.closed_flag
81        | Ptyp_class of Longident.t Asttypes.loc * core_type list
82        | Ptyp_alias of core_type * string
83        |  Ptyp_variant  of  row_field  list  *  Asttypes.closed_flag  *  Ast‐
84       types.label list option
85        | Ptyp_poly of string Asttypes.loc list * core_type
86        | Ptyp_package of package_type
87        | Ptyp_extension of extension
88
89
90
91
92       type  package_type  =  Longident.t  Asttypes.loc  *  (Longident.t  Ast‐
93       types.loc * core_type) list
94
95
96
97
98       type row_field =
99        |  Rtag of Asttypes.label Asttypes.loc * attributes * bool * core_type
100       list
101        | Rinherit of core_type
102
103
104
105
106       type object_field =
107        | Otag of Asttypes.label Asttypes.loc * attributes * core_type
108        | Oinherit of core_type
109
110
111
112
113       type pattern = {
114        ppat_desc : pattern_desc ;
115        ppat_loc : Location.t ;
116        ppat_attributes : attributes ;
117        }
118
119
120
121
122       type pattern_desc =
123        | Ppat_any
124        | Ppat_var of string Asttypes.loc
125        | Ppat_alias of pattern * string Asttypes.loc
126        | Ppat_constant of constant
127        | Ppat_interval of constant * constant
128        | Ppat_tuple of pattern list
129        | Ppat_construct of Longident.t Asttypes.loc * pattern option
130        | Ppat_variant of Asttypes.label * pattern option
131        | Ppat_record of (Longident.t Asttypes.loc  *  pattern)  list  *  Ast‐
132       types.closed_flag
133        | Ppat_array of pattern list
134        | Ppat_or of pattern * pattern
135        | Ppat_constraint of pattern * core_type
136        | Ppat_type of Longident.t Asttypes.loc
137        | Ppat_lazy of pattern
138        | Ppat_unpack of string Asttypes.loc
139        | Ppat_exception of pattern
140        | Ppat_extension of extension
141        | Ppat_open of Longident.t Asttypes.loc * pattern
142
143
144
145
146       type expression = {
147        pexp_desc : expression_desc ;
148        pexp_loc : Location.t ;
149        pexp_attributes : attributes ;
150        }
151
152
153
154
155       type expression_desc =
156        | Pexp_ident of Longident.t Asttypes.loc
157        | Pexp_constant of constant
158        | Pexp_let of Asttypes.rec_flag * value_binding list * expression
159        | Pexp_function of case list
160        |  Pexp_fun  of  Asttypes.arg_label  *  expression  option * pattern *
161       expression
162        | Pexp_apply of expression * (Asttypes.arg_label * expression) list
163        | Pexp_match of expression * case list
164        | Pexp_try of expression * case list
165        | Pexp_tuple of expression list
166        | Pexp_construct of Longident.t Asttypes.loc * expression option
167        | Pexp_variant of Asttypes.label * expression option
168        | Pexp_record  of  (Longident.t  Asttypes.loc  *  expression)  list  *
169       expression option
170        | Pexp_field of expression * Longident.t Asttypes.loc
171        | Pexp_setfield of expression * Longident.t Asttypes.loc * expression
172        | Pexp_array of expression list
173        | Pexp_ifthenelse of expression * expression * expression option
174        | Pexp_sequence of expression * expression
175        | Pexp_while of expression * expression
176        |  Pexp_for  of  pattern  *  expression * expression * Asttypes.direc‐
177       tion_flag * expression
178        | Pexp_constraint of expression * core_type
179        | Pexp_coerce of expression * core_type option * core_type
180        | Pexp_send of expression * Asttypes.label Asttypes.loc
181        | Pexp_new of Longident.t Asttypes.loc
182        | Pexp_setinstvar of Asttypes.label Asttypes.loc * expression
183        | Pexp_override of (Asttypes.label Asttypes.loc * expression) list
184        | Pexp_letmodule of string Asttypes.loc * module_expr * expression
185        | Pexp_letexception of extension_constructor * expression
186        | Pexp_assert of expression
187        | Pexp_lazy of expression
188        | Pexp_poly of expression * core_type option
189        | Pexp_object of class_structure
190        | Pexp_newtype of string Asttypes.loc * expression
191        | Pexp_pack of module_expr
192        | Pexp_open of Asttypes.override_flag  *  Longident.t  Asttypes.loc  *
193       expression
194        | Pexp_extension of extension
195        | Pexp_unreachable
196
197
198
199
200       type case = {
201        pc_lhs : pattern ;
202        pc_guard : expression option ;
203        pc_rhs : expression ;
204        }
205
206
207
208
209       type value_description = {
210        pval_name : string Asttypes.loc ;
211        pval_type : core_type ;
212        pval_prim : string list ;
213        pval_attributes : attributes ;
214        pval_loc : Location.t ;
215        }
216
217
218
219
220       type type_declaration = {
221        ptype_name : string Asttypes.loc ;
222        ptype_params : (core_type * Asttypes.variance) list ;
223        ptype_cstrs : (core_type * core_type * Location.t) list ;
224        ptype_kind : type_kind ;
225        ptype_private : Asttypes.private_flag ;
226        ptype_manifest : core_type option ;
227        ptype_attributes : attributes ;
228        ptype_loc : Location.t ;
229        }
230
231
232
233
234       type type_kind =
235        | Ptype_abstract
236        | Ptype_variant of constructor_declaration list
237        | Ptype_record of label_declaration list
238        | Ptype_open
239
240
241
242
243       type label_declaration = {
244        pld_name : string Asttypes.loc ;
245        pld_mutable : Asttypes.mutable_flag ;
246        pld_type : core_type ;
247        pld_loc : Location.t ;
248        pld_attributes : attributes ;
249        }
250
251
252
253
254       type constructor_declaration = {
255        pcd_name : string Asttypes.loc ;
256        pcd_args : constructor_arguments ;
257        pcd_res : core_type option ;
258        pcd_loc : Location.t ;
259        pcd_attributes : attributes ;
260        }
261
262
263
264
265       type constructor_arguments =
266        | Pcstr_tuple of core_type list
267        | Pcstr_record of label_declaration list
268
269
270
271
272       type type_extension = {
273        ptyext_path : Longident.t Asttypes.loc ;
274        ptyext_params : (core_type * Asttypes.variance) list ;
275        ptyext_constructors : extension_constructor list ;
276        ptyext_private : Asttypes.private_flag ;
277        ptyext_attributes : attributes ;
278        }
279
280
281
282
283       type extension_constructor = {
284        pext_name : string Asttypes.loc ;
285        pext_kind : extension_constructor_kind ;
286        pext_loc : Location.t ;
287        pext_attributes : attributes ;
288        }
289
290
291
292
293       type extension_constructor_kind =
294        | Pext_decl of constructor_arguments * core_type option
295        | Pext_rebind of Longident.t Asttypes.loc
296
297
298
299
300
301
302       === Class language ===
303
304
305       type class_type = {
306        pcty_desc : class_type_desc ;
307        pcty_loc : Location.t ;
308        pcty_attributes : attributes ;
309        }
310
311
312
313
314       type class_type_desc =
315        | Pcty_constr of Longident.t Asttypes.loc * core_type list
316        | Pcty_signature of class_signature
317        | Pcty_arrow of Asttypes.arg_label * core_type * class_type
318        | Pcty_extension of extension
319        |  Pcty_open  of  Asttypes.override_flag  * Longident.t Asttypes.loc *
320       class_type
321
322
323
324
325       type class_signature = {
326        pcsig_self : core_type ;
327        pcsig_fields : class_type_field list ;
328        }
329
330
331
332
333       type class_type_field = {
334        pctf_desc : class_type_field_desc ;
335        pctf_loc : Location.t ;
336        pctf_attributes : attributes ;
337        }
338
339
340
341
342       type class_type_field_desc =
343        | Pctf_inherit of class_type
344        | Pctf_val of (Asttypes.label Asttypes.loc *  Asttypes.mutable_flag  *
345       Asttypes.virtual_flag * core_type)
346        |  Pctf_method of (Asttypes.label Asttypes.loc * Asttypes.private_flag
347       * Asttypes.virtual_flag * core_type)
348        | Pctf_constraint of (core_type * core_type)
349        | Pctf_attribute of attribute
350        | Pctf_extension of extension
351
352
353
354
355       type 'a class_infos = {
356        pci_virt : Asttypes.virtual_flag ;
357        pci_params : (core_type * Asttypes.variance) list ;
358        pci_name : string Asttypes.loc ;
359        pci_expr : 'a ;
360        pci_loc : Location.t ;
361        pci_attributes : attributes ;
362        }
363
364
365
366
367       type class_description = class_type class_infos
368
369
370
371
372       type class_type_declaration = class_type class_infos
373
374
375
376
377       type class_expr = {
378        pcl_desc : class_expr_desc ;
379        pcl_loc : Location.t ;
380        pcl_attributes : attributes ;
381        }
382
383
384
385
386       type class_expr_desc =
387        | Pcl_constr of Longident.t Asttypes.loc * core_type list
388        | Pcl_structure of class_structure
389        | Pcl_fun of  Asttypes.arg_label  *  expression  option  *  pattern  *
390       class_expr
391        | Pcl_apply of class_expr * (Asttypes.arg_label * expression) list
392        | Pcl_let of Asttypes.rec_flag * value_binding list * class_expr
393        | Pcl_constraint of class_expr * class_type
394        | Pcl_extension of extension
395        |  Pcl_open  of  Asttypes.override_flag  *  Longident.t Asttypes.loc *
396       class_expr
397
398
399
400
401       type class_structure = {
402        pcstr_self : pattern ;
403        pcstr_fields : class_field list ;
404        }
405
406
407
408
409       type class_field = {
410        pcf_desc : class_field_desc ;
411        pcf_loc : Location.t ;
412        pcf_attributes : attributes ;
413        }
414
415
416
417
418       type class_field_desc =
419        | Pcf_inherit of Asttypes.override_flag *  class_expr  *  string  Ast‐
420       types.loc option
421        |  Pcf_val  of  (Asttypes.label Asttypes.loc * Asttypes.mutable_flag *
422       class_field_kind)
423        | Pcf_method of (Asttypes.label Asttypes.loc * Asttypes.private_flag *
424       class_field_kind)
425        | Pcf_constraint of (core_type * core_type)
426        | Pcf_initializer of expression
427        | Pcf_attribute of attribute
428        | Pcf_extension of extension
429
430
431
432
433       type class_field_kind =
434        | Cfk_virtual of core_type
435        | Cfk_concrete of Asttypes.override_flag * expression
436
437
438
439
440       type class_declaration = class_expr class_infos
441
442
443
444
445
446
447       === Module language ===
448
449
450       type module_type = {
451        pmty_desc : module_type_desc ;
452        pmty_loc : Location.t ;
453        pmty_attributes : attributes ;
454        }
455
456
457
458
459       type module_type_desc =
460        | Pmty_ident of Longident.t Asttypes.loc
461        | Pmty_signature of signature
462        |  Pmty_functor  of  string  Asttypes.loc  * module_type option * mod‐
463       ule_type
464        | Pmty_with of module_type * with_constraint list
465        | Pmty_typeof of module_expr
466        | Pmty_extension of extension
467        | Pmty_alias of Longident.t Asttypes.loc
468
469
470
471
472       type signature = signature_item list
473
474
475
476
477       type signature_item = {
478        psig_desc : signature_item_desc ;
479        psig_loc : Location.t ;
480        }
481
482
483
484
485       type signature_item_desc =
486        | Psig_value of value_description
487        | Psig_type of Asttypes.rec_flag * type_declaration list
488        | Psig_typext of type_extension
489        | Psig_exception of extension_constructor
490        | Psig_module of module_declaration
491        | Psig_recmodule of module_declaration list
492        | Psig_modtype of module_type_declaration
493        | Psig_open of open_description
494        | Psig_include of include_description
495        | Psig_class of class_description list
496        | Psig_class_type of class_type_declaration list
497        | Psig_attribute of attribute
498        | Psig_extension of extension * attributes
499
500
501
502
503       type module_declaration = {
504        pmd_name : string Asttypes.loc ;
505        pmd_type : module_type ;
506        pmd_attributes : attributes ;
507        pmd_loc : Location.t ;
508        }
509
510
511
512
513       type module_type_declaration = {
514        pmtd_name : string Asttypes.loc ;
515        pmtd_type : module_type option ;
516        pmtd_attributes : attributes ;
517        pmtd_loc : Location.t ;
518        }
519
520
521
522
523       type open_description = {
524        popen_lid : Longident.t Asttypes.loc ;
525        popen_override : Asttypes.override_flag ;
526        popen_loc : Location.t ;
527        popen_attributes : attributes ;
528        }
529
530
531
532
533       type 'a include_infos = {
534        pincl_mod : 'a ;
535        pincl_loc : Location.t ;
536        pincl_attributes : attributes ;
537        }
538
539
540
541
542       type include_description = module_type include_infos
543
544
545
546
547       type include_declaration = module_expr include_infos
548
549
550
551
552       type with_constraint =
553        | Pwith_type of Longident.t Asttypes.loc * type_declaration
554        | Pwith_module of Longident.t Asttypes.loc * Longident.t Asttypes.loc
555        | Pwith_typesubst of Longident.t Asttypes.loc * type_declaration
556        |  Pwith_modsubst  of  Longident.t  Asttypes.loc  *  Longident.t  Ast‐
557       types.loc
558
559
560
561
562       type module_expr = {
563        pmod_desc : module_expr_desc ;
564        pmod_loc : Location.t ;
565        pmod_attributes : attributes ;
566        }
567
568
569
570
571       type module_expr_desc =
572        | Pmod_ident of Longident.t Asttypes.loc
573        | Pmod_structure of structure
574        |  Pmod_functor  of  string  Asttypes.loc  * module_type option * mod‐
575       ule_expr
576        | Pmod_apply of module_expr * module_expr
577        | Pmod_constraint of module_expr * module_type
578        | Pmod_unpack of expression
579        | Pmod_extension of extension
580
581
582
583
584       type structure = structure_item list
585
586
587
588
589       type structure_item = {
590        pstr_desc : structure_item_desc ;
591        pstr_loc : Location.t ;
592        }
593
594
595
596
597       type structure_item_desc =
598        | Pstr_eval of expression * attributes
599        | Pstr_value of Asttypes.rec_flag * value_binding list
600        | Pstr_primitive of value_description
601        | Pstr_type of Asttypes.rec_flag * type_declaration list
602        | Pstr_typext of type_extension
603        | Pstr_exception of extension_constructor
604        | Pstr_module of module_binding
605        | Pstr_recmodule of module_binding list
606        | Pstr_modtype of module_type_declaration
607        | Pstr_open of open_description
608        | Pstr_class of class_declaration list
609        | Pstr_class_type of class_type_declaration list
610        | Pstr_include of include_declaration
611        | Pstr_attribute of attribute
612        | Pstr_extension of extension * attributes
613
614
615
616
617       type value_binding = {
618        pvb_pat : pattern ;
619        pvb_expr : expression ;
620        pvb_attributes : attributes ;
621        pvb_loc : Location.t ;
622        }
623
624
625
626
627       type module_binding = {
628        pmb_name : string Asttypes.loc ;
629        pmb_expr : module_expr ;
630        pmb_attributes : attributes ;
631        pmb_loc : Location.t ;
632        }
633
634
635
636
637
638
639       === Toplevel ===
640
641
642       type toplevel_phrase =
643        | Ptop_def of structure
644        | Ptop_dir of string * directive_argument
645
646
647
648
649       type directive_argument =
650        | Pdir_none
651        | Pdir_string of string
652        | Pdir_int of string * char option
653        | Pdir_ident of Longident.t
654        | Pdir_bool of bool
655
656
657
658
659
660
661
662OCamldoc                          2019-02-02                      Parsetree(3)
Impressum