1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
open Clflags
|
|
|
|
|
2002-02-08 02:16:10 -08:00
|
|
|
let usage = "Usage: ocaml <options> <object-files> [script-file]\noptions are:"
|
1996-10-24 07:17:48 -07:00
|
|
|
|
2002-02-07 18:56:04 -08:00
|
|
|
let preload_objects = ref []
|
|
|
|
|
|
|
|
let prepare ppf =
|
|
|
|
Toploop.set_paths ();
|
2003-06-30 08:31:06 -07:00
|
|
|
try
|
|
|
|
let res =
|
|
|
|
List.for_all (Topdirs.load_file ppf) (List.rev !preload_objects) in
|
|
|
|
!Toploop.toplevel_startup_hook ();
|
|
|
|
res
|
2002-02-07 18:56:04 -08:00
|
|
|
with x ->
|
|
|
|
try Errors.report_error ppf x; false
|
|
|
|
with x ->
|
|
|
|
Format.fprintf ppf "Uncaught exception: %s\n" (Printexc.to_string x);
|
|
|
|
false
|
1997-07-03 07:32:35 -07:00
|
|
|
|
2002-02-07 18:56:04 -08:00
|
|
|
let file_argument name =
|
|
|
|
let ppf = Format.err_formatter in
|
|
|
|
if Filename.check_suffix name ".cmo" || Filename.check_suffix name ".cma"
|
|
|
|
then preload_objects := name :: !preload_objects
|
2003-05-23 07:44:08 -07:00
|
|
|
else
|
|
|
|
begin
|
|
|
|
let newargs = Array.sub Sys.argv !Arg.current
|
|
|
|
(Array.length Sys.argv - !Arg.current)
|
|
|
|
in
|
|
|
|
if prepare ppf && Toploop.run_script ppf name newargs
|
|
|
|
then exit 0
|
|
|
|
else exit 2
|
|
|
|
end
|
2001-09-06 22:56:31 -07:00
|
|
|
|
2004-11-26 17:04:19 -08:00
|
|
|
let print_version () =
|
|
|
|
Printf.printf "The Objective Caml toplevel, version %s\n" Sys.ocaml_version;
|
|
|
|
exit 0;
|
|
|
|
;;
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
let main () =
|
1996-10-24 07:17:48 -07:00
|
|
|
Arg.parse [
|
2000-12-27 21:02:43 -08:00
|
|
|
"-I", Arg.String(fun dir ->
|
|
|
|
let dir = Misc.expand_directory Config.standard_library dir in
|
|
|
|
include_dirs := dir :: !include_dirs),
|
1996-10-24 07:17:48 -07:00
|
|
|
"<dir> Add <dir> to the list of include directories";
|
2001-09-06 22:56:31 -07:00
|
|
|
"-labels", Arg.Clear classic, " Labels commute (default)";
|
1999-11-29 11:04:45 -08:00
|
|
|
"-noassert", Arg.Set noassert, " Do not compile assertion checks";
|
2001-09-06 22:56:31 -07:00
|
|
|
"-nolabels", Arg.Set classic, " Ignore labels and do not commute";
|
2004-11-02 02:42:58 -08:00
|
|
|
"-noprompt", Arg.Set noprompt, " Suppress all prompts";
|
2002-02-14 07:17:11 -08:00
|
|
|
"-nostdlib", Arg.Set no_std_include,
|
|
|
|
" do not add default directory to the list of include directories";
|
2002-04-18 00:27:47 -07:00
|
|
|
"-principal", Arg.Set principal, " Check principality of type inference";
|
1999-11-19 01:11:02 -08:00
|
|
|
"-rectypes", Arg.Set recursive_types, " Allow arbitrary recursive types";
|
1996-10-24 07:17:48 -07:00
|
|
|
"-unsafe", Arg.Set fast, " No bound checking on array and string access";
|
2004-11-26 17:04:19 -08:00
|
|
|
"-version", Arg.Unit print_version, " Print version and exit";
|
2000-08-23 10:13:09 -07:00
|
|
|
"-w", Arg.String (Warnings.parse_options false),
|
1999-11-29 11:04:45 -08:00
|
|
|
"<flags> Enable or disable warnings according to <flags>:\n\
|
|
|
|
\032 A/a enable/disable all warnings\n\
|
|
|
|
\032 C/c enable/disable suspicious comment\n\
|
2001-09-27 00:31:29 -07:00
|
|
|
\032 D/d enable/disable deprecated features\n\
|
2003-05-02 01:48:31 -07:00
|
|
|
\032 E/e enable/disable fragile match\n\
|
1999-11-29 11:04:45 -08:00
|
|
|
\032 F/f enable/disable partially applied function\n\
|
2003-07-25 05:18:25 -07:00
|
|
|
\032 L/l enable/disable labels omitted in application\n\
|
1999-11-29 11:04:45 -08:00
|
|
|
\032 M/m enable/disable overriden method\n\
|
|
|
|
\032 P/p enable/disable partial match\n\
|
|
|
|
\032 S/s enable/disable non-unit statement\n\
|
|
|
|
\032 U/u enable/disable unused match case\n\
|
|
|
|
\032 V/v enable/disable hidden instance variable\n\
|
2004-11-30 10:57:04 -08:00
|
|
|
\032 Y/y enable/disable suspicious unused variables\n\
|
|
|
|
\032 Z/z enable/disable all other unused variables\n\
|
1999-11-29 11:04:45 -08:00
|
|
|
\032 X/x enable/disable all other warnings\n\
|
2004-11-30 10:57:04 -08:00
|
|
|
\032 default setting is \"Aelz\"";
|
2000-08-23 10:13:09 -07:00
|
|
|
"-warn-error" , Arg.String (Warnings.parse_options true),
|
|
|
|
"<flags> Enable or disable fatal warnings according to <flags>\n\
|
|
|
|
\032 (see option -w for the list of flags)\n\
|
|
|
|
\032 default setting is a (all warnings are non-fatal)";
|
1999-11-29 11:04:45 -08:00
|
|
|
|
|
|
|
"-dparsetree", Arg.Set dump_parsetree, " (undocumented)";
|
1996-10-24 07:17:48 -07:00
|
|
|
"-drawlambda", Arg.Set dump_rawlambda, " (undocumented)";
|
|
|
|
"-dlambda", Arg.Set dump_lambda, " (undocumented)";
|
2000-08-23 10:13:09 -07:00
|
|
|
"-dinstr", Arg.Set dump_instr, " (undocumented)";
|
1997-07-03 07:32:35 -07:00
|
|
|
] file_argument usage;
|
2002-02-07 18:56:04 -08:00
|
|
|
if not (prepare Format.err_formatter) then exit 2;
|
2000-04-10 07:59:29 -07:00
|
|
|
Toploop.loop Format.std_formatter
|
1995-05-04 03:15:53 -07:00
|
|
|
|