Merge branch 'lucca-tests-bench' into lucca-extentions
[tatoo.git] / src / asta.ml
index 942133c..965486a 100644 (file)
@@ -2,8 +2,8 @@
 (*                                                                     *)
 (*                               TAToo                                 *)
 (*                                                                     *)
-(*                  Lucca Hirschi, ?   *)
-(*                  ?   *)
+(*                   Lucca Hirschi, LRI UMR8623                        *)
+(*                   Université Paris-Sud & CNRS                       *)
 (*                                                                     *)
 (*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
 (*  Recherche Scientifique. All rights reserved.  This file is         *)
@@ -13,6 +13,8 @@
 (*                                                                     *)
 (***********************************************************************)
 
+(* utils.ml-> INCLUDE "utils.ml" HASHINT2 () *)
+
 type state = State.t
 
 type label = QNameSet.t
@@ -72,12 +74,28 @@ let transition asta st lab =
 
 let transitions asta st =
   let filter (s,l,f) = State.compare s st = 0 in
-  let rec remove_states l = match l with
+  let rec remove_states = function
     | [] -> []
-    | (a,s,l) :: tl -> (s,l) :: (remove_states tl) in
+    | (s,l,f) :: tl -> (l,f) :: (remove_states tl) in
   (remove_states (SetT.elements (SetT.filter filter asta.trans_q)),
    (remove_states (SetT.elements (SetT.filter filter asta.trans_r))))
 
+let transitions_lab asta lab = 
+  let filter (s,l,f) = QNameSet.mem lab l in
+    let rec remove_lab = function
+      | [] -> []
+      | (s,l,f) :: tl -> (s,f) :: (remove_lab tl) in
+    (remove_lab (SetT.elements (SetT.filter filter asta.trans_q)),
+     (remove_lab (SetT.elements (SetT.filter filter asta.trans_r))))
+
+let transitions_st_lab asta q lab = 
+  let filter (s,l,f) = q = s && QNameSet.mem lab l in
+    let rec remove_st_lab = function
+      | [] -> []
+      | (s,l,f) :: tl -> f :: (remove_st_lab tl) in
+    (remove_st_lab (SetT.elements (SetT.filter filter asta.trans_q)),
+     (remove_st_lab (SetT.elements (SetT.filter filter asta.trans_r))))
+
 let empty = {
   quer = StateSet.empty;
   reco = StateSet.empty;
@@ -111,6 +129,12 @@ let init_top ast  = ast.top <- (StateSet.empty)
 
 let top_states ast = StateSet.elements ast.top
 
+let top_states_s ast = ast.top
+
+let bot_states_s ast = ast.bottom
+
+let selec_states ast = ast.selec
+
 let print fmt asta =
   let print_box fmt flag = 
     let pp = Format.fprintf fmt in
@@ -122,19 +146,19 @@ let print fmt asta =
       StateSet.print asta.selec;
     pp "@[<v 0># Bottom states: %a@ @]"
       StateSet.print asta.bottom;
-    pp "@[<v 0># Tom states: %a@ @]"
+    pp "@[<v 0># Top states: %a@ @]"
       StateSet.print asta.top;
-    let print_list_tr fmt z=
+    let print_list_tr fmt z =
       if SetT.is_empty z 
       then Format.fprintf fmt "ø"
       else
-       SetT.iter (fun x -> Format.fprintf fmt "|  %a@ "  Transition.print x) z in
-    let print_box_list fmt trans  =
+       SetT.iter (fun x -> Format.fprintf fmt "|  %a  @ "  Transition.print x) z in
+    let print_box_list fmt trans =
       Format.fprintf fmt "  @[<hov 0>%a @]" print_list_tr trans in
     Format.fprintf fmt "@[<v 0># Queries transitions:@ %a@ @]"
       print_box_list asta.trans_q;
-    Format.fprintf fmt "@[<v 0># Recognizing transitions:@ %a@ @]"
+    Format.fprintf fmt "@[<v 0># Recognizing transitions:@ %a@]"
       print_box_list asta.trans_r in
-  Format.fprintf fmt "@[<v 0> ##### ASTA #####@. %a@ @]" print_box 0
+  Format.fprintf fmt "@[<v 1>##### ASTA #####@. %a@ @]@." print_box 0
 
 let to_file out asta = ()