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.Ast
Abstract syntax tree of the desugared representationDesugaring proceeds in three main steps:
Name_resolution.form_context
)Desugared
AST, including dependency checksThe 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_resolution
Builds a context that allows for mapping each name to a precise uid, taking lexical scopes into accountDesugared.From_surface
Translation from Surface.Ast
to Desugared.Ast
.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.Dependency
Scope dependencies computations using OCamlgraphDesugared.Disambiguate
This module does local typing in order to fill some missing type information in the AST: