package kdl
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file loc.ml
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
type pos = Lexing.position = { pos_fname : string; pos_lnum : int; pos_bol : int; pos_cnum : int; } (** [file, line, char] *) let get_pos_info p = p.pos_fname, p.pos_lnum, p.pos_cnum - p.pos_bol + 1 (* zero_pos is not exported from Lexing *) let zero_pos = { pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0; } let pos_to_string p = let file, line, column = get_pos_info p in Printf.sprintf "%s:%d:%d" file line column (* type t = { loc_start : pos; loc_end : pos; } *) type t = pos * pos let make loc_start loc_end = loc_start, loc_end let to_string (loc_start, loc_end) = let (fname, lstart, cstart) = get_pos_info loc_start in let (_, lend, cend) = get_pos_info loc_end in Printf.sprintf "%s:%d:%d-%d:%d" fname lstart cstart lend cend let empty = zero_pos, zero_pos (* type 'node annot = t * 'node *)