package catala

  1. Overview
  2. Docs

Abstract syntax tree built by the Catala parser

module Pos = Utils.Pos
type constructor = string

Constructors are CamlCase

type ident = string

Idents are snake_case

type qident = ident Pos.marked list
type primitive_typ =
  1. | Integer
  2. | Decimal
  3. | Boolean
  4. | Money
  5. | Duration
  6. | Text
  7. | Date
  8. | Named of constructor
type base_typ_data =
  1. | Primitive of primitive_typ
  2. | Collection of base_typ_data Pos.marked
  3. | Optional of base_typ_data Pos.marked
type base_typ =
  1. | Condition
  2. | Data of base_typ_data
type func_typ = {
  1. arg_typ : base_typ Pos.marked;
  2. return_typ : base_typ Pos.marked;
}
type typ =
  1. | Base of base_typ
  2. | Func of func_typ
type struct_decl_field = {
  1. struct_decl_field_name : ident Pos.marked;
  2. struct_decl_field_typ : typ Pos.marked;
}
type struct_decl = {
  1. struct_decl_name : constructor Pos.marked;
  2. struct_decl_fields : struct_decl_field Pos.marked list;
}
type enum_decl_case = {
  1. enum_decl_case_name : constructor Pos.marked;
  2. enum_decl_case_typ : typ Pos.marked option;
}
type enum_decl = {
  1. enum_decl_name : constructor Pos.marked;
  2. enum_decl_cases : enum_decl_case Pos.marked list;
}
type match_case_pattern = constructor Pos.marked list * ident Pos.marked option
type op_kind =
  1. | KInt
    (*

    No suffix

    *)
  2. | KDec
    (*

    Suffix: .

    *)
  3. | KMoney
    (*

    Suffix: $

    *)
  4. | KDate
    (*

    Suffix: @

    *)
  5. | KDuration
    (*

    Suffix: ^

    *)
type binop =
  1. | And
  2. | Or
  3. | Add of op_kind
  4. | Sub of op_kind
  5. | Mult of op_kind
  6. | Div of op_kind
  7. | Lt of op_kind
  8. | Lte of op_kind
  9. | Gt of op_kind
  10. | Gte of op_kind
  11. | Eq
  12. | Neq
type unop =
  1. | Not
  2. | Minus of op_kind
type builtin_expression =
  1. | Cardinal
  2. | Now
type aggregate_func =
  1. | AggregateSum
  2. | AggregateCount
type literal_date = {
  1. literal_date_day : int Pos.marked;
  2. literal_date_month : int Pos.marked;
  3. literal_date_year : int Pos.marked;
}
type literal_number =
  1. | Int of Z.t
  2. | Dec of Z.t * Z.t
type literal_unit =
  1. | Percent
  2. | Year
  3. | Month
  4. | Day
type collection_op =
  1. | Exists
  2. | Forall
  3. | Aggregate of aggregate_func
type money_amount = {
  1. money_amount_units : Z.t;
  2. money_amount_cents : Z.t;
}
type literal =
  1. | Number of literal_number Pos.marked * literal_unit Pos.marked option
  2. | Bool of bool
  3. | MoneyAmount of money_amount
  4. | Date of literal_date
type match_case = {
  1. match_case_pattern : match_case_pattern Pos.marked;
  2. match_case_expr : expression Pos.marked;
}
and match_cases = match_case Pos.marked list
and expression =
  1. | MatchWith of expression Pos.marked * match_cases Pos.marked
  2. | IfThenElse of expression Pos.marked * expression Pos.marked * expression Pos.marked
  3. | Binop of binop Pos.marked * expression Pos.marked * expression Pos.marked
  4. | Unop of unop Pos.marked * expression Pos.marked
  5. | CollectionOp of collection_op Pos.marked * ident Pos.marked * expression Pos.marked * expression Pos.marked
  6. | MemCollection of expression Pos.marked * expression Pos.marked
  7. | TestMatchCase of expression Pos.marked * constructor Pos.marked
  8. | FunCall of expression Pos.marked * expression Pos.marked
  9. | Builtin of builtin_expression
  10. | Literal of literal
  11. | EnumInject of constructor Pos.marked * expression Pos.marked option
  12. | EnumProject of expression Pos.marked * constructor Pos.marked
  13. | StructLit of constructor Pos.marked * (ident Pos.marked * expression Pos.marked) list
  14. | Ident of ident
  15. | Dotted of expression Pos.marked * ident Pos.marked
    (*

    Dotted is for both struct field projection and sub-scope variables

    *)
type rule = {
  1. rule_label : ident Pos.marked option;
  2. rule_exception_to : ident Pos.marked option;
  3. rule_parameter : ident Pos.marked option;
  4. rule_condition : expression Pos.marked option;
  5. rule_name : qident Pos.marked;
  6. rule_consequence : bool Pos.marked;
}
type definition = {
  1. definition_label : ident Pos.marked option;
  2. definition_exception_to : ident Pos.marked option;
  3. definition_name : qident Pos.marked;
  4. definition_parameter : ident Pos.marked option;
  5. definition_condition : expression Pos.marked option;
  6. definition_expr : expression Pos.marked;
}
type variation_typ =
  1. | Increasing
  2. | Decreasing
type meta_assertion =
  1. | FixedBy of qident Pos.marked * ident Pos.marked
  2. | VariesWith of qident Pos.marked * expression Pos.marked * variation_typ Pos.marked option
type assertion = {
  1. assertion_condition : expression Pos.marked option;
  2. assertion_content : expression Pos.marked;
}
type scope_use_item =
  1. | Rule of rule
  2. | Definition of definition
  3. | Assertion of assertion
  4. | MetaAssertion of meta_assertion
type scope_use = {
  1. scope_use_condition : expression Pos.marked option;
  2. scope_use_name : constructor Pos.marked;
  3. scope_use_items : scope_use_item Pos.marked list;
}
type scope_decl_context_scope = {
  1. scope_decl_context_scope_name : ident Pos.marked;
  2. scope_decl_context_scope_sub_scope : constructor Pos.marked;
}
type scope_decl_context_data = {
  1. scope_decl_context_item_name : ident Pos.marked;
  2. scope_decl_context_item_typ : typ Pos.marked;
}
type scope_decl_context_item =
  1. | ContextData of scope_decl_context_data
  2. | ContextScope of scope_decl_context_scope
type scope_decl = {
  1. scope_decl_name : constructor Pos.marked;
  2. scope_decl_context : scope_decl_context_item Pos.marked list;
}
type code_item =
  1. | ScopeUse of scope_use
  2. | ScopeDecl of scope_decl
  3. | StructDecl of struct_decl
  4. | EnumDecl of enum_decl
type code_block = code_item Pos.marked list
type source_repr = string Pos.marked
type law_article = {
  1. law_article_name : string Pos.marked;
  2. law_article_id : string option;
  3. law_article_expiration_date : string option;
}
type law_include =
  1. | PdfFile of string Pos.marked * int option
  2. | CatalaFile of string Pos.marked
  3. | LegislativeText of string Pos.marked
type law_article_item =
  1. | LawText of string
  2. | CodeBlock of code_block * source_repr
type law_heading = {
  1. law_heading_name : string;
  2. law_heading_precedence : int;
}
type law_structure =
  1. | LawInclude of law_include
  2. | LawHeading of law_heading * law_structure list
  3. | LawArticle of law_article * law_article_item list
  4. | MetadataBlock of code_block * source_repr
  5. | IntermediateText of string
type program_item =
  1. | LawStructure of law_structure
type program = {
  1. program_items : program_item list;
  2. program_source_files : string list;
}
type source_file_or_master =
  1. | SourceFile of program_item list
  2. | MasterFile of string Pos.marked list
OCaml

Innovation. Community. Security.