-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathposition.ml
57 lines (53 loc) · 1.17 KB
/
position.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifdef POSITION
let project (_, x) = x
let inject x =
let dummy =
{
file_name = Some "(dummy)";
start_line = 0;
start_column = 0;
end_line = 0;
end_column = 0;
}
in
(dummy, x)
let rec forget_positions ((_, x) : json) =
match x with
| `Null -> `Null
| `Bool b -> `Bool b
#ifdef INT
| `Int i -> `Int i
#endif
#ifdef INTLIT
| `Intlit s -> `Intlit s
#endif
#ifdef FLOAT
| `Float r -> `Float r
#endif
#ifdef FLOATLIT
| `Floatlit s -> `Floatlit s
#endif
#ifdef STRING
| `String s -> `String s
#endif
#ifdef STRINGLIT
| `Stringlit s -> `Stringlit s
#endif
| `Assoc assoc -> `Assoc (assoc |> List.map (fun (k, v) -> (k, forget_positions v)))
| `List js -> `List (js |> List.map forget_positions)
#ifdef TUPLE
| `Tuple js -> `Tuple (js |> List.map forget_positions)
#endif
#ifdef VARIANT
| `Variant (s, jopt) ->
begin
match jopt with
| None -> `Variant (s, None)
| Some(j) -> `Variant (s, Some(forget_positions j))
end
#endif
#else
let project x = x
let inject x = x
let forget_positions x = x
#endif