New version of the Grammar data-structure
[SXSI/xpathcomp.git] / src / main.ml
index cd3d275..b364275 100644 (file)
@@ -33,7 +33,7 @@ let mk_runtime run auto doc arg count print outfile =
 
 
 let main v query_string output =
-  Tag.init (Tree.tag_pool v);
+  Tag.init (Tree.tag_operations v);
   let query =
     time ~msg:"Parsing query" XPath.parse query_string
   in
@@ -94,7 +94,30 @@ let document =
   if Filename.check_suffix !Options.input_file ".g.bin" then
     let g = time ~msg:"Loading grammar" (Grammar.load !Options.input_file) true in
     begin
-      ignore(g);
+      (* Todo Factorise with main *)
+      Tag.init (Grammar.tag_operations g);
+      let query =
+       time ~msg:"Parsing query" XPath.parse !Options.query
+      in
+      if !Options.verbose then begin
+       Printf.eprintf "Parsed query:\n%!";
+       XPath.Ast.print Format.err_formatter query;
+       Format.fprintf Format.err_formatter "\n%!"
+      end;
+      let auto, bu_info =
+       time ~msg:"Compiling query" (Compile.compile) query
+      in
+      if !Options.verbose then Ata.print Format.err_formatter auto;
+      Gc.full_major();
+      Gc.compact();
+      Gc.set (tuned_gc);
+      let runtime =
+       let module R = ResJIT.Count in
+       let module M = Runtime.Make(R) in
+       (* mk_runtime run auto doc arg count print outfile  *)
+       mk_runtime M.grammar_run auto (Obj.magic g) () R.NS.length (Obj.magic R.NS.serialize) None
+      in
+      runtime ();
       exit 0
     end
   else if Filename.check_suffix !Options.input_file ".srx"