package catala
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=b22e238d5d5c8452067109e9c7c0f427
sha512=ccc8c557c67c2f9d1bed4b957b2367f0f6afc0ef9b8b83237cf2a2912b3e8829b7e8af78ea7fe00b20ecf28b436ad04b591e5fff4f82fd08725d40a18c9924d0
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
type unique_rulename = | Ambiguous of Utils.Pos.t list| Unique of Desugared.Ast.RuleName.t Utils.Pos.marked
type scope_def_context = {default_exception_rulename : unique_rulename option;label_idmap : Desugared.Ast.LabelName.t Desugared.Ast.IdentMap.t;label_groups : Desugared.Ast.RuleSet.t Desugared.Ast.LabelMap.t;
}type scope_context = {var_idmap : Desugared.Ast.ScopeVar.t Desugared.Ast.IdentMap.t;(*Scope variables
*)scope_defs_contexts : scope_def_context Desugared.Ast.ScopeDefMap.t;(*What is the default rule to refer to for unnamed exceptions, if any
*)sub_scopes_idmap : Scopelang.Ast.SubScopeName.t Desugared.Ast.IdentMap.t;(*Sub-scopes variables
*)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
type var_sig = {var_sig_typ : typ Utils.Pos.marked;var_sig_is_condition : bool;var_sig_io : Ast.scope_decl_context_io;var_sig_states_idmap : Desugared.Ast.StateName.t Desugared.Ast.IdentMap.t;var_sig_states_list : Desugared.Ast.StateName.t list;
}type context = {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
*)scope_idmap : Scopelang.Ast.ScopeName.t Desugared.Ast.IdentMap.t;(*The names of the scopes
*)struct_idmap : Scopelang.Ast.StructName.t Desugared.Ast.IdentMap.t;(*The names of the structs
*)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
*)enum_idmap : Scopelang.Ast.EnumName.t Desugared.Ast.IdentMap.t;(*The names of the enums
*)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
*)scopes : scope_context Scopelang.Ast.ScopeMap.t;(*For each scope, its context
*)structs : struct_context Scopelang.Ast.StructMap.t;(*For each struct, its context
*)enums : enum_context Scopelang.Ast.EnumMap.t;(*For each enum, its context
*)var_typs : var_sig Desugared.Ast.ScopeVarMap.t;(*The signatures of each scope variable declared
*)
}Main context used throughout Surface.Desugaring
Helpers
Temporary function raising an error message saying that a feature is not supported yet
Function to call whenever an identifier used somewhere has not been declared in the program previously
Gets the type associated to an uid
val get_var_uid :
Scopelang.Ast.ScopeName.t ->
context ->
ident Utils.Pos.marked ->
Desugared.Ast.ScopeVar.tGet the variable uid inside the scope given in argument
val get_subscope_uid :
Scopelang.Ast.ScopeName.t ->
context ->
ident Utils.Pos.marked ->
Scopelang.Ast.SubScopeName.tGet the subscope uid inside the scope given in argument
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
val label_groups :
context ->
Scopelang.Ast.ScopeName.t ->
Desugared.Ast.ScopeDef.t ->
Desugared.Ast.RuleSet.t Desugared.Ast.LabelMap.tAdds a binding to the context
val get_def_key :
Ast.qident ->
Ast.ident Utils.Pos.marked option ->
Scopelang.Ast.ScopeName.t ->
context ->
Utils.Pos.t ->
Desugared.Ast.ScopeDef.tUsage: get_def_key var_name var_state scope_uid ctxt pos
API
Derive the context from metadata, in one pass over the declarations