1 type t
= Type.t
= Atom
of string | List
of t list
2 exception Of_sexp_error
of exn
* t
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
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
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
46 ?buf
:Buffer.t
-> f
:('a
-> Type.t
-> 'a
) -> init
:'a
-> Lexing.lexbuf
-> 'a
48 ?buf
:Buffer.t
-> f
:(Type.t
-> unit) -> Lexing.lexbuf
-> unit
50 ?buf
:Buffer.t
-> f
:(Type.t
-> 'a
) -> Lexing.lexbuf
-> 'a list
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
59 mutable positions
: pos list
;
60 mutable stack
: t list list
;
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
70 mutable text_line
: int;
71 mutable text_char
: int;
72 mutable global_offset
: int;
73 mutable buf_pos
: int;
77 ?text_char
:int -> ?buf_pos
:int -> ?global_offset
:int -> unit -> t
78 val with_buf_pos
: t
-> int -> t
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
;
93 [ `Annot
of Annot.stack parse_state
| `Sexp
of t list list parse_state
];
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
102 pos
:int -> ('a parse_state
-> 'b
-> max_pos
:'c
-> pos
:int -> 'd
) -> 'd
107 pos
:int -> ('a parse_state
-> 'b
-> max_pos
:'c
-> pos
:int -> 'd
) -> 'd
109 ('a parse_state
-> 'b
) ->
114 char
-> ('a parse_state
-> 'c
-> max_pos
:'d
-> pos
:int -> 'e
) -> 'e
120 char
-> ('a parse_state
-> 'b
-> max_pos
:'c
-> pos
:int -> 'd
) -> 'd
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
136 ?parse_pos
:Parse_pos.t
-> ?len
:int -> string -> (string, t
) parse_result
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
->
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
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
170 Annot.stack parse_state
->
171 bigstring
-> max_pos
:int -> pos
:int -> (bigstring
, Annot.t
) parse_result
173 Annot.stack parse_state
->
174 bigstring
-> max_pos
:int -> pos
:int -> (bigstring
, Annot.t
) parse_result
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
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
188 Annot.stack parse_state
->
189 bigstring
-> max_pos
:int -> pos
:int -> (bigstring
, Annot.t
) parse_result
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
197 Annot.stack parse_state
->
200 pos
:int -> count
:int -> d
:int -> (bigstring
, Annot.t
) parse_result
202 Annot.stack parse_state
->
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
210 ?parse_pos
:Parse_pos.t
->
211 (?parse_pos
:Parse_pos.t
-> ?len
:'a
-> 'b
-> 'c
) ->
212 pos
:int -> len
:'a
-> 'b
-> 'c
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
223 ?parse_pos
:Parse_pos.t
-> ?buf
:string -> in_channel
-> t list
224 val of_string_bigstring
:
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
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
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
244 type pos
= Annot.pos
= { line
: int; col
: int; offset
: int; }
245 type range
= Annot.range
= { start_pos
: pos
; end_pos
: pos
; }
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
254 mutable positions
: pos list
;
255 mutable stack
: t list list
;
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
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
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
283 string -> (t
-> 'a
) -> [> `Error
of exn
* Annotated.t
| `Result
of 'a
]
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
:
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
:
295 ('a
-> Annotated.t
) ->
296 'a
-> (Type.t
-> 'b
) -> [> `Error
of exn
* Annotated.t
| `Result
of 'b
]
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
:
303 type t
= { exc
: exn
; sexp
: Type.t
; sub_sexp
: Type.t
; }
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
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