Skip to content

Commit

Permalink
Add new convenient accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbin committed Jan 17, 2024
1 parent 0060f17 commit a56c46f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/loc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,17 @@ let line t =
let t = Stdune.Loc.to_lexbuf_loc t in
t.start.pos_lnum
;;

let start_pos_cnum = Stdune.Loc.start_pos_cnum
let stop_pos_cnum = Stdune.Loc.stop_pos_cnum
let start_pos t = (Stdune.Loc.to_lexbuf_loc t).start
let stop_pos t = (Stdune.Loc.to_lexbuf_loc t).stop

module Lexbuf_loc = struct
type t = Stdune.Lexbuf.Loc.t =
{ start : Source_code_position.t
; stop : Source_code_position.t
}
end

let to_lexbuf_loc = Stdune.Loc.to_lexbuf_loc
13 changes: 13 additions & 0 deletions src/loc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,16 @@ val with_dummy_pos : t -> t

val path : t -> Fpath.t
val line : t -> int
val start_pos_cnum : t -> int
val stop_pos_cnum : t -> int

module Lexbuf_loc : sig
type t = Stdune.Lexbuf.Loc.t =
{ start : Source_code_position.t
; stop : Source_code_position.t
}
end

val to_lexbuf_loc : t -> Lexbuf_loc.t
val start_pos : t -> Source_code_position.t
val stop_pos : t -> Source_code_position.t

0 comments on commit a56c46f

Please sign in to comment.