(* *)
(* Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
(* Recherche Scientifique. All rights reserved. This file is *)
(* *)
(* Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
(* Recherche Scientifique. All rights reserved. This file is *)
(* Buidling of the ASTA step by step with a special case for the last
step. Then add a top most state. Each function modifies asta. *)
(* Buidling of the ASTA step by step with a special case for the last
step. Then add a top most state. Each function modifies asta. *)
(Formula.false_) (Asta.top_states asta)
in
Asta.add_quer asta top_st;
Asta.init_top asta;
Asta.add_top asta top_st;
(Formula.false_) (Asta.top_states asta)
in
Asta.add_quer asta top_st;
Asta.init_top asta;
Asta.add_top asta top_st;
-
- and trans_last (ax,test,pred) = (* a selecting state is needed *)
+
+ (* A selecting state is needed *)
+ and trans_last (ax,test,pred) =
let fo_p = trans_pr pred in
let q,q' = Asta.new_state(), Asta.new_state() in
Asta.add_selec asta q';
let fo_p = trans_pr pred in
let q,q' = Asta.new_state(), Asta.new_state() in
Asta.add_selec asta q';
let Simple lab = test in
let tr_selec = (q', lab, fo_p)
and tr_q = (q, Asta.any_label, form_propa_selec q q' ax) in
Asta.add_tr asta tr_selec true;
Asta.add_tr asta tr_q true
let Simple lab = test in
let tr_selec = (q', lab, fo_p)
and tr_q = (q, Asta.any_label, form_propa_selec q q' ax) in
Asta.add_tr asta tr_selec true;
Asta.add_tr asta tr_q true
-
- and trans_step (ax,test,pred) = (* add a new state for the step *)
+
+ (* Add a new state and its transitions for the step *)
+ 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)
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)
let tr_next = (q, label, form_next)
and tr_propa = (q, Asta.any_label, form_propa q ax) in
Asta.add_quer asta q;
let tr_next = (q, label, form_next)
and tr_propa = (q, Asta.any_label, form_propa q ax) in
Asta.add_quer asta q;
-
- and trans_pr = function (* either we apply De Morgan rules
- in xPath.parse or here *)
+
+ (* Translating of predicates. Either we apply De Morgan rules
+ in xPath.parse or here *)
+ and trans_pr = function
| Expr True -> Formula.true_
| Expr False -> Formula.false_
| Or (p_1,p_2) -> trans_pr(p_1) +| trans_pr(p_2)
| Expr True -> Formula.true_
| Expr False -> Formula.false_
| Or (p_1,p_2) -> trans_pr(p_1) +| trans_pr(p_2)
| Not (Expr Path q) -> (trans_pr_path false q)
| Expr Path q -> (trans_pr_path true q)
| x -> print_predicate pr_er x; raise Not_core_XPath
| Not (Expr Path q) -> (trans_pr_path false q)
| Expr Path q -> (trans_pr_path true q)
| x -> print_predicate pr_er x; raise Not_core_XPath
-
- and trans_pr_path posi = function (* builds asta for predicate and gives
- the formula which must be satsified *)
+
+ (* Builds asta for predicate and gives the formula which must be satsified *)
+ and trans_pr_path posi = function
| Relative [] -> if posi then Formula.true_ else Formula.false_
| Relative steps -> List.fold_left
(fun acc x -> if posi then (`Left *+ x) +| acc else (`Left *- x) +| acc)
Formula.false_ (trans_pr_step_l steps)
| AbsoluteDoS steps as x -> print pr_er x; raise Not_core_XPath
| Absolute steps as x -> print pr_er x; raise Not_core_XPath
| Relative [] -> if posi then Formula.true_ else Formula.false_
| Relative steps -> List.fold_left
(fun acc x -> if posi then (`Left *+ x) +| acc else (`Left *- x) +| acc)
Formula.false_ (trans_pr_step_l steps)
| AbsoluteDoS steps as x -> print pr_er x; raise Not_core_XPath
| Absolute steps as x -> print pr_er x; raise Not_core_XPath
| [step] -> trans_pr_step [] step
| step :: tl -> let list_top = trans_pr_step_l tl in
trans_pr_step list_top step
| [] -> failwith "Can not happened! 1"
| [step] -> trans_pr_step [] step
| step :: tl -> let list_top = trans_pr_step_l tl in
trans_pr_step list_top step
| [] -> failwith "Can not happened! 1"
- and trans_pr_step list (ax,test,pred) = (* add a step on the top of
- list in a predicate *)
+ (* Add a step on the top of a list of states in a predicate *)
+ and trans_pr_step list (ax,test,pred) =
- [q] (* always one element here, but not with self
- axis*)
-
- and form_propa q = function (* gives the propagation formula *)
+ [q] (* always one element here, but more with self
+ axis *)
+ (* Gives the propagation formula *)
+ and form_propa q = function
| Child -> `Right *+ q +| `Right *+ q'
| Descendant -> (`Left *+ q +| `Right *+ q) +| (`Left *+ q' +| `Right *+ q')
| x -> print_axis pr_er x; raise Not_core_XPath
in
| Child -> `Right *+ q +| `Right *+ q'
| Descendant -> (`Left *+ q +| `Right *+ q) +| (`Left *+ q' +| `Right *+ q')
| x -> print_axis pr_er x; raise Not_core_XPath
in
| Absolute steps -> trans steps; trans_init(); asta
| AbsoluteDoS steps as x -> print pr_er x; raise Not_core_XPath
| Relative steps as x -> print pr_er x; raise Not_core_XPath
| Absolute steps -> trans steps; trans_init(); asta
| AbsoluteDoS steps as x -> print pr_er x; raise Not_core_XPath
| Relative steps as x -> print pr_er x; raise Not_core_XPath