5 mutable states : StateSet.t;
6 mutable top_states : StateSet.t;
7 mutable bottom_states: StateSet.t;
8 mutable selection_states: StateSet.t;
9 transitions: (State.t, (QNameSet.t*Formula.t) list) Hashtbl.t;
12 let next = Uid.make_maker ()
14 let create () = { id = next ();
15 states = StateSet.empty;
16 top_states = StateSet.empty;
17 bottom_states = StateSet.empty;
18 selection_states = StateSet.empty;
19 transitions = Hashtbl.create 17;
22 let add_trans a q s f =
23 let trs = try Hashtbl.find a.transitions q with Not_found -> [] in
25 List.fold_left (fun (rem, atrs) ((labs, phi) as tr) ->
26 let nlabs = QNameSet.inter labs rem in
27 if QNameSet.is_empty nlabs then
30 let nrem = QNameSet.diff rem labs in
31 nrem, (nlabs, Formula.or_ phi f)::atrs
34 let ntrs = if QNameSet.is_empty rem then ntrs
37 Hashtbl.replace a.transitions q ntrs
46 Selection states: %a@\n\
47 Alternating transitions:@\n"
49 StateSet.print a.states
50 StateSet.print a.top_states
51 StateSet.print a.bottom_states
52 StateSet.print a.selection_states;
55 (fun q t acc -> List.fold_left (fun acc (s , f) -> (q,s,f)::acc) acc t)
59 let sorted_trs = List.stable_sort (fun (q1, s1, phi1) (q2, s2, phi2) ->
60 let c = State.compare q1 q2 in - (if c == 0 then QNameSet.compare s1 s2 else c))
63 let sfmt = str_formatter in
64 let _ = flush_str_formatter () in
65 let strs_strings, maxs = List.fold_left (fun (accl, accm) (q, s, f) ->
66 let s1 = State.print sfmt q; flush_str_formatter () in
67 let s2 = QNameSet.print sfmt s; flush_str_formatter () in
68 let s3 = Formula.print sfmt f; flush_str_formatter () in
69 ( (s1, s2, s3) :: accl,
71 accm (2 + String.length s1 + String.length s2))
74 List.iter (fun (s1, s2, s3) ->
75 fprintf fmt "%s, %s" s1 s2;
76 fprintf fmt "%s" (Pretty.padding (maxs - String.length s1 - String.length s2 - 2));
77 fprintf fmt "%s %s@\n" Pretty.right_arrow s3) strs_strings