1 (** Extension of standard library's positions. *)
3 (** {2 Extended lexing positions} *)
5 (** Abstract type for pairs of positions in the lexing stream. *)
9 (** Decoration of a value with a position. *)
16 (** [value dv] returns the raw value that underlies the
17 decorated value [dv]. *)
18 val value: 'a located -> 'a
20 (** [position dv] returns the position that decorates the
21 decorated value [dv]. *)
22 val position: 'a located -> t
24 (** [destruct dv] returns the couple of position and value
25 of a decorated value [dv]. *)
26 val destruct: 'a located -> 'a * t
28 (** [with_pos p v] decorates [v] with a position [p]. *)
29 val with_pos : t -> 'a -> 'a located
31 (** [with_cpos p v] decorates [v] with a lexical position [p]. *)
32 val with_cpos: Lexing.lexbuf -> 'a -> 'a located
34 (** [with_poss start stop v] decorates [v] with a position [(start, stop)]. *)
35 val with_poss : Lexing.position -> Lexing.position -> 'a -> 'a located
37 (** [unknown_pos x] decorates [v] with an unknown position. *)
38 val unknown_pos : 'a -> 'a located
40 (** This value is used when an object does not come from a particular
44 (** [map f v] extends the decoration from [v] to [f v]. *)
45 val map: ('a -> 'b) -> 'a located -> 'b located
47 (** [iter f dv] applies [f] to the value inside [dv]. *)
48 val iter: ('a -> unit) -> 'a located -> unit
50 (** [mapd f v] extends the decoration from [v] to both members of the pair
52 val mapd: ('a -> 'b1 * 'b2) -> 'a located -> 'b1 located * 'b2 located
56 (** [column p] returns the number of characters from the
57 beginning of the line of the Lexing.position [p]. *)
58 val column : Lexing.position -> int
60 (** [column p] returns the line number of to the Lexing.position [p]. *)
61 val line : Lexing.position -> int
63 (** [characters p1 p2] returns the character interval
64 between [p1] and [p2] assuming they are located in the same
66 val characters : Lexing.position -> Lexing.position -> int * int
68 (** [start_of_position p] returns the beginning of a position [p]. *)
69 val start_of_position: t -> Lexing.position
71 (** [end_of_position p] returns the end of a position [p]. *)
72 val end_of_position: t -> Lexing.position
74 (** [filename_of_position p] returns the filename of a position [p]. *)
75 val filename_of_position: t -> string
77 (** {2 Position handling} *)
79 (** [join p1 p2] returns a position that starts where [p1]
80 starts and stops where [p2] stops. *)
81 val join : t -> t -> t
83 (** [lex_join l1 l2] returns a position that starts at [l1] and stops
85 val lex_join : Lexing.position -> Lexing.position -> t
87 (** [string_of_lex_pos p] returns a string representation for
88 the lexing position [p]. *)
89 val string_of_lex_pos : Lexing.position -> string
91 (** [string_of_pos p] returns the standard (Emacs-like) representation
92 of the position [p]. *)
93 val string_of_pos : t -> string
95 (** [pos_or_undef po] is the identity function except if po = None,
96 in that case, it returns [undefined_position]. *)
97 val pos_or_undef : t option -> t
99 (** {2 Interaction with the lexer runtime} *)
101 (** [cpos lexbuf] returns the current position of the lexer. *)
102 val cpos : Lexing.lexbuf -> t
104 (** [string_of_cpos p] returns a string representation of
105 the lexer's current position. *)
106 val string_of_cpos : Lexing.lexbuf -> string