1 (***********************************************************************)
5 (* Kim Nguyen, LRI UMR8623 *)
6 (* Université Paris-Sud & CNRS *)
8 (* Copyright 2010-2013 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 *)
14 (***********************************************************************)
17 Time-stamp: <Last modified on 2013-02-12 08:32:59 CET by Kim Nguyen>
25 Ata.SFormula.atom_ (Ata.Move.make (l,b,q))
27 let ( => ) a b = (a, b)
28 let ( ** ) l q = mk_atom l true q
29 let ( ++ ) a b = Ata.SFormula.or_ a b
30 let ( %% ) a b = Ata.SFormula.and_ a b
31 let ( @: ) a b = StateSet.add a b
34 let compile_axis_test ax tst inq trs sts =
37 let outq = State.make () in
39 (inq, [ tst => (`Epsilon ** outq ) ]) :: trs,
43 let outq = State.make () in
44 let outq' = State.make () in
46 (inq, [ QNameSet.any => (`Left ** outq)])
47 :: (outq, [ tst => (`Epsilon ** outq');
48 QNameSet.any => (`Right ** outq) ])
50 outq @: (outq' @: sts)
52 | Descendant | DescendantOrSelf ->
53 let dir = if ax = Descendant then `Left else `Epsilon in
54 let outq = State.make () in
55 let outq' = State.make () in
57 (inq, [ QNameSet.any => (dir ** outq)])
58 :: (outq, [ tst => (`Epsilon ** outq');
59 QNameSet.any => ((`Left ** outq) ++ (`Right ** outq))
62 outq @: (outq' @: sts)
65 let outq = State.make () in
66 let outq' = State.make () in
67 let outq'' = State.make () in
68 let move = (`Up1 ** outq') ++ (`Up2 ** outq) in
70 (inq, [QNameSet.any => move ])
71 :: (outq, [ QNameSet.any => move ])
72 :: (outq', [ tst => (`Epsilon ** outq'') ])
74 outq @: (outq' @: (outq'' @: sts))
76 | Ancestor | AncestorOrSelf ->
77 let outq = State.make () in
78 let outq' = State.make () in
79 let outq'' = State.make () in
81 (if ax = Ancestor then (`Up1 ** outq')
82 else (`Epsilon ** outq')) ++ (`Up1 ** outq) ++ (`Up2 ** outq)
85 (inq, [QNameSet.any => move ])
86 :: (outq, [ QNameSet.any => move ])
87 :: (outq', [ tst => (`Epsilon ** outq'') ])
89 outq @: (outq' @: (outq'' @: sts))
91 | FollowingSibling | PrecedingSibling ->
92 let outq = State.make () in
93 let outq' = State.make () in
94 let dir = if ax = FollowingSibling then `Right else `Up2 in
96 (inq, [ QNameSet.any => (dir ** outq) ])
97 :: (outq, [ tst => (`Epsilon ** outq');
98 QNameSet.any => (dir ** outq) ])
100 outq @: (outq' @: sts)