Coccinelle release 1.0.0-rc14
[bpt/coccinelle.git] / bundles / sexplib / sexplib-7.0.5 / lib / sexp_intf.mli
CommitLineData
d6ce1786
C
1module type S =
2 sig
3 type t = Type.t = Atom of string | List of t list
4 type bigstring =
5 (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout)
6 Bigarray.Array1.t
7 val default_indent : int ref
8 val size : t -> int * int
9 val scan_sexp : ?buf:Buffer.t -> Lexing.lexbuf -> t
10 val scan_sexps : ?buf:Buffer.t -> Lexing.lexbuf -> t list
11 val scan_iter_sexps :
12 ?buf:Buffer.t -> f:(t -> unit) -> Lexing.lexbuf -> unit
13 val scan_fold_sexps :
14 ?buf:Buffer.t -> f:('a -> t -> 'a) -> init:'a -> Lexing.lexbuf -> 'a
15 val scan_sexps_conv :
16 ?buf:Buffer.t -> f:(t -> 'a) -> Lexing.lexbuf -> 'a list
17 module Parse_pos :
18 sig
19 type t =
20 Pre_sexp.Parse_pos.t = private {
21 mutable text_line : int;
22 mutable text_char : int;
23 mutable global_offset : int;
24 mutable buf_pos : int;
25 }
26 val create :
27 ?text_line:int ->
28 ?text_char:int -> ?buf_pos:int -> ?global_offset:int -> unit -> t
29 val with_buf_pos : t -> int -> t
30 end
31 type ('a, 'b) parse_result =
32 ('a, 'b) Pre_sexp.parse_result =
33 Done of 'b * Parse_pos.t
34 | Cont of bool * ('a, 'b) parse_fun
35 and ('a, 'b) parse_fun =
36 pos:int -> len:int -> 'a -> ('a, 'b) parse_result
37 module Annotated :
38 sig
39 type pos =
40 Pre_sexp.Annotated.pos = {
41 line : int;
42 col : int;
43 offset : int;
44 }
45 type range =
46 Pre_sexp.Annotated.range = {
47 start_pos : pos;
48 end_pos : pos;
49 }
50 type t =
51 Pre_sexp.Annotated.t =
52 Atom of range * Type.t
53 | List of range * t list * Type.t
54 type 'a conv = [ `Error of exn * t | `Result of 'a ]
55 exception Conv_exn of string * exn
56 type stack =
57 Pre_sexp.Annotated.stack = {
58 mutable positions : pos list;
59 mutable stack : t list list;
60 }
61 val get_sexp : t -> Type.t
62 val get_range : t -> range
63 val find_sexp : t -> Type.t -> t option
64 val parse :
65 ?parse_pos:Parse_pos.t ->
66 ?len:int -> string -> (string, t) parse_result
67 val parse_bigstring :
68 ?parse_pos:Parse_pos.t ->
69 ?len:int -> bigstring -> (bigstring, t) parse_result
70 val input_sexp : ?parse_pos:Parse_pos.t -> in_channel -> t
71 val input_sexps :
72 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> t list
73 val input_rev_sexps :
74 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> t list
75 val load_sexp : ?strict:bool -> ?buf:string -> string -> t
76 val load_sexps : ?buf:string -> string -> t list
77 val load_rev_sexps : ?buf:string -> string -> t list
78 val of_string : string -> t
79 val of_bigstring : bigstring -> t
80 val conv : (Type.t -> 'a) -> t -> 'a conv
81 val get_conv_exn : file:string -> exc:exn -> t -> exn
82 end
83 type 'a parse_state =
84 'a Pre_sexp.parse_state = private {
85 parse_pos : Parse_pos.t;
86 mutable pstack : 'a;
87 pbuf : Buffer.t;
88 }
89 type parse_error =
90 Pre_sexp.parse_error = {
91 location : string;
92 err_msg : string;
93 parse_state :
94 [ `Annot of Annotated.stack parse_state
95 | `Sexp of t list list parse_state ];
96 }
97 exception Parse_error of parse_error
98 val parse :
99 ?parse_pos:Parse_pos.t ->
100 ?len:int -> string -> (string, t) parse_result
101 val parse_bigstring :
102 ?parse_pos:Parse_pos.t ->
103 ?len:int -> bigstring -> (bigstring, t) parse_result
104 val input_sexp : ?parse_pos:Parse_pos.t -> in_channel -> t
105 val input_sexps :
106 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> t list
107 val input_rev_sexps :
108 ?parse_pos:Parse_pos.t -> ?buf:string -> in_channel -> t list
109 val load_sexp : ?strict:bool -> ?buf:string -> string -> t
110 val load_sexps : ?buf:string -> string -> t list
111 val load_rev_sexps : ?buf:string -> string -> t list
112 val load_sexp_conv :
113 ?strict:bool -> ?buf:string -> string -> (t -> 'a) -> 'a Annotated.conv
114 val load_sexp_conv_exn :
115 ?strict:bool -> ?buf:string -> string -> (t -> 'a) -> 'a
116 val load_sexps_conv :
117 ?buf:string -> string -> (t -> 'a) -> 'a Annotated.conv list
118 val load_sexps_conv_exn : ?buf:string -> string -> (t -> 'a) -> 'a list
119 val output_hum : out_channel -> t -> unit
120 val output_hum_indent : int -> out_channel -> t -> unit
121 val output_mach : out_channel -> t -> unit
122 val output : out_channel -> t -> unit
123 val save_hum : ?perm:int -> string -> t -> unit
124 val save_mach : ?perm:int -> string -> t -> unit
125 val save : ?perm:int -> string -> t -> unit
126 val save_sexps_hum : ?perm:int -> string -> t list -> unit
127 val save_sexps_mach : ?perm:int -> string -> t list -> unit
128 val save_sexps : ?perm:int -> string -> t list -> unit
129 val pp_hum : Format.formatter -> t -> unit
130 val pp_hum_indent : int -> Format.formatter -> t -> unit
131 val pp_mach : Format.formatter -> t -> unit
132 val pp : Format.formatter -> t -> unit
133 module Of_string_conv_exn :
134 sig
135 type t = { exc : exn; sexp : Type.t; sub_sexp : Type.t; }
136 exception E of t
137 end
138 val of_string : string -> t
139 val of_string_conv : string -> (t -> 'a) -> 'a Annotated.conv
140 val of_string_conv_exn : string -> (t -> 'a) -> 'a
141 val of_bigstring : bigstring -> t
142 val of_bigstring_conv : bigstring -> (t -> 'a) -> 'a Annotated.conv
143 val of_bigstring_conv_exn : bigstring -> (t -> 'a) -> 'a
144 val to_string_hum : ?indent:int -> t -> string
145 val to_string_mach : t -> string
146 val to_string : t -> string
147 val to_buffer_hum : buf:Buffer.t -> ?indent:int -> t -> unit
148 val to_buffer_mach : buf:Buffer.t -> t -> unit
149 val to_buffer : buf:Buffer.t -> t -> unit
150 val unit : t
151 external sexp_of_t : t -> t = "%identity"
152 external t_of_sexp : t -> t = "%identity"
153 type found = [ `Found | `Pos of int * found ]
154 type search_result = [ `Found | `Not_found | `Pos of int * found ]
155 val search_physical : t -> contained:t -> search_result
156 val subst_found : t -> subst:t -> found -> t
157 end