package catala

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

Install

Dune Dependency

Authors

Maintainers

Sources

0.7.0.tar.gz
md5=6dbbc2f50c23693f26ab6f048e78172f
sha512=a5701e14932d8a866e2aa3731f76df85ff2a68b4fa943fd510c535913573274d66eaec1ae6fcae17f20b475876048a9ab196ef6d8c23d4ea6b90b986aa0a6daa

doc/catala.surface/Surface/Name_resolution/index.html

Module Surface.Name_resolutionSource

Builds a context that allows for mapping each name to a precise uid, taking lexical scopes into account

Name resolution context

Sourcetype ident = string
Sourcetype unique_rulename =
  1. | Ambiguous of Utils.Pos.t list
  2. | Unique of Desugared.Ast.RuleName.t Utils.Marked.pos
Sourcetype scope_def_context = {
  1. default_exception_rulename : unique_rulename option;
  2. label_idmap : Desugared.Ast.LabelName.t Desugared.Ast.IdentMap.t;
}
Sourcetype scope_context = {
  1. var_idmap : Desugared.Ast.ScopeVar.t Desugared.Ast.IdentMap.t;
    (*

    Scope variables

    *)
  2. scope_defs_contexts : scope_def_context Desugared.Ast.ScopeDefMap.t;
    (*

    What is the default rule to refer to for unnamed exceptions, if any

    *)
  3. sub_scopes_idmap : Scopelang.Ast.SubScopeName.t Desugared.Ast.IdentMap.t;
    (*

    Sub-scopes variables

    *)
  4. sub_scopes : Scopelang.Ast.ScopeName.t Scopelang.Ast.SubScopeMap.t;
    (*

    To what scope sub-scopes refer to?

    *)
}

Inside a scope, we distinguish between the variables and the subscopes.

Types of the fields of a struct

Types of the payloads of the cases of an enum

Sourcetype var_sig = {
  1. var_sig_typ : typ Utils.Marked.pos;
  2. var_sig_is_condition : bool;
  3. var_sig_io : Ast.scope_decl_context_io;
  4. var_sig_states_idmap : Desugared.Ast.StateName.t Desugared.Ast.IdentMap.t;
  5. var_sig_states_list : Desugared.Ast.StateName.t list;
}
Sourcetype context = {
  1. local_var_idmap : Desugared.Ast.Var.t Desugared.Ast.IdentMap.t;
    (*

    Inside a definition, local variables can be introduced by functions arguments or pattern matching

    *)
  2. scope_idmap : Scopelang.Ast.ScopeName.t Desugared.Ast.IdentMap.t;
    (*

    The names of the scopes

    *)
  3. struct_idmap : Scopelang.Ast.StructName.t Desugared.Ast.IdentMap.t;
    (*

    The names of the structs

    *)
  4. field_idmap : Scopelang.Ast.StructFieldName.t Scopelang.Ast.StructMap.t Desugared.Ast.IdentMap.t;
    (*

    The names of the struct fields. Names of fields can be shared between different structs

    *)
  5. enum_idmap : Scopelang.Ast.EnumName.t Desugared.Ast.IdentMap.t;
    (*

    The names of the enums

    *)
  6. constructor_idmap : Scopelang.Ast.EnumConstructor.t Scopelang.Ast.EnumMap.t Desugared.Ast.IdentMap.t;
    (*

    The names of the enum constructors. Constructor names can be shared between different enums

    *)
  7. scopes : scope_context Scopelang.Ast.ScopeMap.t;
    (*

    For each scope, its context

    *)
  8. structs : struct_context Scopelang.Ast.StructMap.t;
    (*

    For each struct, its context

    *)
  9. enums : enum_context Scopelang.Ast.EnumMap.t;
    (*

    For each enum, its context

    *)
  10. var_typs : var_sig Desugared.Ast.ScopeVarMap.t;
    (*

    The signatures of each scope variable declared

    *)
}

Main context used throughout Surface.Desugaring

Helpers

Sourceval raise_unsupported_feature : string -> Utils.Pos.t -> 'a

Temporary function raising an error message saying that a feature is not supported yet

Sourceval raise_unknown_identifier : string -> ident Utils.Marked.pos -> 'a

Function to call whenever an identifier used somewhere has not been declared in the program previously

Gets the type associated to an uid

Sourceval is_var_cond : context -> Desugared.Ast.ScopeVar.t -> bool

Get the variable uid inside the scope given in argument

Get the subscope uid inside the scope given in argument

Sourceval is_subscope_uid : Scopelang.Ast.ScopeName.t -> context -> ident -> bool

is_subscope_uid scope_uid ctxt y returns true if y belongs to the subscopes of scope_uid.

Checks if the var_uid belongs to the scope scope_uid

Retrieves the type of a scope definition from the context

Sourceval is_def_cond : context -> Desugared.Ast.ScopeDef.t -> bool
Sourceval is_type_cond : Ast.typ Utils.Marked.pos -> bool
Sourceval add_def_local_var : context -> ident -> context * Desugared.Ast.Var.t

Adds a binding to the context

Usage: get_def_key var_name var_state scope_uid ctxt pos

API

Sourceval form_context : Ast.program -> context

Derive the context from metadata, in one pass over the declarations

OCaml

Innovation. Community. Security.