Coccinelle release 1.0.0-rc13
[bpt/coccinelle.git] / bundles / sexplib / sexplib-7.0.5 / lib / pre_sexp.mli
1 type t = Type.t = Atom of string | List of t list
2 exception Of_sexp_error of exn * t
3 type bigstring =
4 (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
5 val default_indent : int ref
6 val is_special_char : char -> bool
7 val must_escape : string -> bool
8 val maybe_esc_str : string -> string
9 val pp_maybe_esc_str : Format.formatter -> string -> unit
10 val pp_hum_indent : int -> Format.formatter -> t -> unit
11 val pp_hum_rest : int -> Format.formatter -> t list -> unit
12 val pp_mach_internal : bool -> Format.formatter -> t -> bool
13 val pp_mach_rest : bool -> Format.formatter -> t list -> unit
14 val pp_hum : Format.formatter -> t -> unit
15 val pp_mach : Format.formatter -> t -> unit
16 val pp : Format.formatter -> t -> unit
17 val size_loop : int * int -> t -> int * int
18 val size : t -> int * int
19 val to_buffer_hum : buf:Buffer.t -> ?indent:int -> t -> unit
20 val to_buffer_mach : buf:Buffer.t -> t -> unit
21 val to_buffer : buf:Buffer.t -> t -> unit
22 val buffer : unit -> Buffer.t
23 val with_new_buffer : out_channel -> (Buffer.t -> 'a) -> unit
24 val output_hum : out_channel -> t -> unit
25 val output_hum_indent : int -> out_channel -> t -> unit
26 val output_mach : out_channel -> t -> unit
27 val output : out_channel -> t -> unit
28 val save_of_output :
29 ?perm:Unix.file_perm -> (out_channel -> 'a -> 'b) -> string -> 'a -> unit
30 val output_sexp_nl : (out_channel -> 'a -> 'b) -> out_channel -> 'a -> unit
31 val save_hum : ?perm:Unix.file_perm -> string -> t -> unit
32 val save_mach : ?perm:Unix.file_perm -> string -> t -> unit
33 val save : ?perm:Unix.file_perm -> string -> t -> unit
34 val output_sexps_nl :
35 (out_channel -> 'a -> 'b) -> out_channel -> 'a list -> unit
36 val save_sexps_hum : ?perm:Unix.file_perm -> string -> t list -> unit
37 val save_sexps_mach : ?perm:Unix.file_perm -> string -> t list -> unit
38 val save_sexps : ?perm:Unix.file_perm -> string -> t list -> unit
39 val to_string_hum : ?indent:int -> t -> string
40 val to_string_mach : t -> string
41 val to_string : t -> string
42 val scan_sexp : ?buf:Buffer.t -> Lexing.lexbuf -> Type.t
43 val scan_sexps : ?buf:Buffer.t -> Lexing.lexbuf -> Type.t list
44 val get_main_buf : Buffer.t option -> Lexing.lexbuf -> Parser.token
45 val scan_fold_sexps :
46 ?buf:Buffer.t -> f:('a -> Type.t -> 'a) -> init:'a -> Lexing.lexbuf -> 'a
47 val scan_iter_sexps :
48 ?buf:Buffer.t -> f:(Type.t -> unit) -> Lexing.lexbuf -> unit
49 val scan_sexps_conv :
50 ?buf:Buffer.t -> f:(Type.t -> 'a) -> Lexing.lexbuf -> 'a list
51 module Annot :
52 sig
53 type pos = { line : int; col : int; offset : int; }
54 type range = { start_pos : pos; end_pos : pos; }
55 type t = Atom of range * Type.t | List of range * t list * Type.t
56 type 'a conv = [ `Error of exn * t | `Result of 'a ]
57 exception Conv_exn of string * exn
58 type stack = {
59 mutable positions : pos list;
60 mutable stack : t list list;
61 }
62 val get_sexp : t -> Type.t
63 val get_range : t -> range
64 exception Annot_sexp of t
65 val find_sexp : t -> Type.t -> t option
66 end
67 module Parse_pos :
68 sig
69 type t = {
70 mutable text_line : int;
71 mutable text_char : int;
72 mutable global_offset : int;
73 mutable buf_pos : int;
74 }
75 val create :
76 ?text_line:int ->
77 ?text_char:int -> ?buf_pos:int -> ?global_offset:int -> unit -> t
78 val with_buf_pos : t -> int -> t
79 end
80 type ('a, 'b) parse_result =
81 Done of 'b * Parse_pos.t
82 | Cont of bool * ('a, 'b) parse_fun
83 and ('a, 'b) parse_fun = pos:int -> len:int -> 'a -> ('a, 'b) parse_result
84 type 'a parse_state = {
85 parse_pos : Parse_pos.t;
86 mutable pstack : 'a;
87 pbuf : Buffer.t;
88 }
89 type parse_error = {
90 location : string;
91 err_msg : string;
92 parse_state :
93 [ `Annot of Annot.stack parse_state | `Sexp of t list list parse_state ];
94 }
95 exception Parse_error of parse_error
96 val bump_text_line : 'a parse_state -> unit
97 val bump_text_pos : 'a parse_state -> unit
98 val bump_pos_cont :
99 'a parse_state ->
100 'b ->
101 max_pos:'c ->
102 pos:int -> ('a parse_state -> 'b -> max_pos:'c -> pos:int -> 'd) -> 'd
103 val bump_line_cont :
104 'a parse_state ->
105 'b ->
106 max_pos:'c ->
107 pos:int -> ('a parse_state -> 'b -> max_pos:'c -> pos:int -> 'd) -> 'd
108 val add_bump :
109 ('a parse_state -> 'b) ->
110 'a parse_state ->
111 'c ->
112 max_pos:'d ->
113 pos:int ->
114 char -> ('a parse_state -> 'c -> max_pos:'d -> pos:int -> 'e) -> 'e
115 val add_bump_pos :
116 'a parse_state ->
117 'b ->
118 max_pos:'c ->
119 pos:int ->
120 char -> ('a parse_state -> 'b -> max_pos:'c -> pos:int -> 'd) -> 'd
121 val add_bump_line :
122 'a parse_state ->
123 'b ->
124 max_pos:'c ->
125 pos:int ->
126 char -> ('a parse_state -> 'b -> max_pos:'c -> pos:int -> 'd) -> 'd
127 val set_parse_pos : Parse_pos.t -> int -> unit
128 val mk_parse_pos : 'a parse_state -> int -> Parse_pos.t
129 val raise_parse_error :
130 [ `Annot of Annot.stack parse_state | `Sexp of t list list parse_state ] ->
131 string -> int -> string -> 'a
132 val raise_unexpected_char :
133 [ `Annot of Annot.stack parse_state | `Sexp of t list list parse_state ] ->
134 string -> int -> char -> 'a
135 val parse_str :
136 ?parse_pos:Parse_pos.t -> ?len:int -> string -> (string, t) parse_result
137 val parse :
138 ?parse_pos:Parse_pos.t -> ?len:int -> string -> (string, t) parse_result
139 val get_glob_ofs : Parse_pos.t -> int -> int
140 val mk_annot_pos : Parse_pos.t -> int -> Annot.pos
141 val mk_annot_pos1 : Parse_pos.t -> int -> Annot.pos
142 val add_annot_pos : Annot.stack parse_state -> int -> unit
143 val add_annot_pos1 : Annot.stack parse_state -> int -> unit
144 val get_annot_range : Annot.stack parse_state -> int -> Annot.range
145 val mk_annot_atom : Annot.stack parse_state -> string -> int -> Annot.t
146 val mk_annot_list : Annot.stack parse_state -> Annot.t list -> int -> Annot.t
147 val init_annot_pstate : unit -> Annot.stack
148 val parse_str_annot :
149 ?parse_pos:Parse_pos.t ->
150 ?len:int -> string -> (string, Annot.t) parse_result
151 val parse_bigstring :
152 ?parse_pos:Parse_pos.t ->
153 ?len:int -> bigstring -> (bigstring, t) parse_result
154 val bump_found_atom :
155 (Annot.stack parse_state -> 'a) ->
156 Annot.stack parse_state ->
157 'b ->
158 max_pos:'c ->
159 pos:int ->
160 (Annot.stack parse_state ->
161 'b -> max_pos:'c -> pos:int -> ('d, Annot.t) parse_result) ->
162 ('d, Annot.t) parse_result
163 val check_str_bounds : string -> pos:int -> len:int -> bigstring -> int
164 val mk_cont :
165 string ->
166 (Annot.stack parse_state ->
167 bigstring -> max_pos:int -> pos:int -> (bigstring, 'a) parse_result) ->
168 Annot.stack parse_state -> (bigstring, 'a) parse_result
169 val parse_nl :
170 Annot.stack parse_state ->
171 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
172 val parse_comment :
173 Annot.stack parse_state ->
174 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
175 val parse_atom :
176 Annot.stack parse_state ->
177 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
178 val reg_parse_quoted :
179 Annot.stack parse_state ->
180 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
181 val parse_quoted :
182 Annot.stack parse_state ->
183 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
184 val parse_quoted_nl :
185 Annot.stack parse_state ->
186 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
187 val parse_escaped :
188 Annot.stack parse_state ->
189 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
190 val parse_skip_ws :
191 Annot.stack parse_state ->
192 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
193 val parse_skip_ws_nl :
194 Annot.stack parse_state ->
195 bigstring -> max_pos:int -> pos:int -> (bigstring, Annot.t) parse_result
196 val parse_dec :
197 Annot.stack parse_state ->
198 bigstring ->
199 max_pos:int ->
200 pos:int -> count:int -> d:int -> (bigstring, Annot.t) parse_result
201 val parse_hex :
202 Annot.stack parse_state ->
203 bigstring ->
204 max_pos:int ->
205 pos:int -> count:int -> d:int -> (bigstring, Annot.t) parse_result
206 val parse_bigstring_annot :
207 ?parse_pos:Parse_pos.t ->
208 ?len:int -> bigstring -> (bigstring, Annot.t) parse_result
209 val mk_this_parse :
210 ?parse_pos:Parse_pos.t ->
211 (?parse_pos:Parse_pos.t -> ?len:'a -> 'b -> 'c) ->
212 pos:int -> len:'a -> 'b -> 'c
213 val gen_input_sexp :
214 (?parse_pos:Parse_pos.t -> ?len:int -> string -> (string, 'a) parse_result) ->
215 ?parse_pos:Parse_pos.t -> in_channel -> 'a
216 val input_sexp : ?parse_pos:Parse_pos.t -> in_channel -> t
217 val gen_input_rev_sexps :
218 (?parse_pos:Parse_pos.t -> ?len:int -> string -> (string, 'a) parse_result) ->
219 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> 'a list
220 val input_rev_sexps :
221 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> t list
222 val input_sexps :
223 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> t list
224 val of_string_bigstring :
225 string ->
226 ('a -> ('b, 'c) parse_result) ->
227 'b -> ('a -> int) -> ('a -> int -> int -> string) -> 'a -> 'c
228 val of_string : string -> t
229 val get_bstr_sub_str :
230 (char, 'a, 'b) Bigarray.Array1.t -> int -> int -> string
231 val bstr_ws_buf :
232 (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
233 val of_bigstring : bigstring -> t
234 val gen_load_rev_sexps :
235 (?parse_pos:'a -> ?buf:'b -> in_channel -> 'c) -> ?buf:'b -> string -> 'c
236 val load_rev_sexps : ?buf:string -> string -> t list
237 val load_sexps : ?buf:string -> string -> t list
238 val gen_load_sexp :
239 (?parse_pos:Parse_pos.t -> ?len:int -> string -> (string, 'a) parse_result) ->
240 ?strict:bool -> ?buf:string -> string -> 'a
241 val load_sexp : ?strict:bool -> ?buf:string -> string -> t
242 module Annotated :
243 sig
244 type pos = Annot.pos = { line : int; col : int; offset : int; }
245 type range = Annot.range = { start_pos : pos; end_pos : pos; }
246 type t =
247 Annot.t =
248 Atom of range * Type.t
249 | List of range * t list * Type.t
250 type 'a conv = [ `Error of exn * t | `Result of 'a ]
251 exception Conv_exn of string * exn
252 type stack =
253 Annot.stack = {
254 mutable positions : pos list;
255 mutable stack : t list list;
256 }
257 val get_sexp : t -> Type.t
258 val get_range : t -> range
259 exception Annot_sexp of t
260 val find_sexp : t -> Type.t -> t option
261 val parse :
262 ?parse_pos:Parse_pos.t ->
263 ?len:int -> string -> (string, Annot.t) parse_result
264 val parse_bigstring :
265 ?parse_pos:Parse_pos.t ->
266 ?len:int -> bigstring -> (bigstring, Annot.t) parse_result
267 val input_rev_sexps :
268 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> Annot.t list
269 val input_sexp : ?parse_pos:Parse_pos.t -> in_channel -> Annot.t
270 val input_sexps :
271 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> Annot.t list
272 val of_string : string -> Annot.t
273 val of_bigstring : bigstring -> Annot.t
274 val load_rev_sexps : ?buf:string -> string -> Annot.t list
275 val load_sexps : ?buf:string -> string -> Annot.t list
276 val load_sexp : ?strict:bool -> ?buf:string -> string -> Annot.t
277 val conv : (Type.t -> 'a) -> t -> [> `Error of exn * t | `Result of 'a ]
278 val get_conv_exn : file:string -> exc:exn -> t -> exn
279 end
280 val load_sexp_conv :
281 ?strict:bool ->
282 ?buf:string ->
283 string -> (t -> 'a) -> [> `Error of exn * Annotated.t | `Result of 'a ]
284 val raise_conv_exn :
285 file:string -> [< `Error of exn * Annotated.t | `Result of 'a ] -> 'a
286 val load_sexp_conv_exn :
287 ?strict:bool -> ?buf:string -> string -> (t -> 'a) -> 'a
288 val load_sexps_conv :
289 ?buf:string ->
290 string ->
291 (t -> 'a) -> [> `Error of exn * Annotated.t | `Result of 'a ] list
292 val load_sexps_conv_exn : ?buf:string -> string -> (t -> 'a) -> 'a list
293 val gen_of_string_conv :
294 ('a -> Type.t) ->
295 ('a -> Annotated.t) ->
296 'a -> (Type.t -> 'b) -> [> `Error of exn * Annotated.t | `Result of 'b ]
297 val of_string_conv :
298 string -> (t -> 'a) -> [> `Error of exn * Annotated.t | `Result of 'a ]
299 val of_bigstring_conv :
300 bigstring -> (t -> 'a) -> [> `Error of exn * Annotated.t | `Result of 'a ]
301 module Of_string_conv_exn :
302 sig
303 type t = { exc : exn; sexp : Type.t; sub_sexp : Type.t; }
304 exception E of t
305 end
306 val gen_of_string_conv_exn : ('a -> Type.t) -> 'a -> (Type.t -> 'b) -> 'b
307 val of_string_conv_exn : string -> (t -> 'a) -> 'a
308 val of_bigstring_conv_exn : bigstring -> (t -> 'a) -> 'a
309 val unit : t
310 external sexp_of_t : t -> t = "%identity"
311 external t_of_sexp : t -> t = "%identity"
312 type found = [ `Found | `Pos of int * found ]
313 type search_result = [ `Found | `Not_found | `Pos of int * found ]
314 val search_physical :
315 t -> contained:t -> [ `Found | `Not_found | `Pos of int * found ]
316 val subst_found : t -> subst:t -> ([< `Found | `Pos of int * 'a ] as 'a) -> t