X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Futf8_macros%2Fmake_table.ml;h=68309b1c444afd531142bacdc519a8d6f621a2ae;hb=97c2d258a5c524eb5c4b85208899d80751a2c82f;hp=89b9286058144a4aff83514015b779cc2e9cb577;hpb=8aa30d200433c2518b42f4b25d4b429e4cf44372;p=helm.git diff --git a/helm/ocaml/utf8_macros/make_table.ml b/helm/ocaml/utf8_macros/make_table.ml index 89b928605..68309b1c4 100644 --- a/helm/ocaml/utf8_macros/make_table.ml +++ b/helm/ocaml/utf8_macros/make_table.ml @@ -26,7 +26,7 @@ open Printf let debug = false -let debug_print s = if debug then prerr_endline s +let debug_print s = if debug then prerr_endline (Lazy.force s) (* source files for tables xml parsing (if unmarshall=false) *) let xml_tables = [ @@ -37,6 +37,8 @@ let xml_tables = [ `Entities, "data/entities-table.xml"; `Dictionary, "data/dictionary-tex.xml"; `Entities, "data/extra-entities.xml"; + (** extra-entities.xml should be the last one since it is used to override + * previous mappings. Add there overrides as needed. *) ] let iter_gen record_tag name_field value_field f fname = @@ -61,9 +63,9 @@ let iter_dictionary_file = iter_gen "entry" "name" "val" let parse_from_xml () = let (macro2utf8, utf82macro) = (Hashtbl.create 2000, Hashtbl.create 2000) in let add_macro macro utf8 = - debug_print (sprintf "Adding macro %s = '%s'" macro utf8); - Hashtbl.add macro2utf8 macro utf8; -(* Hashtbl.add utf82macro utf8 macro *) + debug_print (lazy (sprintf "Adding macro %s = '%s'" macro utf8)); + Hashtbl.replace macro2utf8 macro utf8; + Hashtbl.replace utf82macro utf8 macro in let fill_table () = List.iter @@ -74,18 +76,24 @@ let parse_from_xml () = xml_tables in fill_table (); - macro2utf8 + macro2utf8, utf82macro 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"; - let macro2utf8 = parse_from_xml () in + output_string oc "let utf82macro = Hashtbl.create 2000\n"; + let macro2utf8, utf82macro = parse_from_xml () in Hashtbl.iter (fun macro utf8 -> - fprintf oc "let _ = Hashtbl.add macro2utf8 \"%s\" \"%s\"\n" + fprintf oc "let _ = Hashtbl.replace macro2utf8 \"%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; close_out oc let _ = main ()