X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fasta.ml;h=9682bd1b76ab95231b1d3ddbdabfb5540ac8f79a;hb=91c3b3585a018dd5f98949e4838ef3d6c5c120fc;hp=8b9682cfdd6ea2d63952a8f2f0aa07f3d77e725b;hpb=e80e269c313952b4d427fa6a5a9729ea15e43f39;p=tatoo.git diff --git a/src/asta.ml b/src/asta.ml index 8b9682c..9682bd1 100644 --- a/src/asta.ml +++ b/src/asta.ml @@ -33,7 +33,7 @@ struct let la (st,la,f) = la let fo (st,la,f) = f let print fmt (st,la,f) = - Format.fprintf fmt "(%a,%s,%a)" + Format.fprintf fmt "%a ----%s---> %a" State.print st (QNameSet.to_string la) Formula.print f @@ -47,6 +47,7 @@ end type transition = Transition.t type t = { + mutable quer : StateSet.t; mutable reco : StateSet.t; mutable selec : StateSet.t; mutable bottom : StateSet.t; @@ -74,6 +75,7 @@ let transitions asta st = remove_states (SetT.elements (SetT.filter filter asta.trans)) let empty = { + quer = StateSet.empty; reco = StateSet.empty; selec = StateSet.empty; bottom = StateSet.empty; @@ -87,6 +89,8 @@ let new_state () = State.make() let add_tr ast tr = ast.trans <- (SetT.add tr (ast.trans)) +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)) @@ -95,11 +99,15 @@ 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 pp = Format.fprintf fmt in - pp "Recognizing states: "; + pp "Query states: "; + StateSet.print fmt asta.quer; + pp "\nRecognizing states: "; StateSet.print fmt asta.reco; pp "\nSelecting states: "; StateSet.print fmt asta.selec; @@ -108,9 +116,12 @@ let print fmt asta = pp "\nTop states: "; StateSet.print fmt asta.top; pp "\nTransitions: \n"; - Format.fprintf fmt "{@[ %a @]}" (* todo: check boxes *) - (Pretty.print_list ~sep:"@, " (Transition.print)) - (SetT.elements (asta.trans)) - + Format.fprintf fmt "{"; + Format.open_vbox 20; + SetT.iter (fun x -> Format.fprintf fmt "%a @." Transition.print x) + (asta.trans); + Format.print_flush (); + Format.fprintf fmt "}" + let to_file out asta = ()