Moved Pos and Region to lib_utils so that source locations in lib_utils may use those.

This commit is contained in:
Georges Dupéron 2019-04-15 15:44:08 +02:00
parent 5b577c1fa4
commit e2ef15a9b9
10 changed files with 27 additions and 16 deletions

View File

@ -1,24 +1,24 @@
type file_location = {
filename : string ;
start_line : int ;
start_column : int ;
end_line : int ;
end_column : int ;
}
(* type file_location = { *)
(* filename : string ; *)
(* start_line : int ; *)
(* start_column : int ; *)
(* end_line : int ; *)
(* end_column : int ; *)
(* } *)
type virtual_location = string
type t =
| File of file_location
| File of Region.t (* file_location *)
| Virtual of virtual_location
let make (start_pos:Lexing.position) (end_pos:Lexing.position) : t =
let filename = start_pos.pos_fname in
let start_line = start_pos.pos_lnum in
let end_line = end_pos.pos_lnum in
let start_column = start_pos.pos_cnum - start_pos.pos_bol in
let end_column = end_pos.pos_cnum - end_pos.pos_bol in
File { filename ; start_line ; start_column ; end_line ; end_column }
(* TODO: give correct unicode offsets (the random number is here so
that searching for wrong souce locations appearing in messages
will quickly lead here *)
File (Region.make
~start:(Pos.make ~byte:start_pos ~point_num:(-1897000) ~point_bol:(-1897000))
~stop:(Pos.make ~byte:end_pos ~point_num:(-1897000) ~point_bol:(-1897000)))
let virtual_location s = Virtual s
let dummy = virtual_location "dummy"

View File

@ -21,3 +21,5 @@ module Map = X_map
module Dictionary = Dictionary
module Environment = Environment
module Tree = Tree
module Region = Region
module Pos = Pos

View File

@ -21,6 +21,9 @@
aliased to [token].
*)
module Region = Tezos_utils.Region
module Pos = Tezos_utils.Pos
type lexeme = string
(* TOKENS *)

View File

@ -9,6 +9,8 @@ type lexeme = string
let sprintf = Printf.sprintf
module Region = Tezos_utils.Region
module Pos = Tezos_utils.Pos
module SMap = Utils.String.Map
module SSet = Utils.String.Set

View File

@ -1,3 +1,5 @@
module Region = Tezos_utils.Region
type lexeme = string
type t =

View File

@ -1,6 +1,8 @@
(* This module defines the sorts of markup recognised by the LIGO
lexer *)
module Region = Tezos_utils.Region
(* A lexeme is piece of concrete syntax belonging to a token. In
algebraic terms, a token is also a piece of abstract lexical
syntax. Lexical units emcompass both markup and lexemes. *)