Debian Codegraph @

lib/quickfix.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (* Quickfix management *)
12
13 type t = Loc.t * Pp.t
14 let make ~loc txt = loc, txt
15 let pp (_,x) = x
16 let pp_wloc (loc,x) =
17 let open Pp in
18 h (str "Replace " ++ Loc.pr loc ++ str " with " ++ x)
19 let loc (l,_) = l
20
21 let handle_stack = ref []
22
23 let register h = handle_stack := h::!handle_stack
24
25 let rec accumulate_qf acc stk e =
26 match stk with
27 | [] -> acc
28 | h::stk -> accumulate_qf (h e :: acc) stk e
29
30 let from_exception e =
31 try
32 Ok (CList.flatten (accumulate_qf [] !handle_stack e))
33 with exn ->
34 let ei = Exninfo.capture exn in
35 Error ei
36
37 let print e =
38 let open Pp in
39 match e with
40 | [] -> mt ()
41 | qf ->
42 let open Pp in
43 let qf = prlist_with_sep cut pp_wloc qf in
44 v 0 (prlist_with_sep cut (fun x -> x) [str "Quickfix:"; qf])