2020-04-16 18:47:35 +03:00
|
|
|
(* This file is part of the Catala compiler, a specification language for tax and social benefits
|
2020-04-15 16:33:21 +03:00
|
|
|
computation rules. Copyright (C) 2020 Inria, contributor: Denis Merigoux
|
2020-03-09 14:01:56 +03:00
|
|
|
<denis.merigoux@inria.fr>
|
2020-03-08 02:21:55 +03:00
|
|
|
|
2020-03-09 14:01:56 +03:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
|
|
in compliance with the License. You may obtain a copy of the License at
|
2020-03-08 02:21:55 +03:00
|
|
|
|
2020-03-09 14:01:56 +03:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2020-03-08 02:21:55 +03:00
|
|
|
|
2020-03-09 14:01:56 +03:00
|
|
|
Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
|
|
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
|
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
|
|
the License. *)
|
2020-03-08 02:21:55 +03:00
|
|
|
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@@ocaml.warning "-7"]
|
|
|
|
|
2021-01-21 23:33:04 +03:00
|
|
|
open Utils
|
2020-11-23 11:22:47 +03:00
|
|
|
|
2021-01-20 18:06:04 +03:00
|
|
|
type constructor = (string[@opaque])
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "constructor_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; name = "constructor_iter"; nude = true }]
|
2020-04-14 12:01:31 +03:00
|
|
|
|
2021-01-20 18:06:04 +03:00
|
|
|
type ident = (string[@opaque])
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "ident_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; name = "ident_iter"; nude = true }]
|
2020-04-14 12:46:48 +03:00
|
|
|
|
2020-07-01 00:15:14 +03:00
|
|
|
type qident = ident Pos.marked list
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "Pos.marked_map"; "ident_map" ]; name = "qident_map" },
|
|
|
|
visitors
|
|
|
|
{ variety = "iter"; ancestors = [ "Pos.marked_iter"; "ident_iter" ]; name = "qident_iter" }]
|
2020-04-14 18:58:36 +03:00
|
|
|
|
2020-12-10 13:35:56 +03:00
|
|
|
type primitive_typ =
|
|
|
|
| Integer
|
|
|
|
| Decimal
|
|
|
|
| Boolean
|
|
|
|
| Money
|
|
|
|
| Duration
|
|
|
|
| Text
|
|
|
|
| Date
|
|
|
|
| Named of constructor
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "constructor_map" ]; name = "primitive_typ_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "constructor_iter" ]; name = "primitive_typ_iter" }]
|
2020-04-14 12:46:48 +03:00
|
|
|
|
2020-12-30 00:26:10 +03:00
|
|
|
type base_typ_data = Primitive of primitive_typ | Collection of base_typ_data Pos.marked
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "Pos.marked_map"; "primitive_typ_map" ];
|
|
|
|
name = "base_typ_data_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "Pos.marked_iter"; "primitive_typ_iter" ];
|
|
|
|
name = "base_typ_data_iter";
|
|
|
|
}]
|
2020-04-14 12:46:48 +03:00
|
|
|
|
2020-04-14 13:34:09 +03:00
|
|
|
type base_typ = Condition | Data of base_typ_data
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
2021-01-21 02:14:23 +03:00
|
|
|
{ variety = "map"; ancestors = [ "base_typ_data_map" ]; name = "base_typ_map"; nude = true },
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "base_typ_data_iter" ];
|
|
|
|
name = "base_typ_iter";
|
|
|
|
nude = true;
|
|
|
|
}]
|
2020-04-14 13:34:09 +03:00
|
|
|
|
|
|
|
type func_typ = { arg_typ : base_typ Pos.marked; return_typ : base_typ Pos.marked }
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "base_typ_map" ]; name = "func_typ_map"; nude = true },
|
|
|
|
visitors
|
|
|
|
{ variety = "iter"; ancestors = [ "base_typ_iter" ]; name = "func_typ_iter"; nude = true }]
|
2020-04-14 13:34:09 +03:00
|
|
|
|
|
|
|
type typ = Base of base_typ | Func of func_typ
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "func_typ_map" ]; name = "typ_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "func_typ_iter" ]; name = "typ_iter"; nude = true }]
|
2020-04-14 12:46:48 +03:00
|
|
|
|
|
|
|
type struct_decl_field = {
|
|
|
|
struct_decl_field_name : ident Pos.marked;
|
|
|
|
struct_decl_field_typ : typ Pos.marked;
|
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
2021-01-21 02:14:23 +03:00
|
|
|
{ variety = "map"; ancestors = [ "typ_map"; "ident_map" ]; name = "struct_decl_field_map" },
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "typ_iter"; "ident_iter" ];
|
|
|
|
name = "struct_decl_field_iter";
|
|
|
|
}]
|
2020-04-14 12:46:48 +03:00
|
|
|
|
|
|
|
type struct_decl = {
|
|
|
|
struct_decl_name : constructor Pos.marked;
|
|
|
|
struct_decl_fields : struct_decl_field Pos.marked list;
|
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "struct_decl_field_map" ]; name = "struct_decl_map" },
|
|
|
|
visitors
|
|
|
|
{ variety = "iter"; ancestors = [ "struct_decl_field_iter" ]; name = "struct_decl_iter" }]
|
2020-04-14 12:46:48 +03:00
|
|
|
|
2020-04-14 13:34:09 +03:00
|
|
|
type enum_decl_case = {
|
|
|
|
enum_decl_case_name : constructor Pos.marked;
|
|
|
|
enum_decl_case_typ : typ Pos.marked option;
|
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "typ_map" ]; name = "enum_decl_case_map"; nude = true },
|
|
|
|
visitors
|
|
|
|
{ variety = "iter"; ancestors = [ "typ_iter" ]; name = "enum_decl_case_iter"; nude = true }]
|
2020-04-14 13:34:09 +03:00
|
|
|
|
|
|
|
type enum_decl = {
|
|
|
|
enum_decl_name : constructor Pos.marked;
|
|
|
|
enum_decl_cases : enum_decl_case Pos.marked list;
|
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
2021-01-21 02:14:23 +03:00
|
|
|
{ variety = "map"; ancestors = [ "enum_decl_case_map" ]; name = "enum_decl_map"; nude = true },
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "enum_decl_case_iter" ];
|
|
|
|
name = "enum_decl_iter";
|
|
|
|
nude = true;
|
|
|
|
}]
|
2020-04-14 13:34:09 +03:00
|
|
|
|
2021-01-26 19:41:20 +03:00
|
|
|
type match_case_pattern =
|
|
|
|
(constructor Pos.marked option * constructor Pos.marked) list * ident Pos.marked option
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "ident_map"; "constructor_map"; "Pos.marked_map" ];
|
|
|
|
name = "match_case_pattern_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "ident_iter"; "constructor_iter"; "Pos.marked_iter" ];
|
|
|
|
name = "match_case_pattern_iter";
|
|
|
|
}]
|
2020-04-14 18:58:36 +03:00
|
|
|
|
2021-02-17 12:34:47 +03:00
|
|
|
type op_kind = KInt | KDec | KMoney | KDate | KDuration
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "op_kind_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; name = "op_kind_iter"; nude = true }]
|
2020-12-09 16:51:22 +03:00
|
|
|
|
|
|
|
type binop =
|
|
|
|
| And
|
|
|
|
| Or
|
2021-03-16 22:34:03 +03:00
|
|
|
| Xor
|
2020-12-09 16:51:22 +03:00
|
|
|
| Add of op_kind
|
|
|
|
| Sub of op_kind
|
|
|
|
| Mult of op_kind
|
|
|
|
| Div of op_kind
|
|
|
|
| Lt of op_kind
|
|
|
|
| Lte of op_kind
|
|
|
|
| Gt of op_kind
|
|
|
|
| Gte of op_kind
|
|
|
|
| Eq
|
|
|
|
| Neq
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "op_kind_map" ]; name = "binop_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "op_kind_iter" ]; name = "binop_iter"; nude = true }]
|
2020-12-09 16:51:22 +03:00
|
|
|
|
|
|
|
type unop = Not | Minus of op_kind
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "op_kind_map" ]; name = "unop_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "op_kind_iter" ]; name = "unop_iter"; nude = true }]
|
2020-04-14 20:13:20 +03:00
|
|
|
|
2021-01-05 18:00:15 +03:00
|
|
|
type builtin_expression = Cardinal | IntToDec | GetDay | GetMonth | GetYear
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "builtin_expression_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; name = "builtin_expression_iter"; nude = true }]
|
2020-04-14 20:13:20 +03:00
|
|
|
|
2020-04-15 17:02:40 +03:00
|
|
|
type literal_date = {
|
2021-01-20 18:06:04 +03:00
|
|
|
literal_date_day : (int[@opaque]) Pos.marked;
|
|
|
|
literal_date_month : (int[@opaque]) Pos.marked;
|
|
|
|
literal_date_year : (int[@opaque]) Pos.marked;
|
2020-04-15 17:02:40 +03:00
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "Pos.marked_map" ]; name = "literal_date_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "Pos.marked_iter" ]; name = "literal_date_iter" }]
|
2020-04-15 17:02:40 +03:00
|
|
|
|
2021-03-05 21:16:56 +03:00
|
|
|
type literal_number =
|
|
|
|
| Int of (Runtime.integer[@opaque])
|
|
|
|
| Dec of (Runtime.integer[@opaque]) * (Runtime.integer[@opaque])
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "literal_number_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; name = "literal_number_iter"; nude = true }]
|
2020-04-14 20:13:20 +03:00
|
|
|
|
2020-04-25 16:17:44 +03:00
|
|
|
type literal_unit = Percent | Year | Month | Day
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "literal_unit_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; name = "literal_unit_iter"; nude = true }]
|
2020-04-14 20:13:20 +03:00
|
|
|
|
2021-03-05 21:16:56 +03:00
|
|
|
type money_amount = {
|
|
|
|
money_amount_units : (Runtime.integer[@opaque]);
|
|
|
|
money_amount_cents : (Runtime.integer[@opaque]);
|
|
|
|
}
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "money_amount_map"; nude = true },
|
|
|
|
visitors { variety = "iter"; name = "money_amount_iter"; nude = true }]
|
2020-04-25 16:17:44 +03:00
|
|
|
|
2020-04-15 17:02:40 +03:00
|
|
|
type literal =
|
2021-01-20 18:06:04 +03:00
|
|
|
| LNumber of literal_number Pos.marked * literal_unit Pos.marked option
|
|
|
|
| LBool of bool
|
|
|
|
| LMoneyAmount of money_amount
|
|
|
|
| LDate of literal_date
|
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors =
|
|
|
|
[ "literal_number_map"; "money_amount_map"; "literal_date_map"; "literal_unit_map" ];
|
|
|
|
name = "literal_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors =
|
|
|
|
[ "literal_number_iter"; "money_amount_iter"; "literal_date_iter"; "literal_unit_iter" ];
|
|
|
|
name = "literal_iter";
|
|
|
|
}]
|
2020-04-14 20:13:20 +03:00
|
|
|
|
2021-01-06 14:41:24 +03:00
|
|
|
type aggregate_func =
|
|
|
|
| AggregateSum of primitive_typ
|
|
|
|
| AggregateCount
|
2021-02-17 12:34:47 +03:00
|
|
|
| AggregateExtremum of bool * primitive_typ * expression Pos.marked
|
|
|
|
| AggregateArgExtremum of bool * primitive_typ * expression Pos.marked
|
2021-01-06 14:41:24 +03:00
|
|
|
|
2021-01-10 19:07:41 +03:00
|
|
|
and collection_op = Exists | Forall | Aggregate of aggregate_func | Map | Filter
|
2021-01-06 14:41:24 +03:00
|
|
|
|
|
|
|
and match_case = {
|
2020-04-14 20:13:20 +03:00
|
|
|
match_case_pattern : match_case_pattern Pos.marked;
|
|
|
|
match_case_expr : expression Pos.marked;
|
|
|
|
}
|
|
|
|
|
|
|
|
and match_cases = match_case Pos.marked list
|
|
|
|
|
|
|
|
and expression =
|
|
|
|
| MatchWith of expression Pos.marked * match_cases Pos.marked
|
|
|
|
| IfThenElse of expression Pos.marked * expression Pos.marked * expression Pos.marked
|
|
|
|
| Binop of binop Pos.marked * expression Pos.marked * expression Pos.marked
|
|
|
|
| Unop of unop Pos.marked * expression Pos.marked
|
2020-04-15 17:26:30 +03:00
|
|
|
| CollectionOp of
|
|
|
|
collection_op Pos.marked * ident Pos.marked * expression Pos.marked * expression Pos.marked
|
2020-04-14 20:13:20 +03:00
|
|
|
| MemCollection of expression Pos.marked * expression Pos.marked
|
2021-01-18 18:21:55 +03:00
|
|
|
| TestMatchCase of expression Pos.marked * match_case_pattern Pos.marked
|
2020-04-14 20:13:20 +03:00
|
|
|
| FunCall of expression Pos.marked * expression Pos.marked
|
|
|
|
| Builtin of builtin_expression
|
|
|
|
| Literal of literal
|
2021-01-26 18:38:10 +03:00
|
|
|
| EnumInject of
|
|
|
|
constructor Pos.marked option * constructor Pos.marked * expression Pos.marked option
|
2020-12-05 19:27:08 +03:00
|
|
|
| StructLit of constructor Pos.marked * (ident Pos.marked * expression Pos.marked) list
|
2020-12-30 00:26:10 +03:00
|
|
|
| ArrayLit of expression Pos.marked list
|
2020-07-01 00:15:14 +03:00
|
|
|
| Ident of ident
|
2021-01-26 06:32:31 +03:00
|
|
|
| Dotted of expression Pos.marked * constructor Pos.marked option * ident Pos.marked
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors =
|
|
|
|
[
|
|
|
|
"primitive_typ_map";
|
|
|
|
"match_case_pattern_map";
|
|
|
|
"literal_map";
|
|
|
|
"binop_map";
|
|
|
|
"unop_map";
|
|
|
|
"builtin_expression_map";
|
|
|
|
];
|
|
|
|
name = "expression_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors =
|
|
|
|
[
|
|
|
|
"primitive_typ_iter";
|
|
|
|
"match_case_pattern_iter";
|
|
|
|
"literal_iter";
|
|
|
|
"binop_iter";
|
|
|
|
"unop_iter";
|
|
|
|
"builtin_expression_iter";
|
|
|
|
];
|
|
|
|
name = "expression_iter";
|
|
|
|
}]
|
2020-04-14 20:13:20 +03:00
|
|
|
|
2021-01-21 21:53:25 +03:00
|
|
|
type exception_to = NotAnException | UnlabeledException | ExceptionToLabel of ident Pos.marked
|
|
|
|
[@@deriving
|
|
|
|
visitors
|
2021-01-21 23:10:22 +03:00
|
|
|
{ variety = "map"; ancestors = [ "ident_map"; "Pos.marked_map" ]; name = "exception_to_map" },
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "ident_iter"; "Pos.marked_iter" ];
|
|
|
|
name = "exception_to_iter";
|
|
|
|
}]
|
2021-01-21 21:53:25 +03:00
|
|
|
|
2020-04-14 20:13:20 +03:00
|
|
|
type rule = {
|
2020-12-18 15:13:51 +03:00
|
|
|
rule_label : ident Pos.marked option;
|
2021-01-21 21:53:25 +03:00
|
|
|
rule_exception_to : exception_to;
|
2020-04-14 20:13:20 +03:00
|
|
|
rule_parameter : ident Pos.marked option;
|
|
|
|
rule_condition : expression Pos.marked option;
|
2020-04-14 20:16:40 +03:00
|
|
|
rule_name : qident Pos.marked;
|
2021-01-20 18:06:04 +03:00
|
|
|
rule_consequence : (bool[@opaque]) Pos.marked;
|
2020-04-14 20:13:20 +03:00
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 21:53:25 +03:00
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
2021-01-21 23:10:22 +03:00
|
|
|
ancestors = [ "expression_map"; "qident_map"; "exception_to_map" ];
|
2021-01-21 21:53:25 +03:00
|
|
|
name = "rule_map";
|
2021-01-21 23:10:22 +03:00
|
|
|
},
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors
|
2021-01-21 23:10:22 +03:00
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "expression_iter"; "qident_iter"; "exception_to_iter" ];
|
|
|
|
name = "rule_iter";
|
|
|
|
}]
|
2020-04-14 20:13:20 +03:00
|
|
|
|
|
|
|
type definition = {
|
2020-12-18 15:13:51 +03:00
|
|
|
definition_label : ident Pos.marked option;
|
2021-01-21 21:53:25 +03:00
|
|
|
definition_exception_to : exception_to;
|
2020-04-14 20:13:20 +03:00
|
|
|
definition_name : qident Pos.marked;
|
|
|
|
definition_parameter : ident Pos.marked option;
|
|
|
|
definition_condition : expression Pos.marked option;
|
|
|
|
definition_expr : expression Pos.marked;
|
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
2021-01-21 21:53:25 +03:00
|
|
|
{
|
|
|
|
variety = "map";
|
2021-01-21 23:10:22 +03:00
|
|
|
ancestors = [ "expression_map"; "qident_map"; "exception_to_map" ];
|
2021-01-21 21:53:25 +03:00
|
|
|
name = "definition_map";
|
2021-01-21 23:10:22 +03:00
|
|
|
},
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
2021-01-21 23:10:22 +03:00
|
|
|
ancestors = [ "expression_iter"; "qident_iter"; "exception_to_iter" ];
|
2021-01-21 02:14:23 +03:00
|
|
|
name = "definition_iter";
|
|
|
|
}]
|
2020-04-14 18:58:36 +03:00
|
|
|
|
|
|
|
type variation_typ = Increasing | Decreasing
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "variation_typ_map" },
|
|
|
|
visitors { variety = "iter"; name = "variation_typ_iter" }]
|
2020-04-14 18:58:36 +03:00
|
|
|
|
2020-04-25 15:21:26 +03:00
|
|
|
type meta_assertion =
|
2020-04-14 18:58:36 +03:00
|
|
|
| FixedBy of qident Pos.marked * ident Pos.marked
|
|
|
|
| VariesWith of qident Pos.marked * expression Pos.marked * variation_typ Pos.marked option
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "variation_typ_map"; "qident_map"; "expression_map" ];
|
|
|
|
name = "meta_assertion_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "variation_typ_iter"; "qident_iter"; "expression_iter" ];
|
|
|
|
name = "meta_assertion_iter";
|
|
|
|
}]
|
2020-04-14 18:58:36 +03:00
|
|
|
|
|
|
|
type assertion = {
|
|
|
|
assertion_condition : expression Pos.marked option;
|
2020-04-25 15:21:26 +03:00
|
|
|
assertion_content : expression Pos.marked;
|
2020-04-14 18:58:36 +03:00
|
|
|
}
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; ancestors = [ "expression_map" ]; name = "assertion_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "expression_iter" ]; name = "assertion_iter" }]
|
2020-04-14 18:58:36 +03:00
|
|
|
|
2020-05-14 22:19:46 +03:00
|
|
|
type scope_use_item =
|
2020-04-25 15:21:26 +03:00
|
|
|
| Rule of rule
|
|
|
|
| Definition of definition
|
|
|
|
| Assertion of assertion
|
|
|
|
| MetaAssertion of meta_assertion
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "meta_assertion_map"; "definition_map"; "assertion_map"; "rule_map" ];
|
|
|
|
name = "scope_use_item_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "meta_assertion_iter"; "definition_iter"; "assertion_iter"; "rule_iter" ];
|
|
|
|
name = "scope_use_item_iter";
|
|
|
|
}]
|
2020-04-14 18:58:36 +03:00
|
|
|
|
2020-05-14 22:19:46 +03:00
|
|
|
type scope_use = {
|
2020-05-18 12:29:22 +03:00
|
|
|
scope_use_condition : expression Pos.marked option;
|
2020-05-14 22:19:46 +03:00
|
|
|
scope_use_name : constructor Pos.marked;
|
|
|
|
scope_use_items : scope_use_item Pos.marked list;
|
2020-04-14 18:58:36 +03:00
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "expression_map"; "scope_use_item_map" ];
|
|
|
|
name = "scope_use_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "expression_iter"; "scope_use_item_iter" ];
|
|
|
|
name = "scope_use_iter";
|
|
|
|
}]
|
2020-04-14 18:58:36 +03:00
|
|
|
|
2020-05-19 15:30:52 +03:00
|
|
|
type scope_decl_context_scope = {
|
|
|
|
scope_decl_context_scope_name : ident Pos.marked;
|
|
|
|
scope_decl_context_scope_sub_scope : constructor Pos.marked;
|
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "ident_map"; "constructor_map"; "Pos.marked_map" ];
|
|
|
|
name = "scope_decl_context_scope_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "ident_iter"; "constructor_iter"; "Pos.marked_iter" ];
|
|
|
|
name = "scope_decl_context_scope_iter";
|
|
|
|
}]
|
2020-05-19 15:30:52 +03:00
|
|
|
|
|
|
|
type scope_decl_context_data = {
|
|
|
|
scope_decl_context_item_name : ident Pos.marked;
|
|
|
|
scope_decl_context_item_typ : typ Pos.marked;
|
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "typ_map"; "ident_map" ];
|
|
|
|
name = "scope_decl_context_data_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "typ_iter"; "ident_iter" ];
|
|
|
|
name = "scope_decl_context_data_iter";
|
|
|
|
}]
|
2020-05-19 15:30:52 +03:00
|
|
|
|
|
|
|
type scope_decl_context_item =
|
|
|
|
| ContextData of scope_decl_context_data
|
|
|
|
| ContextScope of scope_decl_context_scope
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "scope_decl_context_data_map"; "scope_decl_context_scope_map" ];
|
|
|
|
name = "scope_decl_context_item_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "scope_decl_context_data_iter"; "scope_decl_context_scope_iter" ];
|
|
|
|
name = "scope_decl_context_item_iter";
|
|
|
|
}]
|
2020-05-19 15:30:52 +03:00
|
|
|
|
|
|
|
type scope_decl = {
|
|
|
|
scope_decl_name : constructor Pos.marked;
|
|
|
|
scope_decl_context : scope_decl_context_item Pos.marked list;
|
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
2021-01-21 02:14:23 +03:00
|
|
|
{ variety = "map"; ancestors = [ "scope_decl_context_item_map" ]; name = "scope_decl_map" },
|
|
|
|
visitors
|
|
|
|
{ variety = "iter"; ancestors = [ "scope_decl_context_item_iter" ]; name = "scope_decl_iter" }]
|
2020-05-19 15:30:52 +03:00
|
|
|
|
2020-04-14 12:46:48 +03:00
|
|
|
type code_item =
|
2020-05-14 22:19:46 +03:00
|
|
|
| ScopeUse of scope_use
|
|
|
|
| ScopeDecl of scope_decl
|
2020-04-14 12:46:48 +03:00
|
|
|
| StructDecl of struct_decl
|
2020-04-14 13:34:09 +03:00
|
|
|
| EnumDecl of enum_decl
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "scope_decl_map"; "enum_decl_map"; "struct_decl_map"; "scope_use_map" ];
|
|
|
|
name = "code_item_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "scope_decl_iter"; "enum_decl_iter"; "struct_decl_iter"; "scope_use_iter" ];
|
|
|
|
name = "code_item_iter";
|
|
|
|
}]
|
2020-04-14 12:46:48 +03:00
|
|
|
|
|
|
|
type code_block = code_item Pos.marked list
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; ancestors = [ "code_item_map" ]; name = "code_block_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "code_item_iter" ]; name = "code_block_iter" }]
|
2020-04-14 12:01:31 +03:00
|
|
|
|
2021-01-20 18:06:04 +03:00
|
|
|
type source_repr = (string[@opaque]) Pos.marked
|
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "Pos.marked_map" ]; name = "source_repr_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "Pos.marked_iter" ]; name = "source_repr_iter" }]
|
2020-04-14 12:01:31 +03:00
|
|
|
|
2020-04-22 13:36:33 +03:00
|
|
|
type law_article = {
|
2021-01-20 18:06:04 +03:00
|
|
|
law_article_name : (string[@opaque]) Pos.marked;
|
|
|
|
law_article_id : (string[@opaque]) option;
|
|
|
|
law_article_expiration_date : (string[@opaque]) option;
|
2021-03-09 20:48:58 +03:00
|
|
|
law_article_precedence : (int[@opaque]);
|
2020-04-22 13:36:33 +03:00
|
|
|
}
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "Pos.marked_map" ]; name = "law_article_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "Pos.marked_iter" ]; name = "law_article_iter" }]
|
2020-04-22 12:51:17 +03:00
|
|
|
|
2020-04-30 11:19:45 +03:00
|
|
|
type law_include =
|
2021-01-20 18:06:04 +03:00
|
|
|
| PdfFile of (string[@opaque]) Pos.marked * (int[@opaque]) option
|
|
|
|
| CatalaFile of (string[@opaque]) Pos.marked
|
|
|
|
| LegislativeText of (string[@opaque]) Pos.marked
|
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "Pos.marked_map" ]; name = "law_include_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "Pos.marked_iter" ]; name = "law_include_iter" }]
|
2021-01-20 18:06:04 +03:00
|
|
|
|
|
|
|
type law_article_item = LawText of (string[@opaque]) | CodeBlock of code_block * source_repr
|
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors = [ "code_block_map"; "source_repr_map" ];
|
|
|
|
name = "law_article_item_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors = [ "code_block_iter"; "source_repr_iter" ];
|
|
|
|
name = "law_article_item_iter";
|
|
|
|
}]
|
2021-01-20 18:06:04 +03:00
|
|
|
|
|
|
|
type law_heading = { law_heading_name : (string[@opaque]); law_heading_precedence : (int[@opaque]) }
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; name = "law_heading_map" },
|
|
|
|
visitors { variety = "iter"; name = "law_heading_iter" }]
|
2020-10-04 02:25:37 +03:00
|
|
|
|
|
|
|
type law_structure =
|
2020-12-11 23:17:01 +03:00
|
|
|
| LawInclude of law_include
|
2020-10-04 02:25:37 +03:00
|
|
|
| LawHeading of law_heading * law_structure list
|
|
|
|
| LawArticle of law_article * law_article_item list
|
|
|
|
| MetadataBlock of code_block * source_repr
|
2021-01-20 18:06:04 +03:00
|
|
|
| IntermediateText of (string[@opaque])
|
|
|
|
[@@deriving
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "map";
|
|
|
|
ancestors =
|
|
|
|
[
|
|
|
|
"law_include_map";
|
|
|
|
"law_article_map";
|
|
|
|
"law_article_item_map";
|
|
|
|
"code_block_map";
|
|
|
|
"source_repr_map";
|
|
|
|
"law_heading_map";
|
|
|
|
];
|
|
|
|
name = "law_structure_map";
|
2021-01-21 02:14:23 +03:00
|
|
|
},
|
|
|
|
visitors
|
|
|
|
{
|
|
|
|
variety = "iter";
|
|
|
|
ancestors =
|
|
|
|
[
|
|
|
|
"law_include_iter";
|
|
|
|
"law_article_iter";
|
|
|
|
"law_article_item_iter";
|
|
|
|
"code_block_iter";
|
|
|
|
"source_repr_iter";
|
|
|
|
"law_heading_iter";
|
|
|
|
];
|
|
|
|
name = "law_structure_iter";
|
|
|
|
}]
|
2020-10-04 02:25:37 +03:00
|
|
|
|
|
|
|
type program_item = LawStructure of law_structure
|
2021-01-20 18:06:04 +03:00
|
|
|
[@@deriving
|
2021-01-21 02:14:23 +03:00
|
|
|
visitors { variety = "map"; ancestors = [ "law_structure_map" ]; name = "program_item_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "law_structure_iter" ]; name = "program_item_iter" }]
|
2020-10-04 02:25:37 +03:00
|
|
|
|
2021-01-20 18:06:04 +03:00
|
|
|
type program = { program_items : program_item list; program_source_files : (string[@opaque]) list }
|
2021-01-21 02:14:23 +03:00
|
|
|
[@@deriving
|
|
|
|
visitors { variety = "map"; ancestors = [ "program_item_map" ]; name = "program_map" },
|
|
|
|
visitors { variety = "iter"; ancestors = [ "program_item_iter" ]; name = "program_iter" }]
|
2020-04-19 16:53:35 +03:00
|
|
|
|
|
|
|
type source_file_or_master =
|
|
|
|
| SourceFile of program_item list
|
|
|
|
| MasterFile of string Pos.marked list
|