Expose option module to the rest of the program
[tiger.ml.git] / compiler / src / lib / tiger / tiger_symbol.ml
... / ...
CommitLineData
1module H = MoreLabels.Hashtbl
2
3type t =
4 { name : string
5 ; symbol : int
6 }
7
8let nextsym = ref 0
9
10let symbols = H.create 16
11
12let 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
22let to_string {name; _} =
23 name
24
25let is_equal {symbol=s1; _} {symbol=s2; _} =
26 s1 = s2
This page took 0.031967 seconds and 4 git commands to generate.