1 (* Abstract type for the index, generated from C++ code *)
5 external build_lex_index : Tree.tree_pointer -> Tag.t -> index = "caml_build_lex_index"
7 external print_lex_index : index -> unit = "caml_print_lex_index"
11 if Array.length Sys.argv != 3 then
12 let () = Printf.eprintf "Error: invalid argument" in exit 1
14 let file = Sys.argv.(1) in
15 (* Load the index or the xml file *)
16 Printf.printf "Loading document\n%!";
18 if Filename.check_suffix file ".srx"
20 else if Filename.check_suffix file ".xml" then Tree.parse_xml_uri file
22 let () = Printf.eprintf "Error: unrecognized extension" in exit 2
24 Tag.init (Tree.tag_operations document);
25 Printf.printf "Building lex index for tag %s\n%!" (Tag.to_string (Tag.tag Sys.argv.(2)));
26 let index = build_lex_index (Tree.get_tree_pointer document) (Tag.tag Sys.argv.(2)) in
27 Printf.printf "Printing lex index\n%!";
28 print_lex_index index;
36 e -> Printf.eprintf "Fatal error: %s" (Printexc.to_string e); exit 3