dune/src/loc.ml

18 lines
323 B
OCaml
Raw Normal View History

2016-11-03 16:44:09 +00:00
type t =
{ start : Lexing.position
; stop : Lexing.position
}
2016-11-13 11:13:47 +00:00
let of_lexbuf lb =
2016-11-13 11:27:31 +00:00
{ start = Lexing.lexeme_start_p lb
; stop = Lexing.lexeme_end_p lb
2016-11-13 11:13:47 +00:00
}
exception Error of t * string
let fail t fmt =
2016-11-13 11:27:31 +00:00
Printf.ksprintf (fun msg -> raise (Error (t, msg))) fmt
2016-11-13 11:13:47 +00:00
let fail_lex lb fmt =
fail (of_lexbuf lb) fmt