2022-08-17 17:14:14 +03:00
|
|
|
(* This file is part of the Catala compiler, a specification language for tax
|
|
|
|
and social benefits computation rules. Copyright (C) 2020 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. *)
|
|
|
|
|
|
|
|
(** Printing functions for the default calculus AST *)
|
|
|
|
|
2022-11-21 12:46:17 +03:00
|
|
|
open Catala_utils
|
2022-08-22 19:53:30 +03:00
|
|
|
open Definitions
|
2022-08-17 17:14:14 +03:00
|
|
|
|
|
|
|
(** {1 Common syntax highlighting helpers}*)
|
|
|
|
|
|
|
|
val base_type : Format.formatter -> string -> unit
|
|
|
|
val keyword : Format.formatter -> string -> unit
|
2023-04-17 16:10:47 +03:00
|
|
|
|
2022-08-17 17:14:14 +03:00
|
|
|
val punctuation : Format.formatter -> string -> unit
|
2023-04-17 16:10:47 +03:00
|
|
|
(** The argument is assumed to be 1-column wide (but can be a multi-char utf8
|
|
|
|
character) *)
|
|
|
|
|
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
|
|
|
val op_style : Format.formatter -> string -> unit
|
2022-08-17 17:14:14 +03:00
|
|
|
val lit_style : Format.formatter -> string -> unit
|
|
|
|
|
|
|
|
(** {1 Formatters} *)
|
|
|
|
|
|
|
|
val uid_list : Format.formatter -> Uid.MarkedString.info list -> unit
|
|
|
|
val enum_constructor : Format.formatter -> EnumConstructor.t -> unit
|
|
|
|
val tlit : Format.formatter -> typ_lit -> unit
|
2022-08-25 13:09:51 +03:00
|
|
|
val location : Format.formatter -> 'a glocation -> unit
|
2022-08-25 18:29:00 +03:00
|
|
|
val typ : decl_ctx -> Format.formatter -> typ -> unit
|
2023-03-30 19:53:07 +03:00
|
|
|
val lit : Format.formatter -> lit -> unit
|
2023-05-02 12:59:39 +03:00
|
|
|
val operator : ?debug:bool -> Format.formatter -> 'a operator -> unit
|
2022-08-17 17:14:14 +03:00
|
|
|
val log_entry : Format.formatter -> log_entry -> unit
|
|
|
|
val except : Format.formatter -> except -> unit
|
|
|
|
val var : Format.formatter -> 'e Var.t -> unit
|
2022-11-17 19:13:35 +03:00
|
|
|
val var_debug : Format.formatter -> 'e Var.t -> unit
|
2022-08-17 17:14:14 +03:00
|
|
|
|
2023-05-02 17:33:23 +03:00
|
|
|
val expr :
|
2023-05-02 12:59:39 +03:00
|
|
|
?debug:bool -> unit -> Format.formatter -> ('a, 'm mark) gexpr -> unit
|
|
|
|
(** Same as [expr], but with a debug flag that defaults to [!Cli.debug_flag] *)
|
2022-09-30 17:37:43 +03:00
|
|
|
|
|
|
|
(** {1 Debugging versions that don't require a context} *)
|
|
|
|
|
|
|
|
val typ_debug : Format.formatter -> typ -> unit
|
2023-04-07 12:26:10 +03:00
|
|
|
|
|
|
|
val scope :
|
|
|
|
?debug:bool ->
|
|
|
|
decl_ctx ->
|
|
|
|
Format.formatter ->
|
|
|
|
ScopeName.t * ('a, 'm mark) gexpr scope_body ->
|
|
|
|
unit
|
|
|
|
|
|
|
|
val program :
|
|
|
|
?debug:bool -> Format.formatter -> ('a, 'm mark) gexpr program -> unit
|