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
])
126 let hashset_of_sexp__ =
127 let _loc = "Xxx.hashset"
128 in fun _of_a
-> Conv.hashtbl_of_sexp _of_a
Conv.bool_of_sexp
130 let hashset_of_sexp _of_a sexp
=
131 try hashset_of_sexp__ _of_a sexp
133 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
135 let sexp_of_hashset _of_a
= Conv.sexp_of_hashtbl _of_a
Conv.sexp_of_bool
137 let stack_of_sexp__ =
138 let _loc = "Xxx.stack" in fun _of_a
-> Conv.list_of_sexp _of_a
140 let stack_of_sexp _of_a sexp
=
141 try stack_of_sexp__ _of_a sexp
143 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
145 let sexp_of_stack _of_a
= Conv.sexp_of_list _of_a
147 let parse_info_of_sexp__ =
148 let _loc = "Xxx.parse_info"
151 | (Sexp.List field_sexps
as sexp
) ->
152 let str_field = ref None
and charpos_field
= ref None
153 and line_field
= ref None
and column_field
= ref None
154 and file_field
= ref None
and duplicates
= ref []
155 and extra
= ref [] in
158 | Sexp.List
([ Sexp.Atom field_name
; field_sexp
]) :: tail
->
159 ((match field_name
with
161 (match !str_field with
163 let fvalue = Conv.string_of_sexp field_sexp
164 in str_field := Some
fvalue
165 | Some _
-> duplicates
:= field_name
:: !duplicates
)
167 (match !charpos_field
with
169 let fvalue = Conv.int_of_sexp field_sexp
170 in charpos_field
:= Some
fvalue
171 | Some _
-> duplicates
:= field_name
:: !duplicates
)
173 (match !line_field
with
175 let fvalue = Conv.int_of_sexp field_sexp
176 in line_field
:= Some
fvalue
177 | Some _
-> duplicates
:= field_name
:: !duplicates
)
179 (match !column_field
with
181 let fvalue = Conv.int_of_sexp field_sexp
182 in column_field
:= Some
fvalue
183 | Some _
-> duplicates
:= field_name
:: !duplicates
)
185 (match !file_field
with
187 let fvalue = filename_of_sexp field_sexp
188 in file_field
:= Some
fvalue
189 | Some _
-> duplicates
:= field_name
:: !duplicates
)
191 if !Conv.record_check_extra_fields
192 then extra
:= field_name
:: !extra
195 | sexp
:: _
-> Conv_error.record_only_pairs_expected
_loc sexp
200 then Conv_error.record_duplicate_fields
_loc !duplicates sexp
203 then Conv_error.record_extra_fields
_loc !extra sexp
205 (match ((!str_field), (!charpos_field
), (!line_field
),
206 (!column_field
), (!file_field
))
208 | (Some str_value
, Some charpos_value
, Some line_value
,
209 Some column_value
, Some file_value
) ->
212 charpos
= charpos_value
;
214 column
= column_value
;
218 Conv_error.record_undefined_elements
_loc sexp
219 [ ((!str_field = None
), "str");
220 ((!charpos_field
= None
), "charpos");
221 ((!line_field
= None
), "line");
222 ((!column_field
= None
), "column");
223 ((!file_field
= None
), "file") ]))
224 | (Sexp.Atom _
as sexp
) -> Conv_error.record_list_instead_atom
_loc sexp
226 let parse_info_of_sexp sexp
= parse_info_of_sexp__ sexp
228 let sexp_of_parse_info {
236 let arg = sexp_of_filename v_file
in
237 let bnd = Sexp.List
[ Sexp.Atom
"file"; arg ] in
238 let bnds = bnd :: bnds in
239 let arg = Conv.sexp_of_int v_column
in
240 let bnd = Sexp.List
[ Sexp.Atom
"column"; arg ] in
241 let bnds = bnd :: bnds in
242 let arg = Conv.sexp_of_int v_line
in
243 let bnd = Sexp.List
[ Sexp.Atom
"line"; arg ] in
244 let bnds = bnd :: bnds in
245 let arg = Conv.sexp_of_int v_charpos
in
246 let bnd = Sexp.List
[ Sexp.Atom
"charpos"; arg ] in
247 let bnds = bnd :: bnds in
248 let arg = Conv.sexp_of_string v_str
in
249 let bnd = Sexp.List
[ Sexp.Atom
"str"; arg ] in
250 let bnds = bnd :: bnds in Sexp.List
bnds
254 let score_result_of_sexp__ =
255 let _loc = "Xxx.score_result"
258 | Sexp.Atom
("ok" | "Ok") -> Ok
259 | (Sexp.List
(Sexp.Atom
(("pb" | "Pb" as tag
)) :: sexp_args
) as sexp
) ->
260 (match sexp_args
with
261 | [ v1 ] -> let v1 = Conv.string_of_sexp
v1 in Pb
v1
262 | _
-> Conv_error.stag_incorrect_n_args
_loc tag sexp
)
263 | (Sexp.List
(Sexp.Atom
("ok" | "Ok") :: _
) as sexp
) ->
264 Conv_error.stag_no_args
_loc sexp
265 | (Sexp.Atom
("pb" | "Pb") as sexp
) ->
266 Conv_error.stag_takes_args
_loc sexp
267 | (Sexp.List
(Sexp.List _
:: _
) as sexp
) ->
268 Conv_error.nested_list_invalid_sum
_loc sexp
269 | (Sexp.List
[] as sexp
) -> Conv_error.empty_list_invalid_sum
_loc sexp
270 | sexp
-> Conv_error.unexpected_stag
_loc sexp
272 let score_result_of_sexp sexp
= score_result_of_sexp__ sexp
274 let sexp_of_score_result =
276 | Ok
-> Sexp.Atom
"Ok"
278 let v1 = Conv.sexp_of_string
v1 in Sexp.List
[ Sexp.Atom
"Pb"; v1 ]
280 let score_of_sexp__ =
281 let _loc = "Xxx.score"
284 Conv.hashtbl_of_sexp
Conv.string_of_sexp
score_result_of_sexp sexp
286 let score_of_sexp sexp
=
287 try score_of_sexp__ sexp
289 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
291 let sexp_of_score v
=
292 Conv.sexp_of_hashtbl
Conv.sexp_of_string
sexp_of_score_result v
295 let score_list_of_sexp__ =
296 let _loc = "Xxx.score_list"
301 | Sexp.List
([ v1; v2
]) ->
302 let v1 = Conv.string_of_sexp
v1
303 and v2
= score_result_of_sexp v2
305 | sexp
-> Conv_error.tuple_of_size_n_expected
_loc 2 sexp
)
308 let score_list_of_sexp sexp
=
309 try score_list_of_sexp__ sexp
311 | Conv_error.No_variant_match
((msg
, sexp
)) -> Conv.of_sexp_error msg sexp
313 let sexp_of_score_list v
=
316 let v1 = Conv.sexp_of_string
v1
317 and v2
= sexp_of_score_result v2
318 in Sexp.List
[ v1; v2
])