I am doing an exercise of a free course. The following ocaml code compiles when I "make", but it complains once I am trying to put it into toplevel. Why?
let main () =
(* Parsing arguments *)
let f_name = ref "" in
Arg.parse [ ] (fun s -> f_name := s) "Mini-Java analyzer";
(* Parsing of the source file *)
let simple_java_prog =
if String.compare !f_name "" = 0 then failwith "no program file given";
Localizing.current_file_name := !f_name;
let f_desc = open_in !f_name in
let lexbuf = Lexing.from_channel f_desc in
let java_prog =
try Java_parser.program Java_lexer.token lexbuf
with
| e ->
Printf.printf "Exception during parsing: %s\n"
(Printexc.to_string e);
failwith "Stopped" in
Simple_java_translate.tr_java_prog java_prog in
Printf.printf "finished...\n"
let _ = main ()
But when I "c-c c-e" (from emacs) this code to toplevel, it gives me the error
....
let main () =
Error: Reference to undefined global `Localizing'
then, with this error information, I got an explanation from
http://caml.inria.fr/pub/docs/manual-ocaml/manual023.html
which says,
Reference to undefined global mod You have neglected to load in memory an implementation for a module with #load.
Thus, I am trying to do: #load "localizing.cmo". But, now the problem is: There is no localizing.cmo Here is the search result.
bash-3.2$ ls localizing*
localizing.cmi localizing.cmx localizing.ml localizing.mli localizing.o
I hesite to put makefile here, the source of the problem should not come from the "Makefile", besides it's so big. Besides, I am not supposed to modify makefile because that's provided by the course's site.
What's the problem?? Thank you. Am I right to conclude that, Not all ocaml programs are supposed to be able to be executed at toplevel?