Commit | Line | Data |
---|---|---|
b1b2de81 C |
1 | (* automatically generated by ocamltarzan *) |
2 | ||
90aeb998 | 3 | open Sexplib |
b1b2de81 | 4 | open Common |
b1b2de81 C |
5 | let either_of_sexp__ = |
6 | let _loc = "Xxx.either" | |
7 | in | |
8 | fun _of_a _of_b -> | |
9 | function | |
10 | | (Sexp.List (Sexp.Atom (("left" | "Left" as tag)) :: sexp_args) as | |
11 | sexp) -> | |
12 | (match sexp_args with | |
13 | | [ v1 ] -> let v1 = _of_a v1 in Left v1 | |
14 | | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp) | |
15 | | (Sexp.List (Sexp.Atom (("right" | "Right" as tag)) :: sexp_args) as | |
16 | sexp) -> | |
17 | (match sexp_args with | |
18 | | [ v1 ] -> let v1 = _of_b v1 in Right v1 | |
19 | | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp) | |
20 | | (Sexp.Atom ("left" | "Left") as sexp) -> | |
21 | Conv_error.stag_takes_args _loc sexp | |
22 | | (Sexp.Atom ("right" | "Right") as sexp) -> | |
23 | Conv_error.stag_takes_args _loc sexp | |
24 | | (Sexp.List (Sexp.List _ :: _) as sexp) -> | |
25 | Conv_error.nested_list_invalid_sum _loc sexp | |
26 | | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp | |
27 | | sexp -> Conv_error.unexpected_stag _loc sexp | |
ae4735db | 28 | |
b1b2de81 | 29 | let either_of_sexp _of_a _of_b sexp = either_of_sexp__ _of_a _of_b sexp |
ae4735db | 30 | |
b1b2de81 C |
31 | let sexp_of_either _of_a _of_b = |
32 | function | |
33 | | Left v1 -> let v1 = _of_a v1 in Sexp.List [ Sexp.Atom "Left"; v1 ] | |
34 | | Right v1 -> let v1 = _of_b v1 in Sexp.List [ Sexp.Atom "Right"; v1 ] | |
ae4735db | 35 | |
b1b2de81 C |
36 | let either3_of_sexp__ = |
37 | let _loc = "Xxx.either3" | |
38 | in | |
39 | fun _of_a _of_b _of_c -> | |
40 | function | |
41 | | (Sexp.List (Sexp.Atom (("left3" | "Left3" as tag)) :: sexp_args) as | |
42 | sexp) -> | |
43 | (match sexp_args with | |
44 | | [ v1 ] -> let v1 = _of_a v1 in Left3 v1 | |
45 | | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp) | |
46 | | (Sexp.List (Sexp.Atom (("middle3" | "Middle3" as tag)) :: sexp_args) | |
47 | as sexp) -> | |
48 | (match sexp_args with | |
49 | | [ v1 ] -> let v1 = _of_b v1 in Middle3 v1 | |
50 | | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp) | |
51 | | (Sexp.List (Sexp.Atom (("right3" | "Right3" as tag)) :: sexp_args) as | |
52 | sexp) -> | |
53 | (match sexp_args with | |
54 | | [ v1 ] -> let v1 = _of_c v1 in Right3 v1 | |
55 | | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp) | |
56 | | (Sexp.Atom ("left3" | "Left3") as sexp) -> | |
57 | Conv_error.stag_takes_args _loc sexp | |
58 | | (Sexp.Atom ("middle3" | "Middle3") as sexp) -> | |
59 | Conv_error.stag_takes_args _loc sexp | |
60 | | (Sexp.Atom ("right3" | "Right3") as sexp) -> | |
61 | Conv_error.stag_takes_args _loc sexp | |
62 | | (Sexp.List (Sexp.List _ :: _) as sexp) -> | |
63 | Conv_error.nested_list_invalid_sum _loc sexp | |
64 | | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp | |
65 | | sexp -> Conv_error.unexpected_stag _loc sexp | |
ae4735db | 66 | |
b1b2de81 C |
67 | let either3_of_sexp _of_a _of_b _of_c sexp = |
68 | either3_of_sexp__ _of_a _of_b _of_c sexp | |
ae4735db | 69 | |
b1b2de81 C |
70 | let sexp_of_either3 _of_a _of_b _of_c = |
71 | function | |
72 | | Left3 v1 -> let v1 = _of_a v1 in Sexp.List [ Sexp.Atom "Left3"; v1 ] | |
73 | | Middle3 v1 -> let v1 = _of_b v1 in Sexp.List [ Sexp.Atom "Middle3"; v1 ] | |
74 | | Right3 v1 -> let v1 = _of_c v1 in Sexp.List [ Sexp.Atom "Right3"; v1 ] | |
ae4735db | 75 | |
b1b2de81 C |
76 | let filename_of_sexp__ = |
77 | let _loc = "Xxx.filename" in fun sexp -> Conv.string_of_sexp sexp | |
ae4735db | 78 | |
b1b2de81 C |
79 | let filename_of_sexp sexp = |
80 | try filename_of_sexp__ sexp | |
81 | with | |
82 | | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp | |
ae4735db | 83 | |
b1b2de81 | 84 | let sexp_of_filename v = Conv.sexp_of_string v |
ae4735db | 85 | |
b1b2de81 C |
86 | let dirname_of_sexp__ = |
87 | let _loc = "Xxx.dirname" in fun sexp -> Conv.string_of_sexp sexp | |
ae4735db | 88 | |
b1b2de81 C |
89 | let dirname_of_sexp sexp = |
90 | try dirname_of_sexp__ sexp | |
91 | with | |
92 | | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp | |
ae4735db | 93 | |
b1b2de81 | 94 | let sexp_of_dirname v = Conv.sexp_of_string v |
ae4735db | 95 | |
b1b2de81 C |
96 | let set_of_sexp__ = |
97 | let _loc = "Xxx.set" in fun _of_a -> Conv.list_of_sexp _of_a | |
ae4735db | 98 | |
b1b2de81 C |
99 | let set_of_sexp _of_a sexp = |
100 | try set_of_sexp__ _of_a sexp | |
101 | with | |
102 | | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp | |
ae4735db | 103 | |
b1b2de81 | 104 | let sexp_of_set _of_a = Conv.sexp_of_list _of_a |
ae4735db | 105 | |
b1b2de81 C |
106 | let assoc_of_sexp__ = |
107 | let _loc = "Xxx.assoc" | |
108 | in | |
109 | fun _of_a _of_b -> | |
110 | Conv.list_of_sexp | |
111 | (function | |
112 | | Sexp.List ([ v1; v2 ]) -> | |
113 | let v1 = _of_a v1 and v2 = _of_b v2 in (v1, v2) | |
114 | | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp) | |
ae4735db | 115 | |
b1b2de81 C |
116 | let assoc_of_sexp _of_a _of_b sexp = |
117 | try assoc_of_sexp__ _of_a _of_b sexp | |
118 | with | |
119 | | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp | |
ae4735db | 120 | |
b1b2de81 C |
121 | let sexp_of_assoc _of_a _of_b = |
122 | Conv.sexp_of_list | |
123 | (fun (v1, v2) -> | |
124 | let v1 = _of_a v1 and v2 = _of_b v2 in Sexp.List [ v1; v2 ]) | |
ae4735db | 125 | |
6756e19d | 126 | (* |
b1b2de81 C |
127 | let hashset_of_sexp__ = |
128 | let _loc = "Xxx.hashset" | |
129 | in fun _of_a -> Conv.hashtbl_of_sexp _of_a Conv.bool_of_sexp | |
ae4735db | 130 | |
b1b2de81 C |
131 | let hashset_of_sexp _of_a sexp = |
132 | try hashset_of_sexp__ _of_a sexp | |
133 | with | |
134 | | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp | |
ae4735db | 135 | |
b1b2de81 | 136 | let sexp_of_hashset _of_a = Conv.sexp_of_hashtbl _of_a Conv.sexp_of_bool |
6756e19d | 137 | *) |
ae4735db | 138 | |
b1b2de81 C |
139 | let stack_of_sexp__ = |
140 | let _loc = "Xxx.stack" in fun _of_a -> Conv.list_of_sexp _of_a | |
ae4735db | 141 | |
b1b2de81 C |
142 | let stack_of_sexp _of_a sexp = |
143 | try stack_of_sexp__ _of_a sexp | |
144 | with | |
145 | | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp | |
ae4735db | 146 | |
b1b2de81 | 147 | let sexp_of_stack _of_a = Conv.sexp_of_list _of_a |
ae4735db | 148 | |
b1b2de81 C |
149 | let parse_info_of_sexp__ = |
150 | let _loc = "Xxx.parse_info" | |
151 | in | |
152 | function | |
153 | | (Sexp.List field_sexps as sexp) -> | |
154 | let str_field = ref None and charpos_field = ref None | |
155 | and line_field = ref None and column_field = ref None | |
156 | and file_field = ref None and duplicates = ref [] | |
157 | and extra = ref [] in | |
158 | let rec iter = | |
159 | (function | |
160 | | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail -> | |
161 | ((match field_name with | |
162 | | "str" -> | |
163 | (match !str_field with | |
164 | | None -> | |
165 | let fvalue = Conv.string_of_sexp field_sexp | |
166 | in str_field := Some fvalue | |
167 | | Some _ -> duplicates := field_name :: !duplicates) | |
168 | | "charpos" -> | |
169 | (match !charpos_field with | |
170 | | None -> | |
171 | let fvalue = Conv.int_of_sexp field_sexp | |
172 | in charpos_field := Some fvalue | |
173 | | Some _ -> duplicates := field_name :: !duplicates) | |
174 | | "line" -> | |
175 | (match !line_field with | |
176 | | None -> | |
177 | let fvalue = Conv.int_of_sexp field_sexp | |
178 | in line_field := Some fvalue | |
179 | | Some _ -> duplicates := field_name :: !duplicates) | |
180 | | "column" -> | |
181 | (match !column_field with | |
182 | | None -> | |
183 | let fvalue = Conv.int_of_sexp field_sexp | |
184 | in column_field := Some fvalue | |
185 | | Some _ -> duplicates := field_name :: !duplicates) | |
186 | | "file" -> | |
187 | (match !file_field with | |
188 | | None -> | |
189 | let fvalue = filename_of_sexp field_sexp | |
190 | in file_field := Some fvalue | |
191 | | Some _ -> duplicates := field_name :: !duplicates) | |
192 | | _ -> | |
193 | if !Conv.record_check_extra_fields | |
194 | then extra := field_name :: !extra | |
195 | else ()); | |
196 | iter tail) | |
197 | | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp | |
198 | | [] -> ()) | |
199 | in | |
200 | (iter field_sexps; | |
201 | if !duplicates <> [] | |
202 | then Conv_error.record_duplicate_fields _loc !duplicates sexp | |
203 | else | |
204 | if !extra <> [] | |
205 | then Conv_error.record_extra_fields _loc !extra sexp | |
206 | else | |
207 | (match ((!str_field), (!charpos_field), (!line_field), | |
208 | (!column_field), (!file_field)) | |
209 | with | |
210 | | (Some str_value, Some charpos_value, Some line_value, | |
211 | Some column_value, Some file_value) -> | |
212 | { | |
213 | str = str_value; | |
214 | charpos = charpos_value; | |
215 | line = line_value; | |
216 | column = column_value; | |
217 | file = file_value; | |
218 | } | |
219 | | _ -> | |
220 | Conv_error.record_undefined_elements _loc sexp | |
221 | [ ((!str_field = None), "str"); | |
222 | ((!charpos_field = None), "charpos"); | |
223 | ((!line_field = None), "line"); | |
224 | ((!column_field = None), "column"); | |
225 | ((!file_field = None), "file") ])) | |
226 | | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp | |
ae4735db | 227 | |
b1b2de81 | 228 | let parse_info_of_sexp sexp = parse_info_of_sexp__ sexp |
ae4735db | 229 | |
b1b2de81 C |
230 | let sexp_of_parse_info { |
231 | str = v_str; | |
232 | charpos = v_charpos; | |
233 | line = v_line; | |
234 | column = v_column; | |
235 | file = v_file | |
236 | } = | |
237 | let bnds = [] in | |
238 | let arg = sexp_of_filename v_file in | |
239 | let bnd = Sexp.List [ Sexp.Atom "file"; arg ] in | |
240 | let bnds = bnd :: bnds in | |
241 | let arg = Conv.sexp_of_int v_column in | |
242 | let bnd = Sexp.List [ Sexp.Atom "column"; arg ] in | |
243 | let bnds = bnd :: bnds in | |
244 | let arg = Conv.sexp_of_int v_line in | |
245 | let bnd = Sexp.List [ Sexp.Atom "line"; arg ] in | |
246 | let bnds = bnd :: bnds in | |
247 | let arg = Conv.sexp_of_int v_charpos in | |
248 | let bnd = Sexp.List [ Sexp.Atom "charpos"; arg ] in | |
249 | let bnds = bnd :: bnds in | |
250 | let arg = Conv.sexp_of_string v_str in | |
251 | let bnd = Sexp.List [ Sexp.Atom "str"; arg ] in | |
252 | let bnds = bnd :: bnds in Sexp.List bnds | |
ae4735db | 253 | |
b1b2de81 C |
254 | |
255 | ||
256 | let score_result_of_sexp__ = | |
257 | let _loc = "Xxx.score_result" | |
258 | in | |
259 | function | |
260 | | Sexp.Atom ("ok" | "Ok") -> Ok | |
261 | | (Sexp.List (Sexp.Atom (("pb" | "Pb" as tag)) :: sexp_args) as sexp) -> | |
262 | (match sexp_args with | |
263 | | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in Pb v1 | |
264 | | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp) | |
265 | | (Sexp.List (Sexp.Atom ("ok" | "Ok") :: _) as sexp) -> | |
266 | Conv_error.stag_no_args _loc sexp | |
267 | | (Sexp.Atom ("pb" | "Pb") as sexp) -> | |
268 | Conv_error.stag_takes_args _loc sexp | |
269 | | (Sexp.List (Sexp.List _ :: _) as sexp) -> | |
270 | Conv_error.nested_list_invalid_sum _loc sexp | |
271 | | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp | |
272 | | sexp -> Conv_error.unexpected_stag _loc sexp | |
ae4735db | 273 | |
b1b2de81 | 274 | let score_result_of_sexp sexp = score_result_of_sexp__ sexp |
ae4735db | 275 | |
b1b2de81 C |
276 | let sexp_of_score_result = |
277 | function | |
278 | | Ok -> Sexp.Atom "Ok" | |
279 | | Pb v1 -> | |
280 | let v1 = Conv.sexp_of_string v1 in Sexp.List [ Sexp.Atom "Pb"; v1 ] | |
ae4735db | 281 | |
b1b2de81 C |
282 | let score_of_sexp__ = |
283 | let _loc = "Xxx.score" | |
284 | in | |
285 | fun sexp -> | |
286 | Conv.hashtbl_of_sexp Conv.string_of_sexp score_result_of_sexp sexp | |
ae4735db | 287 | |
b1b2de81 C |
288 | let score_of_sexp sexp = |
289 | try score_of_sexp__ sexp | |
290 | with | |
291 | | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp | |
ae4735db | 292 | |
b1b2de81 C |
293 | let sexp_of_score v = |
294 | Conv.sexp_of_hashtbl Conv.sexp_of_string sexp_of_score_result v | |
ae4735db | 295 | |
b1b2de81 C |
296 | |
297 | let score_list_of_sexp__ = | |
298 | let _loc = "Xxx.score_list" | |
299 | in | |
300 | fun sexp -> | |
301 | Conv.list_of_sexp | |
302 | (function | |
303 | | Sexp.List ([ v1; v2 ]) -> | |
304 | let v1 = Conv.string_of_sexp v1 | |
305 | and v2 = score_result_of_sexp v2 | |
306 | in (v1, v2) | |
307 | | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp) | |
308 | sexp | |
ae4735db | 309 | |
b1b2de81 C |
310 | let score_list_of_sexp sexp = |
311 | try score_list_of_sexp__ sexp | |
312 | with | |
313 | | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp | |
ae4735db | 314 | |
b1b2de81 C |
315 | let sexp_of_score_list v = |
316 | Conv.sexp_of_list | |
317 | (fun (v1, v2) -> | |
318 | let v1 = Conv.sexp_of_string v1 | |
319 | and v2 = sexp_of_score_result v2 | |
320 | in Sexp.List [ v1; v2 ]) | |
321 | v |