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