Skip to content

Commit 82bc82a

Browse files
committed
Fix the use of try with
1 parent c8224bf commit 82bc82a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/syntax/sedlex.ml

+17-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ let compile_traces states (start, final) =
147147
| None -> actions
148148
| Some action -> action :: actions
149149
in
150+
let exception Irrelevant in
151+
let is_relevant node =
152+
let relevant_nodes = Hashtbl.create 31 in
153+
let rec aux node =
154+
try ignore (Hashtbl.find relevant_nodes node.id)
155+
with Not_found ->
156+
Hashtbl.add relevant_nodes node.id ();
157+
List.iter aux node.eps;
158+
List.iter (fun (_, n) -> aux n) node.trans
159+
in
160+
aux start;
161+
try ignore (Hashtbl.find relevant_nodes node)
162+
with Not_found -> raise Irrelevant
163+
in
150164
let first_node = final.id in
151165
let trans_cases =
152166
let cases = Hashtbl.create 31 in
@@ -158,8 +172,10 @@ let compile_traces states (start, final) =
158172
(fun from_node ->
159173
try
160174
let node_j = from_node.id in
175+
is_relevant node_j;
161176
let rec dfs cset actions to_node =
162177
let node_i = to_node.id in
178+
is_relevant node_i;
163179
if not (Hashtbl.mem cases (i, node_i, j, cset)) then begin
164180
let actions = append_action actions to_node.action in
165181
if to_node.trans <> [] || to_node == final then
@@ -179,7 +195,7 @@ let compile_traces states (start, final) =
179195
(fun (cset, to_node) ->
180196
if List.mem to_node to_state then dfs cset [] to_node)
181197
from_node.trans
182-
with Not_found -> ())
198+
with Irrelevant -> ())
183199
from_state)
184200
states)
185201
states;

0 commit comments

Comments
 (0)