mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Debugging the R backend
This commit is contained in:
parent
4d419ac167
commit
8743b73459
@ -117,7 +117,7 @@ let avoid_keywords (s : string) : string =
|
||||
| "NA_real_" | "NA_complex_" | "NA_character_"
|
||||
(* additions of things that are not keywords but that we should not
|
||||
overwrite*)
|
||||
| "list" | "c" | "character" | "logical" | "complex" | "setClass" ->
|
||||
| "list" | "c" | "character" | "logical" | "complex" | "setClass" | "new" ->
|
||||
true
|
||||
| _ -> false
|
||||
then s ^ "_"
|
||||
@ -272,7 +272,7 @@ let rec format_expression (ctx : decl_ctx) (fmt : Format.formatter) (e : expr) :
|
||||
| EVar v -> format_var fmt v
|
||||
| EFunc f -> format_func_name fmt f
|
||||
| EStruct (es, s) ->
|
||||
Format.fprintf fmt "catala_struct_%a(%a)" format_struct_name s
|
||||
Format.fprintf fmt "new(\"catala_struct_%a\",@ %a)" format_struct_name s
|
||||
(Format.pp_print_list
|
||||
~pp_sep:(fun fmt () -> Format.fprintf fmt ",@ ")
|
||||
(fun fmt (e, (struct_field, _)) ->
|
||||
@ -294,7 +294,7 @@ let rec format_expression (ctx : decl_ctx) (fmt : Format.formatter) (e : expr) :
|
||||
(* We translate the option type with an overloading by R's [NULL] *)
|
||||
format_expression ctx fmt e
|
||||
| EInj (e, cons, enum_name) ->
|
||||
Format.fprintf fmt "catala_enum_%a(code = \"%a\",@ value = %a)"
|
||||
Format.fprintf fmt "new(\"catala_enum_%a\", code = \"%a\",@ value = %a)"
|
||||
format_enum_name enum_name format_enum_cons_name cons
|
||||
(format_expression ctx) e
|
||||
| EArray es ->
|
||||
@ -457,11 +457,11 @@ let format_ctx
|
||||
let format_struct_decl fmt (struct_name, struct_fields) =
|
||||
let fields = StructField.Map.bindings struct_fields in
|
||||
Format.fprintf fmt
|
||||
"@[<hov 2>catala_struct_%a <- setClass(@,\
|
||||
"@[<hov 2>setClass(@,\
|
||||
\"catala_struct_%a\",@;\
|
||||
representation@[<hov 2>(%a)@]@\n\
|
||||
)@]"
|
||||
format_struct_name struct_name format_struct_name struct_name
|
||||
format_struct_name struct_name
|
||||
(Format.pp_print_list
|
||||
~pp_sep:(fun fmt () -> Format.fprintf fmt ",@;")
|
||||
(fun fmt (struct_field, typ) ->
|
||||
@ -475,7 +475,7 @@ let format_ctx
|
||||
else
|
||||
Format.fprintf fmt
|
||||
"# Enum cases: %a@\n\
|
||||
@[<hov 2>catala_enum_%a <- setClass(@,\
|
||||
@[<hov 2>setClass(@,\
|
||||
\"catala_enum_%a\",@;\
|
||||
representation@[<hov 2>(code =@;\
|
||||
\"character\",@;\
|
||||
@ -487,7 +487,7 @@ let format_ctx
|
||||
Format.fprintf fmt "\"%a\" (%a)" format_enum_cons_name enum_cons
|
||||
format_typ enum_cons_type))
|
||||
(EnumConstructor.Map.bindings enum_cons)
|
||||
format_enum_name enum_name format_enum_name enum_name
|
||||
format_enum_name enum_name
|
||||
in
|
||||
|
||||
let is_in_type_ordering s =
|
||||
@ -526,6 +526,8 @@ let format_program
|
||||
markers. *)
|
||||
Format.fprintf fmt
|
||||
"@[<v># This file has been generated by the Catala compiler, do not edit!@,\
|
||||
@,\
|
||||
library(catalaRuntime)@,\
|
||||
@,\
|
||||
@[<v>%a@]@,\
|
||||
@,\
|
||||
|
@ -5,7 +5,7 @@
|
||||
################ Integers #################
|
||||
|
||||
#' @export
|
||||
catala_integer <- setClass(
|
||||
setClass(
|
||||
"catala_integer",
|
||||
representation(v = "bigz"),
|
||||
)
|
||||
@ -26,7 +26,7 @@ setMethod("Compare", "catala_integer", function(e1, e2) {
|
||||
################ Decimals #################
|
||||
|
||||
#' @export
|
||||
catala_decimal <- setClass(
|
||||
setClass(
|
||||
"catala_decimal",
|
||||
representation(v = "bigq"),
|
||||
)
|
||||
@ -47,7 +47,7 @@ setMethod("Compare", "catala_decimal", function(e1, e2) {
|
||||
################ Money #################
|
||||
|
||||
#' @export
|
||||
catala_money <- setClass(
|
||||
setClass(
|
||||
"catala_money",
|
||||
representation(v = "bigz"),
|
||||
)
|
||||
@ -79,7 +79,7 @@ setMethod("Compare", "catala_money", function(e1, e2) {
|
||||
################ Duration #################
|
||||
|
||||
#' @export
|
||||
catala_duration <- suppressWarnings(setClass(
|
||||
suppressWarnings(setClass(
|
||||
"catala_duration",
|
||||
representation(v = "Period")
|
||||
))
|
||||
@ -111,7 +111,7 @@ setMethod("Compare", "catala_duration", function(e1, e2) {
|
||||
################ Dates #################
|
||||
|
||||
#' @export
|
||||
catala_date <- setClass(
|
||||
setClass(
|
||||
"catala_date",
|
||||
representation(v = "Date"),
|
||||
)
|
||||
@ -299,7 +299,7 @@ catala_list_length <- function(l) {
|
||||
################ Exceptions #################
|
||||
|
||||
#' @export
|
||||
catala_position <- setClass(
|
||||
setClass(
|
||||
"catala_position",
|
||||
representation(
|
||||
filename = "character",
|
||||
|
Loading…
Reference in New Issue
Block a user