]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/graphs/tools/simplify_deps/simplify_deps.ml
ocaml 3.09 transition
[helm.git] / helm / graphs / tools / simplify_deps / simplify_deps.ml
index c924218cbdd54187974eeef7f9705c76b9bc4a9a..9b0fb0042ab5d5847807fcd6fae877789c090c1e 100644 (file)
@@ -26,11 +26,11 @@ let reachable target source_arcs =
    ) false source_arcs
 ;;
 
-let consider_arc (source,target) =
+let consider_arc (source,target,rest) =
  let Node (source_name,source_arcs) = source in
  let Node (target_name,_) = target in
   if not (reachable target !source_arcs) then
-   print_endline (source_name ^ " -> " ^ target_name)
+   print_endline (source_name ^ " -> " ^ target_name ^ rest ^ ";")
   else
    if debug then
     print_endline (source_name ^ " -> " ^ target_name ^ " [color=green];")
@@ -55,31 +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 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)::!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