X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgraphs%2Ftools%2Fsimplify_deps%2Fsimplify_deps.ml;h=9b0fb0042ab5d5847807fcd6fae877789c090c1e;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=0763d614974b35679a6993e06b23622c99a1c36c;hpb=53ae76208da0cf33862c64e60b76a441e1d78863;p=helm.git diff --git a/helm/graphs/tools/simplify_deps/simplify_deps.ml b/helm/graphs/tools/simplify_deps/simplify_deps.ml index 0763d6149..9b0fb0042 100644 --- a/helm/graphs/tools/simplify_deps/simplify_deps.ml +++ b/helm/graphs/tools/simplify_deps/simplify_deps.ml @@ -55,32 +55,36 @@ let parse () = try while true do let line = read_line () in - if Str.string_match (Str.regexp " \([^ ]*\) -> \([^ ;]*\)\(\( \[.*\]\)?\);") line 0 then + if Str.string_match (Str.regexp " \\([^ ]*\\) -> \\([^ ;]*\\)\\(\\( \\[.*\\]\\)?\\);") line 0 then let source = Str.matched_group 1 line in let target = Str.matched_group 2 line in - let rest = Str.matched_group 3 line in - let tar = - try - search_node target - with - Not_found -> - let tar = Node (target,ref []) in - nodes := tar :: !nodes ; - tar - in - let sou = - try - let sou = search_node source in - let Node (_,ts) = sou in - ts := tar::!ts ; - sou - with - Not_found -> - let sou = Node (source,ref [tar]) in - nodes := sou :: !nodes ; - sou - in - arcs := (sou,tar,rest)::!arcs + begin + if source <> target then + (* not a self loop *) + let rest = Str.matched_group 3 line in + let tar = + try + search_node target + with + Not_found -> + let tar = Node (target,ref []) in + nodes := tar :: !nodes ; + tar + in + let sou = + try + let sou = search_node source in + let Node (_,ts) = sou in + ts := tar::!ts ; + sou + with + Not_found -> + let sou = Node (source,ref [tar]) in + nodes := sou :: !nodes ; + sou + in + arcs := (sou,tar,rest)::!arcs + end else print_endline line done