ocaml-base-compiler
  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Abstract syntax tree after typing

By comparison with Parsetree:

  • Every Longindent.t is accompanied by a resolved Path.t.
type partial =
  1. | Partial
  2. | Total

Extension points

type attribute = Parsetree.attribute
type attributes = attribute list

Core language

type value =
  1. | Value_pattern
type computation =
  1. | Computation_pattern
type _ pattern_category =
  1. | Value : value pattern_category
  2. | Computation : computation pattern_category
type pattern = value general_pattern
and 'k general_pattern = 'k pattern_desc pattern_data
and 'a pattern_data = {
  1. pat_desc : 'a;
  2. pat_loc : Location.t;
  3. pat_extra : (pat_extra * Location.t * attributes) list;
  4. pat_type : Types.type_expr;
  5. pat_env : Env.t;
  6. pat_attributes : attributes;
}
and pat_extra =
  1. | Tpat_constraint of core_type
    (*

    P : T pat_desc = P ; pat_extra = (Tpat_constraint T, _, _) :: ...

    *)
  2. | Tpat_type of Path.t * Longident.t Asttypes.loc
    (*

    #tconst pat_desc = disjunction ; pat_extra = (Tpat_type (P, "tconst"), _, _) :: ...

    where disjunction is a Tpat_or _ representing the branches of tconst.

    *)
  3. | Tpat_open of Path.t * Longident.t Asttypes.loc * Env.t
  4. | Tpat_unpack
    (*

    (module P) pat_desc = Tpat_var "P" ; pat_extra = (Tpat_unpack, _, _) :: ...

    *)
and 'k pattern_desc =
  1. | Tpat_any : value pattern_desc
    (*

    _

    *)
  2. | Tpat_var : Ident.t * string Asttypes.loc -> value pattern_desc
    (*

    x

    *)
  3. | Tpat_alias : value general_pattern * Ident.t * string Asttypes.loc -> value pattern_desc
    (*

    P as a

    *)
  4. | Tpat_constant : Asttypes.constant -> value pattern_desc
    (*

    1, 'a', "true", 1.0, 1l, 1L, 1n

    *)
  5. | Tpat_tuple : value general_pattern list -> value pattern_desc
    (*

    (P1, ..., Pn)

    Invariant: n >= 2

    *)
  6. | Tpat_construct : Longident.t Asttypes.loc * Types.constructor_description * value general_pattern list -> value pattern_desc
    (*

    C C P P C (P1, ..., Pn) P1; ...; Pn

    *)
  7. | Tpat_variant : Asttypes.label * value general_pattern option * Types.row_desc ref -> value pattern_desc
    (*

    `A (None) `A P (Some P)

    See Types.row_desc for an explanation of the last parameter.

    *)
  8. | Tpat_record : (Longident.t Asttypes.loc * Types.label_description * value general_pattern) list * Asttypes.closed_flag -> value pattern_desc
    (*

    l1=P1; ...; ln=Pn (flag = Closed) l1=P1; ...; ln=Pn; _ (flag = Open)

    Invariant: n > 0

    *)
  9. | Tpat_array : value general_pattern list -> value pattern_desc
    (*

    | P1; ...; Pn |

    *)
  10. | Tpat_lazy : value general_pattern -> value pattern_desc
    (*

    lazy P

    *)
  11. | Tpat_value : tpat_value_argument -> computation pattern_desc
    (*

    P

    Invariant: Tpat_value pattern should not carry pat_attributes or pat_extra metadata coming from user syntax, which must be on the inner pattern node -- to facilitate searching for a certain value pattern constructor with a specific attributed.

    To enforce this restriction, we made the argument of the Tpat_value constructor a private synonym of pattern, requiring you to use the as_computation_pattern function below instead of using the Tpat_value constructor directly.

    *)
  12. | Tpat_exception : value general_pattern -> computation pattern_desc
    (*

    exception P

    *)
  13. | Tpat_or : 'k general_pattern * 'k general_pattern * Types.row_desc option -> 'k pattern_desc
    (*

    P1 | P2

    row_desc = Some _ when translating Ppat_type _, None otherwise.

    *)
and tpat_value_argument = private value general_pattern
and expression = {
  1. exp_desc : expression_desc;
  2. exp_loc : Location.t;
  3. exp_extra : (exp_extra * Location.t * attributes) list;
  4. exp_type : Types.type_expr;
  5. exp_env : Env.t;
  6. exp_attributes : attributes;
}
and exp_extra =
  1. | Texp_constraint of core_type
    (*

    E : T

    *)
  2. | Texp_coerce of core_type option * core_type
    (*

    E :> T Texp_coerce (None, T) E : T0 :> T Texp_coerce (Some T0, T)

    *)
  3. | Texp_poly of core_type option
    (*

    Used for method bodies.

    *)
  4. <