create ~source start stop builds the range [start, stop) (not including the byte at the ending position) from the byte indices start and stop. A range is empty if its start and stop indices are the same.
parametersource
the associated source of the range.
raisesInvalid_argument
if the start is greater than stop or stop is greater than the end-of-source position in source.
contains t idx returns whether the position idx is within the range t.
Support for Lexing
val of_lex :
?source:Source.t->(Stdlib.Lexing.position * Stdlib.Lexing.position)->t
of_lex (start, stop) takes a pair of OCaml lexer positions and creates a range. It is equivalent to make ~source:default (Byte_index.of_lex start) (Byte_index.of_lex stop).
parametersource
The source of the new range. The default source is `File start.pos_fname.
raisesInvalid_argument
if the optional argument source is not given and start.pos_fname and stop.pos_fname differ. The comparison is done by String.equal without any path canonicalization.
val of_lexbuf : ?source:Source.t->Stdlib.Lexing.lexbuf ->t
of_lexbuf lexbuf constructs a range from the current lexeme that lexbuf points to. It is of_lex (Lexing.lexeme_start_p lexbuf, Lexing.lexeme_end_p lexbuf).
parametersource
The source of the new range. The default source is `File (Lexing.lexeme_start_p lexbuf).pos_fname.