@@ -67,7 +67,6 @@ type manager =
67
67
over_right_gap : limit Links .t ; (* * associates the right limit of a token to
68
68
the left limit of the next *)
69
69
cache : (srcloc * limit ) Links .t ;
70
- leftmost_in_file : (string , limit ) Hashtbl .t ;
71
70
id : string ; (* * manager identifier (for logging/debugging) *)
72
71
}
73
72
@@ -80,7 +79,6 @@ let new_manager: string -> manager =
80
79
right_of = Links. create 42 ;
81
80
over_right_gap = Links. create 42 ;
82
81
cache = Links. create 42 ;
83
- leftmost_in_file = Hashtbl. create 3 ;
84
82
id = Pretty. to_string " %s-%u" manager_name ! id;
85
83
}
86
84
@@ -96,21 +94,13 @@ let limits: manager -> srcloc -> limit * limit = fun ctx loc ->
96
94
| _ -> Limit. make_virtual () , Limit. make_virtual ()
97
95
in
98
96
Links. replace ctx.right_of s (loc, e); (* replace to deal with duplicates *)
99
- if not (Hashtbl. mem ctx.leftmost_in_file s.pos_fname)
100
- then Hashtbl. add ctx.leftmost_in_file s.pos_fname s;
101
97
s, e
102
98
103
99
(* * Links token limits *)
104
100
let link_limits ctx left right =
105
101
(* Replace to deal with overriding of limits during recovery. *)
106
102
Links. replace ctx.over_right_gap left right
107
103
108
- (* * [leftmost_limit_in ~filename ctx] finds the leftmost limit from a location
109
- in [filename] that is registered in [ctx] (internal). Use with moderation
110
- as this is quite inefficient. *)
111
- let leftmost_limit_in ~filename ctx =
112
- Hashtbl. find_opt ctx.leftmost_in_file filename
113
-
114
104
(* * Returns a source location that spans between two given limits; returns a
115
105
valid pointwise location if the two given limits are physically equal. *)
116
106
let join_limits: manager -> limit * limit -> srcloc = fun ctx (s , e ) ->
@@ -165,17 +155,14 @@ let join_limits: manager -> limit * limit -> srcloc = fun ctx (s, e) ->
165
155
in
166
156
(* first attempt assumes proper token limits: `s` is a left and `e` is a
167
157
right of tokens *)
168
- try try_limits (s, e) with Not_found ->
158
+ try
159
+ try_limits (s, e)
160
+ with Not_found ->
169
161
(* otherwise try assuming `s` is an end of token *)
170
- try try_limits (Links. find ctx.over_right_gap s, e) with Not_found ->
171
- try if s.pos_cnum = 0 (* potential special case with left-position forged by
172
- the parser: retry with leftmost limit if it differs
173
- from s *)
174
- then match leftmost_limit_in ~filename: s.pos_fname ctx with
175
- | Some l when l != s -> try_limits (l, e) (* physical equality is enough *)
176
- | Some _ | None -> raise Not_found
177
- else raise Not_found
178
- with Not_found -> join_failure (s, e)
162
+ try
163
+ try_limits (Links. find ctx.over_right_gap s, e)
164
+ with Not_found ->
165
+ join_failure (s, e)
179
166
180
167
module New_manager (Id : sig val name: string end ) : MANAGER = struct
181
168
let ctx = new_manager Id. name
0 commit comments