diff options
author | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-04-09 03:39:07 +0200 |
---|---|---|
committer | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-04-25 00:34:31 +0200 |
commit | 7058b9b400e252a30c1e624cbe0de26b70356d64 (patch) | |
tree | 5115f5af4231761a484e0413f4179423e183ca9a | |
parent | ee2197096fe75a63b4d92cb3a1bb05122c5c625b (diff) |
[location] Cleanup.
We remove some unnecessary functions introduced before in the patch
series + unused functions.
-rw-r--r-- | lib/cAst.ml | 4 | ||||
-rw-r--r-- | lib/loc.ml | 21 | ||||
-rw-r--r-- | lib/loc.mli | 22 |
3 files changed, 17 insertions, 30 deletions
diff --git a/lib/cAst.ml b/lib/cAst.ml index 5916c9ec1..f0a405776 100644 --- a/lib/cAst.ml +++ b/lib/cAst.ml @@ -16,8 +16,8 @@ let make ?loc v = { v; loc } let map f n = { n with v = f n.v } let map_with_loc f n = { n with v = f ?loc:n.loc n.v } -let map_from_loc f n = - let loc, v = Loc.to_pair n in +let map_from_loc f l = + let loc, v = l in { v = f ?loc v ; loc } let with_val f n = f n.v diff --git a/lib/loc.ml b/lib/loc.ml index 9107dce47..ee759bdfc 100644 --- a/lib/loc.ml +++ b/lib/loc.ml @@ -53,31 +53,17 @@ let merge_opt l1 l2 = match l1, l2 with let unloc loc = (loc.bp, loc.ep) -let join_loc = merge - (** Located type *) type 'a located = t option * 'a -let to_pair x = x let tag ?loc x = loc, x -let obj (_,x) = x - -let with_loc f (loc, x) = f ?loc x -let with_unloc f (_,x) = f x - let map f (l,x) = (l, f x) -let map_with_loc f (loc, x) = (loc, f ?loc x) - -let located_fold_left f x (_,a) = f x a -let located_iter2 f (_,a) (_,b) = f a b -let down_located f (_,a) = f a (** Exceptions *) let location : t Exninfo.t = Exninfo.make () let add_loc e loc = Exninfo.add e location loc - let get_loc e = Exninfo.get e location let raise ?loc e = @@ -86,3 +72,10 @@ let raise ?loc e = | Some loc -> let info = Exninfo.add Exninfo.null location loc in Exninfo.iraise (e, info) + +(** Deprecated *) +let located_fold_left f x (_,a) = f x a +let located_iter2 f (_,a) (_,b) = f a b +let down_located f (_,a) = f a + + diff --git a/lib/loc.mli b/lib/loc.mli index ec79ced5d..edcf701bf 100644 --- a/lib/loc.mli +++ b/lib/loc.mli @@ -34,6 +34,7 @@ val make_loc : int * int -> t val merge : t -> t -> t val merge_opt : t option -> t option -> t option +(** Merge locations, usually generating the largest possible span *) (** {5 Located exceptions} *) @@ -49,27 +50,20 @@ val raise : ?loc:t -> exn -> 'a (** {5 Objects with location information } *) type 'a located = t option * 'a -(** Embed a location in a type *) - -(* We would like in the future: - * type 'a located = private { tag: t option; obj: 'a; } - *) -(** Warning, this API is experimental *) -val to_pair : 'a located -> t option * 'a val tag : ?loc:t -> 'a -> 'a located -val obj : 'a located -> 'a - -val with_loc : (?loc:t -> 'a -> 'b) -> 'a located -> 'b -val with_unloc : ('a -> 'b) -> 'a located -> 'b +(** Embed a location in a type *) val map : ('a -> 'b) -> 'a located -> 'b located -val map_with_loc : (?loc:t -> 'a -> 'b) -> 'a located -> 'b located +(** Modify an object carrying a location *) +(** Deprecated functions *) val located_fold_left : ('a -> 'b -> 'a) -> 'a -> 'b located -> 'a + [@@ocaml.deprecated "use pattern matching"] + val down_located : ('a -> 'b) -> 'a located -> 'b + [@@ocaml.deprecated "use pattern matching"] -(* Currently not used *) val located_iter2 : ('a -> 'b -> unit) -> 'a located -> 'b located -> unit + [@@ocaml.deprecated "use pattern matching"] -(** Projects out a located object *) |