diff --git a/src/lib_utils/location.ml b/src/lib_utils/location.ml index 825cdd0bb..8c85c9ee8 100644 --- a/src/lib_utils/location.ml +++ b/src/lib_utils/location.ml @@ -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" diff --git a/src/ligo/ligo_parser/Pos.ml b/src/lib_utils/pos.ml similarity index 100% rename from src/ligo/ligo_parser/Pos.ml rename to src/lib_utils/pos.ml diff --git a/src/ligo/ligo_parser/Pos.mli b/src/lib_utils/pos.mli similarity index 100% rename from src/ligo/ligo_parser/Pos.mli rename to src/lib_utils/pos.mli diff --git a/src/ligo/ligo_parser/Region.ml b/src/lib_utils/region.ml similarity index 100% rename from src/ligo/ligo_parser/Region.ml rename to src/lib_utils/region.ml diff --git a/src/ligo/ligo_parser/Region.mli b/src/lib_utils/region.mli similarity index 100% rename from src/ligo/ligo_parser/Region.mli rename to src/lib_utils/region.mli diff --git a/src/lib_utils/tezos_utils.ml b/src/lib_utils/tezos_utils.ml index aecd41270..efa7804e7 100644 --- a/src/lib_utils/tezos_utils.ml +++ b/src/lib_utils/tezos_utils.ml @@ -21,3 +21,5 @@ module Map = X_map module Dictionary = Dictionary module Environment = Environment module Tree = Tree +module Region = Region +module Pos = Pos diff --git a/src/ligo/ligo_parser/LexToken.mli b/src/ligo/ligo_parser/LexToken.mli index ebf887861..f2c8c8ba7 100644 --- a/src/ligo/ligo_parser/LexToken.mli +++ b/src/ligo/ligo_parser/LexToken.mli @@ -21,6 +21,9 @@ aliased to [token]. *) +module Region = Tezos_utils.Region +module Pos = Tezos_utils.Pos + type lexeme = string (* TOKENS *) diff --git a/src/ligo/ligo_parser/LexToken.mll b/src/ligo/ligo_parser/LexToken.mll index 1bc88a695..a2ba351e7 100644 --- a/src/ligo/ligo_parser/LexToken.mll +++ b/src/ligo/ligo_parser/LexToken.mll @@ -9,8 +9,10 @@ type lexeme = string let sprintf = Printf.sprintf -module SMap = Utils.String.Map -module SSet = Utils.String.Set +module Region = Tezos_utils.Region +module Pos = Tezos_utils.Pos +module SMap = Utils.String.Map +module SSet = Utils.String.Set (* Hack to roll back one lexeme in the current semantic action *) (* diff --git a/src/ligo/ligo_parser/Markup.ml b/src/ligo/ligo_parser/Markup.ml index 5f379b47b..a25e78754 100644 --- a/src/ligo/ligo_parser/Markup.ml +++ b/src/ligo/ligo_parser/Markup.ml @@ -1,3 +1,5 @@ +module Region = Tezos_utils.Region + type lexeme = string type t = diff --git a/src/ligo/ligo_parser/Markup.mli b/src/ligo/ligo_parser/Markup.mli index e9c525893..93ffe2c2c 100644 --- a/src/ligo/ligo_parser/Markup.mli +++ b/src/ligo/ligo_parser/Markup.mli @@ -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. *)