]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/syntax_extensions/utf8Macro.ml
milestone in basic_2, λδ-2A reconstructed
[helm.git] / helm / software / components / syntax_extensions / utf8Macro.ml
index 36d6b175d713cd213ae540bdb9aa953e8f80efaf..c95282d58a061d1569a199a59a5ce582e46350d4 100644 (file)
@@ -42,9 +42,31 @@ let unicode_of_tex s =
 
 let tex_of_unicode s =
  (*WARNING: the space below is a nbsp (0x00A0), not a normal space *)
- if s = " " then Some ""
+ if s = " " then [""]
  else
   try
-    Some ("\\" ^ Hashtbl.find Utf8MacroTable.utf82macro s)
-  with Not_found -> None
+    let alt = 
+      List.map (fun x -> "\\"^x) 
+       (Hashtbl.find_all Utf8MacroTable.utf82macro s)
+    in
+    List.sort 
+      (fun x y -> Pervasives.compare (String.length x) (String.length y)) 
+      alt
+  with Not_found -> []
 
+let pp_table () =
+  let rec list_uniq ?(eq=(=)) = function 
+    | [] -> []
+    | h::[] -> [h]
+    | h1::h2::tl when eq h1 h2 -> list_uniq ~eq (h2 :: tl) 
+    | h1::tl (* when h1 <> h2 *) -> h1 :: list_uniq ~eq tl
+  in
+  let l = ref [] in
+  Hashtbl.iter (fun k _ -> l := k :: !l) Utf8MacroTable.utf82macro;
+  l := list_uniq (List.sort compare !l);
+  List.map 
+    (fun k -> 
+       let vs = Hashtbl.find_all Utf8MacroTable.utf82macro k in
+       (k, List.map (fun x -> "\\"^x) vs))
+    !l
+;;