package catala
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=2615968670ac21b1d00386a9b04b3843
sha512=eff292fdd75012f26ce7b17020f5a8374eef37cd4dd6ba60338dfbe89fbcad3443d1b409e44c182b740da9f58dff7e76dcb8ddefe47f9b2b160666d1c6930143
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: