catala/compiler/catala_web_interpreter.ml
Louis Gesbert dbe0990163 Rework module includes CLI in Catala
Rather than require all files to be listed on the command-line (and having to
check consistency with `> Using` directives), the main catala CLI is now a bit
more clever.

⇒ There is a new assumption that a module name definition must match the file
name (up to case and extension) — with appropriate error handling to enforce it.

In exchange, `> Using` directives are now used to more transparently lookup the
appropriate `.catala_*` interfaces and the compiled artifacts for the used modules (handling transitive dependencies), with just standard `-I` flags for when they need to be looked up in different places.
2023-09-27 13:14:40 +02:00

32 lines
1.0 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:File.Tree.empty ~optimize:false
~check_invariants:false
in
Shared_ast.Interpreter.interpret_program_dcalc prg
(Commands.get_scope_uid ctx scope)
end)