]> matita.cs.unibo.it Git - helm.git/blobdiff - components/utf8_macros/make_table.ml
Huge commit for the release. Includes:
[helm.git] / components / utf8_macros / make_table.ml
index 4722af1e1328dc2ee32fb18ad643eef2c1ebfeab..e8e453df4c1b842772642bf437214806281277fc 100644 (file)
@@ -63,11 +63,10 @@ let iter_entities_file    = iter_gen "entity" "name" "value"
 let iter_dictionary_file  = iter_gen "entry" "name" "val"
 
 let parse_from_xml () =
-  let (macro2utf8, utf82macro) = (Hashtbl.create 2000, Hashtbl.create 2000) in
+  let macro2utf8 = Hashtbl.create 2000 in
   let add_macro macro utf8 =
     debug_print (lazy (sprintf "Adding macro %s = '%s'" macro utf8));
-    Hashtbl.replace macro2utf8 macro utf8;
-    Hashtbl.replace utf82macro utf8 macro
+    Hashtbl.replace macro2utf8 macro utf8
   in
   let fill_table () =
     List.iter
@@ -78,24 +77,26 @@ let parse_from_xml () =
       xml_tables
   in
   fill_table ();
-  macro2utf8, utf82macro
+  macro2utf8
 
 let main () =
   let oc = open_out Sys.argv.(1) in
   output_string oc "(* GENERATED by make_table: DO NOT EDIT! *)\n";
   output_string oc "let macro2utf8 = Hashtbl.create 2000\n";
   output_string oc "let utf82macro = Hashtbl.create 2000\n";
-  let macro2utf8, utf82macro = parse_from_xml () in
+  output_string oc "let data = [\n";
+  let macro2utf8 = parse_from_xml () in
   Hashtbl.iter
     (fun macro utf8 ->
-      fprintf oc "let _ = Hashtbl.replace macro2utf8 \"%s\" \"%s\"\n"
-        macro (String.escaped utf8))
+      fprintf oc "  \"%s\", \"%s\";\n" macro (String.escaped utf8))
     macro2utf8;
-  Hashtbl.iter
-    (fun utf8 macro ->
-      fprintf oc "let _ = Hashtbl.replace utf82macro \"%s\" \"%s\"\n"
-        (String.escaped utf8) macro)
-    utf82macro;
+  output_string oc "  ];;\n";
+  output_string oc "let _ =\n";
+  output_string oc "  List.iter\n";
+  output_string oc "    (fun (macro, utf8) ->\n";
+  output_string oc "      Hashtbl.replace macro2utf8 macro utf8;\n";
+  output_string oc "      Hashtbl.replace utf82macro utf8 macro)\n";
+  output_string oc "    data;;\n";
   close_out oc
 
 let _ = main ()