1 (* Abstract type for the index, generated from C++ code *)
5 external build_lex_index : Tree.t -> Tag.t -> index = "caml_build_lex_index"
6 external print_lex_index : index -> unit = "caml_print_lex_index"
10 if Array.length Sys.argv != 3 then
11 let () = Printf.eprintf "Error: invalid argument" in exit 1
13 let file = Sys.argv.(1) in
14 (* Load the index or the xml file *)
15 Printf.printf "Loading document\n%!";
17 if Filename.check_suffix file ".srx"
19 else if Filename.check_suffix file ".xml" then Tree.parse_xml_uri file
21 let () = Printf.eprintf "Error: unrecognized extension" in exit 2
23 Printf.printf "Building lex index\n%!";
24 let index = build_lex_index document (Tag.tag Sys.argv.(2)) in
25 Printf.printf "Printing lex index\n%!";
26 print_lex_index index;
34 e -> Printf.eprintf "Fatal error: %s" (Printexc.to_string e); exit 3