1 (* Abstract type for the index, generated from C++ code *)
5 external build_lex_index : Tree.tree_pointer -> Tag.t -> Tag.t -> index = "caml_build_lex_index"
7 external print_lex_index : index -> unit = "caml_print_lex_index"
11 if Array.length Sys.argv != 4 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 tags %s, %s\n%!" (Tag.to_string (Tag.tag Sys.argv.(2)))
26 (Tag.to_string (Tag.tag Sys.argv.(3)));
27 let index = build_lex_index (Tree.get_tree_pointer document) (Tag.tag Sys.argv.(2)) (Tag.tag Sys.argv.(3)) in
28 Printf.printf "Printing lex index\n%!";
29 print_lex_index index;
37 e -> Printf.eprintf "Fatal error: %s" (Printexc.to_string e); exit 3