source: Deliverables/D2.2/8051/src/utilities/position.mli @ 486

Last change on this file since 486 was 486, checked in by ayache, 9 years ago

Deliverable D2.2

File size: 3.3 KB
Line 
1(** Extension of standard library's positions. *)
2
3(** {2 Extended lexing positions} *)
4
5(** Abstract type for pairs of positions in the lexing stream. *)
6type t
7type position = t
8
9(** Decoration of a value with a position. *)
10type 'a located =
11    {
12      value    : 'a;
13      position : t;
14    }
15
16(** [value dv] returns the raw value that underlies the
17    decorated value [dv]. *)
18val value: 'a located -> 'a
19
20(** [position dv] returns the position that decorates the
21    decorated value [dv]. *)
22val position: 'a located -> t
23
24(** [destruct dv] returns the couple of position and value
25    of a decorated value [dv]. *)
26val destruct: 'a located -> 'a * t
27
28(** [with_pos p v] decorates [v] with a position [p]. *)
29val with_pos : t -> 'a -> 'a located
30
31(** [with_cpos p v] decorates [v] with a lexical position [p]. *)
32val with_cpos: Lexing.lexbuf -> 'a -> 'a located
33
34(** [with_poss start stop v] decorates [v] with a position [(start, stop)]. *)
35val with_poss : Lexing.position -> Lexing.position -> 'a -> 'a located
36
37(** [unknown_pos x] decorates [v] with an unknown position. *)
38val unknown_pos : 'a -> 'a located
39
40(** This value is used when an object does not come from a particular
41    input location. *)
42val dummy: t
43
44(** [map f v] extends the decoration from [v] to [f v]. *)
45val map: ('a -> 'b) -> 'a located -> 'b located
46
47(** [iter f dv] applies [f] to the value inside [dv]. *)
48val iter: ('a -> unit) -> 'a located -> unit
49
50(** [mapd f v] extends the decoration from [v] to both members of the pair
51    [f v]. *)
52val mapd: ('a -> 'b1 * 'b2) -> 'a located -> 'b1 located * 'b2 located
53
54(** {2 Accessors} *)
55
56(** [column p] returns the number of characters from the
57    beginning of the line of the Lexing.position [p]. *)
58val column : Lexing.position -> int
59
60(** [column p] returns the line number of to the Lexing.position [p]. *)
61val line : Lexing.position -> int
62
63(** [characters p1 p2] returns the character interval
64    between [p1] and [p2] assuming they are located in the same
65    line. *)
66val characters : Lexing.position -> Lexing.position -> int * int
67
68(** [start_of_position p] returns the beginning of a position [p]. *)
69val start_of_position: t -> Lexing.position
70
71(** [end_of_position p] returns the end of a position [p]. *)
72val end_of_position: t -> Lexing.position
73
74(** [filename_of_position p] returns the filename of a position [p]. *)
75val filename_of_position: t -> string
76
77(** {2 Position handling} *)
78
79(** [join p1 p2] returns a position that starts where [p1]
80    starts and stops where [p2] stops. *)
81val join : t -> t -> t
82
83(** [lex_join l1 l2] returns a position that starts at [l1] and stops
84    at [l2]. *)
85val lex_join : Lexing.position -> Lexing.position -> t
86
87(** [string_of_lex_pos p] returns a string representation for
88    the lexing position [p]. *)
89val string_of_lex_pos : Lexing.position -> string
90
91(** [string_of_pos p] returns the standard (Emacs-like) representation
92    of the position [p]. *)
93val string_of_pos : t -> string
94
95(** [pos_or_undef po] is the identity function except if po = None,
96    in that case, it returns [undefined_position]. *)
97val pos_or_undef : t option -> t
98
99(** {2 Interaction with the lexer runtime} *)
100
101(** [cpos lexbuf] returns the current position of the lexer. *)
102val cpos : Lexing.lexbuf -> t
103
104(** [string_of_cpos p] returns a string representation of
105    the lexer's current position. *)
106val string_of_cpos : Lexing.lexbuf -> string
Note: See TracBrowser for help on using the repository browser.