Add Usexp.Loc.in_file

Moved from Loc
This commit is contained in:
Rudi Grinberg 2018-04-24 01:46:33 +07:00
parent 03e439e449
commit 77af5b3a88
3 changed files with 18 additions and 12 deletions

View File

@ -51,17 +51,7 @@ let fail_opt t fmt =
| None -> die fmt
| Some t -> fail t fmt
let in_file fn =
let pos : Lexing.position =
{ pos_fname = fn
; pos_lnum = 1
; pos_cnum = 0
; pos_bol = 0
}
in
{ start = pos
; stop = pos
}
let in_file = Usexp.Loc.in_file
let of_pos (fname, lnum, cnum, enum) =
let pos : Lexing.position =

View File

@ -240,7 +240,21 @@ let prepare_formatter ppf =
| _ -> n))
}
module Loc = Sexp_ast.Loc
module Loc = struct
include Sexp_ast.Loc
let in_file fn =
let pos : Lexing.position =
{ pos_fname = fn
; pos_lnum = 1
; pos_cnum = 0
; pos_bol = 0
}
in
{ start = pos
; stop = pos
}
end
module Ast = struct
type t = Sexp_ast.t =

View File

@ -28,6 +28,8 @@ module Loc : sig
{ start : Lexing.position
; stop : Lexing.position
}
val in_file : string -> t
end
(** The S-expression type *)