1 (* automatically generated by ocamltarzan *)
6 let _loc = "Xxx.either"
10 | (Sexp.List
(Sexp.Atom
(("left" | "Left" as tag
)) :: sexp_args
) as
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
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
29 let either_of_sexp _of_a _of_b sexp
= either_of_sexp__ _of_a _of_b sexp
31 let sexp_of_either _of_a _of_b
=
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 ]
36 let either3_of_sexp__ =
37 let _loc = "Xxx.either3"
39 fun _of_a _of_b _of_c
->
41 | (Sexp.List
(Sexp.Atom
(("left3" | "Left3" as tag
)) :: sexp_args
) as
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
)
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
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
67 let either3_of_sexp _of_a _of_b _of_c sexp
=
68 either3_of_sexp__ _of_a _of_b _of_c sexp
70 let sexp_of_either3 _of_a _of_b _of_c
=
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 ]
76 let filename_of_sexp__ =
77 let _loc = "Xxx.filename" in fun sexp
-> Conv.string_of_sexp sexp
79 let filename_of_sexp sexp
=
80 try filename_of_sexp__ sexp
82 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
84 let sexp_of_filename v
= Conv.sexp_of_string v
86 let dirname_of_sexp__ =
87 let _loc = "Xxx.dirname" in fun sexp
-> Conv.string_of_sexp sexp
89 let dirname_of_sexp sexp
=
90 try dirname_of_sexp__ sexp
92 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
94 let sexp_of_dirname v
= Conv.sexp_of_string v
97 let _loc = "Xxx.set" in fun _of_a
-> Conv.list_of_sexp _of_a
99 let set_of_sexp _of_a sexp
=
100 try set_of_sexp__ _of_a sexp
102 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
104 let sexp_of_set _of_a
= Conv.sexp_of_list _of_a
106 let assoc_of_sexp__ =
107 let _loc = "Xxx.assoc"
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
)
116 let assoc_of_sexp _of_a _of_b sexp
=
117 try assoc_of_sexp__ _of_a _of_b sexp
119 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
121 let sexp_of_assoc _of_a _of_b
=
124 let v1 = _of_a
v1 and v2
= _of_b v2
in Sexp.List
[ v1; v2
])
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
131 let hashset_of_sexp _of_a sexp =
132 try hashset_of_sexp__ _of_a sexp
134 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
136 let sexp_of_hashset _of_a = Conv.sexp_of_hashtbl _of_a Conv.sexp_of_bool
139 let stack_of_sexp__ =
140 let _loc = "Xxx.stack" in fun _of_a
-> Conv.list_of_sexp _of_a
142 let stack_of_sexp _of_a sexp
=
143 try stack_of_sexp__ _of_a sexp
145 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
147 let sexp_of_stack _of_a
= Conv.sexp_of_list _of_a
149 let parse_info_of_sexp__ =
150 let _loc = "Xxx.parse_info"
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
160 | Sexp.List
([ Sexp.Atom field_name
; field_sexp
]) :: tail
->
161 ((match field_name
with
163 (match !str_field with
165 let fvalue = Conv.string_of_sexp field_sexp
166 in str_field := Some
fvalue
167 | Some _
-> duplicates
:= field_name
:: !duplicates
)
169 (match !charpos_field
with
171 let fvalue = Conv.int_of_sexp field_sexp
172 in charpos_field
:= Some
fvalue
173 | Some _
-> duplicates
:= field_name
:: !duplicates
)
175 (match !line_field
with
177 let fvalue = Conv.int_of_sexp field_sexp
178 in line_field
:= Some
fvalue
179 | Some _
-> duplicates
:= field_name
:: !duplicates
)
181 (match !column_field
with
183 let fvalue = Conv.int_of_sexp field_sexp
184 in column_field
:= Some
fvalue
185 | Some _
-> duplicates
:= field_name
:: !duplicates
)
187 (match !file_field
with
189 let fvalue = filename_of_sexp field_sexp
190 in file_field
:= Some
fvalue
191 | Some _
-> duplicates
:= field_name
:: !duplicates
)
193 if !Conv.record_check_extra_fields
194 then extra
:= field_name
:: !extra
197 | sexp
:: _
-> Conv_error.record_only_pairs_expected
_loc sexp
202 then Conv_error.record_duplicate_fields
_loc !duplicates sexp
205 then Conv_error.record_extra_fields
_loc !extra sexp
207 (match ((!str_field), (!charpos_field
), (!line_field
),
208 (!column_field
), (!file_field
))
210 | (Some str_value
, Some charpos_value
, Some line_value
,
211 Some column_value
, Some file_value
) ->
214 charpos
= charpos_value
;
216 column
= column_value
;
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
228 let parse_info_of_sexp sexp
= parse_info_of_sexp__ sexp
230 let sexp_of_parse_info {
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
256 let score_result_of_sexp__ =
257 let _loc = "Xxx.score_result"
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
274 let score_result_of_sexp sexp
= score_result_of_sexp__ sexp
276 let sexp_of_score_result =
278 | Ok
-> Sexp.Atom
"Ok"
280 let v1 = Conv.sexp_of_string
v1 in Sexp.List
[ Sexp.Atom
"Pb"; v1 ]
282 let score_of_sexp__ =
283 let _loc = "Xxx.score"
286 Conv.hashtbl_of_sexp
Conv.string_of_sexp
score_result_of_sexp sexp
288 let score_of_sexp sexp
=
289 try score_of_sexp__ sexp
291 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
293 let sexp_of_score v
=
294 Conv.sexp_of_hashtbl
Conv.sexp_of_string
sexp_of_score_result v
297 let score_list_of_sexp__ =
298 let _loc = "Xxx.score_list"
303 | Sexp.List
([ v1; v2
]) ->
304 let v1 = Conv.string_of_sexp
v1
305 and v2
= score_result_of_sexp v2
307 | sexp
-> Conv_error.tuple_of_size_n_expected
_loc 2 sexp
)
310 let score_list_of_sexp sexp
=
311 try score_list_of_sexp__ sexp
313 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
315 let sexp_of_score_list v
=
318 let v1 = Conv.sexp_of_string
v1
319 and v2
= sexp_of_score_result v2
320 in Sexp.List
[ v1; v2
])