aboutsummaryrefslogtreecommitdiff
path: root/lib/syntax/report.ml
diff options
context:
space:
mode:
authorChimrod <>2024-03-27 15:50:56 +0100
committerChimrod <>2024-03-27 15:50:56 +0100
commit246d3c93e6c628e333c047e225edd284ed156ecb (patch)
treeb0e017132fdf587b83269441d1c54b2446cf0c02 /lib/syntax/report.ml
parent14504f36b603984c14b05995a8928cbd40dfa670 (diff)
parentbaa258ac91df8a80209b322e8d42c5deb2ada536 (diff)
Added the check (I should have had order my commit betters)
Diffstat (limited to 'lib/syntax/report.ml')
-rw-r--r--lib/syntax/report.ml30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/syntax/report.ml b/lib/syntax/report.ml
index 19a9104..0c839fe 100644
--- a/lib/syntax/report.ml
+++ b/lib/syntax/report.ml
@@ -28,22 +28,34 @@ let pp_pos : Format.formatter -> pos -> unit =
Format.fprintf f "Lines %d-%d" start_line end_line
else Format.fprintf f "Line %d %d:%d" start_line start_c end_c
+let pp_line : Format.formatter -> pos -> unit =
+ fun f (start_pos, end_pos) ->
+ (* Only care about the first line *)
+ ignore end_pos;
+ let start_line = start_pos.Lexing.pos_lnum in
+ Format.fprintf f "%d" start_line
+
type t = { level : level; loc : pos; message : string }
[@@deriving show { with_path = false }]
+(** Compare two positions *)
+let compare_pos : pos -> pos -> int =
+ fun (pos1_start, pos1_end) (pos2_start, pos2_end) ->
+ (* first compare the position *)
+ match compare pos1_start.pos_cnum pos2_start.pos_cnum with
+ | 0 ->
+ (* Then the ending position *)
+ compare pos1_end.pos_cnum pos2_end.pos_cnum
+ | other -> other
+
let compare : t -> t -> int =
fun t1 t2 ->
(* first compare the position *)
- let pos1_start, pos1_end = t1.loc and pos2_start, pos2_end = t2.loc in
- match compare pos1_start.pos_cnum pos2_start.pos_cnum with
+ match compare_pos t1.loc t2.loc with
| 0 -> (
- (* Then the ending position *)
- match compare pos1_end.pos_cnum pos2_end.pos_cnum with
- | 0 -> (
- (* And the level *)
- match compare (level_to_enum t1.level) (level_to_enum t2.level) with
- | 0 -> String.compare t1.message t2.message
- | other -> other)
+ (* And the level *)
+ match compare (level_to_enum t1.level) (level_to_enum t2.level) with
+ | 0 -> String.compare t1.message t2.message
| other -> other)
| other -> other