package camlon

  1. Overview
  2. Docs

Module Camlon.LocationSource

Source code locations (ranges of positions), used in parsetree.

Sourcetype t = {
  1. loc_start : Lexing.position;
  2. loc_end : Lexing.position;
  3. loc_ghost : bool;
}

Note on the use of Lexing.position in this module. If pos_fname = "", then use !input_name instead. If pos_lnum = -1, then pos_bol = 0. Use pos_cnum and re-parse the file to get the line and character numbers. Else all fields are correct.

Sourceval none : t

An arbitrary value of type t; describes an empty ghost range.

Sourceval in_file : string -> t

Return an empty ghost range located in a given file.

Sourceval init : Lexing.lexbuf -> string -> unit

Set the file name and line number of the lexbuf to be the start of the named file.

Sourceval curr : Lexing.lexbuf -> t

Get the location of the current token from the lexbuf.

Sourceval symbol_rloc : unit -> t
Sourceval symbol_gloc : unit -> t
Sourceval rhs_loc : int -> t

rhs_loc n returns the location of the symbol at position n, starting at 1, in the current parser rule.

Sourceval input_name : string ref
Sourceval input_lexbuf : Lexing.lexbuf option ref
Sourceval get_pos_info : Lexing.position -> string * int * int
Sourceval print_loc : Format.formatter -> t -> unit
Sourceval print_error : Format.formatter -> t -> unit
Sourceval print_error_cur_file : Format.formatter -> unit -> unit
Sourceval print_warning : t -> Format.formatter -> Warnings.t -> unit
Sourceval formatter_for_warnings : Format.formatter ref
Sourceval prerr_warning : t -> Warnings.t -> unit
Sourceval echo_eof : unit -> unit
Sourceval reset : unit -> unit
Sourceval warning_printer : (t -> Format.formatter -> Warnings.t -> unit) ref

Hook for intercepting warnings.

Sourceval default_warning_printer : t -> Format.formatter -> Warnings.t -> unit

Original warning printer for use in hooks.

Sourceval highlight_locations : Format.formatter -> t list -> bool
Sourcetype 'a loc = {
  1. txt : 'a;
  2. loc : t;
}
Sourceval mknoloc : 'a -> 'a loc
Sourceval mkloc : 'a -> t -> 'a loc
Sourceval print : Format.formatter -> t -> unit
Sourceval print_compact : Format.formatter -> t -> unit
Sourceval print_filename : Format.formatter -> string -> unit
Sourceval absolute_path : string -> string
Sourceval show_filename : string -> string

In -absname mode, return the absolute path for this filename. Otherwise, returns the filename unchanged.

Sourceval absname : bool ref
Sourcetype error = {
  1. loc : t;
  2. msg : string;
  3. sub : error list;
  4. if_highlight : string;
}
Sourceexception Error of error
Sourceval print_error_prefix : Format.formatter -> unit -> unit
Sourceval error : ?loc:t -> ?sub:error list -> ?if_highlight:string -> string -> error
Sourceval errorf : ?loc:t -> ?sub:error list -> ?if_highlight:string -> ('a, Format.formatter, unit, error) format4 -> 'a
Sourceval raise_errorf : ?loc:t -> ?sub:error list -> ?if_highlight:string -> ('a, Format.formatter, unit, 'b) format4 -> 'a
Sourceval error_of_printer : t -> (Format.formatter -> 'a -> unit) -> 'a -> error
Sourceval error_of_printer_file : (Format.formatter -> 'a -> unit) -> 'a -> error
Sourceval error_of_exn : exn -> error option
Sourceval register_error_of_exn : (exn -> error option) -> unit
Sourceval report_error : Format.formatter -> error -> unit
Sourceval error_reporter : (Format.formatter -> error -> unit) ref

Hook for intercepting error reports.

Sourceval default_error_reporter : Format.formatter -> error -> unit

Original error reporter for use in hooks.

Sourceval report_exception : Format.formatter -> exn -> unit
OCaml

Innovation. Community. Security.