package catala

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

Abstract syntax tree of the desugared representation

Names, Maps and Keys

module IdentMap : Stdlib.Map.S with type key = Stdlib.String.t
module RuleMap : Stdlib.Map.S with type key = RuleName.t
module RuleSet : Stdlib.Set.S with type elt = RuleName.t
module LabelMap : Stdlib.Map.S with type key = LabelName.t
module LabelSet : Stdlib.Set.S with type elt = LabelName.t
module ScopeVarSet : Stdlib.Set.S with type elt = ScopeVar.t
module ScopeVarMap : Stdlib.Map.S with type key = ScopeVar.t
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

module LocationSet : Stdlib.Set.S with type elt = location Utils.Marked.pos
type marked_expr = expr Utils.Marked.pos

The expressions use the Bindlib library, based on higher-order abstract syntax

and expr =
  1. | ELocation of location
  2. | EVar of expr Bindlib.var
  3. | EStruct of Scopelang.Ast.StructName.t * marked_expr Scopelang.Ast.StructFieldMap.t
  4. | EStructAccess of marked_expr * Scopelang.Ast.StructFieldName.t * Scopelang.Ast.StructName.t
  5. | EEnumInj of marked_expr * Scopelang.Ast.EnumConstructor.t * Scopelang.Ast.EnumName.t
  6. | EMatch of marked_expr * Scopelang.Ast.EnumName.t * marked_expr Scopelang.Ast.EnumConstructorMap.t
  7. | ELit of Dcalc.Ast.lit
  8. | EAbs of (expr, marked_expr) Bindlib.mbinder * Scopelang.Ast.typ Utils.Marked.pos list
  9. | EApp of marked_expr * marked_expr list
  10. | EOp of Dcalc.Ast.operator
  11. | EDefault of marked_expr list * marked_expr * marked_expr
  12. | EIfThenElse of marked_expr * marked_expr * marked_expr
  13. | EArray of marked_expr list
  14. | ErrorOnEmpty of marked_expr
module ExprMap : Stdlib.Map.S with type key = expr

Variable helpers

module Var : sig ... end
module VarMap : Stdlib.Map.S with type key = Var.t
type vars = expr Bindlib.mvar

Rules and scopes

type exception_situation =
  1. | BaseCase
  2. | ExceptionToLabel of LabelName.t Utils.Marked.pos
  3. | ExceptionToRule of RuleName.t Utils.Marked.pos
type label_situation =
  1. | ExplicitlyLabeled of LabelName.t Utils.Marked.pos
  2. | Unlabeled
type rule = {
  1. rule_id : RuleName.t;
  2. rule_just : expr Utils.Marked.pos Bindlib.box;
  3. rule_cons : expr Utils.Marked.pos Bindlib.box;
  4. rule_parameter : (Var.t * Scopelang.Ast.typ Utils.Marked.pos) option;
  5. rule_exception : exception_situation;
  6. rule_label : label_situation;
}
module Rule : Stdlib.Set.OrderedType with type t = rule
val empty_rule : Utils.Pos.t -> Scopelang.Ast.typ Utils.Marked.pos option -> rule
val always_false_rule : Utils.Pos.t -> Scopelang.Ast.typ Utils.Marked.pos option -> rule
type variation_typ =
  1. | Increasing
  2. | Decreasing
type reference_typ =
  1. | Decree
  2. | Law
type meta_assertion =
  1. | FixedBy of reference_typ Utils.Marked.pos
  2. | VariesWith of unit * variation_typ Utils.Marked.pos option
type scope_def = {
  1. scope_def_rules : rule RuleMap.t;
  2. scope_def_typ : Scopelang.Ast.typ Utils.Marked.pos;
  3. scope_def_is_condition : bool;
  4. scope_def_io : Scopelang.Ast.io;
}
type var_or_states =
  1. | WholeVar
  2. | States of StateName.t list
type scope = {
  1. scope_vars : var_or_states ScopeVarMap.t;
  2. scope_sub_scopes : Scopelang.Ast.ScopeName.t Scopelang.Ast.SubScopeMap.t;
  3. scope_uid : Scopelang.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 Scopelang.Ast.ScopeMap.t;
  2. program_enums : Scopelang.Ast.enum_ctx;
  3. program_structs : Scopelang.Ast.struct_ctx;
}

Helpers

val locations_used : expr Utils.Marked.pos -> LocationSet.t
val free_variables : rule RuleMap.t -> Utils.Pos.t ScopeDefMap.t