package catala

  1. Overview
  2. Docs

Abstract syntax tree of the scope language

Identifiers

module ScopeName = Dcalc.Ast.ScopeName
module ScopeNameSet : Stdlib.Set.S with type elt = ScopeName.t
module ScopeMap : Stdlib.Map.S with type key = ScopeName.t
module SubScopeNameSet : Stdlib.Set.S with type elt = SubScopeName.t
module SubScopeMap : Stdlib.Map.S with type key = SubScopeName.t
module ScopeVarSet : Stdlib.Set.S with type elt = ScopeVar.t
module ScopeVarMap : Stdlib.Map.S with type key = ScopeVar.t
module StructName = Dcalc.Ast.StructName
module StructMap = Dcalc.Ast.StructMap
module StructFieldName = Dcalc.Ast.StructFieldName
module StructFieldMap : Stdlib.Map.S with type key = StructFieldName.t
module EnumName = Dcalc.Ast.EnumName
module EnumMap = Dcalc.Ast.EnumMap
module EnumConstructor = Dcalc.Ast.EnumConstructor
module EnumConstructorMap : Stdlib.Map.S with type key = EnumConstructor.t
module LocationSet : Stdlib.Set.S with type elt = location Utils.Pos.marked

Abstract syntax tree

type typ =
  1. | TLit of Dcalc.Ast.typ_lit
  2. | TStruct of StructName.t
  3. | TEnum of EnumName.t
  4. | TArrow of typ Utils.Pos.marked * typ Utils.Pos.marked
  5. | TArray of typ
  6. | TAny
type expr =
  1. | ELocation of location
  2. | EVar of expr Bindlib.var Utils.Pos.marked
  3. | EStruct of StructName.t * expr Utils.Pos.marked StructFieldMap.t
  4. | EStructAccess of expr Utils.Pos.marked * StructFieldName.t * StructName.t
  5. | EEnumInj of expr Utils.Pos.marked * EnumConstructor.t * EnumName.t
  6. | EMatch of expr Utils.Pos.marked * EnumName.t * expr Utils.Pos.marked EnumConstructorMap.t
  7. | ELit of Dcalc.Ast.lit
  8. | EAbs of Utils.Pos.t * (expr, expr Utils.Pos.marked) Bindlib.mbinder * typ Utils.Pos.marked list
  9. | EApp of expr Utils.Pos.marked * expr Utils.Pos.marked list
  10. | EOp of Dcalc.Ast.operator
  11. | EDefault of expr Utils.Pos.marked list * expr Utils.Pos.marked * expr Utils.Pos.marked
  12. | EIfThenElse of expr Utils.Pos.marked * expr Utils.Pos.marked * expr Utils.Pos.marked
  13. | EArray of expr Utils.Pos.marked list

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

val locations_used : expr Utils.Pos.marked -> LocationSet.t
type scope_decl = {
  1. scope_decl_name : ScopeName.t;
  2. scope_sig : typ Utils.Pos.marked ScopeVarMap.t;
  3. scope_decl_rules : rule list;
}
type struct_ctx = (StructFieldName.t * typ Utils.Pos.marked) list StructMap.t
type enum_ctx = (EnumConstructor.t * typ Utils.Pos.marked) list EnumMap.t
type program = {
  1. program_scopes : scope_decl ScopeMap.t;
  2. program_enums : enum_ctx;
  3. program_structs : struct_ctx;
}

Variable helpers

module Var : sig ... end
module VarMap : Stdlib.Map.S with type key = Var.t
type vars = expr Bindlib.mvar
val make_var : Var.t Utils.Pos.marked -> expr Utils.Pos.marked Bindlib.box
val make_abs : vars -> expr Utils.Pos.marked Bindlib.box -> Utils.Pos.t -> typ Utils.Pos.marked list -> Utils.Pos.t -> expr Utils.Pos.marked Bindlib.box
val make_app : expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box list -> Utils.Pos.t -> expr Utils.Pos.marked Bindlib.box
val make_let_in : Var.t -> typ Utils.Pos.marked -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box
OCaml

Innovation. Community. Security.