package catala

  1. Overview
  2. Docs
Compiler and library for the literate programming language for tax code specification

Install

dune-project
 Dependency

Authors

Maintainers

Sources

1.0.0.tar.gz
md5=42196e9a9c5e12839b38cb3da935f10c
sha512=ede2d8c17dcb936c1c8c596f1453bf89370a2f824a190efe74e438d7d7f7f83875c1ecbc18219c6a8a3e98b3ab4da1c3a6cc4e534687dbc90f3dca8230f43f7b

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.Ast Abstract syntax tree of the desugared representation

Desugaring proceeds in three main steps:

  • Name resolution (Name_resolution.form_context)
  • Conversion to the Desugared AST, 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:

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: