2021-04-29 19:40:29 +03:00
|
|
|
(*
|
|
|
|
This file is part of the Catala compiler, a specification language for tax and social benefits
|
|
|
|
computation rules.
|
2021-05-27 19:56:47 +03:00
|
|
|
Copyright (C) 2020 Inria, contributors: Denis Merigoux <denis.merigoux@inria.fr>,
|
|
|
|
Emile Rolley <emile.rolley@tuta.io>
|
2021-04-29 19:40:29 +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
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
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.
|
|
|
|
*)
|
|
|
|
|
|
|
|
%{
|
|
|
|
open Ast
|
|
|
|
%}
|
|
|
|
|
|
|
|
%token EOF
|
2022-09-07 18:14:22 +03:00
|
|
|
%token<string * string option * bool * int> LAW_HEADING
|
2021-08-17 16:49:48 +03:00
|
|
|
|
2023-12-01 17:24:54 +03:00
|
|
|
%token BEGIN_DIRECTIVE END_DIRECTIVE LAW_INCLUDE MODULE_DEF MODULE_USE MODULE_ALIAS MODULE_EXTERNAL
|
2021-08-17 16:49:48 +03:00
|
|
|
%token<int> AT_PAGE
|
|
|
|
%token<string> DIRECTIVE_ARG
|
|
|
|
|
2021-04-29 19:40:29 +03:00
|
|
|
%token<string> LAW_TEXT
|
2022-12-15 13:48:48 +03:00
|
|
|
%token<string> UIDENT LIDENT
|
2021-04-29 19:40:29 +03:00
|
|
|
%token<string> END_CODE
|
2022-04-22 15:26:28 +03:00
|
|
|
%token<string> INT_LITERAL
|
2022-07-21 15:14:22 +03:00
|
|
|
%token<int * int * int> DATE_LITERAL
|
2021-04-29 19:40:29 +03:00
|
|
|
%token TRUE FALSE
|
2022-04-22 15:26:28 +03:00
|
|
|
%token<string * string> DECIMAL_LITERAL
|
|
|
|
%token<string * string> MONEY_AMOUNT
|
2021-05-15 02:16:08 +03:00
|
|
|
%token BEGIN_CODE TEXT
|
2023-01-13 16:49:05 +03:00
|
|
|
%token COLON ALT DATA
|
2023-12-05 17:06:28 +03:00
|
|
|
%token OF INTEGER LIST CONTAINS AMONG
|
2021-04-29 19:40:29 +03:00
|
|
|
%token RULE CONDITION DEFINED_AS
|
Add overloaded operators for the common operations
This uses the same disambiguation mechanism put in place for
structures, calling the typer on individual rules on the desugared AST
to propagate types, in order to resolve ambiguous operators like `+`
to their strongly typed counterparts (`+!`, `+.`, `+$`, `+@`, `+$`) in
the translation to scopelang.
The patch includes some normalisation of the definition of all the
operators, and classifies them based on their typing policy instead of
their arity. It also adds a little more flexibility:
- a couple new operators, like `-` on date and duration
- optional type annotation on some aggregation constructions
The `Shared_ast` lib is also lightly restructured, with the `Expr`
module split into `Type`, `Operator` and `Expr`.
2022-11-29 11:47:53 +03:00
|
|
|
%token<Ast.op_kind> LESSER GREATER LESSER_EQUAL GREATER_EQUAL
|
2023-01-12 13:12:48 +03:00
|
|
|
%token LET EXISTS IN SUCH THAT COMMA
|
2024-10-22 18:07:07 +03:00
|
|
|
%token INITIALLY
|
2021-04-29 19:40:29 +03:00
|
|
|
%token DOT AND OR XOR LPAREN RPAREN EQUAL
|
2024-10-28 16:37:30 +03:00
|
|
|
%token CARDINAL ASSERTION YEAR MONTH DAY
|
Add overloaded operators for the common operations
This uses the same disambiguation mechanism put in place for
structures, calling the typer on individual rules on the desugared AST
to propagate types, in order to resolve ambiguous operators like `+`
to their strongly typed counterparts (`+!`, `+.`, `+$`, `+@`, `+$`) in
the translation to scopelang.
The patch includes some normalisation of the definition of all the
operators, and classifies them based on their typing policy instead of
their arity. It also adds a little more flexibility:
- a couple new operators, like `-` on date and duration
- optional type annotation on some aggregation constructions
The `Shared_ast` lib is also lightly restructured, with the `Expr`
module split into `Type`, `Operator` and `Expr`.
2022-11-29 11:47:53 +03:00
|
|
|
%token<Ast.op_kind> PLUS MINUS MULT DIV
|
2021-08-19 19:26:06 +03:00
|
|
|
%token PLUSPLUS
|
2024-10-28 16:37:30 +03:00
|
|
|
%token MATCH WITH WITH_V WILDCARD
|
2021-04-29 19:40:29 +03:00
|
|
|
%token FOR ALL WE_HAVE INCREASING DECREASING
|
|
|
|
%token NOT BOOLEAN PERCENT DURATION
|
2022-02-28 16:33:07 +03:00
|
|
|
%token SCOPE FILLED NOT_EQUAL DEFINITION STATE
|
2021-04-29 19:40:29 +03:00
|
|
|
%token STRUCT CONTENT IF THEN DEPENDS DECLARATION
|
2022-01-27 20:03:47 +03:00
|
|
|
%token CONTEXT INPUT OUTPUT INTERNAL ENUM ELSE DATE SUM
|
2021-10-01 11:01:25 +03:00
|
|
|
%token BEGIN_METADATA MONEY DECIMAL
|
2022-12-15 13:48:48 +03:00
|
|
|
%token UNDER_CONDITION CONSEQUENCE LBRACE RBRACE
|
|
|
|
%token LABEL EXCEPTION LBRACKET RBRACKET SEMICOLON
|
2024-10-22 18:07:07 +03:00
|
|
|
%token COMBINE MAXIMUM MINIMUM IS LIST_EMPTY BUT_REPLACE
|
2021-04-29 19:40:29 +03:00
|
|
|
%%
|