X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fasta.ml;h=2f4083638686b4fbe38c52b8c869c7f752581900;hb=7f20d23e406e81e6e7271d2621cb868d9fe63aae;hp=4e53bcd5d1ce3cd4b72ce9e072429b0987e047b2;hpb=f4eb8149f6cdec4f56c4947690e0aa8ce2ff17c2;p=tatoo.git diff --git a/src/asta.ml b/src/asta.ml index 4e53bcd..2f40836 100644 --- a/src/asta.ml +++ b/src/asta.ml @@ -2,7 +2,7 @@ (* *) (* TAToo *) (* *) -(* ? *) +(* Lucca Hirschi, ? *) (* ? *) (* *) (* Copyright 2010-2012 Université Paris-Sud and Centre National de la *) @@ -13,8 +13,6 @@ (* *) (***********************************************************************) -open Format - type state = State.t type label = QNameSet.t @@ -34,6 +32,11 @@ struct let st (st,la,f) = st let la (st,la,f) = la let fo (st,la,f) = f + let print fmt (st,la,f) = + Format.fprintf fmt "%a ----%s---> %a" + State.print st + (QNameSet.to_string la) + Formula.print f end module SetT = @@ -41,21 +44,27 @@ struct include Set.Make(Transition) end +type transition = Transition.t + type t = { - reco : StateSet.t; - selec : StateSet.t; - bottom : StateSet.t; - top : StateSet.t; - trans : SetT.t; + mutable quer : StateSet.t; + mutable reco : StateSet.t; + mutable selec : StateSet.t; + mutable bottom : StateSet.t; + mutable top : StateSet.t; + mutable trans_q : SetT.t; + mutable trans_r : SetT.t; } exception Not_found_transition exception Transition_not_injective - + let transition asta st lab = let filter (s,l,f) = (State.compare s st = 0) && (QNameSet.compare l lab = 0) in - let tr_set = SetT.elements (SetT.filter filter asta.trans) in + let tr_set = (SetT.elements (SetT.filter filter asta.trans_q)) @ + (SetT.elements (SetT.filter filter asta.trans_r)) + in match tr_set with | [] -> raise Not_found_transition | x::y::z -> raise Transition_not_injective @@ -66,8 +75,63 @@ let transitions asta st = let rec remove_states l = match l with | [] -> [] | (a,s,l) :: tl -> (s,l) :: (remove_states tl) in - remove_states (SetT.elements (SetT.filter filter asta.trans)) + (remove_states (SetT.elements (SetT.filter filter asta.trans_q)), + (remove_states (SetT.elements (SetT.filter filter asta.trans_r)))) + +let empty = { + quer = StateSet.empty; + reco = StateSet.empty; + selec = StateSet.empty; + bottom = StateSet.empty; + top = StateSet.empty; + trans_q = SetT.empty; + trans_r = SetT.empty +} + +let any_label = QNameSet.complement (QNameSet.empty) + +let new_state () = State.make() + +let add_tr ast tr flag = + if flag + then ast.trans_q <- (SetT.add tr (ast.trans_q)) + else ast.trans_r <- (SetT.add tr (ast.trans_r)) + +let add_quer ast st = ast.quer <- (StateSet.add st (ast.quer)) + +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 init_top ast = ast.top <- (StateSet.empty) + +let top_states ast = StateSet.elements ast.top -let print fmt asta = () +let print fmt asta = + let print_box fmt flag = + let pp = Format.fprintf fmt in + Format.fprintf fmt "@[# Query states: %a@ @]" + StateSet.print asta.quer; + Format.fprintf fmt "@[# Recognizing states: %a@ @]" + StateSet.print asta.reco; + Format.fprintf fmt "@[# Selecting states: %a@ @]" + StateSet.print asta.selec; + Format.fprintf fmt "@[# Bottom states: %a@ @]" + StateSet.print asta.bottom; + Format.fprintf fmt "@[# Tom states: %a@ @]" + StateSet.print asta.top; + let print_list_tr fmt z= + SetT.iter (fun x -> Format.fprintf fmt "| %a@ " Transition.print x) z in + let print_box_list fmt trans = + Format.fprintf fmt " @[%a @]" print_list_tr trans in + Format.fprintf fmt "@[# Queries transitions:@ %a@ @]" + print_box_list asta.trans_q; + Format.fprintf fmt "@[# Recognizing transitions:@ %a@ @]" + print_box_list asta.trans_r in + Format.fprintf fmt "@[ ##### ASTA #####@. %a@ @]@ " print_box 0 let to_file out asta = ()