package catala
Install
Dune Dependency
Authors
Maintainers
Sources
md5=4c6f725ef4d21c5ff91f60d74b454ef7
sha512=98806e03daa6f33740b80a0f78a37320fb70ebea8cb927ea8fed022673459189c32e2389ccba0fa25d93f754b0fa0128a5ee28e1bb9abefa330deb4be8cc7d95
doc/catala.surface/Surface/Desugaring/index.html
Module Surface.Desugaring
Source
Translation from Surface.Ast
to Desugaring.Ast
.
- Removes syntactic sugars
- Separate code from legislation
Translating expressions
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
val translate_expr :
Scopelang.Ast.ScopeName.t ->
Name_resolution.context ->
Ast.expression Pos.marked ->
Scopelang.Ast.expr Scopelang.Ast.Pos.marked Bindlib.box
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.
val process_default :
Name_resolution.context ->
Scopelang.Ast.ScopeName.t ->
Desugared.Ast.ScopeDef.t Pos.marked ->
Scopelang.Ast.Var.t Pos.marked option ->
Scopelang.Ast.expr Pos.marked Bindlib.box option ->
Desugared.Ast.RuleName.t option ->
Ast.expression Pos.marked option ->
Ast.expression Pos.marked ->
Desugared.Ast.rule
Translates a surface definition into condition into a desugared Desugared.Ast.rule
val process_def :
Scopelang.Ast.expr Pos.marked Bindlib.box option ->
Scopelang.Ast.ScopeName.t ->
Name_resolution.context ->
Desugared.Ast.program ->
Ast.definition ->
Desugared.Ast.program
Wrapper around process_default
that performs some name disambiguation
val process_rule :
Scopelang.Ast.expr Pos.marked Bindlib.box option ->
Scopelang.Ast.ScopeName.t ->
Name_resolution.context ->
Desugared.Ast.program ->
Ast.rule ->
Desugared.Ast.program
Translates a Surface.Ast.rule
from the surface language
val process_assert :
Scopelang.Ast.expr Pos.marked Bindlib.box option ->
Scopelang.Ast.ScopeName.t ->
Name_resolution.context ->
Desugared.Ast.program ->
Ast.assertion ->
Desugared.Ast.program
Translates assertions
val process_scope_use_item :
Ast.expression Pos.marked option ->
Scopelang.Ast.ScopeName.t ->
Name_resolution.context ->
Desugared.Ast.program ->
Ast.scope_use_item Pos.marked ->
Desugared.Ast.program
Translates a surface definition, rule or assertion
Translating top-level items
val process_scope_use :
Name_resolution.context ->
Desugared.Ast.program ->
Ast.scope_use ->
Desugared.Ast.program
Translates a surface scope use, which is a bunch of definitions
Main function of this module