package catala
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=c41cbc1fa003e167bbc0bb1cd7723ab3
sha512=1e07951e2d73040bc0bea89f04bcb50c3a533323a7c7d8bac9ee9aa6be5233f795a32857421d04f17e52a841057cdc78b33f79fa239a17dd12de97a738c81999
doc/desugared.html
Desugared representation
This representation is the second in the compilation chain (see Architecture). Its main difference with the surface representation is that the legislative text has been discarded and all the definitions of each variables have been collected in the same place rather than being scattered across the code base.
The module describing the abstract syntax tree is:
Desugared.AstAbstract syntax tree of the desugared representation
Desugaring proceeds in three main steps:
- Name resolution (
Name_resolution.form_context) - Conversion to the
DesugaredAST, including dependency checks - Disambiguation (resolution of constructors to their enums, etc.)
- de-tuplification of function calls and injection of implicit position arguments
Name resolution and translation
The desugaring consists of translating Surface.Ast to Desugared.Ast of the desugared representation. The translation is implemented in Desugared.From_surface, but it relies on a helper module to perform the name resolution: Desugared.Name_resolution. Indeed, in Surface.Ast, the variables identifiers are just string, whereas in Desugared.Ast they have been turned into well-categorized types with an unique identifier like Shared_ast.ScopeName.t.
Relevant modules:
Desugared.Name_resolutionBuilds a context that allows for mapping each name to a precise uid, taking lexical scopes into accountDesugared.From_surfaceTranslation fromSurface.AsttoDesugared.Ast.
Towards the scope language
Before the translation to the scope language, Desugared.Dependency checks that within a scope, there is no computational circular dependency between the variables of the scope. When the dependency graph is a DAG, Scopelang.From_desugared performs a topological ordering to produce an ordered list of the scope definitions compatible with the computation order. All the graph computations are done using the Ocamlgraph library.
Related modules:
Desugared.DependencyScope dependencies computations using OCamlgraphDesugared.DisambiguateThis module does local typing in order to fill some missing type information in the AST: