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-alpha.tar.gz
md5=2615968670ac21b1d00386a9b04b3843
sha512=eff292fdd75012f26ce7b17020f5a8374eef37cd4dd6ba60338dfbe89fbcad3443d1b409e44c182b740da9f58dff7e76dcb8ddefe47f9b2b160666d1c6930143

doc/catala_utils.html

Compiler utilities

Unique identifiers

In the desugared representation or in the the scope language, a number of things are named using global identifiers. These identifiers use OCaml's type system to statically distinguish e.g. a scope identifier from a struct identifier.

The Catala_utils.Uid module provides a generative functor whose output is a fresh sort of global identifiers.

Related modules:

Source code positions and attributes

This module is used throughout the compiler to annotate the abstract syntax trees with information about the position of the element in the original source code. These annotations are critical to produce readable error messages.

The positions also include attribute information, as an extensible variant defined in the same module.

Related modules:

Error messages

Error handling is critical in a compiler. The Catala compiler uses an architecture of error messages inspired by the Rust compiler, where error messages all correspond to the same exception. This exception carries messages and positions that are displayed in the end in a nicely-formatted error message.

Hence, all error thrown by the compiler should use Catala_utils.Message

Related modules:

AST marks

Throughout we use values with a "mark", which most often contains position information, or more in the case of AST nodes. Such values are simply pairs payload, mark, but the following module provides some helper to work with them (e.g. to do mark-agnostic comparisons).

Related modules:

Globals

For some global flags, like the debug option, having a global reference is more convenient than passing the information everywhere. This is all gathered in the single global value Global.options (and forbidden in other modules).

Related modules:

  • Catala_utils.Global This module contains definitions of global flags and types used throughout. They should be defined from the command-line and never modified afterwards.

Maps

The Map module is an overlay on the OCaml stdlib Map that provides some extensions and convenience functions.

Note of warning: the Not_found exception is specialised for every instance of the functor. This is useful to automatically report what element was not found, but be careful with catching Stdlib.Not_found, which won't work.

Related modules:

  • Catala_utils.Map Small wrapper on top of the stdlib Map module to add some useful functions

Other utilies

Related modules: