]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_disambiguation/macro.ml
new experimental cic textual parser: checkin
[helm.git] / helm / ocaml / cic_disambiguation / macro.ml
1
2 exception Macro_not_found of string
3 exception Utf8_not_found of string
4
5 let dump_file = "macro_table.dump"
6
7 let init () =
8   let ic = open_in dump_file in
9   let (macro2utf8, utf82macro):
10     ((string, string) Hashtbl.t * (string, string) Hashtbl.t)
11   =
12     Marshal.from_channel ic
13   in
14   close_in ic;
15   (macro2utf8, utf82macro)
16
17 let (macro2utf8, utf82macro) = init ()
18
19 let expand macro =
20   try
21     Hashtbl.find macro2utf8 macro
22   with Not_found -> raise (Macro_not_found macro)
23
24 let contract utf8 =
25   try
26     Hashtbl.find utf82macro utf8
27   with Not_found -> raise (Utf8_not_found utf8)
28