Skip to content

Commit

Permalink
Add some bits of documentation for Cobol_common.Srcloc
Browse files Browse the repository at this point in the history
  • Loading branch information
nberth committed Sep 29, 2023
1 parent b15c551 commit 72ad995
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lsp/cobol_common/srcloc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ let rec start_pos: type t. t slt -> Lexing.position = function
| Rpl { old; _ } -> start_pos old
| Cat { left; _ } -> start_pos left

(** [shallow_multiline_lexloc_in ~filename loc] retrieves a lexical location in
[filename] from [loc], iff [loc] directly originates from [filename] and was
not subject to any replacement or copy. Returns [None] otherwise. *)
let shallow_multiline_lexloc_in ~filename loc =
let rec aux: type t. t slt -> lexloc option = function
| Raw (s, e, _) when s.pos_fname = filename -> Some (s, e)
Expand All @@ -114,6 +117,9 @@ let shallow_multiline_lexloc_in ~filename loc =
in
aux loc

(** [shallow_single_line_lexloc_in ~filename loc] is similar to
{!shallow_multiline_lexloc_in}, except that any returned lexical location is
guaranteed to span a single line. *)
let shallow_single_line_lexloc_in ~filename = function
| Raw (s, e, _) when s.pos_fname = filename -> Some (s, e)
| Raw _ | Cpy _ | Rpl _ | Cat _ -> None
Expand Down

0 comments on commit 72ad995

Please sign in to comment.