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