aboutsummaryrefslogtreecommitdiff
path: root/gramlib/ploc.ml
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2018-12-05 17:48:53 +0100
committerPierre-Marie Pédrot2018-12-05 17:48:53 +0100
commit8a28cf181a47072fe9a09e98bca761774520d0c3 (patch)
tree42faf529e552d5682be4ab827f8c71d7a4afef96 /gramlib/ploc.ml
parentce4910fe9299bbd54a313980eedaf8d57daade1c (diff)
parent0422f7e67c6c87ab364212a267288afcc7313e90 (diff)
Merge PR #9065: [gramlib] Remove `Ploc.t` in favor of `Loc.t`
Diffstat (limited to 'gramlib/ploc.ml')
-rw-r--r--gramlib/ploc.ml45
1 files changed, 4 insertions, 41 deletions
diff --git a/gramlib/ploc.ml b/gramlib/ploc.ml
index 082686db01..9342fc6c1d 100644
--- a/gramlib/ploc.ml
+++ b/gramlib/ploc.ml
@@ -2,60 +2,23 @@
(* ploc.ml,v *)
(* Copyright (c) INRIA 2007-2017 *)
-type t =
- { fname : string;
- line_nb : int;
- bol_pos : int;
- line_nb_last : int;
- bol_pos_last : int;
- bp : int;
- ep : int;
- comm : string;
- ecomm : string }
-
-let make_loc fname line_nb bol_pos (bp, ep) comm =
- {fname = fname; line_nb = line_nb; bol_pos = bol_pos;
- line_nb_last = line_nb; bol_pos_last = bol_pos; bp = bp; ep = ep;
- comm = comm; ecomm = ""}
+open Loc
let make_unlined (bp, ep) =
- {fname = ""; line_nb = 1; bol_pos = 0; line_nb_last = -1; bol_pos_last = 0;
+ {fname = InFile ""; line_nb = 1; bol_pos = 0; line_nb_last = -1; bol_pos_last = 0;
bp = bp; ep = ep; comm = ""; ecomm = ""}
let dummy =
- {fname = ""; line_nb = 1; bol_pos = 0; line_nb_last = -1; bol_pos_last = 0;
+ {fname = InFile ""; line_nb = 1; bol_pos = 0; line_nb_last = -1; bol_pos_last = 0;
bp = 0; ep = 0; comm = ""; ecomm = ""}
-let file_name loc = loc.fname
-let first_pos loc = loc.bp
-let last_pos loc = loc.ep
-let line_nb loc = loc.line_nb
-let bol_pos loc = loc.bol_pos
-let line_nb_last loc = loc.line_nb_last
-let bol_pos_last loc = loc.bol_pos_last
-let comment loc = loc.comm
-let comment_last loc = loc.ecomm
-
(* *)
-let encl loc1 loc2 =
- if loc1.bp < loc2.bp then
- if loc1.ep < loc2.ep then
- {fname = loc1.fname; line_nb = loc1.line_nb; bol_pos = loc1.bol_pos;
- line_nb_last = loc2.line_nb_last; bol_pos_last = loc2.bol_pos_last;
- bp = loc1.bp; ep = loc2.ep; comm = loc1.comm; ecomm = loc2.comm}
- else loc1
- else if loc2.ep < loc1.ep then
- {fname = loc2.fname; line_nb = loc2.line_nb; bol_pos = loc2.bol_pos;
- line_nb_last = loc1.line_nb_last; bol_pos_last = loc1.bol_pos_last;
- bp = loc2.bp; ep = loc1.ep; comm = loc2.comm; ecomm = loc1.comm}
- else loc2
-let shift sh loc = {loc with bp = sh + loc.bp; ep = sh + loc.ep}
let sub loc sh len = {loc with bp = loc.bp + sh; ep = loc.bp + sh + len}
let after loc sh len = {loc with bp = loc.ep + sh; ep = loc.ep + sh + len}
let with_comment loc comm = {loc with comm = comm}
-exception Exc of t * exn
+exception Exc of Loc.t * exn
let raise loc exc =
match exc with