Repository navigation
Expand file tree
/
Copy pathlocation.ml
More file actions
34 lines (26 loc) · 1.58 KB
/
Copy pathlocation.ml
File metadata and controls
34 lines (26 loc) · 1.58 KB
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
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
open Lexing
type t = {loc_start: position; loc_end: position; loc_ghost: bool}
let in_file name =
let loc = {pos_fname = name; pos_lnum = 1; pos_bol = 0; pos_cnum = -1} in
{loc_start = loc; loc_end = loc; loc_ghost = true}
let none = in_file "_none_"
(* return file, line, char from the given position *)
let get_pos_info pos = (pos.pos_fname, pos.pos_lnum, pos.pos_cnum - pos.pos_bol)
type 'a loc = {txt: 'a; loc: t}
let mkloc txt loc = {txt; loc}
let mknoloc txt = mkloc txt none
let map_loc f {txt; loc} = {txt = f txt; loc}