2006-07-06 08:43:03 -07:00
|
|
|
(* camlp4r *)
|
2006-06-29 01:12:46 -07:00
|
|
|
(****************************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
2006-06-29 01:12:46 -07:00
|
|
|
(* *)
|
|
|
|
(* INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 2006 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. All rights reserved. This file is distributed under *)
|
|
|
|
(* the terms of the GNU Library General Public License, with the special *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* exception on linking described in LICENSE at the top of the OCaml *)
|
|
|
|
(* source tree. *)
|
2006-06-29 01:12:46 -07:00
|
|
|
(* *)
|
|
|
|
(****************************************************************************)
|
|
|
|
|
|
|
|
(* Authors:
|
|
|
|
* - Daniel de Rauglaudre: initial version
|
|
|
|
* - Nicolas Pouillard: refactoring
|
|
|
|
*)
|
2006-07-06 08:43:03 -07:00
|
|
|
|
2008-10-27 07:03:15 -07:00
|
|
|
|
2006-06-29 01:12:46 -07:00
|
|
|
|
|
|
|
open Camlp4;
|
|
|
|
open PreCast.Syntax;
|
|
|
|
open PreCast;
|
|
|
|
open Format;
|
2006-09-06 08:43:03 -07:00
|
|
|
module CleanAst = Camlp4.Struct.CleanAst.Make Ast;
|
2006-07-06 08:43:03 -07:00
|
|
|
module SSet = Set.Make String;
|
|
|
|
|
2007-02-07 02:09:29 -08:00
|
|
|
value pa_r = "Camlp4OCamlRevisedParser";
|
2007-10-08 07:19:34 -07:00
|
|
|
value pa_rr = "Camlp4OCamlReloadedParser";
|
2007-02-07 02:09:29 -08:00
|
|
|
value pa_o = "Camlp4OCamlParser";
|
|
|
|
value pa_rp = "Camlp4OCamlRevisedParserParser";
|
|
|
|
value pa_op = "Camlp4OCamlParserParser";
|
|
|
|
value pa_g = "Camlp4GrammarParser";
|
|
|
|
value pa_m = "Camlp4MacroParser";
|
|
|
|
value pa_qb = "Camlp4QuotationCommon";
|
|
|
|
value pa_q = "Camlp4QuotationExpander";
|
|
|
|
value pa_rq = "Camlp4OCamlRevisedQuotationExpander";
|
|
|
|
value pa_oq = "Camlp4OCamlOriginalQuotationExpander";
|
2007-02-27 07:50:57 -08:00
|
|
|
value pa_l = "Camlp4ListComprehension";
|
2006-07-06 08:43:03 -07:00
|
|
|
|
2007-10-08 07:19:34 -07:00
|
|
|
open Register;
|
|
|
|
|
2006-07-06 08:43:03 -07:00
|
|
|
value dyn_loader = ref (fun []);
|
|
|
|
value rcall_callback = ref (fun () -> ());
|
|
|
|
value loaded_modules = ref SSet.empty;
|
|
|
|
value add_to_loaded_modules name =
|
|
|
|
loaded_modules.val := SSet.add name loaded_modules.val;
|
|
|
|
|
2007-11-06 07:16:56 -08:00
|
|
|
value (objext,libext) =
|
2008-01-11 08:13:18 -08:00
|
|
|
if DynLoader.is_native then (".cmxs",".cmxs")
|
2007-11-06 07:16:56 -08:00
|
|
|
else (".cmo",".cma");
|
|
|
|
|
2006-07-06 08:43:03 -07:00
|
|
|
value rewrite_and_load n x =
|
|
|
|
let dyn_loader = dyn_loader.val () in
|
|
|
|
let find_in_path = DynLoader.find_in_path dyn_loader in
|
|
|
|
let real_load name = do {
|
|
|
|
add_to_loaded_modules name;
|
|
|
|
DynLoader.load dyn_loader name
|
|
|
|
} in
|
2007-10-08 07:19:34 -07:00
|
|
|
let load = List.iter begin fun n ->
|
|
|
|
if SSet.mem n loaded_modules.val || List.mem n Register.loaded_modules.val then ()
|
|
|
|
else begin
|
2006-07-06 08:43:03 -07:00
|
|
|
add_to_loaded_modules n;
|
2007-11-06 07:16:56 -08:00
|
|
|
DynLoader.load dyn_loader (n ^ objext);
|
2007-10-08 07:19:34 -07:00
|
|
|
end
|
|
|
|
end in
|
2006-07-06 08:43:03 -07:00
|
|
|
do {
|
2007-02-07 02:09:29 -08:00
|
|
|
match (n, String.lowercase x) with
|
|
|
|
[ ("Parsers"|"", "pa_r.cmo" | "r" | "ocamlr" | "ocamlrevised" | "camlp4ocamlrevisedparser.cmo") -> load [pa_r]
|
2007-10-08 07:19:34 -07:00
|
|
|
| ("Parsers"|"", "rr" | "reloaded" | "ocamlreloaded" | "camlp4ocamlreloadedparser.cmo") -> load [pa_rr]
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Parsers"|"", "pa_o.cmo" | "o" | "ocaml" | "camlp4ocamlparser.cmo") -> load [pa_r; pa_o]
|
2011-07-20 02:17:07 -07:00
|
|
|
| ("Parsers"|"", "pa_rp.cmo" | "rp" | "rparser" | "camlp4ocamlrevisedparserparser.cmo") -> load [pa_r; pa_rp]
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Parsers"|"", "pa_op.cmo" | "op" | "parser" | "camlp4ocamlparserparser.cmo") -> load [pa_r; pa_o; pa_rp; pa_op]
|
2007-10-08 07:19:34 -07:00
|
|
|
| ("Parsers"|"", "pa_extend.cmo" | "pa_extend_m.cmo" | "g" | "grammar" | "camlp4grammarparser.cmo") -> load [pa_g]
|
|
|
|
| ("Parsers"|"", "pa_macro.cmo" | "m" | "macro" | "camlp4macroparser.cmo") -> load [pa_m]
|
|
|
|
| ("Parsers"|"", "q" | "camlp4quotationexpander.cmo") -> load [pa_qb; pa_q]
|
|
|
|
| ("Parsers"|"", "q_mlast.cmo" | "rq" | "camlp4ocamlrevisedquotationexpander.cmo") -> load [pa_qb; pa_rq]
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Parsers"|"", "oq" | "camlp4ocamloriginalquotationexpander.cmo") -> load [pa_r; pa_o; pa_qb; pa_oq]
|
2007-02-27 07:50:57 -08:00
|
|
|
| ("Parsers"|"", "rf") -> load [pa_r; pa_rp; pa_qb; pa_q; pa_g; pa_l; pa_m]
|
2011-07-20 02:17:07 -07:00
|
|
|
| ("Parsers"|"", "of") -> load [pa_r; pa_o; pa_rp; pa_op; pa_qb; pa_q; pa_g; pa_l; pa_m]
|
2007-02-27 07:50:57 -08:00
|
|
|
| ("Parsers"|"", "comp" | "camlp4listcomprehension.cmo") -> load [pa_l]
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Filters"|"", "lift" | "camlp4astlifter.cmo") -> load ["Camlp4AstLifter"]
|
|
|
|
| ("Filters"|"", "exn" | "camlp4exceptiontracer.cmo") -> load ["Camlp4ExceptionTracer"]
|
|
|
|
| ("Filters"|"", "prof" | "camlp4profiler.cmo") -> load ["Camlp4Profiler"]
|
2007-11-21 10:11:24 -08:00
|
|
|
(* map is now an alias of fold since fold handles map too *)
|
|
|
|
| ("Filters"|"", "map" | "camlp4mapgenerator.cmo") -> load ["Camlp4FoldGenerator"]
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Filters"|"", "fold" | "camlp4foldgenerator.cmo") -> load ["Camlp4FoldGenerator"]
|
|
|
|
| ("Filters"|"", "meta" | "camlp4metagenerator.cmo") -> load ["Camlp4MetaGenerator"]
|
|
|
|
| ("Filters"|"", "trash" | "camlp4trashremover.cmo") -> load ["Camlp4TrashRemover"]
|
|
|
|
| ("Filters"|"", "striploc" | "camlp4locationstripper.cmo") -> load ["Camlp4LocationStripper"]
|
|
|
|
| ("Printers"|"", "pr_r.cmo" | "r" | "ocamlr" | "camlp4ocamlrevisedprinter.cmo") ->
|
2006-10-02 05:59:01 -07:00
|
|
|
Register.enable_ocamlr_printer ()
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Printers"|"", "pr_o.cmo" | "o" | "ocaml" | "camlp4ocamlprinter.cmo") ->
|
2006-10-02 05:59:01 -07:00
|
|
|
Register.enable_ocaml_printer ()
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Printers"|"", "pr_dump.cmo" | "p" | "dumpocaml" | "camlp4ocamlastdumper.cmo") ->
|
2006-10-02 05:59:01 -07:00
|
|
|
Register.enable_dump_ocaml_ast_printer ()
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Printers"|"", "d" | "dumpcamlp4" | "camlp4astdumper.cmo") ->
|
2006-10-02 05:59:01 -07:00
|
|
|
Register.enable_dump_camlp4_ast_printer ()
|
2007-02-07 02:09:29 -08:00
|
|
|
| ("Printers"|"", "a" | "auto" | "camlp4autoprinter.cmo") ->
|
|
|
|
load ["Camlp4AutoPrinter"]
|
2006-07-06 08:58:01 -07:00
|
|
|
| _ ->
|
2007-11-06 07:16:56 -08:00
|
|
|
let y = "Camlp4"^n^"/"^x^objext in
|
2006-07-06 08:58:01 -07:00
|
|
|
real_load (try find_in_path y with [ Not_found -> x ]) ];
|
2006-07-06 08:43:03 -07:00
|
|
|
rcall_callback.val ();
|
|
|
|
};
|
2006-06-29 01:12:46 -07:00
|
|
|
|
|
|
|
value print_warning = eprintf "%a:\n%s@." Loc.print;
|
|
|
|
|
|
|
|
value rec parse_file dyn_loader name pa getdir =
|
|
|
|
let directive_handler = Some (fun ast ->
|
|
|
|
match getdir ast with
|
|
|
|
[ Some x ->
|
|
|
|
match x with
|
2006-07-06 08:58:01 -07:00
|
|
|
[ (_, "load", s) -> do { rewrite_and_load "" s; None }
|
2006-06-29 01:12:46 -07:00
|
|
|
| (_, "directory", s) -> do { DynLoader.include_dir dyn_loader s; None }
|
|
|
|
| (_, "use", s) -> Some (parse_file dyn_loader s pa getdir)
|
2006-07-05 04:23:29 -07:00
|
|
|
| (_, "default_quotation", s) -> do { Quotation.default.val := s; None }
|
2006-06-29 01:12:46 -07:00
|
|
|
| (loc, _, _) -> Loc.raise loc (Stream.Error "bad directive") ]
|
|
|
|
| None -> None ]) in
|
|
|
|
let loc = Loc.mk name
|
|
|
|
in do {
|
2007-10-08 07:19:34 -07:00
|
|
|
current_warning.val := print_warning;
|
2007-11-21 10:11:24 -08:00
|
|
|
let ic = if name = "-" then stdin else open_in_bin name;
|
|
|
|
let cs = Stream.of_channel ic;
|
|
|
|
let clear () = if name = "-" then () else close_in ic;
|
2006-06-29 01:12:46 -07:00
|
|
|
let phr =
|
|
|
|
try pa ?directive_handler loc cs
|
2007-11-21 10:11:24 -08:00
|
|
|
with x -> do { clear (); raise x };
|
2006-06-29 01:12:46 -07:00
|
|
|
clear ();
|
|
|
|
phr
|
|
|
|
};
|
|
|
|
|
|
|
|
value output_file = ref None;
|
|
|
|
|
2006-09-06 08:43:03 -07:00
|
|
|
value process dyn_loader name pa pr clean fold_filters getdir =
|
2006-06-29 01:12:46 -07:00
|
|
|
let ast = parse_file dyn_loader name pa getdir in
|
|
|
|
let ast = fold_filters (fun t filter -> filter t) ast in
|
2006-09-06 08:43:03 -07:00
|
|
|
let ast = clean ast in
|
2006-06-29 01:12:46 -07:00
|
|
|
pr ?input_file:(Some name) ?output_file:output_file.val ast;
|
|
|
|
|
|
|
|
value gind =
|
|
|
|
fun
|
|
|
|
[ <:sig_item@loc< # $n$ $str:s$ >> -> Some (loc, n, s)
|
|
|
|
| _ -> None ];
|
|
|
|
|
|
|
|
value gimd =
|
|
|
|
fun
|
|
|
|
[ <:str_item@loc< # $n$ $str:s$ >> -> Some (loc, n, s)
|
|
|
|
| _ -> None ];
|
|
|
|
|
|
|
|
value process_intf dyn_loader name =
|
|
|
|
process dyn_loader name CurrentParser.parse_interf CurrentPrinter.print_interf
|
2006-09-06 08:43:03 -07:00
|
|
|
(new CleanAst.clean_ast)#sig_item
|
2006-06-29 01:12:46 -07:00
|
|
|
AstFilters.fold_interf_filters gind;
|
|
|
|
value process_impl dyn_loader name =
|
|
|
|
process dyn_loader name CurrentParser.parse_implem CurrentPrinter.print_implem
|
2006-09-06 08:43:03 -07:00
|
|
|
(new CleanAst.clean_ast)#str_item
|
2006-06-29 01:12:46 -07:00
|
|
|
AstFilters.fold_implem_filters gimd;
|
|
|
|
|
|
|
|
value just_print_the_version () =
|
2007-02-07 02:09:29 -08:00
|
|
|
do { printf "%s@." Camlp4_config.version; exit 0 };
|
2006-06-29 01:12:46 -07:00
|
|
|
|
|
|
|
value print_version () =
|
2007-02-07 02:09:29 -08:00
|
|
|
do { eprintf "Camlp4 version %s@." Camlp4_config.version; exit 0 };
|
2006-06-29 01:12:46 -07:00
|
|
|
|
|
|
|
value print_stdlib () =
|
2007-02-07 02:09:29 -08:00
|
|
|
do { printf "%s@." Camlp4_config.camlp4_standard_library; exit 0 };
|
2006-06-29 01:12:46 -07:00
|
|
|
|
|
|
|
value usage ini_sl ext_sl =
|
|
|
|
do {
|
|
|
|
eprintf "\
|
2010-01-07 07:15:07 -08:00
|
|
|
Usage: camlp4 [load-options] [--] [other-options]\n\
|
|
|
|
Options:\n\
|
|
|
|
<file>.ml Parse this implementation file\n\
|
|
|
|
<file>.mli Parse this interface file\n\
|
2007-11-06 07:16:56 -08:00
|
|
|
<file>.%s Load this module inside the Camlp4 core@."
|
2008-11-28 10:46:47 -08:00
|
|
|
(if DynLoader.is_native then "cmxs " else "(cmo|cma)")
|
2007-11-06 07:16:56 -08:00
|
|
|
;
|
2006-06-29 01:12:46 -07:00
|
|
|
Options.print_usage_list ini_sl;
|
|
|
|
(* loop (ini_sl @ ext_sl) where rec loop =
|
|
|
|
fun
|
|
|
|
[ [(y, _, _) :: _] when y = "-help" -> ()
|
|
|
|
| [_ :: sl] -> loop sl
|
|
|
|
| [] -> eprintf " -help Display this list of options.@." ]; *)
|
|
|
|
if ext_sl <> [] then do {
|
|
|
|
eprintf "Options added by loaded object files:@.";
|
|
|
|
Options.print_usage_list ext_sl;
|
|
|
|
}
|
|
|
|
else ();
|
|
|
|
};
|
|
|
|
|
|
|
|
value warn_noassert () =
|
|
|
|
do {
|
|
|
|
eprintf "\
|
2010-01-07 07:15:07 -08:00
|
|
|
camlp4 warning: option -noassert is obsolete\n\
|
2006-06-29 01:12:46 -07:00
|
|
|
You should give the -noassert option to the ocaml compiler instead.@.";
|
|
|
|
};
|
|
|
|
|
|
|
|
type file_kind =
|
|
|
|
[ Intf of string
|
|
|
|
| Impl of string
|
|
|
|
| Str of string
|
|
|
|
| ModuleImpl of string
|
|
|
|
| IncludeDir of string ];
|
|
|
|
|
|
|
|
value search_stdlib = ref True;
|
|
|
|
value print_loaded_modules = ref False;
|
|
|
|
value (task, do_task) =
|
2006-07-06 08:43:03 -07:00
|
|
|
let t = ref None in
|
|
|
|
let task f x =
|
2007-02-07 02:09:29 -08:00
|
|
|
let () = Camlp4_config.current_input_file.val := x in
|
2006-07-06 08:43:03 -07:00
|
|
|
t.val := Some (if t.val = None then (fun _ -> f x)
|
|
|
|
else (fun usage -> usage ())) in
|
|
|
|
let do_task usage = match t.val with [ Some f -> f usage | None -> () ] in
|
|
|
|
(task, do_task);
|
2006-06-29 01:12:46 -07:00
|
|
|
value input_file x =
|
2006-07-06 08:43:03 -07:00
|
|
|
let dyn_loader = dyn_loader.val () in
|
2006-06-29 01:12:46 -07:00
|
|
|
do {
|
2008-01-11 08:13:18 -08:00
|
|
|
rcall_callback.val ();
|
2006-06-29 01:12:46 -07:00
|
|
|
match x with
|
2006-07-06 08:43:03 -07:00
|
|
|
[ Intf file_name -> task (process_intf dyn_loader) file_name
|
|
|
|
| Impl file_name -> task (process_impl dyn_loader) file_name
|
2007-11-21 10:11:24 -08:00
|
|
|
| Str s ->
|
|
|
|
begin
|
|
|
|
let (f, o) = Filename.open_temp_file "from_string" ".ml";
|
|
|
|
output_string o s;
|
|
|
|
close_out o;
|
|
|
|
task (process_impl dyn_loader) f;
|
|
|
|
at_exit (fun () -> Sys.remove f);
|
|
|
|
end
|
2006-07-06 08:58:01 -07:00
|
|
|
| ModuleImpl file_name -> rewrite_and_load "" file_name
|
2006-06-29 01:12:46 -07:00
|
|
|
| IncludeDir dir -> DynLoader.include_dir dyn_loader dir ];
|
|
|
|
rcall_callback.val ();
|
|
|
|
};
|
|
|
|
|
|
|
|
value initial_spec_list =
|
|
|
|
[("-I", Arg.String (fun x -> input_file (IncludeDir x)),
|
|
|
|
"<directory> Add directory in search patch for object files.");
|
|
|
|
("-where", Arg.Unit print_stdlib,
|
|
|
|
"Print camlp4 library directory and exit.");
|
|
|
|
("-nolib", Arg.Clear search_stdlib,
|
|
|
|
"No automatic search for object files in library directory.");
|
|
|
|
("-intf", Arg.String (fun x -> input_file (Intf x)),
|
|
|
|
"<file> Parse <file> as an interface, whatever its extension.");
|
|
|
|
("-impl", Arg.String (fun x -> input_file (Impl x)),
|
|
|
|
"<file> Parse <file> as an implementation, whatever its extension.");
|
|
|
|
("-str", Arg.String (fun x -> input_file (Str x)),
|
|
|
|
"<string> Parse <string> as an implementation.");
|
2007-02-07 02:09:29 -08:00
|
|
|
("-unsafe", Arg.Set Camlp4_config.unsafe,
|
2006-06-29 01:12:46 -07:00
|
|
|
"Generate unsafe accesses to array and strings.");
|
|
|
|
("-noassert", Arg.Unit warn_noassert,
|
|
|
|
"Obsolete, do not use this option.");
|
2007-02-07 02:09:29 -08:00
|
|
|
("-verbose", Arg.Set Camlp4_config.verbose,
|
2006-06-29 01:12:46 -07:00
|
|
|
"More verbose in parsing errors.");
|
|
|
|
("-loc", Arg.Set_string Loc.name,
|
|
|
|
"<name> Name of the location variable (default: " ^ Loc.name.val ^ ").");
|
|
|
|
("-QD", Arg.String (fun x -> Quotation.dump_file.val := Some x),
|
|
|
|
"<file> Dump quotation expander result in case of syntax error.");
|
|
|
|
("-o", Arg.String (fun x -> output_file.val := Some x),
|
|
|
|
"<file> Output on <file> instead of standard output.");
|
|
|
|
("-v", Arg.Unit print_version,
|
|
|
|
"Print Camlp4 version and exit.");
|
|
|
|
("-version", Arg.Unit just_print_the_version,
|
|
|
|
"Print Camlp4 version number and exit.");
|
2010-05-20 07:06:29 -07:00
|
|
|
("-vnum", Arg.Unit just_print_the_version,
|
|
|
|
"Print Camlp4 version number and exit.");
|
2007-02-07 02:09:29 -08:00
|
|
|
("-no_quot", Arg.Clear Camlp4_config.quotations,
|
2006-06-29 01:12:46 -07:00
|
|
|
"Don't parse quotations, allowing to use, e.g. \"<:>\" as token.");
|
|
|
|
("-loaded-modules", Arg.Set print_loaded_modules, "Print the list of loaded modules.");
|
2006-07-06 08:43:03 -07:00
|
|
|
("-parser", Arg.String (rewrite_and_load "Parsers"),
|
2008-11-28 10:46:47 -08:00
|
|
|
"<name> Load the parser Camlp4Parsers/<name>.cm(o|a|xs)");
|
2006-07-06 08:43:03 -07:00
|
|
|
("-printer", Arg.String (rewrite_and_load "Printers"),
|
2008-11-28 10:46:47 -08:00
|
|
|
"<name> Load the printer Camlp4Printers/<name>.cm(o|a|xs)");
|
2006-07-06 08:43:03 -07:00
|
|
|
("-filter", Arg.String (rewrite_and_load "Filters"),
|
2008-11-28 10:46:47 -08:00
|
|
|
"<name> Load the filter Camlp4Filters/<name>.cm(o|a|xs)");
|
2006-07-28 05:46:35 -07:00
|
|
|
("-ignore", Arg.String ignore, "ignore the next argument");
|
2006-07-06 23:46:54 -07:00
|
|
|
("--", Arg.Unit ignore, "Deprecated, does nothing")
|
2006-06-29 01:12:46 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
Options.init initial_spec_list;
|
|
|
|
|
|
|
|
value anon_fun name =
|
|
|
|
input_file
|
|
|
|
(if Filename.check_suffix name ".mli" then Intf name
|
|
|
|
else if Filename.check_suffix name ".ml" then Impl name
|
2007-11-06 07:16:56 -08:00
|
|
|
else if Filename.check_suffix name objext then ModuleImpl name
|
|
|
|
else if Filename.check_suffix name libext then ModuleImpl name
|
2006-06-29 01:12:46 -07:00
|
|
|
else raise (Arg.Bad ("don't know what to do with " ^ name)));
|
|
|
|
|
2006-07-06 08:43:03 -07:00
|
|
|
value main argv =
|
2006-06-29 01:12:46 -07:00
|
|
|
let usage () = do { usage initial_spec_list (Options.ext_spec_list ()); exit 0 } in
|
|
|
|
try do {
|
2006-07-06 08:43:03 -07:00
|
|
|
let dynloader = DynLoader.mk ~ocaml_stdlib:search_stdlib.val
|
|
|
|
~camlp4_stdlib:search_stdlib.val ();
|
|
|
|
dyn_loader.val := fun () -> dynloader;
|
2006-06-29 01:12:46 -07:00
|
|
|
let call_callback () =
|
2006-07-06 08:43:03 -07:00
|
|
|
Register.iter_and_take_callbacks
|
|
|
|
(fun (name, module_callback) ->
|
|
|
|
let () = add_to_loaded_modules name in
|
|
|
|
module_callback ());
|
2006-06-29 01:12:46 -07:00
|
|
|
call_callback ();
|
|
|
|
rcall_callback.val := call_callback;
|
|
|
|
match Options.parse anon_fun argv with
|
|
|
|
[ [] -> ()
|
2006-07-06 08:43:03 -07:00
|
|
|
| ["-help"|"--help"|"-h"|"-?" :: _] -> usage ()
|
2006-06-29 01:12:46 -07:00
|
|
|
| [s :: _] ->
|
|
|
|
do { eprintf "%s: unknown or misused option\n" s;
|
|
|
|
eprintf "Use option -help for usage@.";
|
|
|
|
exit 2 } ];
|
|
|
|
do_task usage;
|
2006-06-29 08:01:37 -07:00
|
|
|
call_callback ();
|
2006-06-29 01:12:46 -07:00
|
|
|
if print_loaded_modules.val then do {
|
2006-07-06 08:43:03 -07:00
|
|
|
SSet.iter (eprintf "%s@.") loaded_modules.val;
|
2006-06-29 01:12:46 -07:00
|
|
|
} else ()
|
|
|
|
}
|
|
|
|
with
|
|
|
|
[ Arg.Bad s -> do { eprintf "Error: %s\n" s;
|
|
|
|
eprintf "Use option -help for usage@.";
|
|
|
|
exit 2 }
|
|
|
|
| Arg.Help _ -> usage ()
|
|
|
|
| exc -> do { eprintf "@[<v0>%a@]@." ErrorHandler.print exc; exit 2 } ];
|
|
|
|
|
2006-07-06 08:43:03 -07:00
|
|
|
main Sys.argv;
|