X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=src%2Fcompil.ml;h=610360bb9dc37751e24644e9d02911cfffbad301;hp=30440f376b836a74e742da1743af9000e37436ce;hb=e80e269c313952b4d427fa6a5a9729ea15e43f39;hpb=5a9c2accf1b54294cd71b90ca5cca5f69ac8e76e diff --git a/src/compil.ml b/src/compil.ml index 30440f3..610360b 100644 --- a/src/compil.ml +++ b/src/compil.ml @@ -13,4 +13,37 @@ (* *) (***********************************************************************) -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)