2022-11-21 12:46:17 +03:00
|
|
|
open Catala_utils
|
2021-04-29 18:05:53 +03:00
|
|
|
open Driver
|
2020-12-26 19:37:41 +03:00
|
|
|
open Js_of_ocaml
|
|
|
|
|
2023-09-09 23:02:39 +03:00
|
|
|
let () =
|
2020-12-26 19:37:41 +03:00
|
|
|
Js.export_all
|
|
|
|
(object%js
|
|
|
|
method interpret
|
|
|
|
(contents : Js.js_string Js.t)
|
|
|
|
(scope : Js.js_string Js.t)
|
|
|
|
(language : Js.js_string Js.t)
|
|
|
|
(trace : bool) =
|
2023-06-28 16:57:52 +03:00
|
|
|
let contents = Js.to_string contents in
|
|
|
|
let scope = Js.to_string scope in
|
|
|
|
let language = Js.to_string language in
|
|
|
|
let language =
|
|
|
|
try List.assoc (String.lowercase_ascii language) Cli.languages
|
|
|
|
with Not_found ->
|
|
|
|
Message.raise_error "Unrecognised input locale %S" language
|
|
|
|
in
|
|
|
|
let options =
|
|
|
|
Cli.enforce_globals ~input_file:(Contents contents)
|
|
|
|
~language:(Some language) ~debug:false ~color:Never ~trace ()
|
|
|
|
in
|
|
|
|
let prg, ctx, _type_order =
|
2023-09-24 12:25:34 +03:00
|
|
|
Passes.dcalc options ~includes:Catala_utils.File.Tree.empty ~optimize:false
|
2023-06-28 16:57:52 +03:00
|
|
|
~check_invariants:false
|
|
|
|
in
|
|
|
|
Shared_ast.Interpreter.interpret_program_dcalc prg
|
|
|
|
(Commands.get_scope_uid ctx scope)
|
2020-12-26 19:37:41 +03:00
|
|
|
end)
|