diff options
author | Chimrod <> | 2025-01-05 19:01:14 +0100 |
---|---|---|
committer | Chimrod <> | 2025-01-05 19:01:14 +0100 |
commit | 23bcff2eaf5938acc04507636698c034c4767a1e (patch) | |
tree | 3599e0f606670ad0e644d9002504db10d71f505a /bin/qsp_parser.ml | |
parent | 9e6eb0c04cf5667bb0acc1b56cc21fcaf162ecc9 (diff) |
Factorized some code
Diffstat (limited to 'bin/qsp_parser.ml')
-rw-r--r-- | bin/qsp_parser.ml | 19 |
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 |