Commit | Line | Data |
---|---|---|
abad11c5 C |
1 | (* Provides a dictionary of possible annotations on tokens, indexed by keys. |
2 | * | |
3 | * The purpose of these annotations is to direct the pretty printing of | |
4 | * tokens. The annotations can be set by AST transformations. | |
5 | * | |
6 | * Assumptions: only a few tokens have annotations, and those have only | |
7 | * a few of them. | |
8 | *) | |
9 | ||
10 | type annot_key = | |
11 | Exclude_start | |
12 | | Exclude_end | |
13 | ||
14 | type annot_val = | |
15 | Unit | |
16 | ||
17 | (* A linked list should offer a good tradeoff between space usage | |
18 | * and lookup overhead given our assumptions. | |
19 | *) | |
20 | type annots = (annot_key * annot_val) list | |
21 | ||
22 | let empty = [] | |
23 | ||
24 | let get_annot anns key = | |
25 | if List.mem_assoc key anns | |
26 | then Some (List.assoc key anns) | |
27 | else None | |
28 | ||
29 | let put_annot key value anns = | |
30 | (key, value) :: anns |