(** Source locations. Every form carries one: error messages, the step debugger and nREPL's find-definition all need them, and retrofitting locations onto a reader is far worse than carrying them from the start. *) type t = { file : string; line : int; (* 1-based *) col : int; (* 1-based *) } let make file line col = { file; line; col } let unknown = { file = ""; line = 0; col = 0 } let to_string t = Printf.sprintf "%s:%d:%d" t.file t.line t.col (** Raised by every stage of the frontend. *) exception Error of t * string let fail loc fmt = Printf.ksprintf (fun msg -> raise (Error (loc, msg))) fmt