package catala

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Abstract syntax tree built by the Catala parser

To allow for quick traversal and/or modification of this AST structure, we provide a visitor design pattern. This feature is implemented via François Pottier's OCaml visitors library.

Type definitions

type constructor = string

Constructors are CamelCase

include sig ... end
class virtual +'a constructor_map : object ... end
include sig ... end
class virtual +'a constructor_iter : object ... end
type ident = string

Idents are snake_case

include sig ... end
class virtual +'a ident_map : object ... end
include sig ... end
class virtual +'a ident_iter : object ... end
type qident = ident Utils.Marked.pos list
include sig ... end
class virtual +'b qident_map : object ... end
include sig ... end
class virtual +'b qident_iter : object ... end
type primitive_typ =
  1. | Integer
  2. | Decimal
  3. | Boolean
  4. | Money
  5. | Duration
  6. | Text
  7. | Date
  8. | Named of constructor
include sig ... end
class virtual +'a primitive_typ_map : object ... end
include sig ... end
class virtual +'a primitive_typ_iter : object ... end
type base_typ_data =
  1. | Primitive of primitive_typ
  2. | Collection of base_typ_data Utils.Marked.pos
include sig ... end
class virtual +'b base_typ_data_map : object ... end
include sig ... end
class virtual +'b base_typ_data_iter : object ... end
type base_typ =
  1. | Condition
  2. | Data of base_typ_data
include sig ... end
class virtual +'b base_typ_map : object ... end
include sig ... end
class virtual +'b base_typ_iter : object ... end
type func_typ = {
  1. arg_typ : base_typ Utils.Marked.pos;
  2. return_typ : base_typ Utils.Marked.pos;
}
include sig ... end
class virtual +'b func_typ_map : object ... end
include sig ... end
class virtual +'b func_typ_iter : object ... end
type typ =
  1. | Base of base_typ
  2. | Func of func_typ
include sig ... end
class virtual +'b typ_map : object ... end
include sig ... end
class virtual +'b typ_iter : object ... end
type struct_decl_field = {
  1. struct_decl_field_name : ident Utils.Marked.pos;
  2. struct_decl_field_typ : typ Utils.Marked.pos;
}
include sig ... end
class virtual +'b struct_decl_field_map : object ... end
include sig ... end
class virtual +'b struct_decl_field_iter : object ... end
type struct_decl = {
  1. struct_decl_name : constructor Utils.Marked.pos;
  2. struct_decl_fields : struct_decl_field Utils.Marked.pos list;
}
include sig ... end
class virtual +'b struct_decl_map : object ... end
include sig ... end
class virtual +'b struct_decl_iter : object ... end
type enum_decl_case = {
  1. enum_decl_case_name : constructor Utils.Marked.pos;
  2. enum_decl_case_typ : typ Utils.Marked.pos option;
}
include sig ... end
class virtual +'b enum_decl_case_map : object ... end
include sig ... end
class virtual +'b enum_decl_case_iter : object ... end
type enum_decl = {
  1. enum_decl_name : constructor Utils.Marked.pos;
  2. enum_decl_cases : enum_decl_case Utils.Marked.pos list;
}
include sig ... end
class virtual +'b enum_decl_map : object ... end
include sig ... end
class virtual +'b enum_decl_iter : object ... end
type match_case_pattern = (constructor Utils.Marked.pos option * constructor Utils.Marked.pos) list * ident Utils.Marked.pos option
include sig ... end
class virtual +'b match_case_pattern_map : object ... end
include sig ... end
class virtual +'b match_case_pattern_iter : object ... end
type op_kind =
  1. | KInt
  2. | KDec
  3. | KMoney
  4. | KDate
  5. | KDuration
include sig ... end
class virtual +'a op_kind_map : object ... end
include sig ... end
class virtual +'a op_kind_iter : object ... end
type binop =
  1. | And
  2. | Or
  3. | Xor
  4. | Add of op_kind
  5. | Sub of op_kind
  6. | Mult of op_kind
  7. | Div of op_kind
  8. | Lt of op_kind
  9. | Lte of op_kind
  10. | Gt of op_kind
  11. | Gte of op_kind
  12. | Eq
  13. | Neq
  14. | Concat
include sig ... end
class virtual +'a binop_map : object ... end
include sig ... end
class virtual +'a binop_iter : object ... end
type unop =
  1. | Not
  2. | Minus of op_kind
include sig ... end
class virtual +'a unop_map : object ... end
include sig ... end
class virtual +'a unop_iter : object ... end
type builtin_expression =
  1. | Cardinal
  2. | IntToDec
  3. | MoneyToDec
  4. | DecToMoney
  5. | GetDay
  6. | GetMonth
  7. | GetYear
  8. | LastDayOfMonth
  9. | FirstDayOfMonth
  10. | RoundMoney
  11. | RoundDecimal
include sig ... end
class virtual +'a builtin_expression_map : object ... end
include sig ... end
class virtual +'a builtin_expression_iter : object ... end
type literal_date = {
  1. literal_date_day : int;
  2. literal_date_month : int;
  3. literal_date_year : int;
}
include sig ... end
class virtual +'b literal_date_map : object ... end
include sig ... end
class virtual +'b literal_date_iter : object ... end
type literal_number =
  1. | Int of string
  2. | Dec of string * string
include sig ... end
class virtual +'a literal_number_map : object ... end
include sig ... end
class virtual +'a literal_number_iter : object ... end
type literal_unit =
  1. | Percent
  2. | Year
  3. | Month
  4. | Day
include sig ... end
class virtual +'a literal_unit_map : object ... end
include sig ... end
class virtual +'a literal_unit_iter : object ... end
type money_amount = {
  1. money_amount_units : string;
  2. money_amount_cents : string;
}
include sig ... end
class virtual +'a money_amount_map : object ... end
include sig ... end
class virtual +'a money_amount_iter : object ... end
type literal =
  1. | LNumber of literal_number Utils.Marked.pos * literal_unit Utils.Marked.pos option
  2. | LBool of bool
  3. | LMoneyAmount of money_amount
  4. | LDate of literal_date
include sig ... end
class virtual +'b literal_map : object ... end
include sig ... end
class virtual +'b literal_iter : object ... end
type aggregate_func =
  1. | AggregateSum of primitive_typ
  2. | AggregateCount
  3. | AggregateExtremum of bool * primitive_typ * expression Utils.Marked.pos
  4. | AggregateArgExtremum of bool * primitive_typ * expression Utils.Marked.pos
and collection_op =
  1. | Exists
  2. | Forall
  3. | Aggregate of aggregate_func
  4. | Map
  5. | Filter
and explicit_match_case = {
  1. match_case_pattern : match_case_pattern Utils.Marked.pos;
  2. match_case_expr : expression Utils.Marked.pos;
}
and match_case =
  1. | WildCard of expression Utils.Marked.pos
  2. | MatchCase of explicit_match_case
and match_cases = match_case Utils.Marked.pos list
include sig ... end
class virtual +'b expression_map : object ... end
include sig ... end
class virtual +'b expression_iter : object ... end
type exception_to =
  1. | NotAnException
  2. | UnlabeledException
  3. | ExceptionToLabel of ident Utils.Marked.pos
include sig ... end
class virtual +'b exception_to_map : object ... end
include sig ... end
class virtual +'b exception_to_iter : object ... end
type rule = {
  1. rule_label : ident Utils.Marked.pos option;
  2. rule_exception_to : exception_to;
  3. rule_parameter : ident Utils.Marked.pos option;
  4. rule_condition : expression Utils.Marked.pos option;
  5. rule_name : qident Utils.Marked.pos;
  6. rule_id : Desugared.Ast.RuleName.t;
  7. rule_consequence : bool Utils.Marked.pos;
  8. rule_state : ident Utils.Marked.pos option;
}
include sig ... end
class virtual +'b rule_map : object ... end
include sig ... end
class virtual +'b rule_iter : object ... end
type definition = {
  1. definition_label : ident Utils.Marked.pos option;
  2. definition_exception_to : exception_to;
  3. definition_name : qident Utils.Marked.pos;
  4. definition_parameter : ident Utils.Marked.pos option;
  5. definition_condition : expression Utils.Marked.pos option;
  6. definition_id : Desugared.Ast.RuleName.t;
  7. definition_expr : expression Utils.Marked.pos;
  8. definition_state : ident Utils.Marked.pos option;
}
include sig ... end
class virtual +'b definition_map : object ... end
include sig ... end
class virtual +'b definition_iter : object ... end
type variation_typ =
  1. | Increasing
  2. | Decreasing
include sig ... end
class virtual +'a variation_typ_map : object ... end
include sig ... end
class virtual +'a variation_typ_iter : object ... end
include sig ... end
class virtual +'b meta_assertion_map : object ... end
include sig ... end
class virtual +'b meta_assertion_iter : object ... end
type assertion = {
  1. assertion_condition : expression Utils.Marked.pos option;
  2. assertion_content : expression Utils.Marked.pos;
}
include sig ... end
class virtual +'b assertion_map : object ... end
include sig ... end
class virtual +'b assertion_iter : object ... end
type scope_use_item =
  1. | Rule of rule
  2. | Definition of definition
  3. | Assertion of assertion
  4. | MetaAssertion of meta_assertion
include sig ... end
class virtual +'b scope_use_item_map : object ... end
include sig ... end
class virtual +'b scope_use_item_iter : object ... end
type scope_use = {
  1. scope_use_condition : expression Utils.Marked.pos option;
  2. scope_use_name : constructor Utils.Marked.pos;
  3. scope_use_items : scope_use_item Utils.Marked.pos list;
}
include sig ... end
class virtual +'b scope_use_map : object ... end
include sig ... end
class virtual +'b scope_use_iter : object ... end
type io_input =
  1. | Input
  2. | Context
  3. | Internal
include sig ... end
class virtual +'a io_input_map : object ... end
include sig ... end
class virtual +'a io_input_iter : object ... end
type scope_decl_context_io = {
  1. scope_decl_context_io_input : io_input Utils.Marked.pos;
  2. scope_decl_context_io_output : bool Utils.Marked.pos;
}
include sig ... end
class virtual +'b scope_decl_context_io_map : object ... end
include sig ... end
class virtual +'b scope_decl_context_io_iter : object ... end
type scope_decl_context_scope = {
  1. scope_decl_context_scope_name : ident Utils.Marked.pos;
  2. scope_decl_context_scope_sub_scope : constructor Utils.Marked.pos;
  3. scope_decl_context_scope_attribute : scope_decl_context_io;
}
include sig ... end
class virtual +'b scope_decl_context_scope_map : object ... end
include sig ... end
class virtual +'b scope_decl_context_scope_iter : object ... end
type scope_decl_context_data = {
  1. scope_decl_context_item_name : ident Utils.Marked.pos;
  2. scope_decl_context_item_typ : typ Utils.Marked.pos;
  3. scope_decl_context_item_attribute : scope_decl_context_io;
  4. scope_decl_context_item_states : ident Utils.Marked.pos list;
}
include sig ... end
class virtual +'b scope_decl_context_data_map : object ... end
include sig ... end
class virtual +'b scope_decl_context_data_iter : object ... end
type scope_decl_context_item =
  1. | ContextData of scope_decl_context_data
  2. | ContextScope of scope_decl_context_scope
include sig ... end
class virtual +'b scope_decl_context_item_map : object ... end
include sig ... end
class virtual +'b scope_decl_context_item_iter : object ... end
type scope_decl = {
  1. scope_decl_name : constructor Utils.Marked.pos;
  2. scope_decl_context : scope_decl_context_item Utils.Marked.pos list;
}
include sig ... end
class virtual +'b scope_decl_map : object ... end
include sig ... end
class virtual +'b scope_decl_iter : object ... end
type code_item =
  1. | ScopeUse of scope_use
  2. | ScopeDecl of scope_decl
  3. | StructDecl of struct_decl
  4. | EnumDecl of enum_decl
include sig ... end
class virtual +'b code_item_map : object ... end
include sig ... end
class virtual +'b code_item_iter : object ... end
type code_block = code_item Utils.Marked.pos list
include sig ... end
class virtual +'b code_block_map : object ... end
include sig ... end
class virtual +'b code_block_iter : object ... end
type source_repr = string Utils.Marked.pos
include sig ... end
class virtual +'b source_repr_map : object ... end
include sig ... end
class virtual +'b source_repr_iter : object ... end
type law_heading = {
  1. law_heading_name : string Utils.Marked.pos;
  2. law_heading_id : string option;
  3. law_heading_expiration_date : string option;
  4. law_heading_precedence : int;
}
include sig ... end
class virtual +'b law_heading_map : object ... end
include sig ... end
class virtual +'b law_heading_iter : object ... end
type law_include =
  1. | PdfFile of string Utils.Marked.pos * int option
  2. | CatalaFile of string Utils.Marked.pos
  3. | LegislativeText of string Utils.Marked.pos
include sig ... end
class virtual +'b law_include_map : object ... end
include sig ... end
class virtual +'b law_include_iter : object ... end
type law_structure =
  1. | LawInclude of law_include
  2. | LawHeading of law_heading * law_structure list
  3. | LawText of string
  4. | CodeBlock of code_block * source_repr * bool
include sig ... end
class virtual +'b law_structure_map : object ... end
include sig ... end
class virtual +'b law_structure_iter : object ... end
type program = {
  1. program_items : law_structure list;
  2. program_source_files : string list;
}
include sig ... end
class virtual +'b program_map : object ... end
include sig ... end
class virtual +'b program_iter : object ... end
type source_file = law_structure list

Helpers

val rule_to_def : rule -> definition

Translates a rule into the corresponding definition

OCaml

Innovation. Community. Security.