Module Js_of_ocaml_compiler.Parse_info

type t = {
  1. src : string option;
    (*

    Path of the source file, when it is known to exist; source maps and source excerpts use it.

    *)
  2. name : string option;
    (*

    Name of the source file, as given by the producer.

    *)
  3. col : int;
    (*

    Column, 0-based (pos_cnum - pos_bol), in code points for JavaScript sources and in bytes for OCaml sources.

    *)
  4. line : int;
    (*

    Line, 1-based (pos_lnum).

    *)
  5. idx : int;
    (*

    Offset from the start of the lexed buffer (pos_cnum), in code points. Only set by the JavaScript lexer; 0 for OCaml positions.

    *)
}

A source position, as a Lexing.position with the file name split into the name the producer knew and the path resolved on disk.

Positions come from two producers with slightly different conventions:

  • the JavaScript lexer (t_of_pos, t_of_lexbuf), which counts in code points and knows the file only by the name it was given, so src and name are the same, possibly Some "" for an anonymous string;
  • the OCaml debug events of a bytecode file (t_of_position), whose positions are those of the OCaml compiler, in bytes, with name the file name recorded by the compiler (relative to where it ran) and src the path where js_of_ocaml found the source, if it did.
val zero : t

No position: no file, line 0, column 0.

val equal : t -> t -> bool
val t_of_lexbuf : Stdlib.Lexing.lexbuf -> t

Position of the start of the current lexeme.

val t_of_pos : Stdlib.Lexing.position -> t

Position from the JavaScript lexer: src and name are both the pos_fname.

val start_position : t -> Stdlib.Lexing.position

Inverse of t_of_pos.

val t_of_position : src:string option -> Stdlib.Lexing.position -> t

Position from an OCaml debug event: name is the pos_fname of the event, src the resolved path of the source file.

val file : t -> string option

The file to show for the position: name, or src when the name is unknown; None when neither is known.

module Debug : sig ... end

Locations in debugging output, where the printed values should match the fields: the IR printer and the location comments of --debug-info.

module Diagnostic : sig ... end

Locations in error and warning messages.