package catala
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=2615968670ac21b1d00386a9b04b3843
sha512=eff292fdd75012f26ce7b17020f5a8374eef37cd4dd6ba60338dfbe89fbcad3443d1b409e44c182b740da9f58dff7e76dcb8ddefe47f9b2b160666d1c6930143
doc/catala.desugared/Desugared/Ast/index.html
Module Desugared.Ast
Source
Abstract syntax tree of the desugared representation
Inside a scope, a definition can refer to a variable (possibly an intermediate state thereof) or an input of a subscope.
module AssertionName :
Catala_utils.Uid.Id with type info = Catala_utils.Uid.MarkedString.info
AST
Expressions
See Shared_ast.naked_gexpr
for the complete definition
Rules and scopes
type exception_situation =
| BaseCase
| ExceptionToLabel of Shared_ast.LabelName.t Catala_utils.Mark.pos
| ExceptionToRule of Shared_ast.RuleName.t Catala_utils.Mark.pos
type label_situation =
| ExplicitlyLabeled of Shared_ast.LabelName.t Catala_utils.Mark.pos
| Unlabeled
type rule = {
rule_id : Shared_ast.RuleName.t;
rule_just : expr Shared_ast.boxed;
rule_cons : expr Shared_ast.boxed;
rule_parameter : (expr Shared_ast.Var.t Catala_utils.Mark.pos * Shared_ast.typ) list Catala_utils.Mark.pos option;
rule_exception : exception_situation;
rule_label : label_situation;
}
val empty_rule :
Catala_utils.Pos.t ->
(Catala_utils.Uid.MarkedString.info * Shared_ast.typ) list
Catala_utils.Mark.pos
option ->
rule
val always_false_rule :
Catala_utils.Pos.t ->
(Catala_utils.Uid.MarkedString.info * Shared_ast.typ) list
Catala_utils.Mark.pos
option ->
rule
type meta_assertion =
| FixedBy of reference_typ Catala_utils.Mark.pos
| VariesWith of unit * variation_typ Catala_utils.Mark.pos option
type io = {
io_output : bool Catala_utils.Mark.pos;
(*
*)true
is present in the output of the scope.io_input : Catala_runtime.io_input Catala_utils.Mark.pos;
}
Characterization of the input/output status of a scope variable.
type scope_def = {
scope_def_rules : rule Shared_ast.RuleName.Map.t;
(*empty outside of the root module
*)scope_def_typ : Shared_ast.typ;
scope_def_parameters : (Catala_utils.Uid.MarkedString.info * Shared_ast.typ) list Catala_utils.Mark.pos option;
scope_def_is_condition : bool;
scope_def_io : io;
}
type scope = {
scope_vars : var_or_states Shared_ast.ScopeVar.Map.t;
scope_sub_scopes : Shared_ast.ScopeName.t Shared_ast.ScopeVar.Map.t;
scope_uid : Shared_ast.ScopeName.t;
scope_defs : scope_def ScopeDef.Map.t;
scope_assertions : assertion AssertionName.Map.t;
(*empty outside of the root module
*)scope_options : catala_option Catala_utils.Mark.pos list;
scope_meta_assertions : meta_assertion list;
scope_visibility : Shared_ast.visibility;
}
type topdef = {
topdef_expr : expr option;
(*Always
*)None
outside of the root moduletopdef_type : Shared_ast.typ;
topdef_arg_names : string Catala_utils.Mark.pos list;
topdef_visibility : Shared_ast.visibility;
(*Necessarily
*)Public
outside of the root moduletopdef_external : bool;
}
type modul = {
module_scopes : scope Shared_ast.ScopeName.Map.t;
module_topdefs : topdef Shared_ast.TopdefName.Map.t;
}
type program = {
program_module_name : (Shared_ast.ModuleName.t * Shared_ast.module_intf_id) option;
program_ctx : Shared_ast.decl_ctx;
program_modules : modul Shared_ast.ModuleName.Map.t;
(*Contains all submodules of the program, in a flattened structure
*)program_root : modul;
program_lang : Catala_utils.Global.backend_lang;
}
Interface hash computations
These hashes are computed on interfaces: only signatures are considered.
Helpers
Usage: fold_exprs ~f ~init program
applies ~f to all the expressions inside rules (justifications and consequences), expressions and top-level definitions of the program. Note that there may be free variables in these expressions.