1 (***********************************************************************)
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 *)
14 (***********************************************************************)
18 type label = QNameSet.t
20 type formula = Formula.t
24 type t = state * label * formula
26 let compare (st,la,f) (st',la',f') =
27 let x_1 = State.compare st st' in
29 else let x_2 = QNameSet.compare la la' in
31 else Formula.compare f f'
35 let print fmt (st,la,f) =
36 Format.fprintf fmt "%a ----%s---> %a"
38 (QNameSet.to_string la)
44 include Set.Make(Transition)
47 type transition = Transition.t
50 mutable quer : StateSet.t;
51 mutable reco : StateSet.t;
52 mutable selec : StateSet.t;
53 mutable bottom : StateSet.t;
54 mutable top : StateSet.t;
55 mutable trans : SetT.t;
58 exception Not_found_transition
59 exception Transition_not_injective
61 let transition asta st lab =
63 (State.compare s st = 0) && (QNameSet.compare l lab = 0) in
64 let tr_set = SetT.elements (SetT.filter filter asta.trans) in
66 | [] -> raise Not_found_transition
67 | x::y::z -> raise Transition_not_injective
68 | [l] -> Transition.fo l
70 let transitions asta st =
71 let filter (s,l,f) = State.compare s st = 0 in
72 let rec remove_states l = match l with
74 | (a,s,l) :: tl -> (s,l) :: (remove_states tl) in
75 remove_states (SetT.elements (SetT.filter filter asta.trans))
78 quer = StateSet.empty;
79 reco = StateSet.empty;
80 selec = StateSet.empty;
81 bottom = StateSet.empty;
86 let any_label = QNameSet.complement (QNameSet.empty)
88 let new_state () = State.make()
90 let add_tr ast tr = ast.trans <- (SetT.add tr (ast.trans))
92 let add_quer ast st = ast.quer <- (StateSet.add st (ast.quer))
94 let add_reco ast st = ast.reco <- (StateSet.add st (ast.reco))
96 let add_selec ast st = ast.selec <- (StateSet.add st (ast.selec))
98 let add_bot ast st = ast.bottom <- (StateSet.add st (ast.bottom))
100 let add_top ast st = ast.top <- (StateSet.add st (ast.top))
102 let init_top ast = ast.top <- (StateSet.empty)
104 let top_states ast = StateSet.elements ast.top
107 let pp = Format.fprintf fmt in
109 StateSet.print fmt asta.quer;
110 pp "\nRecognizing states: ";
111 StateSet.print fmt asta.reco;
112 pp "\nSelecting states: ";
113 StateSet.print fmt asta.selec;
114 pp "\nBottom states: ";
115 StateSet.print fmt asta.bottom;
117 StateSet.print fmt asta.top;
118 pp "\nTransitions: \n";
119 Format.fprintf fmt "{";
121 SetT.iter (fun x -> Format.fprintf fmt "%a @." Transition.print x)
123 Format.print_flush ();
124 Format.fprintf fmt "}"
127 let to_file out asta = ()