this repo has no description
at main 29 lines 1.0 kB view raw
1type t = { location : Loc.span; message : string } 2 3let to_string e = 4 let { location; message } = e in 5 let location_string = 6 if location.start.line = location.end_.line then 7 Printf.sprintf "line %i, characters %i-%i" location.start.line 8 location.start.column location.end_.column 9 else 10 Printf.sprintf "line %i, character %i to line %i, character %i" 11 location.start.line location.start.column location.end_.line 12 location.end_.column 13 in 14 Printf.sprintf "File \"%s\", %s:\n%s" location.file location_string message 15 16let pp fmt v = Format.fprintf fmt "%s" (to_string v) 17 18let kasprintf k fmt = 19 Format.(kfprintf (fun _ -> k (flush_str_formatter ())) str_formatter fmt) 20 21let kmake k ?suggestion = 22 kasprintf (fun message -> 23 match suggestion with 24 | None -> k message 25 | Some suggestion -> k (message ^ "\nSuggestion: " ^ suggestion)) 26 27let make ?suggestion format = 28 let k message location = { location; message } in 29 kmake k ?suggestion format