Print labels (=QName -> qname.ml? )
[tatoo.git] / src / compil.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                               TAToo                                 *)
4 (*                                                                     *)
5 (*                  Lucca Hirschi, ?   *)
6 (*                  ?   *)
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 open XPath.Ast
17 open Formula.Infix
18
19 exception Not_core_XPath of path
20 (** Raised whenever the XPath query contains not implemented structures *)
21
22 let trans query =
23   let asta = Asta.empty in
24   let rec trans = function
25     | [s] -> trans_last s
26     | s :: tl -> trans_step s; trans tl
27     | [] -> ()
28       
29   and trans_init () =                   (* add THE top state  *)
30     let top_st = Asta.new_state () in
31     let or_top = 
32       List.fold_left (fun acc x -> (`Left *+ x +| acc))
33         Formula.true_ (Asta.top_states asta)
34     in
35     Asta.add_tr asta (top_st, Asta.any_label, or_top)
36       
37   and trans_last (ax,test,pred) =       (* a selecting state is needed *)
38     ()
39       
40   and trans_step (ax,test,pred) =
41     ()
42       
43   and trans_pr p = ()
44
45   in
46   match query with
47     | Absolute steps -> trans_init(); trans steps; asta
48     | AbsoluteDoS steps as x -> raise (Not_core_XPath x)
49     | Relative steps as x -> raise (Not_core_XPath x)