1 (* Pasted from Pottier's PP compiler *)
5 let print_graph instruction successors () (graph, entry) =
7 (* Print instructions in depth-first order; this is a
8 rather natural and readable order. *)
10 let rec visit (visited, lines) l =
11 if Label.Set.mem l visited then
14 let visited = Label.Set.add l visited in
15 let i = Label.Map.find l graph in
16 let lines = instruction l i :: lines in
17 List.fold_left visit (visited, lines) (successors i)
19 let _, lines = visit (Label.Set.empty, []) entry in
20 String.concat "\n" (catenate (transposerev lines))