2021-06-22 17:01:57 +03:00
|
|
|
(* This file is part of the Catala compiler, a specification language for tax
|
|
|
|
and social benefits computation rules. Copyright (C) 2021 Inria, contributor:
|
|
|
|
Denis Merigoux <denis.merigoux@inria.fr>
|
|
|
|
|
|
|
|
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 Utils
|
2022-08-12 23:42:39 +03:00
|
|
|
open Shared_ast
|
2021-06-22 17:01:57 +03:00
|
|
|
module D = Dcalc.Ast
|
|
|
|
module L = Lcalc.Ast
|
2021-06-24 15:52:51 +03:00
|
|
|
module TopLevelName = Uid.Make (Uid.MarkedString) ()
|
|
|
|
module LocalName = Uid.Make (Uid.MarkedString) ()
|
2021-06-22 17:01:57 +03:00
|
|
|
|
2022-07-25 12:00:18 +03:00
|
|
|
let dead_value = LocalName.fresh ("dead_value", Pos.no_pos)
|
2022-07-29 18:04:34 +03:00
|
|
|
let handle_default = TopLevelName.fresh ("handle_default", Pos.no_pos)
|
|
|
|
let handle_default_opt = TopLevelName.fresh ("handle_default_opt", Pos.no_pos)
|
2022-07-25 12:00:18 +03:00
|
|
|
|
2022-08-25 17:35:08 +03:00
|
|
|
type naked_expr =
|
2021-06-24 15:52:51 +03:00
|
|
|
| EVar of LocalName.t
|
|
|
|
| EFunc of TopLevelName.t
|
2022-08-25 17:35:08 +03:00
|
|
|
| EStruct of naked_expr Marked.pos list * StructName.t
|
|
|
|
| EStructFieldAccess of naked_expr Marked.pos * StructFieldName.t * StructName.t
|
|
|
|
| EInj of naked_expr Marked.pos * EnumConstructor.t * EnumName.t
|
|
|
|
| EArray of naked_expr Marked.pos list
|
2021-06-22 17:01:57 +03:00
|
|
|
| ELit of L.lit
|
2022-08-25 17:35:08 +03:00
|
|
|
| EApp of naked_expr Marked.pos * naked_expr Marked.pos list
|
2022-08-12 23:42:39 +03:00
|
|
|
| EOp of operator
|
2021-06-22 17:01:57 +03:00
|
|
|
|
|
|
|
type stmt =
|
2022-05-30 12:20:48 +03:00
|
|
|
| SInnerFuncDef of LocalName.t Marked.pos * func
|
2022-08-12 23:42:39 +03:00
|
|
|
| SLocalDecl of LocalName.t Marked.pos * typ Marked.pos
|
2022-08-25 17:35:08 +03:00
|
|
|
| SLocalDef of LocalName.t Marked.pos * naked_expr Marked.pos
|
2022-08-12 23:42:39 +03:00
|
|
|
| STryExcept of block * except * block
|
|
|
|
| SRaise of except
|
2022-08-25 17:35:08 +03:00
|
|
|
| SIfThenElse of naked_expr Marked.pos * block * block
|
2021-06-24 15:52:51 +03:00
|
|
|
| SSwitch of
|
2022-08-25 17:35:08 +03:00
|
|
|
naked_expr Marked.pos
|
2022-08-12 23:42:39 +03:00
|
|
|
* EnumName.t
|
2021-06-24 15:52:51 +03:00
|
|
|
* (block (* Statements corresponding to arm closure body*)
|
|
|
|
* (* Variable instantiated with enum payload *) LocalName.t)
|
|
|
|
list (** Each block corresponds to one case of the enum *)
|
2022-08-25 17:35:08 +03:00
|
|
|
| SReturn of naked_expr
|
|
|
|
| SAssert of naked_expr
|
2021-06-22 17:01:57 +03:00
|
|
|
|
2022-05-30 12:20:48 +03:00
|
|
|
and block = stmt Marked.pos list
|
2021-06-22 17:01:57 +03:00
|
|
|
|
2021-06-24 15:52:51 +03:00
|
|
|
and func = {
|
2022-08-12 23:42:39 +03:00
|
|
|
func_params : (LocalName.t Marked.pos * typ Marked.pos) list;
|
2021-06-24 15:52:51 +03:00
|
|
|
func_body : block;
|
|
|
|
}
|
2021-06-22 17:01:57 +03:00
|
|
|
|
2022-02-14 19:01:34 +03:00
|
|
|
type scope_body = {
|
2022-08-12 23:42:39 +03:00
|
|
|
scope_body_name : ScopeName.t;
|
2022-02-14 19:01:34 +03:00
|
|
|
scope_body_var : TopLevelName.t;
|
|
|
|
scope_body_func : func;
|
|
|
|
}
|
|
|
|
|
2022-08-12 23:42:39 +03:00
|
|
|
type program = { decl_ctx : decl_ctx; scopes : scope_body list }
|