]> matita.cs.unibo.it Git - pkg-cerco/frama-c-cost-plugin.git/blob - wrapper/position.mli
Imported Upstream version 0.1
[pkg-cerco/frama-c-cost-plugin.git] / wrapper / position.mli
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. *)
6 type t
7 type position = t
8
9 (** Decoration of a value with a position. *)
10 type '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]. *)
18 val value: 'a located -> 'a
19
20 (** [position dv] returns the position that decorates the
21     decorated value [dv]. *)
22 val position: 'a located -> t
23
24 (** [destruct dv] returns the couple of position and value
25     of a decorated value [dv]. *)
26 val destruct: 'a located -> 'a * t
27
28 (** [with_pos p v] decorates [v] with a position [p]. *)
29 val with_pos : t -> 'a -> 'a located
30
31 (** [with_cpos p v] decorates [v] with a lexical position [p]. *)
32 val with_cpos: Lexing.lexbuf -> 'a -> 'a located
33
34 (** [with_poss start stop v] decorates [v] with a position [(start, stop)]. *)
35 val with_poss : Lexing.position -> Lexing.position -> 'a -> 'a located
36
37 (** [unknown_pos x] decorates [v] with an unknown position. *)
38 val unknown_pos : 'a -> 'a located
39
40 (** This value is used when an object does not come from a particular
41     input location. *)
42 val dummy: t
43
44 (** [map f v] extends the decoration from [v] to [f v]. *)
45 val map: ('a -> 'b) -> 'a located -> 'b located
46
47 (** [iter f dv] applies [f] to the value inside [dv]. *)
48 val 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]. *)
52 val 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]. *)
58 val column : Lexing.position -> int
59
60 (** [column p] returns the line number of to the Lexing.position [p]. *)
61 val 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. *)
66 val characters : Lexing.position -> Lexing.position -> int * int
67
68 (** [start_of_position p] returns the beginning of a position [p]. *)
69 val start_of_position: t -> Lexing.position
70
71 (** [end_of_position p] returns the end of a position [p]. *)
72 val end_of_position: t -> Lexing.position
73
74 (** [filename_of_position p] returns the filename of a position [p]. *)
75 val 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. *)
81 val join : t -> t -> t
82
83 (** [lex_join l1 l2] returns a position that starts at [l1] and stops
84     at [l2]. *)
85 val lex_join : Lexing.position -> Lexing.position -> t
86
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
90
91 (** [string_of_pos p] returns the standard (Emacs-like) representation
92     of the position [p]. *)
93 val 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]. *)
97 val 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. *)
102 val cpos : Lexing.lexbuf -> t
103
104 (** [string_of_cpos p] returns a string representation of
105     the lexer's current position. *)
106 val string_of_cpos : Lexing.lexbuf -> string