diff --git a/compiler/driver.ml b/compiler/driver.ml index 77c894ea..f2ba87c6 100644 --- a/compiler/driver.ml +++ b/compiler/driver.ml @@ -345,7 +345,8 @@ let driver source_file (options : Cli.options) : int = p.Plugin.name; Cli.debug_print "Writing to %s..." (Option.value ~default:"stdout" output_file); - p.Plugin.apply output_file prgm type_ordering + p.Plugin.apply ~output_file ~scope:options.ex_scope prgm + type_ordering | (`Python | `Scalc | `Plugin (Plugin.Scalc _)) as backend -> ( let prgm = Scalc.Compile_from_lambda.translate_program prgm in match backend with @@ -383,7 +384,8 @@ let driver source_file (options : Cli.options) : int = p.Plugin.name; Cli.debug_print "Writing to %s..." (Option.value ~default:"stdout" output_file); - p.Plugin.apply output_file prgm type_ordering))))))); + p.Plugin.apply ~output_file ~scope:options.ex_scope prgm + type_ordering))))))); 0 with | Errors.StructuredError (msg, pos) -> diff --git a/compiler/plugin.ml b/compiler/plugin.ml index 08fce637..b7b6fd05 100644 --- a/compiler/plugin.ml +++ b/compiler/plugin.ml @@ -14,10 +14,17 @@ License for the specific language governing permissions and limitations under the License. *) +type 'ast plugin_apply_fun_typ = + output_file:string option -> + scope:string option -> + 'ast -> + Scopelang.Dependency.TVertex.t list -> + unit + type 'ast gen = { name : string; extension : string; - apply : string option -> 'ast -> Scopelang.Dependency.TVertex.t list -> unit; + apply : 'ast plugin_apply_fun_typ; } type t = diff --git a/compiler/plugin.mli b/compiler/plugin.mli index 27acbef7..0df3b1c2 100644 --- a/compiler/plugin.mli +++ b/compiler/plugin.mli @@ -16,10 +16,17 @@ (** {2 catala-facing API} *) +type 'ast plugin_apply_fun_typ = + output_file:string option -> + scope:string option -> + 'ast -> + Scopelang.Dependency.TVertex.t list -> + unit + type 'ast gen = { name : string; extension : string; - apply : string option -> 'ast -> Scopelang.Dependency.TVertex.t list -> unit; + apply : 'ast plugin_apply_fun_typ; } type t = @@ -41,19 +48,13 @@ module PluginAPI : sig val register_lcalc : name:string -> extension:string -> - (string option -> - Dcalc.Ast.untyped Lcalc.Ast.program -> - Scopelang.Dependency.TVertex.t list -> - unit) -> + Dcalc.Ast.untyped Lcalc.Ast.program plugin_apply_fun_typ -> unit val register_scalc : name:string -> extension:string -> - (string option -> - Scalc.Ast.program -> - Scopelang.Dependency.TVertex.t list -> - unit) -> + Scalc.Ast.program plugin_apply_fun_typ -> unit end diff --git a/compiler/plugins/jsoo.ml b/compiler/plugins/jsoo.ml index cadc84a2..64639157 100644 --- a/compiler/plugins/jsoo.ml +++ b/compiler/plugins/jsoo.ml @@ -414,9 +414,11 @@ module To_jsoo = struct end let apply - (output_file : string option) + ~(output_file : string option) + ~(scope : string option) (prgm : 'm Lcalc.Ast.program) (type_ordering : Scopelang.Dependency.TVertex.t list) = + let _ = scope in let filename_without_ext_opt = Option.map (fun f -> Filename.basename f |> String.split_on_char '.' |> List.hd) diff --git a/compiler/plugins/python.ml b/compiler/plugins/python.ml index 9cb7ed06..02819332 100644 --- a/compiler/plugins/python.ml +++ b/compiler/plugins/python.ml @@ -23,7 +23,8 @@ let name = "python-plugin" let extension = ".py" -let apply output_file prgm type_ordering = +let apply ~output_file ~scope prgm type_ordering = + ignore scope; Utils.File.with_formatter_of_opt_file output_file @@ fun fmt -> Scalc.To_python.format_program fmt prgm type_ordering