package dolmen
Standard implementation of file locations.
Interface definition
type loc = private {
file : string;
start_line : int;
start_column : int;
start_line_offset : int;
stop_line : int;
stop_column : int;
stop_line_offset : int;
max_line_length : int;
}
A full location, including file, start position and end position. Dummy positions (i.e. with start_line = stop_line
and start_column = stop_column
) are allowed to represent unknown locations.
Interface definition
module type S = Dolmen_intf.Location.S
An anstract module type for providing locations. Used as argumentby much of the functors provided in Dolmen.
This module implements the signature S
.
include S with type t := t and type file := file
exception Uncaught of t * exn * Stdlib.Printexc.raw_backtrace
The exception to be raised whenever an unexpected exception is raised during parsing.
exception Lexing_error of t * string
The exception to be raised when the lexer cannot parse the input.
exception Syntax_error of t
* [ `Regular of Dolmen_intf.Msg.t
| `Advanced of Dolmen_intf.Msg.t * Dolmen_intf.Msg.t * Dolmen_intf.Msg.t ]
Syntax_error (loc, msg)
denotes a syntax error at the given location. In the `Advanced (prod, parsed, expected)
case,
- prod is a delayed message to print in order to identify which production/syntax construction the parser was trying to reduce,
- parsed is a description of the token which raised the error,
- expected is a messages describing what would have been corect tokens/inputs at that point.
val of_lexbuf : Stdlib.Lexing.lexbuf -> t
Make a position using a lexbuf directly.
val mk_pos : Stdlib.Lexing.position -> Stdlib.Lexing.position -> t
Make a position from two lewing positions.
val newline : file -> Stdlib.Lexing.lexbuf -> unit
Offer a way for the file meta-data to store the current location of the lexbuf as the start of a new line.
val update_size : file -> Stdlib.Lexing.lexbuf -> unit
Update the file meta-data to store the maximum offset currently seen for this file.
val hash : t -> int
Hashing function.
val no_loc : t
A dummy location pointing at the first byte of a file.
val dummy : loc
A dummy location pointing at the first byte of a file.
val is_dummy : loc -> bool
Is the location an actual location, or a dummy one ?
Compact location handling
val mk_file : string -> file
Create a new set of meta-data for the given filename.
val new_line : file -> int -> unit
Register a new line whose first char is at the given offset.
Compact<->full translations
val lexing_positions : loc -> Stdlib.Lexing.position * Stdlib.Lexing.position
Reutnr the pari of lexing positions corresponding to a location.
Printing locations
val pp : Stdlib.Buffer.t -> loc -> unit
val fmt : Stdlib.Format.formatter -> loc -> unit
val fmt_pos : Stdlib.Format.formatter -> loc -> unit
val fmt_hint : Stdlib.Format.formatter -> loc -> unit
Printing functions
val file_name : file -> string
Filename for a file