Module Mlang.Mast
Abstract Syntax Tree
Names
type application
= string
Applications are rule annotations. The 3 main DGFiP applications seem to be:
batch
: deprecated, used to compute the income tax but not anymore;bareme
: seems to compute the income tax;iliad
: usage unkown, much bigger thanbareme
.
Literals
type variable
=
|
Normal of variable_name
|
Generic of variable_generic_name
A variable is either generic (with loop parameters) or normal
val get_normal_var : variable -> variable_name
val get_table_size : table_size -> int
val get_table_size_opt : (table_size * 'a) option -> (int * 'a) option
Expressions
type var_category_id
= string Pos.marked list Pos.marked
type set_value
= variable Com.set_value
type expression
= variable Com.expression
type m_expression
= expression Pos.marked
Toplevel clauses
Rules
type instruction
= (variable, error_name) Com.instruction
type m_instruction
= instruction Pos.marked
type rule
=
{
rule_number : int Pos.marked;
rule_tag_names : string Pos.marked list Pos.marked;
rule_apps : application Pos.marked Mlang.StrMap.t;
rule_chainings : chaining Pos.marked Mlang.StrMap.t;
rule_tmp_vars : (string Pos.marked * table_size Pos.marked option) Mlang.StrMap.t;
rule_formulaes : instruction Pos.marked list;
A rule can contain many variable definitions
}
type target
=
{
target_name : string Pos.marked;
target_file : string option;
target_apps : application Pos.marked Mlang.StrMap.t;
target_args : string Pos.marked list;
target_result : string Pos.marked option;
target_tmp_vars : (string Pos.marked * table_size Pos.marked option) Mlang.StrMap.t;
target_nb_tmps : int;
target_sz_tmps : int;
target_nb_refs : int;
target_prog : instruction Pos.marked list;
}
type 'a domain_decl
=
{
dom_names : string Pos.marked list Pos.marked list;
dom_parents : string Pos.marked list Pos.marked list;
dom_by_default : bool;
dom_data : 'a;
}
type rule_domain_data
=
{
rdom_computable : bool;
}
type rule_domain_decl
= rule_domain_data domain_decl
Variable declaration
Input variables
type variable_attribute
= string Pos.marked * int Pos.marked
type input_variable
=
{
input_name : variable_name Pos.marked;
input_category : string Pos.marked list;
input_attributes : variable_attribute list;
input_alias : variable_name Pos.marked;
Unused for now
input_is_givenback : bool;
input_description : string Pos.marked;
input_typ : Com.value_typ Pos.marked option;
}
type computed_variable
=
{
comp_name : variable_name Pos.marked;
comp_table : table_size Pos.marked option;
size of the table,
None
for non-table variablescomp_attributes : variable_attribute list;
comp_category : string Pos.marked list;
comp_typ : Com.value_typ Pos.marked option;
comp_is_givenback : bool;
comp_description : string Pos.marked;
}
type variable_decl
=
|
ComputedVar of computed_variable Pos.marked
|
ConstVar of variable_name Pos.marked * variable Com.atom Pos.marked
The literal is the constant value
|
InputVar of input_variable Pos.marked
type var_type
=
|
Input
|
Computed
type var_category_decl
=
{
var_type : var_type;
var_category : string Pos.marked list;
var_attributes : string Pos.marked list;
}
Verification clauses
type verification_condition
=
{
verif_cond_expr : expression Pos.marked;
verif_cond_error : error_name Pos.marked * variable_name Pos.marked option;
A verification condition error can ba associated to a variable
}
type verification
=
{
verif_number : int Pos.marked;
verif_tag_names : string Pos.marked list Pos.marked;
verif_apps : application Pos.marked Mlang.StrMap.t;
Verification conditions are application-specific
verif_conditions : verification_condition Pos.marked list;
}
type verif_domain_data
=
{
vdom_auth : var_category_id list;
vdom_verifiable : bool;
}
type verif_domain_decl
= verif_domain_data domain_decl
type error_
=
{
error_name : error_name Pos.marked;
error_typ : Com.Error.typ Pos.marked;
error_descr : string Pos.marked list;
}
M programs
type source_file_item
=
|
Application of application Pos.marked
Declares an application
|
Chaining of chaining Pos.marked * application Pos.marked list
|
VariableDecl of variable_decl
|
Function of target
|
Rule of rule
|
Target of target
|
Verification of verification
|
Error of error_
Declares an error
|
Output of variable_name Pos.marked
Declares an output variable
|
Func
Declares a function, unused
|
VarCatDecl of var_category_decl Pos.marked
|
RuleDomDecl of rule_domain_decl
|
VerifDomDecl of verif_domain_decl
type source_file
= source_file_item Pos.marked list
type program
= source_file list
Helper functions
val get_variable_name : variable -> string