Print labels (=QName -> qname.ml? )
[tatoo.git] / src / asta.ml
index cb4521e..8b9682c 100644 (file)
@@ -13,8 +13,6 @@
 (*                                                                     *)
 (***********************************************************************)
 
-open Format
-
 type state = State.t
 
 type label = QNameSet.t
@@ -37,7 +35,7 @@ struct
   let print fmt (st,la,f) =
     Format.fprintf fmt "(%a,%s,%a)"
       State.print st
-      "TODO la"
+      (QNameSet.to_string la)
       Formula.print f
 end
 
@@ -46,6 +44,8 @@ struct
   include Set.Make(Transition)
 end
 
+type transition = Transition.t
+
 type t = {
   mutable reco : StateSet.t;
   mutable selec : StateSet.t;
@@ -73,6 +73,29 @@ let transitions asta st =
     | (a,s,l) :: tl -> (s,l) :: (remove_states tl) in
   remove_states (SetT.elements (SetT.filter filter asta.trans))
 
+let empty = {
+  reco = StateSet.empty;
+  selec = StateSet.empty;
+  bottom = StateSet.empty;
+  top = StateSet.empty;
+  trans = SetT.empty;
+}
+
+let any_label = QNameSet.complement (QNameSet.empty)
+
+let new_state () = State.make()
+
+let add_tr ast tr = ast.trans <- (SetT.add tr (ast.trans))
+
+let add_reco ast st = ast.reco <- (StateSet.add st (ast.reco))
+
+let add_selec ast st = ast.selec <- (StateSet.add st (ast.selec))
+
+let add_bot ast st = ast.bottom <- (StateSet.add st (ast.bottom))
+
+let add_top ast st = ast.top <- (StateSet.add st (ast.top))
+
+let top_states ast = StateSet.elements ast.top
 
 let print fmt asta =
   let pp = Format.fprintf fmt in
@@ -85,7 +108,7 @@ let print fmt asta =
   pp "\nTop states: ";
   StateSet.print fmt asta.top;
   pp "\nTransitions: \n";
-  Format.fprintf fmt "{@[<hov n> %a @]}" (* todo: check boxes *)
+  Format.fprintf fmt "{@[<hov 2> %a @]}" (* todo: check boxes *)
     (Pretty.print_list ~sep:"@, " (Transition.print))
     (SetT.elements (asta.trans))