X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Flextest.ml;fp=src%2Flextest.ml;h=0c297ca11d4fb27a4d810d2c6bb15cf9a6bc247b;hb=7d26a502050836784010cabae6acedee8aa9a46c;hp=0000000000000000000000000000000000000000;hpb=a05cf380a8b16c742dbb1e005e96600e6f727436;p=SXSI%2Fxpathcomp.git diff --git a/src/lextest.ml b/src/lextest.ml new file mode 100644 index 0000000..0c297ca --- /dev/null +++ b/src/lextest.ml @@ -0,0 +1,35 @@ +(* Abstract type for the index, generated from C++ code *) + +type index + +external build_lex_index : Tree.t -> Tag.t -> index = "caml_build_lex_index" +external print_lex_index : index -> unit = "caml_print_lex_index" + + +let main () = + if Array.length Sys.argv != 3 then + let () = Printf.eprintf "Error: invalid argument" in exit 1 + else + let file = Sys.argv.(1) in + (* Load the index or the xml file *) + Printf.printf "Loading document\n%!"; + let document = + if Filename.check_suffix file ".srx" + then Tree.load file + else if Filename.check_suffix file ".xml" then Tree.parse_xml_uri file + else + let () = Printf.eprintf "Error: unrecognized extension" in exit 2 + in + Printf.printf "Building lex index\n%!"; + let index = build_lex_index document (Tag.tag Sys.argv.(2)) in + Printf.printf "Printing lex index\n%!"; + print_lex_index index; + exit 0 + + +let () = + try + main () + with + e -> Printf.eprintf "Fatal error: %s" (Printexc.to_string e); exit 3 +