catala/compiler/catala_web_interpreter.ml
Louis Gesbert cc7066e9a8 Clerk: better handling of transitive dependencies
We need a concrete intermediate target for e.g. transitive uses of `> Include`
for Ninja to correctly handle them.

Of course we could also unroll all transitive dependencies, but meh.

Note also that now tests now just generate the outputs but facilities for
diffing and resetting are temporarily absent.
2023-09-27 13:14:40 +02:00

32 lines
1.1 KiB
OCaml

open Catala_utils
open Driver
open Js_of_ocaml
let () =
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) =
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 =
Passes.dcalc options ~includes:Catala_utils.File.Tree.empty ~optimize:false
~check_invariants:false
in
Shared_ast.Interpreter.interpret_program_dcalc prg
(Commands.get_scope_uid ctx scope)
end)