aboutsummaryrefslogtreecommitdiff
path: root/bin/qsp_parser.ml
diff options
context:
space:
mode:
Diffstat (limited to 'bin/qsp_parser.ml')
-rw-r--r--bin/qsp_parser.ml19
1 files changed, 13 insertions, 6 deletions
diff --git a/bin/qsp_parser.ml b/bin/qsp_parser.ml
index f928d24..60db5ec 100644
--- a/bin/qsp_parser.ml
+++ b/bin/qsp_parser.ml
@@ -98,6 +98,17 @@ let checkers :
end) in
(module Check))
+let pp_report :
+ (Format.formatter -> 'a -> unit) ->
+ Qparser.Lexbuf.t ->
+ Format.formatter ->
+ 'a ->
+ unit =
+ fun pp lexbuf fmt e ->
+ let start_position, _ = Qparser.Lexbuf.positions lexbuf in
+ Format.fprintf fmt "Location@ %s@;@[%a]@." start_position.Lexing.pos_fname pp
+ e
+
let display_result :
ctx:ctx ref ->
Qparser.Lexbuf.t ->
@@ -108,9 +119,7 @@ let display_result :
match result with
| Error e ->
(* Syntax error, we haven’t been able to run the test *)
- let start_position, _ = Qparser.Lexbuf.positions lexbuf in
- Format.fprintf Format.std_formatter "Location@ %s@;@[%a]@."
- start_position.Lexing.pos_fname Report.pp e;
+ pp_report Report.pp lexbuf Format.std_formatter e;
ctx := { !ctx with error_nb = succ !ctx.error_nb; fatal_error = true }
| Ok report -> (
let report =
@@ -121,9 +130,7 @@ let display_result :
| [] -> ()
| _ ->
(* Display the result *)
- let start_position, _ = Qparser.Lexbuf.positions lexbuf in
- Format.fprintf Format.std_formatter "Location@ %s@;@[%a@]@."
- start_position.Lexing.pos_fname Report.pp_result report;
+ pp_report Report.pp_result lexbuf Format.std_formatter report;
List.iter report ~f:(fun report ->
match report.Report.level with