File: location.mli

package info (click to toggle)
ppxlib 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,284 kB
  • sloc: ml: 17,184; sh: 149; makefile: 36; python: 36
file content (65 lines) | stat: -rw-r--r-- 1,944 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(** Overrides the Location module of OCaml *)

(** There are less functions in this module. However the API should be more stable than
    the Location module of OCaml. *)

open! Import

type t = location =
  { loc_start : Lexing.position
  ; loc_end   : Lexing.position
  ; loc_ghost : bool
  }

(** Return an empty ghost range located in a given file. *)
val in_file : string -> t

(** An arbitrary value of type [t]; describes an empty ghost range. *)
val none : t

(** Raise a located error. The exception is caught by driver and handled
    appropriately *)
val raise_errorf : ?loc:t -> ('a, Caml.Format.formatter, unit, 'b) format4 -> 'a

(** Return the location corresponding to the last matched regular expression *)
val of_lexbuf : Lexing.lexbuf -> t

(** Report an exception on the given formatter *)
val report_exception : Caml.Format.formatter -> exn -> unit

(** Prints [File "...", line ..., characters ...-...:] *)
val print : Caml.Format.formatter -> t -> unit

type nonrec 'a loc = 'a loc =
  { txt : 'a
  ; loc : t
  }

val compare_pos : Lexing.position -> Lexing.position -> int
val min_pos : Lexing.position -> Lexing.position -> Lexing.position
val max_pos : Lexing.position -> Lexing.position -> Lexing.position

val compare : t -> t -> int

module Error : sig
  type location = t
  type t

  val make : loc:location -> string -> sub:(location * string) list -> t
  val createf : loc:location -> ('a, unit, string, t) format4 -> 'a

  val message : t -> string
  val set_message : t -> string -> t

  (** Register an exception handler. Exception registered this way will be properly
      displayed by [report_exception]. *)
  val register_error_of_exn: (exn -> t option) -> unit

  val of_exn : exn -> t option

  (** Convert an error to an extension point. The compiler recognizes this and displays
      the error properly. *)
  val to_extension : t -> extension
end with type location := t

exception Error of Error.t