package lambdapi
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=0e2e73e0ea0c674f1263bf85ed3453ed3d6084d38eea29974a03ba9e382d29d7
sha512=2831db57fcd09206687a92fc9ee7d363e87bcec5167949e9c8161d41c63d5887b9f3556bfd63a7a9a0c12e5a5dc61a397baf4f496ebdb2a2fce122142c05e7a1
doc/lambdapi.common/Common/Pos/index.html
Module Common.PosSource
Positions in Lambdapi files.
type pos = {fname : string option;(*File name for the position.
*)start_line : int;(*Line number of the starting point.
*)start_col : int;(*Column number (utf8) of the starting point.
*)start_offset : int;(*Number of chars since the beginning of the document for the starting point
*)end_line : int;(*Line number of the ending point.
*)end_col : int;(*Column number (utf8) of the ending point.
*)end_offset : int;(*Number of chars since the beginning of the document for the ending point
*)
}Type of a position, corresponding to a continuous range of characters in a (utf8-encoded) source.
Total comparison function on pos.
file_start fname is a zero-length position at the start of file fname, used as a fallback for error reporting when no finer position is known.
locate ?fname (p1,p2) converts the pair of Lexing positions p1,p2 and filename fname into a pos.
lexing p converts a pos into a Lexing.position.
to_string ?print_fname pos transforms pos into a readable string. If print_fname is true (the default), the filename contained in pos is printed.
prefix n p is the sub-position of p covering only its first n characters, which are assumed to lie on the first line of p and to be ASCII (so that n is both a column count and a character count).
shift k p returns a position that is k characters after p. /!\ The generated position may not actually exist in the user input. The fields start_offset, end_offset and end_col are inconsistent.
lexing_opt p converts a popt into a Lexing.position.
type 'a loc = {elt : 'a;(*The element that is being localised.
*)pos : popt;(*Position of the element in the source code.
*)
}Type constructor extending a type (e.g. a piece of abstract syntax) with a an optional source code position.
none elt wraps elt in a 'a loc structure without any specific source code position.
map f loc applies function f on the value of loc and keeps the position unchanged.
make_pos lps elt creates a located element from the lexing positions lps and the element elt.
pp ppf pos prints the optional position pos on ppf.
short ppf pos prints the optional position pos on ppf.
pp_lexing ppf lps prints the Lexing.position pair lps on ppf.
val print_file_contents :
parse_file:(string -> (unit -> string) * (unit -> unit)) ->
escape:(string -> string) ->
delimiters:(string * string) ->
complain_if_location_unknown:bool ->
popt Lplib.Base.ppprint_file_contents parse_file escape sep delimiters pos prints the contents of the file at position pos. The parse_file function takes in input pos.fname (that in reality may be a filename or a URI, e.g. when the text comes from LSP) and it returns both a stream of lines provided by a function that raises End_of_file if the file content is terminated, and a function to close the resources when we are done with the stream. sep is the separator replacing each newline (e.g. "<br>\n"). delimiters is a pair of delimiters used to wrap the "unknown location" message returned when the position does not refer to a file. escape is used to escape the file contents.
The value -1 for end_col is to be interpreted as "at the end of line".