diff options
author | Chimrod <> | 2023-10-22 07:14:20 +0200 |
---|---|---|
committer | Chimrod <> | 2023-10-25 17:56:30 +0200 |
commit | 2a2198e91063684a1b19974acc19c25b55266724 (patch) | |
tree | b43e4b1b62c61fd828a53d6b261c790ffa797ae0 /lib/syntax/report.ml | |
parent | 2cad3abf180c14e0c026033d65f4fb895b5348f7 (diff) |
Refactoring the API
Diffstat (limited to 'lib/syntax/report.ml')
-rw-r--r-- | lib/syntax/report.ml | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/syntax/report.ml b/lib/syntax/report.ml index 9dae0f5..19a9104 100644 --- a/lib/syntax/report.ml +++ b/lib/syntax/report.ml @@ -31,6 +31,22 @@ let pp_pos : Format.formatter -> pos -> unit = type t = { level : level; loc : pos; message : string } [@@deriving show { with_path = false }] +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 + | 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) + | other -> other) + | other -> other + let debug : pos -> string -> t = fun loc message -> { level = Debug; loc; message } @@ -41,3 +57,5 @@ let error : pos -> string -> t = fun loc message -> { level = Error; loc; message } let message level loc message = { level; loc; message } + +type result = t list [@@deriving show] |