package catala

  1. Overview
  2. Docs

Translation from Surface.Ast to Desugaring.Ast.

  • Removes syntactic sugars
  • Separate code from legislation
module Pos = Utils.Pos
module Errors = Utils.Errors
module Cli = Utils.Cli

Translating expressions

val translate_op_kind : Ast.op_kind -> Dcalc.Ast.op_kind
val translate_binop : Ast.binop -> Dcalc.Ast.binop
val translate_unop : Ast.unop -> Dcalc.Ast.unop

The two modules below help performing operations on map with the Bindlib.box. Indeed, Catala uses the Bindlib library to represent bound variables in the AST. In this translation, bound variables are used to represent function parameters or pattern macthing bindings.

module LiftStructFieldMap : sig ... end
module LiftEnumConstructorMap : sig ... end

Usage: translate_expr scope ctxt expr

Translates expr into its desugared equivalent. scope is used to disambiguate the scope and subscopes variables than occur in the expresion

Translating scope definitions

val merge_conditions : Scopelang.Ast.expr Pos.marked Bindlib.box option -> Scopelang.Ast.expr Pos.marked Bindlib.box option -> Pos.t -> Scopelang.Ast.expr Pos.marked Bindlib.box

A scope use can be annotated with a pervasive precondition, in which case this precondition has to be appended to the justifications of each definition in the subscope use. This is what this function does.

Wrapper around process_default that performs some name disambiguation

Translates a Surface.Ast.rule from the surface language

Translates a surface definition, rule or assertion

Translating top-level items

Translates a surface scope use, which is a bunch of definitions

Main function of this module

OCaml

Innovation. Community. Security.