mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
0f9ee2c72e
- Use separate functions for successive passes in module `Driver.Passes` - Use other functions for end results printing in module `Driver.Commands` As a consequence, it is much more flexible to use by plugins or libs and we no longer need the complex polymorphic variant parameter. This patch leverages previous changes to use Cmdliner subcommands and effectively specialises the flags of each Catala subcommand. Other changes include: - an attempt to normalise the generic options and reduce the number of global references. Some are ok, like `debug` ; some would better be further cleaned up, e.g. the ones used by Proof backend were moved to a `Proof.globals` module and need discussion. The printer no longer relies on the global languages and prints money amounts in an agnostic way. - the plugin directory is automatically guessed and loaded even in dev setups. Plugins are shown by the main `catala` command and listed in `catala --help` - exception catching at the toplevel has been refactored a bit as well; return codes are normalised to follow the manpage and avoid codes >= 128 that are generally reserved for shells. Update tests
32 lines
1.0 KiB
OCaml
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 ~link_modules:[] ~optimize:false
|
|
~check_invariants:false
|
|
in
|
|
Shared_ast.Interpreter.interpret_program_dcalc prg
|
|
(Commands.get_scope_uid ctx scope)
|
|
end)
|