Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Fmlib_parse.Position
Represent a position in a text file.
A position in a text file is represented by a line number and a column number, both starting with zero. So the first line is line number zero and the first column is column number zero.
Sometimes the absolute byte offset since the beginning of the file is important. Therefore the absolute byte offset for the last newline is included as well.
Furthermore it is important to distinguish between the byte position and the character position within a line. Therefore a correction offset is needed which is added to the byte column to get the character column.
An object of type Position.t has the following content:
Byte offset from the beginning of the stream to the beginning of the previous line.
Number of the current line (zero based)
Byte position within the current line (zero based)
Correction between the byte position and the visible character position on the current line.
By default all bytes between space and ascii 126 and between decimal 128 and decimal 255 are treated as one character. The tab character is treated as 4 characters and the newline character increments the line number and resets the column number. All other bytes between decimal 0 and before the space are treated as zero characters.
This default handling is done by the function next. For more special treatments (e.g. unicode characters) there is the function correct to adapt the character position with respect to the by position and the functions advance and newline for find granular control of the position.
byte_column pos The byte column number corresponding to the position p.
Note: If the line up to the position has only printable ascii or latin-1 characters, then the byte_column p is the same as column p. If the line has some multibyte unicode characters, then both columns might be different. Notprintable ascii characters i.e. characters before the space character increase the byte column, but not the column.
next next_char pos: Advance the position by using the next character. If the next character is a newline, then the line number is increment and the column number is reset to 0.
Merge the ranges range_1 and range_2 the result range has the maximum span of both. I.e. the merges selects as start position the lowest position of both and as end position the highest position of both. I.e. the merges selects as start position the lowest position of both and as end position the highest position of both.