package catala

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Abstract syntax tree of the desugared representation

module ScopeDef : sig ... end

Inside a scope, a definition can refer either to a scope def, or a subscope def

module ScopeDefMap : Stdlib.Map.S with type key = ScopeDef.t
module ScopeDefSet : Stdlib.Set.S with type elt = ScopeDef.t

AST

Expressions

module LocationSet : Stdlib.Set.S with type elt = location Catala_utils.Marked.pos
module ExprMap : Stdlib.Map.S with type key = expr

Rules and scopes

type exception_situation =
  1. | BaseCase
  2. | ExceptionToLabel of Shared_ast.LabelName.t Catala_utils.Marked.pos
  3. | ExceptionToRule of Shared_ast.RuleName.t Catala_utils.Marked.pos
type label_situation =
  1. | ExplicitlyLabeled of Shared_ast.LabelName.t Catala_utils.Marked.pos
  2. | Unlabeled
type rule = {
  1. rule_id : Shared_ast.RuleName.t;
  2. rule_just : expr Shared_ast.boxed;
  3. rule_cons : expr Shared_ast.boxed;
  4. rule_parameter : (expr Shared_ast.Var.t Catala_utils.Marked.pos * Shared_ast.typ) list Catala_utils.Marked.pos option;
  5. rule_exception : exception_situation;
  6. rule_label : label_situation;
}
module Rule : Stdlib.Set.OrderedType with type t = rule
type assertion = expr Shared_ast.boxed
type variation_typ =
  1. | Increasing
  2. | Decreasing
type reference_typ =
  1. | Decree
  2. | Law
type meta_assertion =
  1. | FixedBy of reference_typ Catala_utils.Marked.pos
  2. | VariesWith of unit * variation_typ Catala_utils.Marked.pos option
type io_input =
  1. | NoInput
    (*

    For an internal variable defined only in the scope, and does not appear in the input.

    *)
  2. | OnlyInput
    (*

    For variables that should not be redefined in the scope, because they appear in the input.

    *)
  3. | Reentrant
    (*

    For variables defined in the scope that can also be redefined by the caller as they appear in the input.

    *)

This type characterizes the three levels of visibility for a given scope variable with regards to the scope's input and possible redefinitions inside the scope..

type io = {
  1. io_output : bool Catala_utils.Marked.pos;
    (*

    true is present in the output of the scope.

    *)
  2. io_input : io_input Catala_utils.Marked.pos;
}

Characterization of the input/output status of a scope variable.

type scope_def = {
  1. scope_def_rules : rule Shared_ast.RuleName.Map.t;
  2. scope_def_typ : Shared_ast.typ;
  3. scope_def_parameters : (Catala_utils.Uid.MarkedString.info * Shared_ast.typ) list Catala_utils.Marked.pos option;
  4. scope_def_is_condition : bool;
  5. scope_def_io : io;
}
type var_or_states =
  1. | WholeVar
  2. | States of Shared_ast.StateName.t list
type scope = {
  1. scope_vars : var_or_states Shared_ast.ScopeVar.Map.t;
  2. scope_sub_scopes : Shared_ast.ScopeName.t Shared_ast.SubScopeName.Map.t;
  3. scope_uid : Shared_ast.ScopeName.t;
  4. scope_defs : scope_def ScopeDefMap.t;
  5. scope_assertions : assertion list;
  6. scope_meta_assertions : meta_assertion list;
}
type program = {
  1. program_scopes : scope Shared_ast.ScopeName.Map.t;
  2. program_topdefs : (expr * Shared_ast.typ) Shared_ast.TopdefName.Map.t;
  3. program_ctx : Shared_ast.decl_ctx;
}

Helpers

val locations_used : expr -> LocationSet.t
val free_variables : rule Shared_ast.RuleName.Map.t -> Catala_utils.Pos.t ScopeDefMap.t