Module M_ir.Com
Categories
module CatVar : sig ... endHigh level representation of categories of variable. In practice, there only are two types of categories: * "calculee" (Input) variables, with several sub categories; * "saisie" (Computed) variable, that can either be base or non-base.
Variables
type loc_tgv={loc_cat : CatVar.loc;Its category kind
loc_idx : int;TODO
loc_tab_idx : int;TODO
loc_cat_id : CatVar.t;Full details on its category
loc_cat_str : string;String representation of its category
loc_cat_idx : int;The variable's identifier in its category.
}Location of a TGV variable in the compiler's context.
type loc_tmp={loc_idx : int;TODO
loc_tab_idx : int;TODO
loc_cat_idx : int;The variable's identifier in its category
}Location of a temporary variable in the compiler's context.
type loc=|LocTgv of string * loc_tgvA TGV variable
|LocTmp of string * loc_tmpA temporary variable
|LocRef of string * intA reference (the integer is the 'loc_idx')
The different kinds of variables; the 'string' is the variable's name.
module Var : sig ... endtype event_field={name : string Utils.Pos.marked;The field name
index : int;Position of the event field. Set in the validator.
is_var : bool;Is a reference to a variable or a value?
}Data on an event field.
module DomainId : Utils.StrSet.Tmodule DomainIdSet : Utils.SetSetExt.T with type base_elt = string and type T.elt = DomainId.tmodule DomainIdMap : Utils.MapExt.T with type T.key = DomainId.ttype 'a domain={dom_id : DomainId.t Utils.Pos.marked;dom_names : Utils.Pos.t DomainIdMap.t;dom_by_default : bool;dom_min : DomainIdSet.t;dom_max : DomainIdSet.t;dom_rov : Utils.IntSet.t;dom_data : 'a;dom_used : int Utils.Pos.marked option;}type rule_domain_data={rdom_computable : bool;}type rule_domain= rule_domain_data domaintype verif_domain_data={vdom_auth : Utils.Pos.t CatVar.Map.t;vdom_verifiable : bool;}type variable_space={vs_id : int;vs_name : string Utils.Pos.marked;vs_cats : CatVar.loc Utils.Pos.marked CatVar.LocMap.t;vs_by_default : bool;}type verif_domain= verif_domain_data domain
Values and expressions
type comp_op=|Gt|Gte|Lt|Lte|Eq|NeqComparison operators. Comparison always return 0 or 1 when the compared values are both defined; otherwise, it returns 'undefined'.
Note that this is even true when comparing undefined with undefined: the proper way to test if a value is undefined is through the function 'PresentFunc' (present).
type func=Functions callable in M. There is only a subset of the whole M functions; some are translated into dedicated expressions at parsing (champ_evenement for example is directly transformed into an
accessto a variable).
type var_name_generic={base : string;parameters : char list;}For generic variables, we record the list of their lowercase parameters
type var_name=|Normal of string|Generic of var_name_genericA variable is either generic (with loop parameters) or normal
type m_var_name= var_name Utils.Pos.markedtype var_space= (m_var_name * int) optionThe prefix of a variable that defines its space. No space is equivalent to the default space.
type 'v var_id= var_space * 'vtype 'v access=|VarAccess of 'v var_idSimple variable occurence
|TabAccess of 'v var_id * 'v m_expressionAccess to a cell of a table
|FieldAccess of var_space * 'v m_expression * string Utils.Pos.marked * intCall to 'champ_evenement'
A generic representation of an access to a variable, read or write.
and 'v m_access= 'v access Utils.Pos.markedand 'v case=|CDefault|CValue of literal|CVar of 'v m_accessand 'v atom=|AtomVar of 'v|AtomLiteral of literalValues that can be substituted for loop parameters
and 'v set_value_loop=|Single of 'v atom Utils.Pos.marked|Range of 'v atom Utils.Pos.marked * 'v atom Utils.Pos.marked|Interval of 'v atom Utils.Pos.marked * 'v atom Utils.Pos.markedand 'v loop_variable= char Utils.Pos.marked * 'v set_value_loop listA loop variable is the character that should be substituted in variable names inside the loop plus the set of value to substitute.
and 'v loop_variables=|ValueSets of 'v loop_variable list|Ranges of 'v loop_variable listThere are two kind of loop variables declaration, but they are semantically the same though they have different concrete syntax.
and 'v set_value=|FloatValue of float Utils.Pos.markedA literal singleton
|VarValue of 'v m_accessA variable singleton
|IntervalValue of int Utils.Pos.marked * int Utils.Pos.markedA literal interval
A set of values.
and 'v expression=|TestInSet of bool * 'v m_expression * 'v set_value listTest if an expression is in a set of value (or not in the set if the flag is set to
false)|Unop of unop * 'v m_expression|Comparison of comp_op Utils.Pos.marked * 'v m_expression * 'v m_expression|Binop of binop Utils.Pos.marked * 'v m_expression * 'v m_expression|Conditional of 'v m_expression * 'v m_expression * 'v m_expression option|FuncCall of func Utils.Pos.marked * 'v m_expression list|FuncCallLoop of func Utils.Pos.marked * 'v loop_variables Utils.Pos.marked * 'v m_expression|Literal of literal|Var of 'v access|Loop of 'v loop_variables Utils.Pos.marked * 'v m_expressionThe loop is prefixed with the loop variables declarations
|NbCategory of Utils.Pos.t CatVar.Map.t|Attribut of 'v m_access * string Utils.Pos.marked|Size of 'v m_access|Type of 'v m_access * value_typ Utils.Pos.marked|SameVariable of 'v m_access * 'v m_access|InDomain of 'v m_access * Utils.Pos.t CatVar.Map.t|NbAnomalies|NbDiscordances|NbInformatives|NbBloquantesBasic M expressions.
and 'v m_expression= 'v expression Utils.Pos.marked
module Error : sig ... endHandling of errors.
Printing in M
type 'v print_arg=|PrintString of string|PrintAccess of print_info * 'v m_access|PrintIndent of 'v m_expressionEvaluates the expression and indents as much
|PrintExpr of 'v m_expression * int * intPrints an expression with a minimal and maximal precision.
Something to print
Loops
type 'v formula_loop= 'v loop_variables Utils.Pos.markedtype 'v formula_decl=|VarDecl of 'v access Utils.Pos.marked * 'v m_expression|EventFieldRef of 'v m_expression * string Utils.Pos.marked * int * 'vtype 'v formula=|SingleFormula of 'v formula_decl|MultipleFormulaes of 'v formula_loop * 'v formula_decl
Stopping
Instructions
type 'v switch_expression=|SEValue of 'v m_expression|SESameVariable of 'v m_accesstype ('v, 'e) instruction=|Affectation of 'v formula Utils.Pos.marked|IfThenElse of 'v m_expression * ('v, 'e) m_instruction list * ('v, 'e) m_instruction list|WhenDoElse of ('v m_expression * ('v, 'e) m_instruction list * Utils.Pos.t) list * ('v, 'e) m_instruction list Utils.Pos.marked|ComputeDomain of string Utils.Pos.marked list Utils.Pos.marked * var_space|ComputeChaining of string Utils.Pos.marked * var_space|ComputeVerifs of string Utils.Pos.marked list Utils.Pos.marked * 'v m_expression * var_space|ComputeTarget of string Utils.Pos.marked * 'v m_access list * var_space|VerifBlock of ('v, 'e) m_instruction list|Print of print_std * 'v print_arg Utils.Pos.marked list|Iterate of 'v * 'v m_access list * (Utils.Pos.t CatVar.Map.t * 'v m_expression * var_space) list * ('v, 'e) m_instruction list|Iterate_values of 'v * ('v m_expression * 'v m_expression * 'v m_expression) list * ('v, 'e) m_instruction list|Restore of 'v m_access list * ('v * Utils.Pos.t CatVar.Map.t * 'v m_expression * var_space) list * 'v m_expression list * ('v * 'v m_expression) list * ('v, 'e) m_instruction list|ArrangeEvents of ('v * 'v * 'v m_expression) option * ('v * 'v m_expression) option * 'v m_expression option * ('v, 'e) m_instruction list|Switch of 'v switch_expression * ('v case list * ('v, 'e) m_instruction list) list|RaiseError of 'e Utils.Pos.marked * string Utils.Pos.marked option|CleanErrors|CleanFinalizedErrors|ExportErrors|FinalizeErrors|Stop of stop_kindand ('v, 'e) m_instruction= ('v, 'e) instruction Utils.Pos.markedtype ('v, 'e) target={target_name : string Utils.Pos.marked;target_file : string option;target_apps : string Utils.Pos.marked Utils.StrMap.t;target_args : 'v list;target_result : 'v option;target_tmp_vars : 'v Utils.StrMap.t;target_nb_tmps : int;target_sz_tmps : int;target_nb_refs : int;target_prog : ('v, 'e) m_instruction list;}A target is a list of instructions. They are very similar to rules, except targets are entrypoints of the M program.
Utils
val target_is_function : ('v, 'e) target -> boolval expr_map_var : ('v -> 'w) -> 'v expression -> 'w expressionval m_expr_map_var : ('v -> 'w) -> 'v m_expression -> 'w m_expressionval instr_map_var : ('v -> 'w) -> ('e -> 'f) -> ('v, 'e) instruction -> ('w, 'f) instructionval m_instr_map_var : ('v -> 'w) -> ('e -> 'f) -> ('v, 'e) m_instruction -> ('w, 'f) m_instruction
val expr_fold_var : (var_usage -> var_space -> 'v option -> 'a -> 'a) -> 'v expression -> 'a -> 'aval m_expr_fold_var : (var_usage -> var_space -> 'v option -> 'a -> 'a) -> 'v m_expression -> 'a -> 'aval instr_fold_var : (var_usage -> var_space -> 'v option -> 'a -> 'a) -> ('v, 'e) instruction -> 'a -> 'aval m_instr_fold_var : (var_usage -> var_space -> 'v option -> 'a -> 'a) -> ('v, 'e) m_instruction -> 'a -> 'aval get_var_name : var_name -> stringval get_normal_var : var_name -> string
Pretty printing functions
val format_value_typ : Utils.Pp.t -> value_typ -> unitval format_literal : Utils.Pp.t -> literal -> unitval format_case : (Utils.Pp.t -> 'v -> unit) -> (Utils.Pp.t -> 'v expression -> unit) -> Utils.Pp.t -> 'v case -> unitval format_atom : (Utils.Pp.t -> 'v -> unit) -> Utils.Pp.t -> 'v atom -> unitval format_loop_variables : (Utils.Pp.t -> 'v -> unit) -> Utils.Pp.t -> 'v loop_variables -> unitval format_unop : Utils.Pp.t -> unop -> unitval format_binop : Utils.Pp.t -> binop -> unitval format_comp_op : Utils.Pp.t -> comp_op -> unitval format_set_value : (Utils.Pp.t -> 'v -> unit) -> (Utils.Pp.t -> 'v expression -> unit) -> Utils.Pp.t -> 'v set_value -> unitval format_func : Utils.Pp.t -> func -> unitval format_expression : (Utils.Pp.t -> 'v -> unit) -> Utils.Pp.t -> 'v expression -> unitval format_print_arg : (Utils.Pp.t -> 'v -> unit) -> Utils.Pp.t -> 'v print_arg -> unitval format_formula : (Utils.Pp.t -> 'v -> unit) -> Utils.Pp.t -> 'v formula -> unitval format_instruction : (Utils.Pp.t -> 'v -> unit) -> (Utils.Pp.t -> 'e -> unit) -> Utils.Pp.t -> ('v, 'e) instruction -> unitval format_instructions : (Utils.Pp.t -> 'v -> unit) -> (Utils.Pp.t -> 'e -> unit) -> Utils.Pp.t -> ('v, 'e) m_instruction list -> unit