From c5e1e4d1726bd78464a7d458df3aca047749567b Mon Sep 17 00:00:00 2001 From: natile Date: Wed, 9 Oct 2002 15:19:27 +0000 Subject: [PATCH] Debugging Sub and Meet --- helm/ocaml/mathql_interpreter/meet.ml | 6 +++-- helm/ocaml/mathql_interpreter/mqint.ml | 32 ++++++++++++++++++++------ helm/ocaml/mathql_interpreter/sub.ml | 8 ++++--- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/helm/ocaml/mathql_interpreter/meet.ml b/helm/ocaml/mathql_interpreter/meet.ml index 53a75ccb1..2482ea02e 100644 --- a/helm/ocaml/mathql_interpreter/meet.ml +++ b/helm/ocaml/mathql_interpreter/meet.ml @@ -28,5 +28,7 @@ let rec meet_ex v1 v2 = match v1,v2 with [],_ | _,[] -> false - | s::tl,l -> if List.mem s l then true - else meet_ex tl l + | s1::tl1, s2::_ when s1 < s2 -> sub_ex tl1 v2 + | s1::_, s2::tl2 when s2 < s1 -> false + | s1::_, s2::_ when s1 = s2 -> true +;; diff --git a/helm/ocaml/mathql_interpreter/mqint.ml b/helm/ocaml/mathql_interpreter/mqint.ml index 9553f56df..a9d18940b 100644 --- a/helm/ocaml/mathql_interpreter/mqint.ml +++ b/helm/ocaml/mathql_interpreter/mqint.ml @@ -81,7 +81,8 @@ let rec exec_set_exp c = function print_endline (string_of_float (Sys.time () -. before) ^ "s") ; flush stdout ; res | MathQL.Relation (rop, path, sexp, attl) -> relation_ex rop path (exec_set_exp c sexp) attl - | MathQL.Select (rvar, sexp, bexp) -> + | MathQL.Select (rvar, sexp, bexp) -> + let before = Sys.time () in let rset = (exec_set_exp c sexp) in let rec select_ex rset = match rset with @@ -89,7 +90,11 @@ let rec exec_set_exp c = function | r::tl -> let c1 = upd_rvars c ((rvar,r)::c.rvars) in if (exec_boole_exp c1 bexp) then r::(select_ex tl) else select_ex tl - in select_ex rset + in + let res = select_ex rset in + print_string ("SELECT " ^ rvar ^ " = " ^ string_of_int (List.length res) ^ ": ") ; + print_endline (string_of_float (Sys.time () -. before) ^ "s") ; + flush stdout ; res | MathQL.Diff (sexp1, sexp2) -> diff_ex (exec_set_exp c sexp1) (exec_set_exp c sexp2) | _ -> assert false @@ -101,11 +106,21 @@ and exec_boole_exp c = function | MathQL.Not x -> not (exec_boole_exp c x) | MathQL.And (x, y) -> (exec_boole_exp c x) && (exec_boole_exp c y) | MathQL.Or (x, y) -> (exec_boole_exp c x) || (exec_boole_exp c y) - | MathQL.Sub (vexp1, vexp2) -> sub_ex (exec_val_exp c vexp1) (exec_val_exp c vexp2) - | MathQL.Meet (vexp1, vexp2) -> meet_ex (exec_val_exp c vexp1) (exec_val_exp c vexp2) + | MathQL.Sub (vexp1, vexp2) -> let res = sub_ex (exec_val_exp c vexp1) (exec_val_exp c vexp2) + in + if res then (print_endline"SUB: TRUE";flush stdout) + else (print_endline"SUB: FALSE";flush stdout); + res + | MathQL.Meet (vexp1, vexp2) -> let res = meet_ex (exec_val_exp c vexp1) (exec_val_exp c vexp2) + in + if res then (print_endline"MEET: TRUE";flush stdout) + else (print_endline"MEET: FALSE";flush stdout); + res + | MathQL.Eq (vexp1, vexp2) -> (exec_val_exp c vexp1) = (exec_val_exp c vexp2) | MathQL.Ex l bexp -> - if l = [] then (exec_boole_exp c bexp) + let res = + if l = [] then (print_endline"LISTA VUOTA!";flush stdout;(exec_boole_exp c bexp)) else let latt = List.map (fun uri -> let (r,attl) = List.assoc uri c.rvars in (uri,attl)) l (*latt = l + attributi*) @@ -121,8 +136,11 @@ and exec_boole_exp c = function in sub_prod attl in - prod c latt; false - with BooleExpTrue -> true + prod c latt; print_endline"SONO ARRIVATO ALLA FINE!"; flush stdout;false + with BooleExpTrue -> true + in if res then (print_endline"TRUE"; flush stdout) + else (print_endline"FALSE"; flush stdout); + res | _ -> assert false (* valuta una MathQL.val_exp e ritorna un MathQL.value *) diff --git a/helm/ocaml/mathql_interpreter/sub.ml b/helm/ocaml/mathql_interpreter/sub.ml index 17804c754..b4c65d207 100644 --- a/helm/ocaml/mathql_interpreter/sub.ml +++ b/helm/ocaml/mathql_interpreter/sub.ml @@ -26,7 +26,9 @@ let rec sub_ex v1 v2 = match v1,v2 with - [],_ + [],_ -> true | _,[] -> false - | s::tl,l -> if (List.mem s l) then sub_ex tl l - else false + | s1::tl1, s2::_ when s1 < s2 -> sub_ex tl1 v2 + | s1::_, s2::_ when s2 < s1 -> false + | s1::tl1, s2::tl2 -> (tl1,tl2) +;; -- 2.39.2