diff --git a/src/driver.ml b/src/driver.ml index 5d91a6b4..b8ec76a0 100644 --- a/src/driver.ml +++ b/src/driver.ml @@ -1414,9 +1414,31 @@ let standalone_args = let get_args ?(standalone_args = standalone_args) () = standalone_args @ List.rev !args +let apply_keyword_edition () = + match Sys.getenv_opt "OCAMLPARAM" with + | None -> () + | Some s -> + let items = + if String.equal s "" then + [] + else + (* cf. Compenv.parse_args *) + match s.[0] with + | ( ':' | '|' | ';' | ' ' | ',' ) as sep -> + List.tl (String.split_on_char s ~sep) + | _ -> String.split_on_char s ~sep:',' + in + let apply_if_keyword item = + if String.starts_with ~prefix:"keywords=" item then + Clflags.keyword_edition := + Some (String.sub item ~pos:9 ~len:(String.length item - 9)) + in + List.iter items ~f:apply_if_keyword + let standalone_main () = let usage = Printf.sprintf "%s [extra_args] []" exe_name in let args = get_args () in + apply_keyword_edition (); Arg.parse (Arg.align args) set_input usage; interpret_mask (); if !request_print_transformations then ( diff --git a/src/dune b/src/dune index a9152b2a..b0ab88ed 100644 --- a/src/dune +++ b/src/dune @@ -3,6 +3,7 @@ (public_name ppxlib) (libraries (re_export ppxlib_ast) + compiler-libs.common ocaml-compiler-libs.shadow astlib ppxlib_print_diff