Purge libxml++ from build.
[SXSI/xpathcomp.git] / src / options.ml
1 let index_empty_texts = ref false
2 let sample_factor = ref 64
3 let disable_text_collection = ref false
4 let tc_threshold = ref 60000
5
6 let query = ref ""
7 let input_file = ref ""
8 let output_file = ref None
9 let save_file = ref ""
10 let count_only = ref false
11 let time = ref false
12 let bottom_up = ref false
13 let no_jump = ref false
14 let verbose = ref false
15 let text_index_type = ref 0
16
17 (* Only valid if compiled with -DTRACE *)
18 let trace_file = ref "trace.dot"
19
20
21 let set_index_type = function
22   | "default" -> text_index_type := 0
23   | "swcsa" -> text_index_type := 1
24   | "rlcsa" -> text_index_type := 2
25   | s -> raise (Arg.Bad(s))
26
27 let usage_msg = Printf.sprintf "%s [options] <input.{xml|srx}> 'query' [output]" Sys.argv.(0)
28
29
30 let pos = ref 0
31 let anon_fun =
32   fun s -> match !pos with
33     | 0 -> input_file:= s;incr pos
34     | 1 -> query := s; incr pos
35     | 2 -> output_file := Some s; incr pos
36     | _ -> raise (Arg.Bad(s))
37
38 let spec = Arg.align
39   [ "-c", Arg.Set(count_only),
40     " counting only (don't materialize the result set)";
41
42     "-f", Arg.Set_int(sample_factor),
43     "<n> sample factor [default=64]";
44
45     "-i", Arg.Set(index_empty_texts),
46     " index empty texts [default=false]";
47
48     "-d", Arg.Set(disable_text_collection),
49     " disable text collection[default=false]";
50
51     "-s", Arg.Set_string(save_file),
52     "<save_file> save the intermediate representation into file.srx";
53
54     "-b", Arg.Set(bottom_up), " real bottom up run";
55
56     "-nj", Arg.Set(no_jump), " disable jumping";
57
58     "-index-type", Arg.Symbol ([ "default"; "swcsa"; "rlcsa" ],
59                                set_index_type),
60     " choose text index type";
61
62     "-v", Arg.Set(verbose), " verbose mode"; ] @
63 IFDEF TRACE
64 THEN [
65     "-trace-file", Arg.Set_string(trace_file),
66     "<trace_file> save the full trace in dot format in <trace_file>"
67      ]
68 ELSE []
69 END
70
71
72 let parse_cmdline() =
73   let _ = Arg.parse spec anon_fun usage_msg
74   in
75   if (!pos > 3 || !pos < 2)
76   then begin Arg.usage spec usage_msg; exit 1 end
77
78
79
80
81