]> 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 e5fca10c48cc06e3a428865ea94190758f7cbc3f..c95282d58a061d1569a199a59a5ce582e46350d4 100644 (file)
@@ -41,7 +41,32 @@ let unicode_of_tex s =
   with Macro_not_found _ -> s
 
 let tex_of_unicode s =
+ (*WARNING: the space below is a nbsp (0x00A0), not a normal space *)
+ if s = " " then [""]
+ else
   try
-    "\\" ^ Hashtbl.find Utf8MacroTable.utf82macro s
-  with Not_found -> s
+    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
+;;