package catala
Compiler and library for the literate programming language for tax code specification
Install
Dune Dependency
Authors
Maintainers
Sources
0.10.0.tar.gz
md5=5abd76e8c51a47670645e91b21b57fc5
sha512=9c6fbe50c0b5a60566e877eeddadca0a339e2ce35deb5c1beceb03bc40eb6af2d519313e71859d88645b53fad591d4fa5288c633b185c9d765603da0f5b7dd7b
doc/catala.surface/Surface/Ast/index.html
Module Surface.Ast
Source
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
Constructors are CamelCase
Idents are snake_case
foo.bar
in binding position: used to specify variables of subscopes
Source
and primitive_typ =
| Integer
| Decimal
| Boolean
| Money
| Duration
| Text
| Date
| Named of path * uident Catala_utils.Mark.pos
Source
and base_typ_data =
| Primitive of primitive_typ
| Collection of base_typ_data Catala_utils.Mark.pos
| TTuple of base_typ_data Catala_utils.Mark.pos list
Source
and func_typ = {
arg_typ : (lident Catala_utils.Mark.pos * base_typ Catala_utils.Mark.pos) list;
return_typ : base_typ Catala_utils.Mark.pos;
}
Source
and struct_decl_field = {
struct_decl_field_name : lident Catala_utils.Mark.pos;
struct_decl_field_typ : typ;
}
Source
and struct_decl = {
struct_decl_name : uident Catala_utils.Mark.pos;
struct_decl_fields : struct_decl_field Catala_utils.Mark.pos list;
}
Source
and enum_decl_case = {
enum_decl_case_name : uident Catala_utils.Mark.pos;
enum_decl_case_typ : typ option;
}
Source
and enum_decl = {
enum_decl_name : uident Catala_utils.Mark.pos;
enum_decl_cases : enum_decl_case Catala_utils.Mark.pos list;
}
Source
and match_case_pattern =
(path * uident Catala_utils.Mark.pos) Catala_utils.Mark.pos list
* lident Catala_utils.Mark.pos option
Source
and 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_date
Source
and 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;
}
| AggregateArgExtremum of {
max : bool;
default : expression;
f : lident Catala_utils.Mark.pos list * expression;
}
Source
and explicit_match_case = {
match_case_pattern : match_case_pattern Catala_utils.Mark.pos;
match_case_expr : expression;
}
Source
and 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 (path * uident Catala_utils.Mark.pos) 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.pos
(*Dotted is for both struct field projection and sub-scope variables
*)| TupleAccess of expression * int Catala_utils.Mark.pos
Source
and exception_to =
| NotAnException
| UnlabeledException
| ExceptionToLabel of lident Catala_utils.Mark.pos
Source
and 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;
}
Source
and 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;
}
Source
and meta_assertion =
| FixedBy of scope_var Catala_utils.Mark.pos * lident Catala_utils.Mark.pos
| VariesWith of scope_var Catala_utils.Mark.pos * expression * variation_typ Catala_utils.Mark.pos option
Source
and scope_use_item =
| Rule of rule
| Definition of definition
| Assertion of assertion
| MetaAssertion of meta_assertion
| DateRounding of variation_typ Catala_utils.Mark.pos
Source
and 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;
}
Source
and 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;
}
Source
and 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;
}
Source
and 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;
}
Source
and scope_decl_context_item =
| ContextData of scope_decl_context_data
| ContextScope of scope_decl_context_scope
Source
and scope_decl = {
scope_decl_name : uident Catala_utils.Mark.pos;
scope_decl_context : scope_decl_context_item Catala_utils.Mark.pos list;
}
Source
and 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;
}
Source
and code_item =
| ScopeUse of scope_use
| ScopeDecl of scope_decl
| StructDecl of struct_decl
| EnumDecl of enum_decl
| Topdef of top_def
Source
and law_heading = {
law_heading_name : string Catala_utils.Mark.pos;
law_heading_id : string option;
law_heading_is_archive : bool;
law_heading_precedence : int;
}
Source
and law_include =
| PdfFile of string Catala_utils.Mark.pos * int option
| CatalaFile of string Catala_utils.Mark.pos
| LegislativeText of string Catala_utils.Mark.pos
Source
and 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 * bool
Source
and interface = {
intf_modname : uident Catala_utils.Mark.pos;
intf_code : code_block;
(*Invariant: an interface shall only contain
*)*Decl
elements, orTopdef
elements withtopdef_expr = None
intf_submodules : module_use list;
}
Source
and module_use = {
mod_use_name : uident Catala_utils.Mark.pos;
mod_use_alias : uident Catala_utils.Mark.pos;
}
Source
and program = {
program_module_name : uident Catala_utils.Mark.pos option;
program_items : law_structure list;
program_source_files : string list;
program_used_modules : module_use list;
program_lang : Catala_utils.Global.backend_lang;
}
Helpers
Translates a rule
into the corresponding definition
Source
val type_from_args :
(lident Catala_utils.Mark.pos * base_typ Catala_utils.Mark.pos) list
Catala_utils.Mark.pos
option ->
base_typ Catala_utils.Mark.pos ->
typ
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page