Commit | Line | Data |
---|---|---|
28875fec SK |
1 | module H = MoreLabels.Hashtbl |
2 | ||
3 | type t = | |
4 | { name : string | |
5 | ; symbol : int | |
6 | } | |
7 | ||
8 | let nextsym = ref 0 | |
9 | ||
10 | let symbols = H.create 16 | |
11 | ||
12 | let of_string name = | |
13 | match H.find_opt symbols name with | |
14 | | Some symbol -> | |
15 | {name; symbol} | |
16 | | None -> | |
17 | incr nextsym; | |
18 | let symbol = !nextsym in | |
19 | H.replace symbols ~key:name ~data:symbol; | |
20 | {name; symbol} | |
21 | ||
22 | let to_string {name; _} = | |
23 | name |