Print labels (=QName -> qname.ml? )
[tatoo.git] / src / compil.ml
index 30440f3..610360b 100644 (file)
 (*                                                                     *)
 (***********************************************************************)
 
-let trad qu = Asta.dummy
+open XPath.Ast
+open Formula.Infix
+
+exception Not_core_XPath of path
+(** Raised whenever the XPath query contains not implemented structures *)
+
+let trans query =
+  let asta = Asta.empty in
+  let rec trans = function
+    | [s] -> trans_last s
+    | s :: tl -> trans_step s; trans tl
+    | [] -> ()
+      
+  and trans_init () =                  (* add THE top state  *)
+    let top_st = Asta.new_state () in
+    let or_top = 
+      List.fold_left (fun acc x -> (`Left *+ x +| acc))
+       Formula.true_ (Asta.top_states asta)
+    in
+    Asta.add_tr asta (top_st, Asta.any_label, or_top)
+      
+  and trans_last (ax,test,pred) =      (* a selecting state is needed *)
+    ()
+      
+  and trans_step (ax,test,pred) =
+    ()
+      
+  and trans_pr p = ()
+
+  in
+  match query with
+    | Absolute steps -> trans_init(); trans steps; asta
+    | AbsoluteDoS steps as x -> raise (Not_core_XPath x)
+    | Relative steps as x -> raise (Not_core_XPath x)