module Positions: sig
.. end
Extension of standard library's positions.
Extended lexing positions
type
position
Abstract for position in the lexing stream. It does
represents non empty interval in the stream.
val undefined_position : position
This value is used when an object does not from
a particular input location.
Accessors
val column : Lexing.position -> int
column p
returns the number of characters from the
beginning of the line of the Lexing.position p
.
val line : Lexing.position -> int
column p
returns the line number of to the Lexing.position p
.
val characters : Lexing.position -> Lexing.position -> int * int
characters p1 p2
returns the character interval
between p1
and p2
assuming they are located in the same
line.
val start_of_position : position -> Lexing.position
val end_of_position : position -> Lexing.position
Position handling
val join : position -> position -> position
join p1 p2
returns a position that starts where p1
starts and stops where p2
stops.
val lex_join : Lexing.position -> Lexing.position -> position
val ljoinf : ('a -> position) -> 'a list -> position
val joinf : ('a -> position) -> 'a -> 'a -> position
val string_of_characters : int * int -> string
string_of_characters (c1,c2)
returns the standard (Emacs-like)
representation of the character interval (c1,c2).
val string_of_lex_pos : Lexing.position -> string
string_of_lex_pos p
returns a string representation for
the lexing position p
.
val string_of_pos : position -> string
string_of_pos p
returns the standard (Emacs-like) representation
of the position p
.
val pos_or_undef : position option -> position
pos_or_undef po
is the identity function except if po = None,
in that case, it returns undefined_position
.
Interaction with the lexer runtime
val cpos : Lexing.lexbuf -> position
cpos lexbuf
returns the current position of the lexer.
val string_of_cpos : Lexing.lexbuf -> string
string_of_cpos p
returns a string representation of
the lexer's current position.