Surface.AstSourceAbstract 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.
Constructors are CamelCase
include sig ... endinclude sig ... endIdents are snake_case
include sig ... endinclude sig ... endinclude sig ... endtype primitive_typ = | Integer| Decimal| Boolean| Money| Duration| Text| Date| Named of constructorinclude sig ... endinclude sig ... endtype base_typ_data = | Primitive of primitive_typ| Collection of base_typ_data Utils.Marked.posinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endtype struct_decl_field = {struct_decl_field_name : ident Utils.Marked.pos;struct_decl_field_typ : typ Utils.Marked.pos;}include sig ... endinclude sig ... endtype struct_decl = {struct_decl_name : constructor Utils.Marked.pos;struct_decl_fields : struct_decl_field Utils.Marked.pos list;}include sig ... endinclude sig ... endtype enum_decl_case = {enum_decl_case_name : constructor Utils.Marked.pos;enum_decl_case_typ : typ Utils.Marked.pos option;}include sig ... endinclude sig ... endtype enum_decl = {enum_decl_name : constructor Utils.Marked.pos;enum_decl_cases : enum_decl_case Utils.Marked.pos list;}include sig ... endinclude sig ... endtype match_case_pattern =
(constructor Utils.Marked.pos option * constructor Utils.Marked.pos) list
* ident Utils.Marked.pos optioninclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endtype literal = | LNumber of literal_number Utils.Marked.pos
* literal_unit Utils.Marked.pos option| LBool of bool| LMoneyAmount of money_amount| LDate of literal_dateinclude sig ... endinclude sig ... endtype aggregate_func = | AggregateSum of primitive_typ| AggregateCount| AggregateExtremum of bool * primitive_typ * expression Utils.Marked.pos| AggregateArgExtremum of bool * primitive_typ * expression Utils.Marked.posand explicit_match_case = {match_case_pattern : match_case_pattern Utils.Marked.pos;match_case_expr : expression Utils.Marked.pos;}and expression = | MatchWith of expression Utils.Marked.pos * match_cases Utils.Marked.pos| IfThenElse of expression Utils.Marked.pos
* expression Utils.Marked.pos
* expression Utils.Marked.pos| Binop of binop Utils.Marked.pos
* expression Utils.Marked.pos
* expression Utils.Marked.pos| Unop of unop Utils.Marked.pos * expression Utils.Marked.pos| CollectionOp of collection_op Utils.Marked.pos
* ident Utils.Marked.pos
* expression Utils.Marked.pos
* expression Utils.Marked.pos| MemCollection of expression Utils.Marked.pos * expression Utils.Marked.pos| TestMatchCase of expression Utils.Marked.pos
* match_case_pattern Utils.Marked.pos| FunCall of expression Utils.Marked.pos * expression Utils.Marked.pos| Builtin of builtin_expression| Literal of literal| EnumInject of constructor Utils.Marked.pos option
* constructor Utils.Marked.pos
* expression Utils.Marked.pos option| StructLit of constructor Utils.Marked.pos
* (ident Utils.Marked.pos * expression Utils.Marked.pos) list| ArrayLit of expression Utils.Marked.pos list| Ident of ident| Dotted of expression Utils.Marked.pos
* constructor Utils.Marked.pos option
* ident Utils.Marked.posDotted is for both struct field projection and sub-scope variables
*)include sig ... endinclude sig ... endtype exception_to = | NotAnException| UnlabeledException| ExceptionToLabel of ident Utils.Marked.posinclude sig ... endinclude sig ... endtype rule = {rule_label : ident Utils.Marked.pos option;rule_exception_to : exception_to;rule_parameter : ident Utils.Marked.pos option;rule_condition : expression Utils.Marked.pos option;rule_name : qident Utils.Marked.pos;rule_id : Desugared.Ast.RuleName.t;rule_consequence : bool Utils.Marked.pos;rule_state : ident Utils.Marked.pos option;}type definition = {definition_label : ident Utils.Marked.pos option;definition_exception_to : exception_to;definition_name : qident Utils.Marked.pos;definition_parameter : ident Utils.Marked.pos option;definition_condition : expression Utils.Marked.pos option;definition_id : Desugared.Ast.RuleName.t;definition_expr : expression Utils.Marked.pos;definition_state : ident Utils.Marked.pos option;}include sig ... endinclude sig ... endinclude sig ... endinclude sig ... endtype meta_assertion = | FixedBy of qident Utils.Marked.pos * ident Utils.Marked.pos| VariesWith of qident Utils.Marked.pos
* expression Utils.Marked.pos
* variation_typ Utils.Marked.pos optioninclude sig ... endinclude sig ... endtype assertion = {assertion_condition : expression Utils.Marked.pos option;assertion_content : expression Utils.Marked.pos;}include sig ... endinclude sig ... endtype scope_use_item = | Rule of rule| Definition of definition| Assertion of assertion| MetaAssertion of meta_assertioninclude sig ... endinclude sig ... endtype scope_use = {scope_use_condition : expression Utils.Marked.pos option;scope_use_name : constructor Utils.Marked.pos;scope_use_items : scope_use_item Utils.Marked.pos list;}include sig ... endinclude sig ... endinclude sig ... endinclude sig ... endtype scope_decl_context_io = {scope_decl_context_io_input : io_input Utils.Marked.pos;scope_decl_context_io_output : bool Utils.Marked.pos;}include sig ... endinclude sig ... endtype scope_decl_context_scope = {scope_decl_context_scope_name : ident Utils.Marked.pos;scope_decl_context_scope_sub_scope : constructor Utils.Marked.pos;scope_decl_context_scope_attribute : scope_decl_context_io;}include sig ... endinclude sig ... endtype scope_decl_context_data = {scope_decl_context_item_name : ident Utils.Marked.pos;scope_decl_context_item_typ : typ Utils.Marked.pos;scope_decl_context_item_attribute : scope_decl_context_io;scope_decl_context_item_states : ident Utils.Marked.pos list;}include sig ... endinclude sig ... endtype scope_decl_context_item = | ContextData of scope_decl_context_data| ContextScope of scope_decl_context_scopeinclude sig ... endinclude sig ... endtype scope_decl = {scope_decl_name : constructor Utils.Marked.pos;scope_decl_context : scope_decl_context_item Utils.Marked.pos list;}include sig ... endinclude sig ... endtype code_item = | ScopeUse of scope_use| ScopeDecl of scope_decl| StructDecl of struct_decl| EnumDecl of enum_declinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endtype law_heading = {law_heading_name : string Utils.Marked.pos;law_heading_id : string option;law_heading_expiration_date : string option;law_heading_precedence : int;}include sig ... endinclude sig ... endtype law_include = | PdfFile of string Utils.Marked.pos * int option| CatalaFile of string Utils.Marked.pos| LegislativeText of string Utils.Marked.posinclude sig ... endinclude sig ... endtype law_structure = | LawInclude of law_include| LawHeading of law_heading * law_structure list| LawText of string| CodeBlock of code_block * source_repr * boolinclude sig ... endinclude sig ... endinclude sig ... endinclude sig ... endTranslates a rule into the corresponding definition