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