]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/contribs/lambdadelta/bin/roles/rolesUtils.ml
update in binaries for λδ
[helm.git] / matita / matita / contribs / lambdadelta / bin / roles / rolesUtils.ml
index 7c779fddfebdcf6aadcad2d331c158eba49e0acc..5fdf312f70321584b0e78b59c95babce4ed7e09f 100644 (file)
@@ -74,6 +74,10 @@ let rec list_exists compare = function
     if b <= 0 then b = 0 else
     list_exists compare tl
 
+let rec list_count s c = function
+  | []         -> s, c
+  | (b, _)::tl -> list_count (s + if b then 1 else 0) (succ c) tl
+
 let string_of_version v =
   String.concat "." (List.map string_of_int v)
 
@@ -163,28 +167,47 @@ let new_status = {
   ET.r = []; ET.s = []; ET.t = []; ET.w = [];
 }
 
+let string_of_pointer = string_of_version
+
 let pointer_of_string = version_of_string
 
+let list_visit before each visit after string_of p l =
+  let ptr p = string_of_pointer (List.rev p) in
+  let rec aux i = function
+    | []         -> ()
+    | (b, x)::tl ->
+      each (ptr (i::p)) b (string_of x);
+      visit (i::p) x;
+      aux (succ i) tl
+  in
+  let s, c = list_count 0 0 l in
+  let count = Printf.sprintf "%u/%u" s c in
+  before (ptr p) count;
+  aux 0 l;
+  after ()
+
 let string_of_error = function
-  | ET.EWrongExt x   ->
+  | ET.EWrongExt x         ->
     Printf.sprintf "unknown input file type %S" x
-  | ET.EStage v      ->
+  | ET.EStage v            ->
     Printf.sprintf "current stage %S" (string_of_version v)
-  | ET.ENoStage      ->
+  | ET.ENoStage            ->
     Printf.sprintf "current stage not defined"
-  | ET.EWaiting      ->
+  | ET.EWaiting            ->
     Printf.sprintf "current stage not finished"
-  | ET.ENameClash n  ->
+  | ET.ENameClash n        ->
     Printf.sprintf "name clash %S" (string_of_name n)
-  | ET.EObjClash o   ->
+  | ET.EObjClash o         ->
     Printf.sprintf "object clash %S" (string_of_obj o)
-  | ET.ERoleClash r  ->
+  | ET.ERoleClash r        ->
     Printf.sprintf "role clash %S" (string_of_role r)
-  | ET.ENoEntry      ->
+  | ET.ENoEntry            ->
     Printf.sprintf "entry not found"
-  | ET.EWrongSelect  ->
+  | ET.EWrongSelect        ->
     Printf.sprintf "selected role is not unique"
-  | ET.EWrongVersion ->
+  | ET.EWrongVersion       ->
     Printf.sprintf "selected role is not in the current stage"
-  | ET.ETops         ->
+  | ET.ETops               ->
     Printf.sprintf "top objects already computed"
+  | ET.EWrongRequest (r,a) ->
+    Printf.sprintf "unknown request \"%s=%s\"" r a