XPath without predicates are correctly compiled.
authorLucca Hirschi <lucca.hirschi@gmail.com>
Tue, 3 Jul 2012 08:35:32 +0000 (10:35 +0200)
committerLucca Hirschi <lucca.hirschi@gmail.com>
Tue, 3 Jul 2012 08:35:32 +0000 (10:35 +0200)
src/compil.ml

index 8044968..b722656 100644 (file)
@@ -27,7 +27,7 @@ let trans query =
      step. Then add a top most state. Each function modifies asta. *)
   let rec trans = function
     | [s] -> trans_last s
-    | s :: tl -> trans_step s; trans tl
+    | s :: tl ->  trans tl; trans_step s
     | [] -> ()
       
   and trans_init () =                  (* add THE top most state  *)
@@ -58,7 +58,21 @@ let trans query =
     Asta.add_tr asta tr_q
     
   and trans_step (ax,test,pred) =
-    ()
+    let fo_p = trans_pr pred
+    and q = Asta.new_state() in
+    let Simple label = test
+    and form_next = (fo_p) *&                    (* (\/ top_next) /\ predicat *)
+      (List.fold_left (fun acc x -> (`Left *+ x ) +| acc)
+        Formula.false_ (Asta.top_states asta)) in
+    let tr_next = (q, label, form_next)
+    and tr_propa = (q, Asta.any_label, form_propa q ax) in
+    Asta.add_quer asta q;
+    Asta.add_top asta q;
+    Asta.add_bot asta q;
+    Asta.add_tr asta tr_next;
+    Asta.add_tr asta tr_propa;
+    Asta.init_top asta;
+    Asta.add_top asta q
       
   and trans_pr  = function             (* either we apply De Morgan rules
                                           in xPath:parse or here *)