Surface.AstAbstract syntax tree built by the Catala parser
type path = uident Catala_utils.Mark.pos listtype scope_var = lident Catala_utils.Mark.pos listfoo.bar in binding position: used to specify variables of subscopes
type primitive_typ = | Integer| Decimal| Boolean| Money| Duration| Date| Position| External of lident| Named of path * uident Catala_utils.Mark.pos| Var of lident Catala_utils.Mark.pos optiontype base_typ_data = | Primitive of primitive_typ| Collection of base_typ_data Catala_utils.Mark.pos| Option of base_typ_data Catala_utils.Mark.pos| TTuple of base_typ_data Catala_utils.Mark.pos listtype func_typ = {arg_typ : (lident Catala_utils.Mark.pos * base_typ Catala_utils.Mark.pos) list;return_typ : base_typ Catala_utils.Mark.pos;}type typ = naked_typ Catala_utils.Mark.postype struct_decl_field = {struct_decl_field_name : lident Catala_utils.Mark.pos;struct_decl_field_typ : typ;}type struct_decl = {struct_decl_name : uident Catala_utils.Mark.pos;struct_decl_fields : struct_decl_field Catala_utils.Mark.pos list;}type enum_decl_case = {enum_decl_case_name : uident Catala_utils.Mark.pos;enum_decl_case_typ : typ option;}type enum_decl = {enum_decl_name : uident Catala_utils.Mark.pos;enum_decl_cases : enum_decl_case Catala_utils.Mark.pos list;}type match_case_pattern =
enum_constr Catala_utils.Mark.pos list * lident Catala_utils.Mark.pos optiontype literal = | LNumber of literal_number Catala_utils.Mark.pos
* literal_unit Catala_utils.Mark.pos option| LBool of bool| LMoneyAmount of money_amount| LDate of literal_datetype collection_op = | Member of {element : expression;}| Exists of {predicate : lident Catala_utils.Mark.pos list * expression;}| Forall of {predicate : lident Catala_utils.Mark.pos list * expression;}| Map of {f : lident Catala_utils.Mark.pos list * expression;}| Filter of {f : lident Catala_utils.Mark.pos list * expression;}| AggregateSum of {typ : primitive_typ;}| AggregateExtremum of {max : bool;default : expression option;}| AggregateArgExtremum of {max : bool;default : expression option;f : lident Catala_utils.Mark.pos list * expression;}| Fold of {f : lident Catala_utils.Mark.pos list
* lident Catala_utils.Mark.pos list
* expression;init : expression;}and explicit_match_case = {match_case_pattern : match_case_pattern Catala_utils.Mark.pos;match_case_expr : expression;}and match_cases = match_case Catala_utils.Mark.pos listand expression = naked_expression Catala_utils.Mark.posand naked_expression = | Paren of expression| MatchWith of expression * match_cases Catala_utils.Mark.pos| IfThenElse of expression * expression * expression| Binop of binop Catala_utils.Mark.pos * expression * expression| Unop of unop Catala_utils.Mark.pos * expression| CollectionOp of collection_op Catala_utils.Mark.pos * expression| TestMatchCase of expression * match_case_pattern Catala_utils.Mark.pos| FunCall of expression * expression list| ScopeCall of (path * uident Catala_utils.Mark.pos) Catala_utils.Mark.pos
* (lident Catala_utils.Mark.pos * expression) list| LetIn of lident Catala_utils.Mark.pos list * expression * expression| Builtin of builtin_expression| Literal of literal| EnumInject of enum_constr Catala_utils.Mark.pos * expression option| StructLit of (path * uident Catala_utils.Mark.pos) Catala_utils.Mark.pos
* (lident Catala_utils.Mark.pos * expression) list| StructReplace of expression * (lident Catala_utils.Mark.pos * expression) list| ArrayLit of expression list| Tuple of expression list| Ident of path
* lident Catala_utils.Mark.pos
* lident Catala_utils.Mark.pos option| Dotted of expression
* (path * lident Catala_utils.Mark.pos) Catala_utils.Mark.posDotted is for both struct field projection and sub-scope variables
*)| TupleAccess of expression * int Catala_utils.Mark.postype exception_to = | NotAnException| UnlabeledException| ExceptionToLabel of lident Catala_utils.Mark.postype rule = {rule_label : lident Catala_utils.Mark.pos option;rule_exception_to : exception_to;rule_parameter : lident Catala_utils.Mark.pos list Catala_utils.Mark.pos option;rule_condition : expression option;rule_name : scope_var Catala_utils.Mark.pos;rule_id : Shared_ast.RuleName.t;rule_consequence : bool Catala_utils.Mark.pos;rule_state : lident Catala_utils.Mark.pos option;}type definition = {definition_label : lident Catala_utils.Mark.pos option;definition_exception_to : exception_to;definition_name : scope_var Catala_utils.Mark.pos;definition_parameter : lident Catala_utils.Mark.pos list Catala_utils.Mark.pos
option;definition_condition : expression option;definition_id : Shared_ast.RuleName.t;definition_expr : expression;definition_state : lident Catala_utils.Mark.pos option;}type scope_use_item = | Rule of rule| Definition of definition| Assertion of assertion| DateRounding of variation_typ Catala_utils.Mark.postype scope_use = {scope_use_condition : expression option;scope_use_name : uident Catala_utils.Mark.pos;scope_use_items : scope_use_item Catala_utils.Mark.pos list;}type scope_decl_context_io = {scope_decl_context_io_input : io_input Catala_utils.Mark.pos;scope_decl_context_io_output : bool Catala_utils.Mark.pos;}type scope_decl_context_scope = {scope_decl_context_scope_name : lident Catala_utils.Mark.pos;scope_decl_context_scope_sub_scope : (path * uident Catala_utils.Mark.pos)
Catala_utils.Mark.pos;scope_decl_context_scope_attribute : scope_decl_context_io;}type scope_decl_context_data = {scope_decl_context_item_name : lident Catala_utils.Mark.pos;scope_decl_context_item_typ : typ;scope_decl_context_item_parameters : (lident Catala_utils.Mark.pos * typ) list
Catala_utils.Mark.pos
option;scope_decl_context_item_attribute : scope_decl_context_io;scope_decl_context_item_states : lident Catala_utils.Mark.pos list;}type scope_decl_context_item = | ContextData of scope_decl_context_data| ContextScope of scope_decl_context_scopetype scope_decl = {scope_decl_name : uident Catala_utils.Mark.pos;scope_decl_context : scope_decl_context_item Catala_utils.Mark.pos list;}type top_def = {topdef_name : lident Catala_utils.Mark.pos;topdef_args : (lident Catala_utils.Mark.pos * base_typ Catala_utils.Mark.pos)
list
Catala_utils.Mark.pos
option;Empty list if this is not a function
*)topdef_type : typ;topdef_expr : expression option;}type code_item = | ScopeUse of scope_use| ScopeDecl of scope_decl| StructDecl of struct_decl| EnumDecl of enum_decl| Topdef of top_deftype code_block = code_item Catala_utils.Mark.pos listtype source_repr = string Catala_utils.Mark.postype law_heading = {law_heading_name : string Catala_utils.Mark.pos;law_heading_id : string option;law_heading_is_archive : bool;law_heading_precedence : int;}type law_include = | PdfFile of string Catala_utils.Mark.pos * int option| CatalaFile of string Catala_utils.Mark.pos| LegislativeText of string Catala_utils.Mark.postype law_structure = | LawInclude of law_include| ModuleDef of uident Catala_utils.Mark.pos * bool| ModuleUse of uident Catala_utils.Mark.pos * uident Catala_utils.Mark.pos option| LawHeading of law_heading * law_structure list| LawText of string| CodeBlock of code_block * source_repr * booltype module_use = {mod_use_name : uident Catala_utils.Mark.pos;mod_use_alias : uident Catala_utils.Mark.pos;}type program = {program_module : program_module option;program_items : law_structure list;program_source_files : string list;program_used_modules : module_use list;program_lang : Catala_utils.Global.backend_lang;}type source_file = law_structure listtype module_items = | Code of law_structure listUsed in whole-program to gather all module code
*)| Interface of (code_item Catala_utils.Mark.pos * Shared_ast.visibility) listInvariant: an interface shall only contain *Decl elements, or Topdef elements with topdef_expr = None (metadata only). The visibility is determined from the presence of the item in a metadata block, but might later be promoted due to test annotations or dependencies
type module_content = {module_modname : program_module;module_items : module_items;module_submodules : module_use list;}