Add a missing ';' and remove some dead code and outdated comments.
[tatoo.git] / src / main.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                               TAToo                                 *)
4 (*                                                                     *)
5 (*                     Kim Nguyen, LRI UMR8623                         *)
6 (*                   Université Paris-Sud & CNRS                       *)
7 (*                                                                     *)
8 (*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
9 (*  Recherche Scientifique. All rights reserved.  This file is         *)
10 (*  distributed under the terms of the GNU Lesser General Public       *)
11 (*  License, with the special exception on linking described in file   *)
12 (*  ../LICENSE.                                                        *)
13 (*                                                                     *)
14 (***********************************************************************)
15
16 (*
17   Time-stamp: <Last modified on 2013-03-10 10:49:33 CET by Kim Nguyen>
18 *)
19
20 let doc =
21   let fd = open_in Sys.argv.(1) in
22   let d = Tree.Naive.load_xml_file fd in
23   close_in fd; d
24
25
26 let query =
27   let arg2 = Sys.argv.(2) in
28   Xpath.Parser.parse (Ulexing.from_latin1_string arg2)
29
30 let auto =
31   Xpath.Compile.path query
32
33 open Format
34
35 let () =
36   fprintf err_formatter "Query: %a\n%!" Xpath.Ast.print_path query;
37   fprintf err_formatter "Automata: %a\n%!" Auto.Ata.print auto;
38   fprintf err_formatter "Evaluating automaton:\n%!";
39   let module Naive = Auto.Eval.Make(Tree.Naive) in
40   let results = Naive.eval auto doc (Tree.Naive.root doc) in
41   output_string stdout "<xml_results>\n";
42   List.iter (fun n ->
43     Tree.Naive.print_xml stdout doc n;
44     output_char stdout '\n'
45   ) results;
46   output_string stdout "\n<xml_results>";
47   flush stdout