Release coccinelle-0.1.9-rc1
[bpt/coccinelle.git] / parsing_c / sexp_ast_c.ml
1 (* generated by ocamltarzan with: camlp4o -o /tmp/yyy.ml -I pa/ pa_type_conv.cmo pa_sexp_conv.cmo pr_o.cmo /tmp/xxx.ml *)
2 open Ast_c
3
4 (*
5 let sexp_of_program x =
6 raise (Common.Todo)
7 *)
8
9 (* pad addons: *)
10 module Common = Sexp_common
11 module Ast_cocci = struct
12 let mcodekind_of_sexp x = failwith "todo"
13 let sexp_of_mcodekind x = failwith "todo"
14 let fixpos_of_sexp x = failwith "todo"
15 let sexp_of_fixpos x = failwith "todo"
16 end
17 module Token_c = struct
18 let comment_like_token_of_sexp x = failwith "todo"
19 let sexp_of_comment_like_token x = failwith "todo"
20 end
21 (* cf also the failwith and comment I have added in this file
22 (C-s failwith et C-s ( * )
23 mainly to break the mutually recursive, for the cocci_tag and
24 metavars_binding stuff. I also moved some function up
25 outside the big 'rec .. and .. and .. and', especially the wrap_of_sexp
26 by transforming some 'and xxx' in 'let xxx'.
27 *)
28
29 let show_info = ref false
30 let show_qualifier = ref false
31 let show_expr_info = ref true
32
33
34
35 let posl_of_sexp__ =
36 let _loc = "Xxx.posl"
37 in
38 function
39 | Sexp.List ([ v1; v2 ]) ->
40 let v1 = Conv.int_of_sexp v1 and v2 = Conv.int_of_sexp v2 in (v1, v2)
41 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
42
43 let posl_of_sexp sexp =
44 try posl_of_sexp__ sexp
45 with
46 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
47
48 let sexp_of_posl (v1, v2) =
49 let v1 = Conv.sexp_of_int v1
50 and v2 = Conv.sexp_of_int v2
51 in Sexp.List [ v1; v2 ]
52
53 let virtual_position_of_sexp__ =
54 let _loc = "Xxx.virtual_position"
55 in
56 function
57 | Sexp.List ([ v1; v2 ]) ->
58 let v1 = Common.parse_info_of_sexp v1
59 and v2 = Conv.int_of_sexp v2
60 in (v1, v2)
61 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
62
63 let virtual_position_of_sexp sexp =
64 try virtual_position_of_sexp__ sexp
65 with
66 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
67
68 let sexp_of_virtual_position (v1, v2) =
69 let v1 = Common.sexp_of_parse_info v1
70 and v2 = Conv.sexp_of_int v2
71 in Sexp.List [ v1; v2 ]
72
73 let parse_info_of_sexp__ =
74 let _loc = "Xxx.parse_info"
75 in
76 function
77 | (Sexp.List
78 (Sexp.Atom (("originTok" | "OriginTok" as tag)) :: sexp_args)
79 as sexp) ->
80 (match sexp_args with
81 | [ v1 ] -> let v1 = Common.parse_info_of_sexp v1 in OriginTok v1
82 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
83 | (Sexp.List (Sexp.Atom (("fakeTok" | "FakeTok" as tag)) :: sexp_args) as
84 sexp) ->
85 (match sexp_args with
86 | [ v1; v2 ] ->
87 let v1 = Conv.string_of_sexp v1
88 and v2 = virtual_position_of_sexp v2
89 in FakeTok ((v1, v2))
90 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
91 | (Sexp.List
92 (Sexp.Atom (("expandedTok" | "ExpandedTok" as tag)) :: sexp_args)
93 as sexp) ->
94 (match sexp_args with
95 | [ v1; v2 ] ->
96 let v1 = Common.parse_info_of_sexp v1
97 and v2 = virtual_position_of_sexp v2
98 in ExpandedTok ((v1, v2))
99 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
100 | (Sexp.List
101 (Sexp.Atom (("abstractLineTok" | "AbstractLineTok" as tag)) ::
102 sexp_args)
103 as sexp) ->
104 (match sexp_args with
105 | [ v1 ] ->
106 let v1 = Common.parse_info_of_sexp v1 in AbstractLineTok v1
107 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
108 | (Sexp.Atom ("originTok" | "OriginTok") as sexp) ->
109 Conv_error.stag_takes_args _loc sexp
110 | (Sexp.Atom ("fakeTok" | "FakeTok") as sexp) ->
111 Conv_error.stag_takes_args _loc sexp
112 | (Sexp.Atom ("expandedTok" | "ExpandedTok") as sexp) ->
113 Conv_error.stag_takes_args _loc sexp
114 | (Sexp.Atom ("abstractLineTok" | "AbstractLineTok") as sexp) ->
115 Conv_error.stag_takes_args _loc sexp
116 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
117 Conv_error.nested_list_invalid_sum _loc sexp
118 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
119 | sexp -> Conv_error.unexpected_stag _loc sexp
120
121 let parse_info_of_sexp sexp = parse_info_of_sexp__ sexp
122
123 let sexp_of_parse_info =
124 function
125 | OriginTok v1 ->
126 let v1 = Common.sexp_of_parse_info v1
127 in Sexp.List [ Sexp.Atom "OriginTok"; v1 ]
128 | FakeTok ((v1, v2)) ->
129 let v1 = Conv.sexp_of_string v1
130 and v2 = sexp_of_virtual_position v2
131 in Sexp.List [ Sexp.Atom "FakeTok"; v1; v2 ]
132 | ExpandedTok ((v1, v2)) ->
133 let v1 = Common.sexp_of_parse_info v1
134 and v2 = sexp_of_virtual_position v2
135 in Sexp.List [ Sexp.Atom "ExpandedTok"; v1; v2 ]
136 | AbstractLineTok v1 ->
137 let v1 = Common.sexp_of_parse_info v1
138 in Sexp.List [ Sexp.Atom "AbstractLineTok"; v1 ]
139
140 let rec info_of_sexp__ =
141 let _loc = "Xxx.info"
142 in
143 function
144 | (Sexp.List field_sexps as sexp) ->
145 let pinfo_field = ref None and cocci_tag_field = ref None
146 and comments_tag_field = ref None and duplicates = ref []
147 and extra = ref [] in
148 let rec iter =
149 (function
150 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
151 ((match field_name with
152 | "pinfo" ->
153 (match !pinfo_field with
154 | None ->
155 let fvalue = parse_info_of_sexp field_sexp
156 in pinfo_field := Some fvalue
157 | Some _ -> duplicates := field_name :: !duplicates)
158 | "cocci_tag" ->
159 (match !cocci_tag_field with
160 | None ->
161 let fvalue =
162 Conv.ref_of_sexp
163 (Conv.option_of_sexp
164 (function
165 | Sexp.List ([ v1; v2 ]) ->
166 let v1 = Ast_cocci.mcodekind_of_sexp v1
167 and v2 =
168 (*metavars_binding_of_sexp v2*)
169 failwith "todo"
170 in (v1, v2)
171 | sexp ->
172 Conv_error.tuple_of_size_n_expected
173 _loc 2 sexp))
174 field_sexp
175 in cocci_tag_field := Some fvalue
176 | Some _ -> duplicates := field_name :: !duplicates)
177 | "comments_tag" ->
178 (match !comments_tag_field with
179 | None ->
180 let fvalue =
181 Conv.ref_of_sexp comments_around_of_sexp
182 field_sexp
183 in comments_tag_field := Some fvalue
184 | Some _ -> duplicates := field_name :: !duplicates)
185 | _ ->
186 if !Conv.record_check_extra_fields
187 then extra := field_name :: !extra
188 else ());
189 iter tail)
190 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
191 | [] -> ())
192 in
193 (iter field_sexps;
194 if !duplicates <> []
195 then Conv_error.record_duplicate_fields _loc !duplicates sexp
196 else
197 if !extra <> []
198 then Conv_error.record_extra_fields _loc !extra sexp
199 else
200 (match ((!pinfo_field), (!cocci_tag_field),
201 (!comments_tag_field))
202 with
203 | (Some pinfo_value, Some cocci_tag_value,
204 Some comments_tag_value) ->
205 {
206 pinfo = pinfo_value;
207 cocci_tag = cocci_tag_value;
208 comments_tag = comments_tag_value;
209 }
210 | _ ->
211 Conv_error.record_undefined_elements _loc sexp
212 [ ((!pinfo_field = None), "pinfo");
213 ((!cocci_tag_field = None), "cocci_tag");
214 ((!comments_tag_field = None), "comments_tag") ]))
215 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
216 and info_of_sexp sexp = info_of_sexp__ sexp
217 and il_of_sexp__ =
218 let _loc = "Xxx.il" in fun sexp -> Conv.list_of_sexp info_of_sexp sexp
219 and il_of_sexp sexp =
220 try il_of_sexp__ sexp
221 with
222 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
223 and wrap_of_sexp__ =
224 let _loc = "Xxx.wrap"
225 in
226 fun _of_a ->
227 function
228 | Sexp.List ([ v1; v2 ]) ->
229 let v1 = _of_a v1 and v2 = il_of_sexp v2 in (v1, v2)
230 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
231 and wrap_of_sexp _of_a sexp =
232 try wrap_of_sexp__ _of_a sexp
233 with
234 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
235 and wrap2_of_sexp__ =
236 let _loc = "Xxx.wrap2"
237 in
238 fun _of_a ->
239 function
240 | Sexp.List ([ v1; v2 ]) ->
241 let v1 = _of_a v1 and v2 = il_of_sexp v2 in (v1, v2)
242 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
243 and wrap2_of_sexp _of_a sexp =
244 try wrap2_of_sexp__ _of_a sexp
245 with
246 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
247
248 (* moved up *)
249 and comments_around_of_sexp__ =
250 let _loc = "Xxx.comments_around"
251 in
252 function
253 | (Sexp.List field_sexps as sexp) ->
254 let mbefore_field = ref None and mafter_field = ref None
255 and mbefore2_field = ref None and mafter2_field = ref None
256 and duplicates = ref [] and extra = ref [] in
257 let rec iter =
258 (function
259 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
260 ((match field_name with
261 | "mbefore" ->
262 (match !mbefore_field with
263 | None ->
264 let fvalue =
265 Conv.list_of_sexp Token_c.
266 comment_like_token_of_sexp field_sexp
267 in mbefore_field := Some fvalue
268 | Some _ -> duplicates := field_name :: !duplicates)
269 | "mafter" ->
270 (match !mafter_field with
271 | None ->
272 let fvalue =
273 Conv.list_of_sexp Token_c.
274 comment_like_token_of_sexp field_sexp
275 in mafter_field := Some fvalue
276 | Some _ -> duplicates := field_name :: !duplicates)
277 | "mbefore2" ->
278 (match !mbefore2_field with
279 | None ->
280 let fvalue =
281 Conv.list_of_sexp
282 comment_and_relative_pos_of_sexp field_sexp
283 in mbefore2_field := Some fvalue
284 | Some _ -> duplicates := field_name :: !duplicates)
285 | "mafter2" ->
286 (match !mafter2_field with
287 | None ->
288 let fvalue =
289 Conv.list_of_sexp
290 comment_and_relative_pos_of_sexp field_sexp
291 in mafter2_field := Some fvalue
292 | Some _ -> duplicates := field_name :: !duplicates)
293 | _ ->
294 if !Conv.record_check_extra_fields
295 then extra := field_name :: !extra
296 else ());
297 iter tail)
298 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
299 | [] -> ())
300 in
301 (iter field_sexps;
302 if !duplicates <> []
303 then Conv_error.record_duplicate_fields _loc !duplicates sexp
304 else
305 if !extra <> []
306 then Conv_error.record_extra_fields _loc !extra sexp
307 else
308 (match ((!mbefore_field), (!mafter_field), (!mbefore2_field),
309 (!mafter2_field))
310 with
311 | (Some mbefore_value, Some mafter_value,
312 Some mbefore2_value, Some mafter2_value) ->
313 {
314 mbefore = mbefore_value;
315 mafter = mafter_value;
316 mbefore2 = mbefore2_value;
317 mafter2 = mafter2_value;
318 }
319 | _ ->
320 Conv_error.record_undefined_elements _loc sexp
321 [ ((!mbefore_field = None), "mbefore");
322 ((!mafter_field = None), "mafter");
323 ((!mbefore2_field = None), "mbefore2");
324 ((!mafter2_field = None), "mafter2") ]))
325 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
326 and comments_around_of_sexp sexp = comments_around_of_sexp__ sexp
327 and comment_and_relative_pos_of_sexp__ =
328 let _loc = "Xxx.comment_and_relative_pos"
329 in
330 function
331 | (Sexp.List field_sexps as sexp) ->
332 let minfo_field = ref None and mpos_field = ref None
333 and duplicates = ref [] and extra = ref [] in
334 let rec iter =
335 (function
336 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
337 ((match field_name with
338 | "minfo" ->
339 (match !minfo_field with
340 | None ->
341 let fvalue = Common.parse_info_of_sexp field_sexp
342 in minfo_field := Some fvalue
343 | Some _ -> duplicates := field_name :: !duplicates)
344 | "mpos" ->
345 (match !mpos_field with
346 | None ->
347 let fvalue = Conv.int_of_sexp field_sexp
348 in mpos_field := Some fvalue
349 | Some _ -> duplicates := field_name :: !duplicates)
350 | _ ->
351 if !Conv.record_check_extra_fields
352 then extra := field_name :: !extra
353 else ());
354 iter tail)
355 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
356 | [] -> ())
357 in
358 (iter field_sexps;
359 if !duplicates <> []
360 then Conv_error.record_duplicate_fields _loc !duplicates sexp
361 else
362 if !extra <> []
363 then Conv_error.record_extra_fields _loc !extra sexp
364 else
365 (match ((!minfo_field), (!mpos_field)) with
366 | (Some minfo_value, Some mpos_value) ->
367 { minfo = minfo_value; mpos = mpos_value; }
368 | _ ->
369 Conv_error.record_undefined_elements _loc sexp
370 [ ((!minfo_field = None), "minfo");
371 ((!mpos_field = None), "mpos") ]))
372 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
373 and comment_and_relative_pos_of_sexp sexp =
374 comment_and_relative_pos_of_sexp__ sexp
375 and comment_of_sexp__ =
376 let _loc = "Xxx.comment" in fun sexp -> Common.parse_info_of_sexp sexp
377 and comment_of_sexp sexp =
378 try comment_of_sexp__ sexp
379 with
380 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
381 and com_of_sexp__ =
382 let _loc = "Xxx.com"
383 in fun sexp -> Conv.ref_of_sexp (Conv.list_of_sexp comment_of_sexp) sexp
384 and com_of_sexp sexp =
385 try com_of_sexp__ sexp
386 with
387 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
388
389
390
391
392
393
394
395 (* break let rec ... and with the previous info *)
396 let rec name_of_sexp__ =
397 let _loc = "Xxx.name"
398 in
399 function
400 | (Sexp.List
401 (Sexp.Atom (("regularName" | "RegularName" as tag)) :: sexp_args)
402 as sexp) ->
403 (match sexp_args with
404 | [ v1 ] ->
405 let v1 = wrap_of_sexp Conv.string_of_sexp v1 in RegularName v1
406 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
407 | (Sexp.List
408 (Sexp.Atom (("cppConcatenatedName" | "CppConcatenatedName" as tag)) ::
409 sexp_args)
410 as sexp) ->
411 (match sexp_args with
412 | [ v1 ] ->
413 let v1 =
414 Conv.list_of_sexp
415 (wrap2_of_sexp (wrap_of_sexp Conv.string_of_sexp)) v1
416 in CppConcatenatedName v1
417 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
418 | (Sexp.List
419 (Sexp.Atom (("cppVariadicName" | "CppVariadicName" as tag)) ::
420 sexp_args)
421 as sexp) ->
422 (match sexp_args with
423 | [ v1 ] ->
424 let v1 = wrap_of_sexp Conv.string_of_sexp v1
425 in CppVariadicName v1
426 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
427 | (Sexp.List
428 (Sexp.Atom (("cppIdentBuilder" | "CppIdentBuilder" as tag)) ::
429 sexp_args)
430 as sexp) ->
431 (match sexp_args with
432 | [ v1; v2 ] ->
433 let v1 = wrap_of_sexp Conv.string_of_sexp v1
434 and v2 =
435 Conv.list_of_sexp
436 (wrap2_of_sexp (wrap_of_sexp Conv.string_of_sexp)) v2
437 in CppIdentBuilder ((v1, v2))
438 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
439 | (Sexp.Atom ("regularName" | "RegularName") as sexp) ->
440 Conv_error.stag_takes_args _loc sexp
441 | (Sexp.Atom ("cppConcatenatedName" | "CppConcatenatedName") as sexp) ->
442 Conv_error.stag_takes_args _loc sexp
443 | (Sexp.Atom ("cppVariadicName" | "CppVariadicName") as sexp) ->
444 Conv_error.stag_takes_args _loc sexp
445 | (Sexp.Atom ("cppIdentBuilder" | "CppIdentBuilder") as sexp) ->
446 Conv_error.stag_takes_args _loc sexp
447 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
448 Conv_error.nested_list_invalid_sum _loc sexp
449 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
450 | sexp -> Conv_error.unexpected_stag _loc sexp
451 and name_of_sexp sexp = name_of_sexp__ sexp
452 and fullType_of_sexp__ =
453 let _loc = "Xxx.fullType"
454 in
455 function
456 | Sexp.List ([ v1; v2 ]) ->
457 let v1 = typeQualifier_of_sexp v1
458 and v2 = typeC_of_sexp v2
459 in (v1, v2)
460 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
461 and fullType_of_sexp sexp =
462 try fullType_of_sexp__ sexp
463 with
464 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
465 and typeC_of_sexp__ =
466 let _loc = "Xxx.typeC" in fun sexp -> wrap_of_sexp typeCbis_of_sexp sexp
467 and typeC_of_sexp sexp =
468 try typeC_of_sexp__ sexp
469 with
470 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
471 and typeCbis_of_sexp__ =
472 let _loc = "Xxx.typeCbis"
473 in
474 function
475 | (Sexp.List (Sexp.Atom (("baseType" | "BaseType" as tag)) :: sexp_args)
476 as sexp) ->
477 (match sexp_args with
478 | [ v1 ] -> let v1 = baseType_of_sexp v1 in BaseType v1
479 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
480 | (Sexp.List (Sexp.Atom (("pointer" | "Pointer" as tag)) :: sexp_args) as
481 sexp) ->
482 (match sexp_args with
483 | [ v1 ] -> let v1 = fullType_of_sexp v1 in Pointer v1
484 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
485 | (Sexp.List (Sexp.Atom (("array" | "Array" as tag)) :: sexp_args) as
486 sexp) ->
487 (match sexp_args with
488 | [ v1; v2 ] ->
489 let v1 = Conv.option_of_sexp constExpression_of_sexp v1
490 and v2 = fullType_of_sexp v2
491 in Array ((v1, v2))
492 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
493 | (Sexp.List
494 (Sexp.Atom (("functionType" | "FunctionType" as tag)) :: sexp_args)
495 as sexp) ->
496 (match sexp_args with
497 | [ v1 ] -> let v1 = functionType_of_sexp v1 in FunctionType v1
498 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
499 | (Sexp.List (Sexp.Atom (("enum" | "Enum" as tag)) :: sexp_args) as sexp)
500 ->
501 (match sexp_args with
502 | [ v1; v2 ] ->
503 let v1 = Conv.option_of_sexp Conv.string_of_sexp v1
504 and v2 = enumType_of_sexp v2
505 in Enum ((v1, v2))
506 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
507 | (Sexp.List
508 (Sexp.Atom (("structUnion" | "StructUnion" as tag)) :: sexp_args)
509 as sexp) ->
510 (match sexp_args with
511 | [ v1; v2; v3 ] ->
512 let v1 = structUnion_of_sexp v1
513 and v2 = Conv.option_of_sexp Conv.string_of_sexp v2
514 and v3 = structType_of_sexp v3
515 in StructUnion ((v1, v2, v3))
516 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
517 | (Sexp.List (Sexp.Atom (("enumName" | "EnumName" as tag)) :: sexp_args)
518 as sexp) ->
519 (match sexp_args with
520 | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in EnumName v1
521 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
522 | (Sexp.List
523 (Sexp.Atom (("structUnionName" | "StructUnionName" as tag)) ::
524 sexp_args)
525 as sexp) ->
526 (match sexp_args with
527 | [ v1; v2 ] ->
528 let v1 = structUnion_of_sexp v1
529 and v2 = Conv.string_of_sexp v2
530 in StructUnionName ((v1, v2))
531 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
532 | (Sexp.List (Sexp.Atom (("typeName" | "TypeName" as tag)) :: sexp_args)
533 as sexp) ->
534 (match sexp_args with
535 | [ v1; v2 ] ->
536 let v1 = name_of_sexp v1
537 and v2 = Conv.option_of_sexp fullType_of_sexp v2
538 in TypeName ((v1, v2))
539 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
540 | (Sexp.List
541 (Sexp.Atom (("parenType" | "ParenType" as tag)) :: sexp_args)
542 as sexp) ->
543 (match sexp_args with
544 | [ v1 ] -> let v1 = fullType_of_sexp v1 in ParenType v1
545 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
546 | (Sexp.List
547 (Sexp.Atom (("typeOfExpr" | "TypeOfExpr" as tag)) :: sexp_args)
548 as sexp) ->
549 (match sexp_args with
550 | [ v1 ] -> let v1 = expression_of_sexp v1 in TypeOfExpr v1
551 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
552 | (Sexp.List
553 (Sexp.Atom (("typeOfType" | "TypeOfType" as tag)) :: sexp_args)
554 as sexp) ->
555 (match sexp_args with
556 | [ v1 ] -> let v1 = fullType_of_sexp v1 in TypeOfType v1
557 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
558 | (Sexp.Atom ("baseType" | "BaseType") as sexp) ->
559 Conv_error.stag_takes_args _loc sexp
560 | (Sexp.Atom ("pointer" | "Pointer") as sexp) ->
561 Conv_error.stag_takes_args _loc sexp
562 | (Sexp.Atom ("array" | "Array") as sexp) ->
563 Conv_error.stag_takes_args _loc sexp
564 | (Sexp.Atom ("functionType" | "FunctionType") as sexp) ->
565 Conv_error.stag_takes_args _loc sexp
566 | (Sexp.Atom ("enum" | "Enum") as sexp) ->
567 Conv_error.stag_takes_args _loc sexp
568 | (Sexp.Atom ("structUnion" | "StructUnion") as sexp) ->
569 Conv_error.stag_takes_args _loc sexp
570 | (Sexp.Atom ("enumName" | "EnumName") as sexp) ->
571 Conv_error.stag_takes_args _loc sexp
572 | (Sexp.Atom ("structUnionName" | "StructUnionName") as sexp) ->
573 Conv_error.stag_takes_args _loc sexp
574 | (Sexp.Atom ("typeName" | "TypeName") as sexp) ->
575 Conv_error.stag_takes_args _loc sexp
576 | (Sexp.Atom ("parenType" | "ParenType") as sexp) ->
577 Conv_error.stag_takes_args _loc sexp
578 | (Sexp.Atom ("typeOfExpr" | "TypeOfExpr") as sexp) ->
579 Conv_error.stag_takes_args _loc sexp
580 | (Sexp.Atom ("typeOfType" | "TypeOfType") as sexp) ->
581 Conv_error.stag_takes_args _loc sexp
582 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
583 Conv_error.nested_list_invalid_sum _loc sexp
584 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
585 | sexp -> Conv_error.unexpected_stag _loc sexp
586 and typeCbis_of_sexp sexp = typeCbis_of_sexp__ sexp
587 and baseType_of_sexp__ =
588 let _loc = "Xxx.baseType"
589 in
590 function
591 | Sexp.Atom ("void" | "Void") -> Void
592 | (Sexp.List (Sexp.Atom (("intType" | "IntType" as tag)) :: sexp_args) as
593 sexp) ->
594 (match sexp_args with
595 | [ v1 ] -> let v1 = intType_of_sexp v1 in IntType v1
596 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
597 | (Sexp.List
598 (Sexp.Atom (("floatType" | "FloatType" as tag)) :: sexp_args)
599 as sexp) ->
600 (match sexp_args with
601 | [ v1 ] -> let v1 = floatType_of_sexp v1 in FloatType v1
602 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
603 | (Sexp.List (Sexp.Atom ("void" | "Void") :: _) as sexp) ->
604 Conv_error.stag_no_args _loc sexp
605 | (Sexp.Atom ("intType" | "IntType") as sexp) ->
606 Conv_error.stag_takes_args _loc sexp
607 | (Sexp.Atom ("floatType" | "FloatType") as sexp) ->
608 Conv_error.stag_takes_args _loc sexp
609 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
610 Conv_error.nested_list_invalid_sum _loc sexp
611 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
612 | sexp -> Conv_error.unexpected_stag _loc sexp
613 and baseType_of_sexp sexp = baseType_of_sexp__ sexp
614 and intType_of_sexp__ =
615 let _loc = "Xxx.intType"
616 in
617 function
618 | Sexp.Atom ("cChar" | "CChar") -> CChar
619 | (Sexp.List (Sexp.Atom (("si" | "Si" as tag)) :: sexp_args) as sexp) ->
620 (match sexp_args with
621 | [ v1 ] -> let v1 = signed_of_sexp v1 in Si v1
622 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
623 | (Sexp.List (Sexp.Atom ("cChar" | "CChar") :: _) as sexp) ->
624 Conv_error.stag_no_args _loc sexp
625 | (Sexp.Atom ("si" | "Si") as sexp) ->
626 Conv_error.stag_takes_args _loc sexp
627 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
628 Conv_error.nested_list_invalid_sum _loc sexp
629 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
630 | sexp -> Conv_error.unexpected_stag _loc sexp
631 and intType_of_sexp sexp = intType_of_sexp__ sexp
632 and signed_of_sexp__ =
633 let _loc = "Xxx.signed"
634 in
635 function
636 | Sexp.List ([ v1; v2 ]) ->
637 let v1 = sign_of_sexp v1 and v2 = base_of_sexp v2 in (v1, v2)
638 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
639 and signed_of_sexp sexp =
640 try signed_of_sexp__ sexp
641 with
642 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
643 and base_of_sexp__ =
644 let _loc = "Xxx.base"
645 in
646 function
647 | Sexp.Atom ("cChar2" | "CChar2") -> CChar2
648 | Sexp.Atom ("cShort" | "CShort") -> CShort
649 | Sexp.Atom ("cInt" | "CInt") -> CInt
650 | Sexp.Atom ("cLong" | "CLong") -> CLong
651 | Sexp.Atom ("cLongLong" | "CLongLong") -> CLongLong
652 | (Sexp.List (Sexp.Atom ("cChar2" | "CChar2") :: _) as sexp) ->
653 Conv_error.stag_no_args _loc sexp
654 | (Sexp.List (Sexp.Atom ("cShort" | "CShort") :: _) as sexp) ->
655 Conv_error.stag_no_args _loc sexp
656 | (Sexp.List (Sexp.Atom ("cInt" | "CInt") :: _) as sexp) ->
657 Conv_error.stag_no_args _loc sexp
658 | (Sexp.List (Sexp.Atom ("cLong" | "CLong") :: _) as sexp) ->
659 Conv_error.stag_no_args _loc sexp
660 | (Sexp.List (Sexp.Atom ("cLongLong" | "CLongLong") :: _) as sexp) ->
661 Conv_error.stag_no_args _loc sexp
662 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
663 Conv_error.nested_list_invalid_sum _loc sexp
664 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
665 | sexp -> Conv_error.unexpected_stag _loc sexp
666 and base_of_sexp sexp = base_of_sexp__ sexp
667 and sign_of_sexp__ =
668 let _loc = "Xxx.sign"
669 in
670 function
671 | Sexp.Atom ("signed" | "Signed") -> Signed
672 | Sexp.Atom ("unSigned" | "UnSigned") -> UnSigned
673 | (Sexp.List (Sexp.Atom ("signed" | "Signed") :: _) as sexp) ->
674 Conv_error.stag_no_args _loc sexp
675 | (Sexp.List (Sexp.Atom ("unSigned" | "UnSigned") :: _) as sexp) ->
676 Conv_error.stag_no_args _loc sexp
677 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
678 Conv_error.nested_list_invalid_sum _loc sexp
679 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
680 | sexp -> Conv_error.unexpected_stag _loc sexp
681 and sign_of_sexp sexp = sign_of_sexp__ sexp
682 and floatType_of_sexp__ =
683 let _loc = "Xxx.floatType"
684 in
685 function
686 | Sexp.Atom ("cFloat" | "CFloat") -> CFloat
687 | Sexp.Atom ("cDouble" | "CDouble") -> CDouble
688 | Sexp.Atom ("cLongDouble" | "CLongDouble") -> CLongDouble
689 | (Sexp.List (Sexp.Atom ("cFloat" | "CFloat") :: _) as sexp) ->
690 Conv_error.stag_no_args _loc sexp
691 | (Sexp.List (Sexp.Atom ("cDouble" | "CDouble") :: _) as sexp) ->
692 Conv_error.stag_no_args _loc sexp
693 | (Sexp.List (Sexp.Atom ("cLongDouble" | "CLongDouble") :: _) as sexp) ->
694 Conv_error.stag_no_args _loc sexp
695 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
696 Conv_error.nested_list_invalid_sum _loc sexp
697 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
698 | sexp -> Conv_error.unexpected_stag _loc sexp
699 and floatType_of_sexp sexp = floatType_of_sexp__ sexp
700 and structUnion_of_sexp__ =
701 let _loc = "Xxx.structUnion"
702 in
703 function
704 | Sexp.Atom ("struct" | "Struct") -> Struct
705 | Sexp.Atom ("union" | "Union") -> Union
706 | (Sexp.List (Sexp.Atom ("struct" | "Struct") :: _) as sexp) ->
707 Conv_error.stag_no_args _loc sexp
708 | (Sexp.List (Sexp.Atom ("union" | "Union") :: _) as sexp) ->
709 Conv_error.stag_no_args _loc sexp
710 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
711 Conv_error.nested_list_invalid_sum _loc sexp
712 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
713 | sexp -> Conv_error.unexpected_stag _loc sexp
714 and structUnion_of_sexp sexp = structUnion_of_sexp__ sexp
715 and structType_of_sexp__ =
716 let _loc = "Xxx.structType"
717 in fun sexp -> Conv.list_of_sexp field_of_sexp sexp
718 and structType_of_sexp sexp =
719 try structType_of_sexp__ sexp
720 with
721 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
722 and field_of_sexp__ =
723 let _loc = "Xxx.field"
724 in
725 function
726 | (Sexp.List
727 (Sexp.Atom (("declarationField" | "DeclarationField" as tag)) ::
728 sexp_args)
729 as sexp) ->
730 (match sexp_args with
731 | [ v1 ] ->
732 let v1 = field_declaration_of_sexp v1 in DeclarationField v1
733 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
734 | (Sexp.List
735 (Sexp.Atom (("emptyField" | "EmptyField" as tag)) :: sexp_args)
736 as sexp) ->
737 (match sexp_args with
738 | [ v1 ] -> let v1 = info_of_sexp v1 in EmptyField v1
739 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
740 | (Sexp.List
741 (Sexp.Atom (("macroDeclField" | "MacroDeclField" as tag)) ::
742 sexp_args)
743 as sexp) ->
744 (match sexp_args with
745 | [ v1 ] ->
746 let v1 =
747 wrap_of_sexp
748 (function
749 | Sexp.List ([ v1; v2 ]) ->
750 let v1 = Conv.string_of_sexp v1
751 and v2 =
752 Conv.list_of_sexp (wrap2_of_sexp argument_of_sexp) v2
753 in (v1, v2)
754 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
755 v1
756 in MacroDeclField v1
757 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
758 | (Sexp.List
759 (Sexp.Atom (("cppDirectiveStruct" | "CppDirectiveStruct" as tag)) ::
760 sexp_args)
761 as sexp) ->
762 (match sexp_args with
763 | [ v1 ] ->
764 let v1 = cpp_directive_of_sexp v1 in CppDirectiveStruct v1
765 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
766 | (Sexp.List
767 (Sexp.Atom (("ifdefStruct" | "IfdefStruct" as tag)) :: sexp_args)
768 as sexp) ->
769 (match sexp_args with
770 | [ v1 ] -> let v1 = ifdef_directive_of_sexp v1 in IfdefStruct v1
771 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
772 | (Sexp.Atom ("declarationField" | "DeclarationField") as sexp) ->
773 Conv_error.stag_takes_args _loc sexp
774 | (Sexp.Atom ("emptyField" | "EmptyField") as sexp) ->
775 Conv_error.stag_takes_args _loc sexp
776 | (Sexp.Atom ("macroDeclField" | "MacroDeclField") as sexp) ->
777 Conv_error.stag_takes_args _loc sexp
778 | (Sexp.Atom ("cppDirectiveStruct" | "CppDirectiveStruct") as sexp) ->
779 Conv_error.stag_takes_args _loc sexp
780 | (Sexp.Atom ("ifdefStruct" | "IfdefStruct") as sexp) ->
781 Conv_error.stag_takes_args _loc sexp
782 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
783 Conv_error.nested_list_invalid_sum _loc sexp
784 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
785 | sexp -> Conv_error.unexpected_stag _loc sexp
786 and field_of_sexp sexp = field_of_sexp__ sexp
787 and field_declaration_of_sexp__ =
788 let _loc = "Xxx.field_declaration"
789 in
790 function
791 | (Sexp.List
792 (Sexp.Atom (("fieldDeclList" | "FieldDeclList" as tag)) :: sexp_args)
793 as sexp) ->
794 (match sexp_args with
795 | [ v1 ] ->
796 let v1 =
797 wrap_of_sexp
798 (Conv.list_of_sexp (wrap2_of_sexp fieldkind_of_sexp)) v1
799 in FieldDeclList v1
800 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
801 | (Sexp.Atom ("fieldDeclList" | "FieldDeclList") as sexp) ->
802 Conv_error.stag_takes_args _loc sexp
803 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
804 Conv_error.nested_list_invalid_sum _loc sexp
805 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
806 | sexp -> Conv_error.unexpected_stag _loc sexp
807 and field_declaration_of_sexp sexp = field_declaration_of_sexp__ sexp
808 and fieldkind_of_sexp__ =
809 let _loc = "Xxx.fieldkind"
810 in
811 function
812 | (Sexp.List (Sexp.Atom (("simple" | "Simple" as tag)) :: sexp_args) as
813 sexp) ->
814 (match sexp_args with
815 | [ v1; v2 ] ->
816 let v1 = Conv.option_of_sexp name_of_sexp v1
817 and v2 = fullType_of_sexp v2
818 in Simple ((v1, v2))
819 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
820 | (Sexp.List (Sexp.Atom (("bitField" | "BitField" as tag)) :: sexp_args)
821 as sexp) ->
822 (match sexp_args with
823 | [ v1; v2; v3; v4 ] ->
824 let v1 = Conv.option_of_sexp name_of_sexp v1
825 and v2 = fullType_of_sexp v2
826 and v3 = info_of_sexp v3
827 and v4 = constExpression_of_sexp v4
828 in BitField ((v1, v2, v3, v4))
829 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
830 | (Sexp.Atom ("simple" | "Simple") as sexp) ->
831 Conv_error.stag_takes_args _loc sexp
832 | (Sexp.Atom ("bitField" | "BitField") as sexp) ->
833 Conv_error.stag_takes_args _loc sexp
834 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
835 Conv_error.nested_list_invalid_sum _loc sexp
836 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
837 | sexp -> Conv_error.unexpected_stag _loc sexp
838 and fieldkind_of_sexp sexp = fieldkind_of_sexp__ sexp
839
840 and enumType_of_sexp__ =
841 let _loc = "Xxx.enumType"
842 in
843 fun sexp ->
844 Conv.list_of_sexp
845 (wrap2_of_sexp
846 (function
847 | Sexp.List ([ v1; v2 ]) ->
848 let v1 = name_of_sexp v1
849 and v2 =
850 Conv.option_of_sexp
851 (function
852 | Sexp.List ([ v1; v2 ]) ->
853 let v1 = info_of_sexp v1
854 and v2 = constExpression_of_sexp v2
855 in (v1, v2)
856 | sexp ->
857 Conv_error.tuple_of_size_n_expected _loc 2 sexp)
858 v2
859 in (v1, v2)
860 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp))
861 sexp
862 and enumType_of_sexp sexp =
863 try enumType_of_sexp__ sexp
864 with
865 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
866 and functionType_of_sexp__ =
867 let _loc = "Xxx.functionType"
868 in
869 function
870 | Sexp.List ([ v1; v2 ]) ->
871 let v1 = fullType_of_sexp v1
872 and v2 =
873 (match v2 with
874 | Sexp.List ([ v1; v2 ]) ->
875 let v1 =
876 Conv.list_of_sexp (wrap2_of_sexp parameterType_of_sexp) v1
877 and v2 = wrap_of_sexp Conv.bool_of_sexp v2
878 in (v1, v2)
879 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
880 in (v1, v2)
881 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
882 and functionType_of_sexp sexp =
883 try functionType_of_sexp__ sexp
884 with
885 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
886 and parameterType_of_sexp__ =
887 let _loc = "Xxx.parameterType"
888 in
889 function
890 | (Sexp.List field_sexps as sexp) ->
891 let p_namei_field = ref None and p_register_field = ref None
892 and p_type_field = ref None and duplicates = ref []
893 and extra = ref [] in
894 let rec iter =
895 (function
896 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
897 ((match field_name with
898 | "p_namei" ->
899 (match !p_namei_field with
900 | None ->
901 let fvalue =
902 Conv.option_of_sexp name_of_sexp field_sexp
903 in p_namei_field := Some fvalue
904 | Some _ -> duplicates := field_name :: !duplicates)
905 | "p_register" ->
906 (match !p_register_field with
907 | None ->
908 let fvalue =
909 wrap_of_sexp Conv.bool_of_sexp field_sexp
910 in p_register_field := Some fvalue
911 | Some _ -> duplicates := field_name :: !duplicates)
912 | "p_type" ->
913 (match !p_type_field with
914 | None ->
915 let fvalue = fullType_of_sexp field_sexp
916 in p_type_field := Some fvalue
917 | Some _ -> duplicates := field_name :: !duplicates)
918 | _ ->
919 if !Conv.record_check_extra_fields
920 then extra := field_name :: !extra
921 else ());
922 iter tail)
923 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
924 | [] -> ())
925 in
926 (iter field_sexps;
927 if !duplicates <> []
928 then Conv_error.record_duplicate_fields _loc !duplicates sexp
929 else
930 if !extra <> []
931 then Conv_error.record_extra_fields _loc !extra sexp
932 else
933 (match ((!p_namei_field), (!p_register_field),
934 (!p_type_field))
935 with
936 | (Some p_namei_value, Some p_register_value,
937 Some p_type_value) ->
938 {
939 p_namei = p_namei_value;
940 p_register = p_register_value;
941 p_type = p_type_value;
942 }
943 | _ ->
944 Conv_error.record_undefined_elements _loc sexp
945 [ ((!p_namei_field = None), "p_namei");
946 ((!p_register_field = None), "p_register");
947 ((!p_type_field = None), "p_type") ]))
948 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
949 and parameterType_of_sexp sexp = parameterType_of_sexp__ sexp
950 and typeQualifier_of_sexp__ =
951 let _loc = "Xxx.typeQualifier"
952 in fun sexp -> wrap_of_sexp typeQualifierbis_of_sexp sexp
953 and typeQualifier_of_sexp sexp =
954 try typeQualifier_of_sexp__ sexp
955 with
956 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
957 and typeQualifierbis_of_sexp__ =
958 let _loc = "Xxx.typeQualifierbis"
959 in
960 function
961 | (Sexp.List field_sexps as sexp) ->
962 let const_field = ref None and volatile_field = ref None
963 and duplicates = ref [] and extra = ref [] in
964 let rec iter =
965 (function
966 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
967 ((match field_name with
968 | "const" ->
969 (match !const_field with
970 | None ->
971 let fvalue = Conv.bool_of_sexp field_sexp
972 in const_field := Some fvalue
973 | Some _ -> duplicates := field_name :: !duplicates)
974 | "volatile" ->
975 (match !volatile_field with
976 | None ->
977 let fvalue = Conv.bool_of_sexp field_sexp
978 in volatile_field := Some fvalue
979 | Some _ -> duplicates := field_name :: !duplicates)
980 | _ ->
981 if !Conv.record_check_extra_fields
982 then extra := field_name :: !extra
983 else ());
984 iter tail)
985 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
986 | [] -> ())
987 in
988 (iter field_sexps;
989 if !duplicates <> []
990 then Conv_error.record_duplicate_fields _loc !duplicates sexp
991 else
992 if !extra <> []
993 then Conv_error.record_extra_fields _loc !extra sexp
994 else
995 (match ((!const_field), (!volatile_field)) with
996 | (Some const_value, Some volatile_value) ->
997 { const = const_value; volatile = volatile_value; }
998 | _ ->
999 Conv_error.record_undefined_elements _loc sexp
1000 [ ((!const_field = None), "const");
1001 ((!volatile_field = None), "volatile") ]))
1002 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
1003 and typeQualifierbis_of_sexp sexp = typeQualifierbis_of_sexp__ sexp
1004 and attribute_of_sexp__ =
1005 let _loc = "Xxx.attribute"
1006 in fun sexp -> wrap_of_sexp attributebis_of_sexp sexp
1007 and attribute_of_sexp sexp =
1008 try attribute_of_sexp__ sexp
1009 with
1010 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1011 and attributebis_of_sexp__ =
1012 let _loc = "Xxx.attributebis"
1013 in
1014 function
1015 | (Sexp.List
1016 (Sexp.Atom (("attribute" | "Attribute" as tag)) :: sexp_args)
1017 as sexp) ->
1018 (match sexp_args with
1019 | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in Attribute v1
1020 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1021 | (Sexp.Atom ("attribute" | "Attribute") as sexp) ->
1022 Conv_error.stag_takes_args _loc sexp
1023 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1024 Conv_error.nested_list_invalid_sum _loc sexp
1025 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1026 | sexp -> Conv_error.unexpected_stag _loc sexp
1027 and attributebis_of_sexp sexp = attributebis_of_sexp__ sexp
1028 and expression_of_sexp__ =
1029 let _loc = "Xxx.expression"
1030 in
1031 fun sexp ->
1032 wrap_of_sexp
1033 (function
1034 | Sexp.List ([ v1; v2 ]) ->
1035 let v1 = expressionbis_of_sexp v1
1036 and v2 = Conv.ref_of_sexp exp_info_of_sexp v2
1037 in (v1, v2)
1038 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
1039 sexp
1040 and expression_of_sexp sexp =
1041 try expression_of_sexp__ sexp
1042 with
1043 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1044 and exp_info_of_sexp__ =
1045 let _loc = "Xxx.exp_info"
1046 in
1047 function
1048 | Sexp.List ([ v1; v2 ]) ->
1049 let v1 = Conv.option_of_sexp exp_type_of_sexp v1
1050 and v2 = test_of_sexp v2
1051 in (v1, v2)
1052 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
1053 and exp_info_of_sexp sexp =
1054 try exp_info_of_sexp__ sexp
1055 with
1056 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1057 and exp_type_of_sexp__ =
1058 let _loc = "Xxx.exp_type"
1059 in
1060 function
1061 | Sexp.List ([ v1; v2 ]) ->
1062 let v1 = fullType_of_sexp v1 and v2 = local_of_sexp v2 in (v1, v2)
1063 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
1064 and exp_type_of_sexp sexp =
1065 try exp_type_of_sexp__ sexp
1066 with
1067 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1068 and local_of_sexp__ =
1069 let _loc = "Xxx.local"
1070 in
1071 function
1072 | (Sexp.List (Sexp.Atom (("localVar" | "LocalVar" as tag)) :: sexp_args)
1073 as sexp) ->
1074 (match sexp_args with
1075 | [ v1 ] -> let v1 = parse_info_of_sexp v1 in LocalVar v1
1076 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1077 | Sexp.Atom ("notLocalVar" | "NotLocalVar") -> NotLocalVar
1078 | (Sexp.Atom ("localVar" | "LocalVar") as sexp) ->
1079 Conv_error.stag_takes_args _loc sexp
1080 | (Sexp.List (Sexp.Atom ("notLocalVar" | "NotLocalVar") :: _) as sexp) ->
1081 Conv_error.stag_no_args _loc sexp
1082 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1083 Conv_error.nested_list_invalid_sum _loc sexp
1084 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1085 | sexp -> Conv_error.unexpected_stag _loc sexp
1086 and local_of_sexp sexp = local_of_sexp__ sexp
1087 and test_of_sexp__ =
1088 let _loc = "Xxx.test"
1089 in
1090 function
1091 | Sexp.Atom ("test" | "Test") -> Test
1092 | Sexp.Atom ("notTest" | "NotTest") -> NotTest
1093 | (Sexp.List (Sexp.Atom ("test" | "Test") :: _) as sexp) ->
1094 Conv_error.stag_no_args _loc sexp
1095 | (Sexp.List (Sexp.Atom ("notTest" | "NotTest") :: _) as sexp) ->
1096 Conv_error.stag_no_args _loc sexp
1097 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1098 Conv_error.nested_list_invalid_sum _loc sexp
1099 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1100 | sexp -> Conv_error.unexpected_stag _loc sexp
1101 and test_of_sexp sexp = test_of_sexp__ sexp
1102 and expressionbis_of_sexp__ =
1103 let _loc = "Xxx.expressionbis"
1104 in
1105 function
1106 | (Sexp.List (Sexp.Atom (("ident" | "Ident" as tag)) :: sexp_args) as
1107 sexp) ->
1108 (match sexp_args with
1109 | [ v1 ] -> let v1 = name_of_sexp v1 in Ident v1
1110 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1111 | (Sexp.List (Sexp.Atom (("constant" | "Constant" as tag)) :: sexp_args)
1112 as sexp) ->
1113 (match sexp_args with
1114 | [ v1 ] -> let v1 = constant_of_sexp v1 in Constant v1
1115 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1116 | (Sexp.List (Sexp.Atom (("funCall" | "FunCall" as tag)) :: sexp_args) as
1117 sexp) ->
1118 (match sexp_args with
1119 | [ v1; v2 ] ->
1120 let v1 = expression_of_sexp v1
1121 and v2 = Conv.list_of_sexp (wrap2_of_sexp argument_of_sexp) v2
1122 in FunCall ((v1, v2))
1123 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1124 | (Sexp.List (Sexp.Atom (("condExpr" | "CondExpr" as tag)) :: sexp_args)
1125 as sexp) ->
1126 (match sexp_args with
1127 | [ v1; v2; v3 ] ->
1128 let v1 = expression_of_sexp v1
1129 and v2 = Conv.option_of_sexp expression_of_sexp v2
1130 and v3 = expression_of_sexp v3
1131 in CondExpr ((v1, v2, v3))
1132 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1133 | (Sexp.List (Sexp.Atom (("sequence" | "Sequence" as tag)) :: sexp_args)
1134 as sexp) ->
1135 (match sexp_args with
1136 | [ v1; v2 ] ->
1137 let v1 = expression_of_sexp v1
1138 and v2 = expression_of_sexp v2
1139 in Sequence ((v1, v2))
1140 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1141 | (Sexp.List
1142 (Sexp.Atom (("assignment" | "Assignment" as tag)) :: sexp_args)
1143 as sexp) ->
1144 (match sexp_args with
1145 | [ v1; v2; v3 ] ->
1146 let v1 = expression_of_sexp v1
1147 and v2 = assignOp_of_sexp v2
1148 and v3 = expression_of_sexp v3
1149 in Assignment ((v1, v2, v3))
1150 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1151 | (Sexp.List (Sexp.Atom (("postfix" | "Postfix" as tag)) :: sexp_args) as
1152 sexp) ->
1153 (match sexp_args with
1154 | [ v1; v2 ] ->
1155 let v1 = expression_of_sexp v1
1156 and v2 = fixOp_of_sexp v2
1157 in Postfix ((v1, v2))
1158 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1159 | (Sexp.List (Sexp.Atom (("infix" | "Infix" as tag)) :: sexp_args) as
1160 sexp) ->
1161 (match sexp_args with
1162 | [ v1; v2 ] ->
1163 let v1 = expression_of_sexp v1
1164 and v2 = fixOp_of_sexp v2
1165 in Infix ((v1, v2))
1166 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1167 | (Sexp.List (Sexp.Atom (("unary" | "Unary" as tag)) :: sexp_args) as
1168 sexp) ->
1169 (match sexp_args with
1170 | [ v1; v2 ] ->
1171 let v1 = expression_of_sexp v1
1172 and v2 = unaryOp_of_sexp v2
1173 in Unary ((v1, v2))
1174 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1175 | (Sexp.List (Sexp.Atom (("binary" | "Binary" as tag)) :: sexp_args) as
1176 sexp) ->
1177 (match sexp_args with
1178 | [ v1; v2; v3 ] ->
1179 let v1 = expression_of_sexp v1
1180 and v2 = binaryOp_of_sexp v2
1181 and v3 = expression_of_sexp v3
1182 in Binary ((v1, v2, v3))
1183 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1184 | (Sexp.List
1185 (Sexp.Atom (("arrayAccess" | "ArrayAccess" as tag)) :: sexp_args)
1186 as sexp) ->
1187 (match sexp_args with
1188 | [ v1; v2 ] ->
1189 let v1 = expression_of_sexp v1
1190 and v2 = expression_of_sexp v2
1191 in ArrayAccess ((v1, v2))
1192 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1193 | (Sexp.List
1194 (Sexp.Atom (("recordAccess" | "RecordAccess" as tag)) :: sexp_args)
1195 as sexp) ->
1196 (match sexp_args with
1197 | [ v1; v2 ] ->
1198 let v1 = expression_of_sexp v1
1199 and v2 = name_of_sexp v2
1200 in RecordAccess ((v1, v2))
1201 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1202 | (Sexp.List
1203 (Sexp.Atom (("recordPtAccess" | "RecordPtAccess" as tag)) ::
1204 sexp_args)
1205 as sexp) ->
1206 (match sexp_args with
1207 | [ v1; v2 ] ->
1208 let v1 = expression_of_sexp v1
1209 and v2 = name_of_sexp v2
1210 in RecordPtAccess ((v1, v2))
1211 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1212 | (Sexp.List
1213 (Sexp.Atom (("sizeOfExpr" | "SizeOfExpr" as tag)) :: sexp_args)
1214 as sexp) ->
1215 (match sexp_args with
1216 | [ v1 ] -> let v1 = expression_of_sexp v1 in SizeOfExpr v1
1217 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1218 | (Sexp.List
1219 (Sexp.Atom (("sizeOfType" | "SizeOfType" as tag)) :: sexp_args)
1220 as sexp) ->
1221 (match sexp_args with
1222 | [ v1 ] -> let v1 = fullType_of_sexp v1 in SizeOfType v1
1223 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1224 | (Sexp.List (Sexp.Atom (("cast" | "Cast" as tag)) :: sexp_args) as sexp)
1225 ->
1226 (match sexp_args with
1227 | [ v1; v2 ] ->
1228 let v1 = fullType_of_sexp v1
1229 and v2 = expression_of_sexp v2
1230 in Cast ((v1, v2))
1231 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1232 | (Sexp.List
1233 (Sexp.Atom (("statementExpr" | "StatementExpr" as tag)) :: sexp_args)
1234 as sexp) ->
1235 (match sexp_args with
1236 | [ v1 ] ->
1237 let v1 = wrap_of_sexp compound_of_sexp v1 in StatementExpr v1
1238 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1239 | (Sexp.List
1240 (Sexp.Atom (("constructor" | "Constructor" as tag)) :: sexp_args)
1241 as sexp) ->
1242 (match sexp_args with
1243 | [ v1; v2 ] ->
1244 let v1 = fullType_of_sexp v1
1245 and v2 =
1246 Conv.list_of_sexp (wrap2_of_sexp initialiser_of_sexp) v2
1247 in Constructor ((v1, v2))
1248 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1249 | (Sexp.List
1250 (Sexp.Atom (("parenExpr" | "ParenExpr" as tag)) :: sexp_args)
1251 as sexp) ->
1252 (match sexp_args with
1253 | [ v1 ] -> let v1 = expression_of_sexp v1 in ParenExpr v1
1254 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1255 | (Sexp.Atom ("ident" | "Ident") as sexp) ->
1256 Conv_error.stag_takes_args _loc sexp
1257 | (Sexp.Atom ("constant" | "Constant") as sexp) ->
1258 Conv_error.stag_takes_args _loc sexp
1259 | (Sexp.Atom ("funCall" | "FunCall") as sexp) ->
1260 Conv_error.stag_takes_args _loc sexp
1261 | (Sexp.Atom ("condExpr" | "CondExpr") as sexp) ->
1262 Conv_error.stag_takes_args _loc sexp
1263 | (Sexp.Atom ("sequence" | "Sequence") as sexp) ->
1264 Conv_error.stag_takes_args _loc sexp
1265 | (Sexp.Atom ("assignment" | "Assignment") as sexp) ->
1266 Conv_error.stag_takes_args _loc sexp
1267 | (Sexp.Atom ("postfix" | "Postfix") as sexp) ->
1268 Conv_error.stag_takes_args _loc sexp
1269 | (Sexp.Atom ("infix" | "Infix") as sexp) ->
1270 Conv_error.stag_takes_args _loc sexp
1271 | (Sexp.Atom ("unary" | "Unary") as sexp) ->
1272 Conv_error.stag_takes_args _loc sexp
1273 | (Sexp.Atom ("binary" | "Binary") as sexp) ->
1274 Conv_error.stag_takes_args _loc sexp
1275 | (Sexp.Atom ("arrayAccess" | "ArrayAccess") as sexp) ->
1276 Conv_error.stag_takes_args _loc sexp
1277 | (Sexp.Atom ("recordAccess" | "RecordAccess") as sexp) ->
1278 Conv_error.stag_takes_args _loc sexp
1279 | (Sexp.Atom ("recordPtAccess" | "RecordPtAccess") as sexp) ->
1280 Conv_error.stag_takes_args _loc sexp
1281 | (Sexp.Atom ("sizeOfExpr" | "SizeOfExpr") as sexp) ->
1282 Conv_error.stag_takes_args _loc sexp
1283 | (Sexp.Atom ("sizeOfType" | "SizeOfType") as sexp) ->
1284 Conv_error.stag_takes_args _loc sexp
1285 | (Sexp.Atom ("cast" | "Cast") as sexp) ->
1286 Conv_error.stag_takes_args _loc sexp
1287 | (Sexp.Atom ("statementExpr" | "StatementExpr") as sexp) ->
1288 Conv_error.stag_takes_args _loc sexp
1289 | (Sexp.Atom ("constructor" | "Constructor") as sexp) ->
1290 Conv_error.stag_takes_args _loc sexp
1291 | (Sexp.Atom ("parenExpr" | "ParenExpr") as sexp) ->
1292 Conv_error.stag_takes_args _loc sexp
1293 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1294 Conv_error.nested_list_invalid_sum _loc sexp
1295 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1296 | sexp -> Conv_error.unexpected_stag _loc sexp
1297 and expressionbis_of_sexp sexp = expressionbis_of_sexp__ sexp
1298 and argument_of_sexp__ =
1299 let _loc = "Xxx.argument"
1300 in
1301 fun sexp -> Common.either_of_sexp expression_of_sexp weird_argument_of_sexp sexp
1302 and argument_of_sexp sexp =
1303 try argument_of_sexp__ sexp
1304 with
1305 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1306 and weird_argument_of_sexp__ =
1307 let _loc = "Xxx.weird_argument"
1308 in
1309 function
1310 | (Sexp.List (Sexp.Atom (("argType" | "ArgType" as tag)) :: sexp_args) as
1311 sexp) ->
1312 (match sexp_args with
1313 | [ v1 ] -> let v1 = parameterType_of_sexp v1 in ArgType v1
1314 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1315 | (Sexp.List
1316 (Sexp.Atom (("argAction" | "ArgAction" as tag)) :: sexp_args)
1317 as sexp) ->
1318 (match sexp_args with
1319 | [ v1 ] -> let v1 = action_macro_of_sexp v1 in ArgAction v1
1320 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1321 | (Sexp.Atom ("argType" | "ArgType") as sexp) ->
1322 Conv_error.stag_takes_args _loc sexp
1323 | (Sexp.Atom ("argAction" | "ArgAction") as sexp) ->
1324 Conv_error.stag_takes_args _loc sexp
1325 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1326 Conv_error.nested_list_invalid_sum _loc sexp
1327 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1328 | sexp -> Conv_error.unexpected_stag _loc sexp
1329 and weird_argument_of_sexp sexp = weird_argument_of_sexp__ sexp
1330 and action_macro_of_sexp__ =
1331 let _loc = "Xxx.action_macro"
1332 in
1333 function
1334 | (Sexp.List (Sexp.Atom (("actMisc" | "ActMisc" as tag)) :: sexp_args) as
1335 sexp) ->
1336 (match sexp_args with
1337 | [ v1 ] -> let v1 = il_of_sexp v1 in ActMisc v1
1338 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1339 | (Sexp.Atom ("actMisc" | "ActMisc") as sexp) ->
1340 Conv_error.stag_takes_args _loc sexp
1341 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1342 Conv_error.nested_list_invalid_sum _loc sexp
1343 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1344 | sexp -> Conv_error.unexpected_stag _loc sexp
1345 and action_macro_of_sexp sexp = action_macro_of_sexp__ sexp
1346 and constant_of_sexp__ =
1347 let _loc = "Xxx.constant"
1348 in
1349 function
1350 | (Sexp.List (Sexp.Atom (("string" | "String" as tag)) :: sexp_args) as
1351 sexp) ->
1352 (match sexp_args with
1353 | [ v1 ] ->
1354 let v1 =
1355 (match v1 with
1356 | Sexp.List ([ v1; v2 ]) ->
1357 let v1 = Conv.string_of_sexp v1
1358 and v2 = isWchar_of_sexp v2
1359 in (v1, v2)
1360 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
1361 in String v1
1362 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1363 | (Sexp.List
1364 (Sexp.Atom (("multiString" | "MultiString" as tag)) :: sexp_args)
1365 as sexp) ->
1366 (match sexp_args with
1367 | [ v1 ] ->
1368 let v1 = Conv.list_of_sexp Conv.string_of_sexp v1
1369 in MultiString v1
1370 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1371 | (Sexp.List (Sexp.Atom (("char" | "Char" as tag)) :: sexp_args) as sexp)
1372 ->
1373 (match sexp_args with
1374 | [ v1 ] ->
1375 let v1 =
1376 (match v1 with
1377 | Sexp.List ([ v1; v2 ]) ->
1378 let v1 = Conv.string_of_sexp v1
1379 and v2 = isWchar_of_sexp v2
1380 in (v1, v2)
1381 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
1382 in Char v1
1383 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1384 | (Sexp.List (Sexp.Atom (("int" | "Int" as tag)) :: sexp_args) as sexp)
1385 ->
1386 (match sexp_args with
1387 | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in Int (v1, failwith "Todo")
1388 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1389 | (Sexp.List (Sexp.Atom (("float" | "Float" as tag)) :: sexp_args) as
1390 sexp) ->
1391 (match sexp_args with
1392 | [ v1 ] ->
1393 let v1 =
1394 (match v1 with
1395 | Sexp.List ([ v1; v2 ]) ->
1396 let v1 = Conv.string_of_sexp v1
1397 and v2 = floatType_of_sexp v2
1398 in (v1, v2)
1399 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
1400 in Float v1
1401 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1402 | (Sexp.Atom ("string" | "String") as sexp) ->
1403 Conv_error.stag_takes_args _loc sexp
1404 | (Sexp.Atom ("multiString" | "MultiString") as sexp) ->
1405 Conv_error.stag_takes_args _loc sexp
1406 | (Sexp.Atom ("char" | "Char") as sexp) ->
1407 Conv_error.stag_takes_args _loc sexp
1408 | (Sexp.Atom ("int" | "Int") as sexp) ->
1409 Conv_error.stag_takes_args _loc sexp
1410 | (Sexp.Atom ("float" | "Float") as sexp) ->
1411 Conv_error.stag_takes_args _loc sexp
1412 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1413 Conv_error.nested_list_invalid_sum _loc sexp
1414 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1415 | sexp -> Conv_error.unexpected_stag _loc sexp
1416 and constant_of_sexp sexp = constant_of_sexp__ sexp
1417 and isWchar_of_sexp__ =
1418 let _loc = "Xxx.isWchar"
1419 in
1420 function
1421 | Sexp.Atom ("isWchar" | "IsWchar") -> IsWchar
1422 | Sexp.Atom ("isChar" | "IsChar") -> IsChar
1423 | (Sexp.List (Sexp.Atom ("isWchar" | "IsWchar") :: _) as sexp) ->
1424 Conv_error.stag_no_args _loc sexp
1425 | (Sexp.List (Sexp.Atom ("isChar" | "IsChar") :: _) as sexp) ->
1426 Conv_error.stag_no_args _loc sexp
1427 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1428 Conv_error.nested_list_invalid_sum _loc sexp
1429 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1430 | sexp -> Conv_error.unexpected_stag _loc sexp
1431 and isWchar_of_sexp sexp = isWchar_of_sexp__ sexp
1432 and unaryOp_of_sexp__ =
1433 let _loc = "Xxx.unaryOp"
1434 in
1435 function
1436 | Sexp.Atom ("getRef" | "GetRef") -> GetRef
1437 | Sexp.Atom ("deRef" | "DeRef") -> DeRef
1438 | Sexp.Atom ("unPlus" | "UnPlus") -> UnPlus
1439 | Sexp.Atom ("unMinus" | "UnMinus") -> UnMinus
1440 | Sexp.Atom ("tilde" | "Tilde") -> Tilde
1441 | Sexp.Atom ("not" | "Not") -> Not
1442 | Sexp.Atom ("getRefLabel" | "GetRefLabel") -> GetRefLabel
1443 | (Sexp.List (Sexp.Atom ("getRef" | "GetRef") :: _) as sexp) ->
1444 Conv_error.stag_no_args _loc sexp
1445 | (Sexp.List (Sexp.Atom ("deRef" | "DeRef") :: _) as sexp) ->
1446 Conv_error.stag_no_args _loc sexp
1447 | (Sexp.List (Sexp.Atom ("unPlus" | "UnPlus") :: _) as sexp) ->
1448 Conv_error.stag_no_args _loc sexp
1449 | (Sexp.List (Sexp.Atom ("unMinus" | "UnMinus") :: _) as sexp) ->
1450 Conv_error.stag_no_args _loc sexp
1451 | (Sexp.List (Sexp.Atom ("tilde" | "Tilde") :: _) as sexp) ->
1452 Conv_error.stag_no_args _loc sexp
1453 | (Sexp.List (Sexp.Atom ("not" | "Not") :: _) as sexp) ->
1454 Conv_error.stag_no_args _loc sexp
1455 | (Sexp.List (Sexp.Atom ("getRefLabel" | "GetRefLabel") :: _) as sexp) ->
1456 Conv_error.stag_no_args _loc sexp
1457 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1458 Conv_error.nested_list_invalid_sum _loc sexp
1459 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1460 | sexp -> Conv_error.unexpected_stag _loc sexp
1461 and unaryOp_of_sexp sexp = unaryOp_of_sexp__ sexp
1462 and assignOp_of_sexp__ =
1463 let _loc = "Xxx.assignOp"
1464 in
1465 function
1466 | Sexp.Atom ("simpleAssign" | "SimpleAssign") -> SimpleAssign
1467 | (Sexp.List (Sexp.Atom (("opAssign" | "OpAssign" as tag)) :: sexp_args)
1468 as sexp) ->
1469 (match sexp_args with
1470 | [ v1 ] -> let v1 = arithOp_of_sexp v1 in OpAssign v1
1471 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1472 | (Sexp.List (Sexp.Atom ("simpleAssign" | "SimpleAssign") :: _) as sexp)
1473 -> Conv_error.stag_no_args _loc sexp
1474 | (Sexp.Atom ("opAssign" | "OpAssign") as sexp) ->
1475 Conv_error.stag_takes_args _loc sexp
1476 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1477 Conv_error.nested_list_invalid_sum _loc sexp
1478 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1479 | sexp -> Conv_error.unexpected_stag _loc sexp
1480 and assignOp_of_sexp sexp = assignOp_of_sexp__ sexp
1481 and fixOp_of_sexp__ =
1482 let _loc = "Xxx.fixOp"
1483 in
1484 function
1485 | Sexp.Atom ("dec" | "Dec") -> Dec
1486 | Sexp.Atom ("inc" | "Inc") -> Inc
1487 | (Sexp.List (Sexp.Atom ("dec" | "Dec") :: _) as sexp) ->
1488 Conv_error.stag_no_args _loc sexp
1489 | (Sexp.List (Sexp.Atom ("inc" | "Inc") :: _) as sexp) ->
1490 Conv_error.stag_no_args _loc sexp
1491 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1492 Conv_error.nested_list_invalid_sum _loc sexp
1493 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1494 | sexp -> Conv_error.unexpected_stag _loc sexp
1495 and fixOp_of_sexp sexp = fixOp_of_sexp__ sexp
1496 and binaryOp_of_sexp__ =
1497 let _loc = "Xxx.binaryOp"
1498 in
1499 function
1500 | (Sexp.List (Sexp.Atom (("arith" | "Arith" as tag)) :: sexp_args) as
1501 sexp) ->
1502 (match sexp_args with
1503 | [ v1 ] -> let v1 = arithOp_of_sexp v1 in Arith v1
1504 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1505 | (Sexp.List (Sexp.Atom (("logical" | "Logical" as tag)) :: sexp_args) as
1506 sexp) ->
1507 (match sexp_args with
1508 | [ v1 ] -> let v1 = logicalOp_of_sexp v1 in Logical v1
1509 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1510 | (Sexp.Atom ("arith" | "Arith") as sexp) ->
1511 Conv_error.stag_takes_args _loc sexp
1512 | (Sexp.Atom ("logical" | "Logical") as sexp) ->
1513 Conv_error.stag_takes_args _loc sexp
1514 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1515 Conv_error.nested_list_invalid_sum _loc sexp
1516 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1517 | sexp -> Conv_error.unexpected_stag _loc sexp
1518 and binaryOp_of_sexp sexp = binaryOp_of_sexp__ sexp
1519 and arithOp_of_sexp__ =
1520 let _loc = "Xxx.arithOp"
1521 in
1522 function
1523 | Sexp.Atom ("plus" | "Plus") -> Plus
1524 | Sexp.Atom ("minus" | "Minus") -> Minus
1525 | Sexp.Atom ("mul" | "Mul") -> Mul
1526 | Sexp.Atom ("div" | "Div") -> Div
1527 | Sexp.Atom ("mod" | "Mod") -> Mod
1528 | Sexp.Atom ("decLeft" | "DecLeft") -> DecLeft
1529 | Sexp.Atom ("decRight" | "DecRight") -> DecRight
1530 | Sexp.Atom ("and" | "And") -> And
1531 | Sexp.Atom ("or" | "Or") -> Or
1532 | Sexp.Atom ("xor" | "Xor") -> Xor
1533 | (Sexp.List (Sexp.Atom ("plus" | "Plus") :: _) as sexp) ->
1534 Conv_error.stag_no_args _loc sexp
1535 | (Sexp.List (Sexp.Atom ("minus" | "Minus") :: _) as sexp) ->
1536 Conv_error.stag_no_args _loc sexp
1537 | (Sexp.List (Sexp.Atom ("mul" | "Mul") :: _) as sexp) ->
1538 Conv_error.stag_no_args _loc sexp
1539 | (Sexp.List (Sexp.Atom ("div" | "Div") :: _) as sexp) ->
1540 Conv_error.stag_no_args _loc sexp
1541 | (Sexp.List (Sexp.Atom ("mod" | "Mod") :: _) as sexp) ->
1542 Conv_error.stag_no_args _loc sexp
1543 | (Sexp.List (Sexp.Atom ("decLeft" | "DecLeft") :: _) as sexp) ->
1544 Conv_error.stag_no_args _loc sexp
1545 | (Sexp.List (Sexp.Atom ("decRight" | "DecRight") :: _) as sexp) ->
1546 Conv_error.stag_no_args _loc sexp
1547 | (Sexp.List (Sexp.Atom ("and" | "And") :: _) as sexp) ->
1548 Conv_error.stag_no_args _loc sexp
1549 | (Sexp.List (Sexp.Atom ("or" | "Or") :: _) as sexp) ->
1550 Conv_error.stag_no_args _loc sexp
1551 | (Sexp.List (Sexp.Atom ("xor" | "Xor") :: _) as sexp) ->
1552 Conv_error.stag_no_args _loc sexp
1553 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1554 Conv_error.nested_list_invalid_sum _loc sexp
1555 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1556 | sexp -> Conv_error.unexpected_stag _loc sexp
1557 and arithOp_of_sexp sexp = arithOp_of_sexp__ sexp
1558 and logicalOp_of_sexp__ =
1559 let _loc = "Xxx.logicalOp"
1560 in
1561 function
1562 | Sexp.Atom ("inf" | "Inf") -> Inf
1563 | Sexp.Atom ("sup" | "Sup") -> Sup
1564 | Sexp.Atom ("infEq" | "InfEq") -> InfEq
1565 | Sexp.Atom ("supEq" | "SupEq") -> SupEq
1566 | Sexp.Atom ("eq" | "Eq") -> Eq
1567 | Sexp.Atom ("notEq" | "NotEq") -> NotEq
1568 | Sexp.Atom ("andLog" | "AndLog") -> AndLog
1569 | Sexp.Atom ("orLog" | "OrLog") -> OrLog
1570 | (Sexp.List (Sexp.Atom ("inf" | "Inf") :: _) as sexp) ->
1571 Conv_error.stag_no_args _loc sexp
1572 | (Sexp.List (Sexp.Atom ("sup" | "Sup") :: _) as sexp) ->
1573 Conv_error.stag_no_args _loc sexp
1574 | (Sexp.List (Sexp.Atom ("infEq" | "InfEq") :: _) as sexp) ->
1575 Conv_error.stag_no_args _loc sexp
1576 | (Sexp.List (Sexp.Atom ("supEq" | "SupEq") :: _) as sexp) ->
1577 Conv_error.stag_no_args _loc sexp
1578 | (Sexp.List (Sexp.Atom ("eq" | "Eq") :: _) as sexp) ->
1579 Conv_error.stag_no_args _loc sexp
1580 | (Sexp.List (Sexp.Atom ("notEq" | "NotEq") :: _) as sexp) ->
1581 Conv_error.stag_no_args _loc sexp
1582 | (Sexp.List (Sexp.Atom ("andLog" | "AndLog") :: _) as sexp) ->
1583 Conv_error.stag_no_args _loc sexp
1584 | (Sexp.List (Sexp.Atom ("orLog" | "OrLog") :: _) as sexp) ->
1585 Conv_error.stag_no_args _loc sexp
1586 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1587 Conv_error.nested_list_invalid_sum _loc sexp
1588 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1589 | sexp -> Conv_error.unexpected_stag _loc sexp
1590 and logicalOp_of_sexp sexp = logicalOp_of_sexp__ sexp
1591 and constExpression_of_sexp__ =
1592 let _loc = "Xxx.constExpression" in fun sexp -> expression_of_sexp sexp
1593 and constExpression_of_sexp sexp =
1594 try constExpression_of_sexp__ sexp
1595 with
1596 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1597 and statement_of_sexp__ =
1598 let _loc = "Xxx.statement"
1599 in fun sexp -> wrap_of_sexp statementbis_of_sexp sexp
1600 and statement_of_sexp sexp =
1601 try statement_of_sexp__ sexp
1602 with
1603 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1604 and statementbis_of_sexp__ =
1605 let _loc = "Xxx.statementbis"
1606 in
1607 function
1608 | (Sexp.List (Sexp.Atom (("labeled" | "Labeled" as tag)) :: sexp_args) as
1609 sexp) ->
1610 (match sexp_args with
1611 | [ v1 ] -> let v1 = labeled_of_sexp v1 in Labeled v1
1612 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1613 | (Sexp.List (Sexp.Atom (("compound" | "Compound" as tag)) :: sexp_args)
1614 as sexp) ->
1615 (match sexp_args with
1616 | [ v1 ] -> let v1 = compound_of_sexp v1 in Compound v1
1617 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1618 | (Sexp.List
1619 (Sexp.Atom (("exprStatement" | "ExprStatement" as tag)) :: sexp_args)
1620 as sexp) ->
1621 (match sexp_args with
1622 | [ v1 ] -> let v1 = exprStatement_of_sexp v1 in ExprStatement v1
1623 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1624 | (Sexp.List
1625 (Sexp.Atom (("selection" | "Selection" as tag)) :: sexp_args)
1626 as sexp) ->
1627 (match sexp_args with
1628 | [ v1 ] -> let v1 = selection_of_sexp v1 in Selection v1
1629 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1630 | (Sexp.List
1631 (Sexp.Atom (("iteration" | "Iteration" as tag)) :: sexp_args)
1632 as sexp) ->
1633 (match sexp_args with
1634 | [ v1 ] -> let v1 = iteration_of_sexp v1 in Iteration v1
1635 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1636 | (Sexp.List (Sexp.Atom (("jump" | "Jump" as tag)) :: sexp_args) as sexp)
1637 ->
1638 (match sexp_args with
1639 | [ v1 ] -> let v1 = jump_of_sexp v1 in Jump v1
1640 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1641 | (Sexp.List (Sexp.Atom (("decl" | "Decl" as tag)) :: sexp_args) as sexp)
1642 ->
1643 (match sexp_args with
1644 | [ v1 ] -> let v1 = declaration_of_sexp v1 in Decl v1
1645 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1646 | (Sexp.List (Sexp.Atom (("asm" | "Asm" as tag)) :: sexp_args) as sexp)
1647 ->
1648 (match sexp_args with
1649 | [ v1 ] -> let v1 = asmbody_of_sexp v1 in Asm v1
1650 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1651 | (Sexp.List
1652 (Sexp.Atom (("nestedFunc" | "NestedFunc" as tag)) :: sexp_args)
1653 as sexp) ->
1654 (match sexp_args with
1655 | [ v1 ] -> let v1 = definition_of_sexp v1 in NestedFunc v1
1656 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1657 | Sexp.Atom ("macroStmt" | "MacroStmt") -> MacroStmt
1658 | (Sexp.Atom ("labeled" | "Labeled") as sexp) ->
1659 Conv_error.stag_takes_args _loc sexp
1660 | (Sexp.Atom ("compound" | "Compound") as sexp) ->
1661 Conv_error.stag_takes_args _loc sexp
1662 | (Sexp.Atom ("exprStatement" | "ExprStatement") as sexp) ->
1663 Conv_error.stag_takes_args _loc sexp
1664 | (Sexp.Atom ("selection" | "Selection") as sexp) ->
1665 Conv_error.stag_takes_args _loc sexp
1666 | (Sexp.Atom ("iteration" | "Iteration") as sexp) ->
1667 Conv_error.stag_takes_args _loc sexp
1668 | (Sexp.Atom ("jump" | "Jump") as sexp) ->
1669 Conv_error.stag_takes_args _loc sexp
1670 | (Sexp.Atom ("decl" | "Decl") as sexp) ->
1671 Conv_error.stag_takes_args _loc sexp
1672 | (Sexp.Atom ("asm" | "Asm") as sexp) ->
1673 Conv_error.stag_takes_args _loc sexp
1674 | (Sexp.Atom ("nestedFunc" | "NestedFunc") as sexp) ->
1675 Conv_error.stag_takes_args _loc sexp
1676 | (Sexp.List (Sexp.Atom ("macroStmt" | "MacroStmt") :: _) as sexp) ->
1677 Conv_error.stag_no_args _loc sexp
1678 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1679 Conv_error.nested_list_invalid_sum _loc sexp
1680 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1681 | sexp -> Conv_error.unexpected_stag _loc sexp
1682 and statementbis_of_sexp sexp = statementbis_of_sexp__ sexp
1683 and labeled_of_sexp__ =
1684 let _loc = "Xxx.labeled"
1685 in
1686 function
1687 | (Sexp.List (Sexp.Atom (("label" | "Label" as tag)) :: sexp_args) as
1688 sexp) ->
1689 (match sexp_args with
1690 | [ v1; v2 ] ->
1691 let v1 = name_of_sexp v1
1692 and v2 = statement_of_sexp v2
1693 in Label ((v1, v2))
1694 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1695 | (Sexp.List (Sexp.Atom (("case" | "Case" as tag)) :: sexp_args) as sexp)
1696 ->
1697 (match sexp_args with
1698 | [ v1; v2 ] ->
1699 let v1 = expression_of_sexp v1
1700 and v2 = statement_of_sexp v2
1701 in Case ((v1, v2))
1702 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1703 | (Sexp.List
1704 (Sexp.Atom (("caseRange" | "CaseRange" as tag)) :: sexp_args)
1705 as sexp) ->
1706 (match sexp_args with
1707 | [ v1; v2; v3 ] ->
1708 let v1 = expression_of_sexp v1
1709 and v2 = expression_of_sexp v2
1710 and v3 = statement_of_sexp v3
1711 in CaseRange ((v1, v2, v3))
1712 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1713 | (Sexp.List (Sexp.Atom (("default" | "Default" as tag)) :: sexp_args) as
1714 sexp) ->
1715 (match sexp_args with
1716 | [ v1 ] -> let v1 = statement_of_sexp v1 in Default v1
1717 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1718 | (Sexp.Atom ("label" | "Label") as sexp) ->
1719 Conv_error.stag_takes_args _loc sexp
1720 | (Sexp.Atom ("case" | "Case") as sexp) ->
1721 Conv_error.stag_takes_args _loc sexp
1722 | (Sexp.Atom ("caseRange" | "CaseRange") as sexp) ->
1723 Conv_error.stag_takes_args _loc sexp
1724 | (Sexp.Atom ("default" | "Default") as sexp) ->
1725 Conv_error.stag_takes_args _loc sexp
1726 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1727 Conv_error.nested_list_invalid_sum _loc sexp
1728 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1729 | sexp -> Conv_error.unexpected_stag _loc sexp
1730 and labeled_of_sexp sexp = labeled_of_sexp__ sexp
1731 and compound_of_sexp__ =
1732 let _loc = "Xxx.compound"
1733 in fun sexp -> Conv.list_of_sexp statement_sequencable_of_sexp sexp
1734 and compound_of_sexp sexp =
1735 try compound_of_sexp__ sexp
1736 with
1737 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1738 and statement_sequencable_of_sexp__ =
1739 let _loc = "Xxx.statement_sequencable"
1740 in
1741 function
1742 | (Sexp.List (Sexp.Atom (("stmtElem" | "StmtElem" as tag)) :: sexp_args)
1743 as sexp) ->
1744 (match sexp_args with
1745 | [ v1 ] -> let v1 = statement_of_sexp v1 in StmtElem v1
1746 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1747 | (Sexp.List
1748 (Sexp.Atom (("cppDirectiveStmt" | "CppDirectiveStmt" as tag)) ::
1749 sexp_args)
1750 as sexp) ->
1751 (match sexp_args with
1752 | [ v1 ] -> let v1 = cpp_directive_of_sexp v1 in CppDirectiveStmt v1
1753 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1754 | (Sexp.List
1755 (Sexp.Atom (("ifdefStmt" | "IfdefStmt" as tag)) :: sexp_args)
1756 as sexp) ->
1757 (match sexp_args with
1758 | [ v1 ] -> let v1 = ifdef_directive_of_sexp v1 in IfdefStmt v1
1759 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1760 | (Sexp.List
1761 (Sexp.Atom (("ifdefStmt2" | "IfdefStmt2" as tag)) :: sexp_args)
1762 as sexp) ->
1763 (match sexp_args with
1764 | [ v1; v2 ] ->
1765 let v1 = Conv.list_of_sexp ifdef_directive_of_sexp v1
1766 and v2 =
1767 Conv.list_of_sexp
1768 (Conv.list_of_sexp statement_sequencable_of_sexp) v2
1769 in IfdefStmt2 ((v1, v2))
1770 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1771 | (Sexp.Atom ("stmtElem" | "StmtElem") as sexp) ->
1772 Conv_error.stag_takes_args _loc sexp
1773 | (Sexp.Atom ("cppDirectiveStmt" | "CppDirectiveStmt") as sexp) ->
1774 Conv_error.stag_takes_args _loc sexp
1775 | (Sexp.Atom ("ifdefStmt" | "IfdefStmt") as sexp) ->
1776 Conv_error.stag_takes_args _loc sexp
1777 | (Sexp.Atom ("ifdefStmt2" | "IfdefStmt2") as sexp) ->
1778 Conv_error.stag_takes_args _loc sexp
1779 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1780 Conv_error.nested_list_invalid_sum _loc sexp
1781 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1782 | sexp -> Conv_error.unexpected_stag _loc sexp
1783 and statement_sequencable_of_sexp sexp = statement_sequencable_of_sexp__ sexp
1784 and exprStatement_of_sexp__ =
1785 let _loc = "Xxx.exprStatement"
1786 in fun sexp -> Conv.option_of_sexp expression_of_sexp sexp
1787 and exprStatement_of_sexp sexp =
1788 try exprStatement_of_sexp__ sexp
1789 with
1790 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1791 and selection_of_sexp__ =
1792 let _loc = "Xxx.selection"
1793 in
1794 function
1795 | (Sexp.List (Sexp.Atom (("if" | "If" as tag)) :: sexp_args) as sexp) ->
1796 (match sexp_args with
1797 | [ v1; v2; v3 ] ->
1798 let v1 = expression_of_sexp v1
1799 and v2 = statement_of_sexp v2
1800 and v3 = statement_of_sexp v3
1801 in If ((v1, v2, v3))
1802 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1803 | (Sexp.List (Sexp.Atom (("switch" | "Switch" as tag)) :: sexp_args) as
1804 sexp) ->
1805 (match sexp_args with
1806 | [ v1; v2 ] ->
1807 let v1 = expression_of_sexp v1
1808 and v2 = statement_of_sexp v2
1809 in Switch ((v1, v2))
1810 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1811 | (Sexp.Atom ("if" | "If") as sexp) ->
1812 Conv_error.stag_takes_args _loc sexp
1813 | (Sexp.Atom ("switch" | "Switch") as sexp) ->
1814 Conv_error.stag_takes_args _loc sexp
1815 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1816 Conv_error.nested_list_invalid_sum _loc sexp
1817 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1818 | sexp -> Conv_error.unexpected_stag _loc sexp
1819 and selection_of_sexp sexp = selection_of_sexp__ sexp
1820 and iteration_of_sexp__ =
1821 let _loc = "Xxx.iteration"
1822 in
1823 function
1824 | (Sexp.List (Sexp.Atom (("while" | "While" as tag)) :: sexp_args) as
1825 sexp) ->
1826 (match sexp_args with
1827 | [ v1; v2 ] ->
1828 let v1 = expression_of_sexp v1
1829 and v2 = statement_of_sexp v2
1830 in While ((v1, v2))
1831 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1832 | (Sexp.List (Sexp.Atom (("doWhile" | "DoWhile" as tag)) :: sexp_args) as
1833 sexp) ->
1834 (match sexp_args with
1835 | [ v1; v2 ] ->
1836 let v1 = statement_of_sexp v1
1837 and v2 = expression_of_sexp v2
1838 in DoWhile ((v1, v2))
1839 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1840 | (Sexp.List (Sexp.Atom (("for" | "For" as tag)) :: sexp_args) as sexp)
1841 ->
1842 (match sexp_args with
1843 | [ v1; v2; v3; v4 ] ->
1844 let v1 = wrap_of_sexp exprStatement_of_sexp v1
1845 and v2 = wrap_of_sexp exprStatement_of_sexp v2
1846 and v3 = wrap_of_sexp exprStatement_of_sexp v3
1847 and v4 = statement_of_sexp v4
1848 in For ((v1, v2, v3, v4))
1849 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1850 | (Sexp.List
1851 (Sexp.Atom (("macroIteration" | "MacroIteration" as tag)) ::
1852 sexp_args)
1853 as sexp) ->
1854 (match sexp_args with
1855 | [ v1; v2; v3 ] ->
1856 let v1 = Conv.string_of_sexp v1
1857 and v2 = Conv.list_of_sexp (wrap2_of_sexp argument_of_sexp) v2
1858 and v3 = statement_of_sexp v3
1859 in MacroIteration ((v1, v2, v3))
1860 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1861 | (Sexp.Atom ("while" | "While") as sexp) ->
1862 Conv_error.stag_takes_args _loc sexp
1863 | (Sexp.Atom ("doWhile" | "DoWhile") as sexp) ->
1864 Conv_error.stag_takes_args _loc sexp
1865 | (Sexp.Atom ("for" | "For") as sexp) ->
1866 Conv_error.stag_takes_args _loc sexp
1867 | (Sexp.Atom ("macroIteration" | "MacroIteration") as sexp) ->
1868 Conv_error.stag_takes_args _loc sexp
1869 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1870 Conv_error.nested_list_invalid_sum _loc sexp
1871 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1872 | sexp -> Conv_error.unexpected_stag _loc sexp
1873 and iteration_of_sexp sexp = iteration_of_sexp__ sexp
1874 and jump_of_sexp__ =
1875 let _loc = "Xxx.jump"
1876 in
1877 function
1878 | (Sexp.List (Sexp.Atom (("goto" | "Goto" as tag)) :: sexp_args) as sexp)
1879 ->
1880 (match sexp_args with
1881 | [ v1 ] -> let v1 = name_of_sexp v1 in Goto v1
1882 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1883 | Sexp.Atom ("continue" | "Continue") -> Continue
1884 | Sexp.Atom ("break" | "Break") -> Break
1885 | Sexp.Atom ("return" | "Return") -> Return
1886 | (Sexp.List
1887 (Sexp.Atom (("returnExpr" | "ReturnExpr" as tag)) :: sexp_args)
1888 as sexp) ->
1889 (match sexp_args with
1890 | [ v1 ] -> let v1 = expression_of_sexp v1 in ReturnExpr v1
1891 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1892 | (Sexp.List
1893 (Sexp.Atom (("gotoComputed" | "GotoComputed" as tag)) :: sexp_args)
1894 as sexp) ->
1895 (match sexp_args with
1896 | [ v1 ] -> let v1 = expression_of_sexp v1 in GotoComputed v1
1897 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1898 | (Sexp.Atom ("goto" | "Goto") as sexp) ->
1899 Conv_error.stag_takes_args _loc sexp
1900 | (Sexp.List (Sexp.Atom ("continue" | "Continue") :: _) as sexp) ->
1901 Conv_error.stag_no_args _loc sexp
1902 | (Sexp.List (Sexp.Atom ("break" | "Break") :: _) as sexp) ->
1903 Conv_error.stag_no_args _loc sexp
1904 | (Sexp.List (Sexp.Atom ("return" | "Return") :: _) as sexp) ->
1905 Conv_error.stag_no_args _loc sexp
1906 | (Sexp.Atom ("returnExpr" | "ReturnExpr") as sexp) ->
1907 Conv_error.stag_takes_args _loc sexp
1908 | (Sexp.Atom ("gotoComputed" | "GotoComputed") as sexp) ->
1909 Conv_error.stag_takes_args _loc sexp
1910 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1911 Conv_error.nested_list_invalid_sum _loc sexp
1912 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1913 | sexp -> Conv_error.unexpected_stag _loc sexp
1914 and jump_of_sexp sexp = jump_of_sexp__ sexp
1915 and asmbody_of_sexp__ =
1916 let _loc = "Xxx.asmbody"
1917 in
1918 function
1919 | Sexp.List ([ v1; v2 ]) ->
1920 let v1 = il_of_sexp v1
1921 and v2 = Conv.list_of_sexp (wrap_of_sexp colon_of_sexp) v2
1922 in (v1, v2)
1923 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
1924 and asmbody_of_sexp sexp =
1925 try asmbody_of_sexp__ sexp
1926 with
1927 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1928 and colon_of_sexp__ =
1929 let _loc = "Xxx.colon"
1930 in
1931 function
1932 | (Sexp.List (Sexp.Atom (("colon" | "Colon" as tag)) :: sexp_args) as
1933 sexp) ->
1934 (match sexp_args with
1935 | [ v1 ] ->
1936 let v1 =
1937 Conv.list_of_sexp (wrap2_of_sexp colon_option_of_sexp) v1
1938 in Colon v1
1939 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1940 | (Sexp.Atom ("colon" | "Colon") as sexp) ->
1941 Conv_error.stag_takes_args _loc sexp
1942 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1943 Conv_error.nested_list_invalid_sum _loc sexp
1944 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1945 | sexp -> Conv_error.unexpected_stag _loc sexp
1946 and colon_of_sexp sexp = colon_of_sexp__ sexp
1947 and colon_option_of_sexp__ =
1948 let _loc = "Xxx.colon_option"
1949 in fun sexp -> wrap_of_sexp colon_option_bis_of_sexp sexp
1950 and colon_option_of_sexp sexp =
1951 try colon_option_of_sexp__ sexp
1952 with
1953 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
1954 and colon_option_bis_of_sexp__ =
1955 let _loc = "Xxx.colon_option_bis"
1956 in
1957 function
1958 | Sexp.Atom ("colonMisc" | "ColonMisc") -> ColonMisc
1959 | (Sexp.List
1960 (Sexp.Atom (("colonExpr" | "ColonExpr" as tag)) :: sexp_args)
1961 as sexp) ->
1962 (match sexp_args with
1963 | [ v1 ] -> let v1 = expression_of_sexp v1 in ColonExpr v1
1964 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1965 | (Sexp.List (Sexp.Atom ("colonMisc" | "ColonMisc") :: _) as sexp) ->
1966 Conv_error.stag_no_args _loc sexp
1967 | (Sexp.Atom ("colonExpr" | "ColonExpr") as sexp) ->
1968 Conv_error.stag_takes_args _loc sexp
1969 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
1970 Conv_error.nested_list_invalid_sum _loc sexp
1971 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
1972 | sexp -> Conv_error.unexpected_stag _loc sexp
1973 and colon_option_bis_of_sexp sexp = colon_option_bis_of_sexp__ sexp
1974 and declaration_of_sexp__ =
1975 let _loc = "Xxx.declaration"
1976 in
1977 function
1978 | (Sexp.List (Sexp.Atom (("declList" | "DeclList" as tag)) :: sexp_args)
1979 as sexp) ->
1980 (match sexp_args with
1981 | [ v1 ] ->
1982 let v1 =
1983 wrap_of_sexp
1984 (Conv.list_of_sexp (wrap2_of_sexp onedecl_of_sexp)) v1
1985 in DeclList v1
1986 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
1987 | (Sexp.List
1988 (Sexp.Atom (("macroDecl" | "MacroDecl" as tag)) :: sexp_args)
1989 as sexp) ->
1990 (match sexp_args with
1991 | [ v1 ] ->
1992 let v1 =
1993 wrap_of_sexp
1994 (function
1995 | Sexp.List ([ v1; v2 ]) ->
1996 let v1 = Conv.string_of_sexp v1
1997 and v2 =
1998 Conv.list_of_sexp (wrap2_of_sexp argument_of_sexp) v2
1999 in (v1, v2)
2000 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
2001 v1
2002 in MacroDecl v1
2003 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2004 | (Sexp.Atom ("declList" | "DeclList") as sexp) ->
2005 Conv_error.stag_takes_args _loc sexp
2006 | (Sexp.Atom ("macroDecl" | "MacroDecl") as sexp) ->
2007 Conv_error.stag_takes_args _loc sexp
2008 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2009 Conv_error.nested_list_invalid_sum _loc sexp
2010 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2011 | sexp -> Conv_error.unexpected_stag _loc sexp
2012 and declaration_of_sexp sexp = declaration_of_sexp__ sexp
2013 and onedecl_of_sexp__ =
2014 let _loc = "Xxx.onedecl"
2015 in
2016 function
2017 | (Sexp.List field_sexps as sexp) ->
2018 let v_namei_field = ref None and v_type_field = ref None
2019 and v_type_bis_field = ref None and v_storage_field = ref None
2020 and v_local_field = ref None and v_attr_field = ref None
2021 and duplicates = ref [] and extra = ref [] in
2022 let rec iter =
2023 (function
2024 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
2025 ((match field_name with
2026 | "v_namei" ->
2027 (match !v_namei_field with
2028 | None ->
2029 let fvalue =
2030 Conv.option_of_sexp
2031 (function
2032 | Sexp.List ([ v1; v2 ]) ->
2033 let v1 = name_of_sexp v1
2034 and v2 =
2035 Conv.option_of_sexp
2036 (function
2037 | Sexp.List ([ v1; v2 ]) ->
2038 let v1 = info_of_sexp v1
2039 and v2 = initialiser_of_sexp v2
2040 in (v1, v2)
2041 | sexp ->
2042 Conv_error.
2043 tuple_of_size_n_expected _loc 2
2044 sexp)
2045 v2
2046 in (v1, v2)
2047 | sexp ->
2048 Conv_error.tuple_of_size_n_expected _loc 2
2049 sexp)
2050 field_sexp
2051 in v_namei_field := Some fvalue
2052 | Some _ -> duplicates := field_name :: !duplicates)
2053 | "v_type" ->
2054 (match !v_type_field with
2055 | None ->
2056 let fvalue = fullType_of_sexp field_sexp
2057 in v_type_field := Some fvalue
2058 | Some _ -> duplicates := field_name :: !duplicates)
2059 | "v_type_bis" ->
2060 (match !v_type_bis_field with
2061 | None ->
2062 let fvalue =
2063 Conv.ref_of_sexp
2064 (Conv.option_of_sexp fullType_of_sexp)
2065 field_sexp
2066 in v_type_bis_field := Some fvalue
2067 | Some _ -> duplicates := field_name :: !duplicates)
2068 | "v_storage" ->
2069 (match !v_storage_field with
2070 | None ->
2071 let fvalue = storage_of_sexp field_sexp
2072 in v_storage_field := Some fvalue
2073 | Some _ -> duplicates := field_name :: !duplicates)
2074 | "v_local" ->
2075 (match !v_local_field with
2076 | None ->
2077 let fvalue = local_decl_of_sexp field_sexp
2078 in v_local_field := Some fvalue
2079 | Some _ -> duplicates := field_name :: !duplicates)
2080 | "v_attr" ->
2081 (match !v_attr_field with
2082 | None ->
2083 let fvalue =
2084 Conv.list_of_sexp attribute_of_sexp field_sexp
2085 in v_attr_field := Some fvalue
2086 | Some _ -> duplicates := field_name :: !duplicates)
2087 | _ ->
2088 if !Conv.record_check_extra_fields
2089 then extra := field_name :: !extra
2090 else ());
2091 iter tail)
2092 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
2093 | [] -> ())
2094 in
2095 (iter field_sexps;
2096 if !duplicates <> []
2097 then Conv_error.record_duplicate_fields _loc !duplicates sexp
2098 else
2099 if !extra <> []
2100 then Conv_error.record_extra_fields _loc !extra sexp
2101 else
2102 (match ((!v_namei_field), (!v_type_field),
2103 (!v_type_bis_field), (!v_storage_field),
2104 (!v_local_field), (!v_attr_field))
2105 with
2106 | (Some v_namei_value, Some v_type_value,
2107 Some v_type_bis_value, Some v_storage_value,
2108 Some v_local_value, Some v_attr_value) ->
2109 {
2110 v_namei = v_namei_value;
2111 v_type = v_type_value;
2112 v_type_bis = v_type_bis_value;
2113 v_storage = v_storage_value;
2114 v_local = v_local_value;
2115 v_attr = v_attr_value;
2116 }
2117 | _ ->
2118 Conv_error.record_undefined_elements _loc sexp
2119 [ ((!v_namei_field = None), "v_namei");
2120 ((!v_type_field = None), "v_type");
2121 ((!v_type_bis_field = None), "v_type_bis");
2122 ((!v_storage_field = None), "v_storage");
2123 ((!v_local_field = None), "v_local");
2124 ((!v_attr_field = None), "v_attr") ]))
2125 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
2126 and onedecl_of_sexp sexp = onedecl_of_sexp__ sexp
2127 and storage_of_sexp__ =
2128 let _loc = "Xxx.storage"
2129 in
2130 function
2131 | Sexp.List ([ v1; v2 ]) ->
2132 let v1 = storagebis_of_sexp v1
2133 and v2 = Conv.bool_of_sexp v2
2134 in (v1, v2)
2135 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
2136 and storage_of_sexp sexp =
2137 try storage_of_sexp__ sexp
2138 with
2139 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
2140 and storagebis_of_sexp__ =
2141 let _loc = "Xxx.storagebis"
2142 in
2143 function
2144 | Sexp.Atom ("noSto" | "NoSto") -> NoSto
2145 | Sexp.Atom ("stoTypedef" | "StoTypedef") -> StoTypedef
2146 | (Sexp.List (Sexp.Atom (("sto" | "Sto" as tag)) :: sexp_args) as sexp)
2147 ->
2148 (match sexp_args with
2149 | [ v1 ] -> let v1 = storageClass_of_sexp v1 in Sto v1
2150 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2151 | (Sexp.List (Sexp.Atom ("noSto" | "NoSto") :: _) as sexp) ->
2152 Conv_error.stag_no_args _loc sexp
2153 | (Sexp.List (Sexp.Atom ("stoTypedef" | "StoTypedef") :: _) as sexp) ->
2154 Conv_error.stag_no_args _loc sexp
2155 | (Sexp.Atom ("sto" | "Sto") as sexp) ->
2156 Conv_error.stag_takes_args _loc sexp
2157 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2158 Conv_error.nested_list_invalid_sum _loc sexp
2159 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2160 | sexp -> Conv_error.unexpected_stag _loc sexp
2161 and storagebis_of_sexp sexp = storagebis_of_sexp__ sexp
2162 and storageClass_of_sexp__ =
2163 let _loc = "Xxx.storageClass"
2164 in
2165 function
2166 | Sexp.Atom ("auto" | "Auto") -> Auto
2167 | Sexp.Atom ("static" | "Static") -> Static
2168 | Sexp.Atom ("register" | "Register") -> Register
2169 | Sexp.Atom ("extern" | "Extern") -> Extern
2170 | (Sexp.List (Sexp.Atom ("auto" | "Auto") :: _) as sexp) ->
2171 Conv_error.stag_no_args _loc sexp
2172 | (Sexp.List (Sexp.Atom ("static" | "Static") :: _) as sexp) ->
2173 Conv_error.stag_no_args _loc sexp
2174 | (Sexp.List (Sexp.Atom ("register" | "Register") :: _) as sexp) ->
2175 Conv_error.stag_no_args _loc sexp
2176 | (Sexp.List (Sexp.Atom ("extern" | "Extern") :: _) as sexp) ->
2177 Conv_error.stag_no_args _loc sexp
2178 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2179 Conv_error.nested_list_invalid_sum _loc sexp
2180 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2181 | sexp -> Conv_error.unexpected_stag _loc sexp
2182 and storageClass_of_sexp sexp = storageClass_of_sexp__ sexp
2183 and local_decl_of_sexp__ =
2184 let _loc = "Xxx.local_decl"
2185 in
2186 function
2187 | Sexp.Atom ("localDecl" | "LocalDecl") -> LocalDecl
2188 | Sexp.Atom ("notLocalDecl" | "NotLocalDecl") -> NotLocalDecl
2189 | (Sexp.List (Sexp.Atom ("localDecl" | "LocalDecl") :: _) as sexp) ->
2190 Conv_error.stag_no_args _loc sexp
2191 | (Sexp.List (Sexp.Atom ("notLocalDecl" | "NotLocalDecl") :: _) as sexp)
2192 -> Conv_error.stag_no_args _loc sexp
2193 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2194 Conv_error.nested_list_invalid_sum _loc sexp
2195 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2196 | sexp -> Conv_error.unexpected_stag _loc sexp
2197 and local_decl_of_sexp sexp = local_decl_of_sexp__ sexp
2198 and initialiser_of_sexp__ =
2199 let _loc = "Xxx.initialiser"
2200 in fun sexp -> wrap_of_sexp initialiserbis_of_sexp sexp
2201 and initialiser_of_sexp sexp =
2202 try initialiser_of_sexp__ sexp
2203 with
2204 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
2205 and initialiserbis_of_sexp__ =
2206 let _loc = "Xxx.initialiserbis"
2207 in
2208 function
2209 | (Sexp.List (Sexp.Atom (("initExpr" | "InitExpr" as tag)) :: sexp_args)
2210 as sexp) ->
2211 (match sexp_args with
2212 | [ v1 ] -> let v1 = expression_of_sexp v1 in InitExpr v1
2213 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2214 | (Sexp.List (Sexp.Atom (("initList" | "InitList" as tag)) :: sexp_args)
2215 as sexp) ->
2216 (match sexp_args with
2217 | [ v1 ] ->
2218 let v1 =
2219 Conv.list_of_sexp (wrap2_of_sexp initialiser_of_sexp) v1
2220 in InitList v1
2221 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2222 | (Sexp.List
2223 (Sexp.Atom (("initDesignators" | "InitDesignators" as tag)) ::
2224 sexp_args)
2225 as sexp) ->
2226 (match sexp_args with
2227 | [ v1; v2 ] ->
2228 let v1 = Conv.list_of_sexp designator_of_sexp v1
2229 and v2 = initialiser_of_sexp v2
2230 in InitDesignators ((v1, v2))
2231 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2232 | (Sexp.List
2233 (Sexp.Atom (("initFieldOld" | "InitFieldOld" as tag)) :: sexp_args)
2234 as sexp) ->
2235 (match sexp_args with
2236 | [ v1; v2 ] ->
2237 let v1 = Conv.string_of_sexp v1
2238 and v2 = initialiser_of_sexp v2
2239 in InitFieldOld ((v1, v2))
2240 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2241 | (Sexp.List
2242 (Sexp.Atom (("initIndexOld" | "InitIndexOld" as tag)) :: sexp_args)
2243 as sexp) ->
2244 (match sexp_args with
2245 | [ v1; v2 ] ->
2246 let v1 = expression_of_sexp v1
2247 and v2 = initialiser_of_sexp v2
2248 in InitIndexOld ((v1, v2))
2249 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2250 | (Sexp.Atom ("initExpr" | "InitExpr") as sexp) ->
2251 Conv_error.stag_takes_args _loc sexp
2252 | (Sexp.Atom ("initList" | "InitList") as sexp) ->
2253 Conv_error.stag_takes_args _loc sexp
2254 | (Sexp.Atom ("initDesignators" | "InitDesignators") as sexp) ->
2255 Conv_error.stag_takes_args _loc sexp
2256 | (Sexp.Atom ("initFieldOld" | "InitFieldOld") as sexp) ->
2257 Conv_error.stag_takes_args _loc sexp
2258 | (Sexp.Atom ("initIndexOld" | "InitIndexOld") as sexp) ->
2259 Conv_error.stag_takes_args _loc sexp
2260 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2261 Conv_error.nested_list_invalid_sum _loc sexp
2262 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2263 | sexp -> Conv_error.unexpected_stag _loc sexp
2264 and initialiserbis_of_sexp sexp = initialiserbis_of_sexp__ sexp
2265 and designator_of_sexp__ =
2266 let _loc = "Xxx.designator"
2267 in fun sexp -> wrap_of_sexp designatorbis_of_sexp sexp
2268 and designator_of_sexp sexp =
2269 try designator_of_sexp__ sexp
2270 with
2271 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
2272 and designatorbis_of_sexp__ =
2273 let _loc = "Xxx.designatorbis"
2274 in
2275 function
2276 | (Sexp.List
2277 (Sexp.Atom (("designatorField" | "DesignatorField" as tag)) ::
2278 sexp_args)
2279 as sexp) ->
2280 (match sexp_args with
2281 | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in DesignatorField v1
2282 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2283 | (Sexp.List
2284 (Sexp.Atom (("designatorIndex" | "DesignatorIndex" as tag)) ::
2285 sexp_args)
2286 as sexp) ->
2287 (match sexp_args with
2288 | [ v1 ] -> let v1 = expression_of_sexp v1 in DesignatorIndex v1
2289 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2290 | (Sexp.List
2291 (Sexp.Atom (("designatorRange" | "DesignatorRange" as tag)) ::
2292 sexp_args)
2293 as sexp) ->
2294 (match sexp_args with
2295 | [ v1; v2 ] ->
2296 let v1 = expression_of_sexp v1
2297 and v2 = expression_of_sexp v2
2298 in DesignatorRange ((v1, v2))
2299 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2300 | (Sexp.Atom ("designatorField" | "DesignatorField") as sexp) ->
2301 Conv_error.stag_takes_args _loc sexp
2302 | (Sexp.Atom ("designatorIndex" | "DesignatorIndex") as sexp) ->
2303 Conv_error.stag_takes_args _loc sexp
2304 | (Sexp.Atom ("designatorRange" | "DesignatorRange") as sexp) ->
2305 Conv_error.stag_takes_args _loc sexp
2306 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2307 Conv_error.nested_list_invalid_sum _loc sexp
2308 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2309 | sexp -> Conv_error.unexpected_stag _loc sexp
2310 and designatorbis_of_sexp sexp = designatorbis_of_sexp__ sexp
2311 and definition_of_sexp__ =
2312 let _loc = "Xxx.definition"
2313 in fun sexp -> wrap_of_sexp definitionbis_of_sexp sexp
2314 and definition_of_sexp sexp =
2315 try definition_of_sexp__ sexp
2316 with
2317 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
2318 and definitionbis_of_sexp__ =
2319 let _loc = "Xxx.definitionbis"
2320 in
2321 function
2322 | (Sexp.List field_sexps as sexp) ->
2323 let f_name_field = ref None and f_type_field = ref None
2324 and f_storage_field = ref None and f_body_field = ref None
2325 and f_attr_field = ref None and f_old_c_style_field = ref None
2326 and duplicates = ref [] and extra = ref [] in
2327 let rec iter =
2328 (function
2329 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
2330 ((match field_name with
2331 | "f_name" ->
2332 (match !f_name_field with
2333 | None ->
2334 let fvalue = name_of_sexp field_sexp
2335 in f_name_field := Some fvalue
2336 | Some _ -> duplicates := field_name :: !duplicates)
2337 | "f_type" ->
2338 (match !f_type_field with
2339 | None ->
2340 let fvalue = functionType_of_sexp field_sexp
2341 in f_type_field := Some fvalue
2342 | Some _ -> duplicates := field_name :: !duplicates)
2343 | "f_storage" ->
2344 (match !f_storage_field with
2345 | None ->
2346 let fvalue = storage_of_sexp field_sexp
2347 in f_storage_field := Some fvalue
2348 | Some _ -> duplicates := field_name :: !duplicates)
2349 | "f_body" ->
2350 (match !f_body_field with
2351 | None ->
2352 let fvalue = compound_of_sexp field_sexp
2353 in f_body_field := Some fvalue
2354 | Some _ -> duplicates := field_name :: !duplicates)
2355 | "f_attr" ->
2356 (match !f_attr_field with
2357 | None ->
2358 let fvalue =
2359 Conv.list_of_sexp attribute_of_sexp field_sexp
2360 in f_attr_field := Some fvalue
2361 | Some _ -> duplicates := field_name :: !duplicates)
2362 | "f_old_c_style" ->
2363 (match !f_old_c_style_field with
2364 | None ->
2365 let fvalue =
2366 Conv.option_of_sexp
2367 (Conv.list_of_sexp declaration_of_sexp)
2368 field_sexp
2369 in f_old_c_style_field := Some fvalue
2370 | Some _ -> duplicates := field_name :: !duplicates)
2371 | _ ->
2372 if !Conv.record_check_extra_fields
2373 then extra := field_name :: !extra
2374 else ());
2375 iter tail)
2376 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
2377 | [] -> ())
2378 in
2379 (iter field_sexps;
2380 if !duplicates <> []
2381 then Conv_error.record_duplicate_fields _loc !duplicates sexp
2382 else
2383 if !extra <> []
2384 then Conv_error.record_extra_fields _loc !extra sexp
2385 else
2386 (match ((!f_name_field), (!f_type_field), (!f_storage_field),
2387 (!f_body_field), (!f_attr_field),
2388 (!f_old_c_style_field))
2389 with
2390 | (Some f_name_value, Some f_type_value,
2391 Some f_storage_value, Some f_body_value,
2392 Some f_attr_value, Some f_old_c_style_value) ->
2393 {
2394 f_name = f_name_value;
2395 f_type = f_type_value;
2396 f_storage = f_storage_value;
2397 f_body = f_body_value;
2398 f_attr = f_attr_value;
2399 f_old_c_style = f_old_c_style_value;
2400 }
2401 | _ ->
2402 Conv_error.record_undefined_elements _loc sexp
2403 [ ((!f_name_field = None), "f_name");
2404 ((!f_type_field = None), "f_type");
2405 ((!f_storage_field = None), "f_storage");
2406 ((!f_body_field = None), "f_body");
2407 ((!f_attr_field = None), "f_attr");
2408 ((!f_old_c_style_field = None), "f_old_c_style") ]))
2409 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
2410 and definitionbis_of_sexp sexp = definitionbis_of_sexp__ sexp
2411 and cpp_directive_of_sexp__ =
2412 let _loc = "Xxx.cpp_directive"
2413 in
2414 function
2415 | (Sexp.List (Sexp.Atom (("define" | "Define" as tag)) :: sexp_args) as
2416 sexp) ->
2417 (match sexp_args with
2418 | [ v1 ] -> let v1 = define_of_sexp v1 in Define v1
2419 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2420 | (Sexp.List (Sexp.Atom (("include" | "Include" as tag)) :: sexp_args) as
2421 sexp) ->
2422 (match sexp_args with
2423 | [ v1 ] -> let v1 = includ_of_sexp v1 in Include v1
2424 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2425 | (Sexp.List (Sexp.Atom (("undef" | "Undef" as tag)) :: sexp_args) as
2426 sexp) ->
2427 (match sexp_args with
2428 | [ v1 ] -> let v1 = wrap_of_sexp Conv.string_of_sexp v1 in Undef v1
2429 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2430 | (Sexp.List
2431 (Sexp.Atom (("pragmaAndCo" | "PragmaAndCo" as tag)) :: sexp_args)
2432 as sexp) ->
2433 (match sexp_args with
2434 | [ v1 ] -> let v1 = il_of_sexp v1 in PragmaAndCo v1
2435 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2436 | (Sexp.Atom ("define" | "Define") as sexp) ->
2437 Conv_error.stag_takes_args _loc sexp
2438 | (Sexp.Atom ("include" | "Include") as sexp) ->
2439 Conv_error.stag_takes_args _loc sexp
2440 | (Sexp.Atom ("undef" | "Undef") as sexp) ->
2441 Conv_error.stag_takes_args _loc sexp
2442 | (Sexp.Atom ("pragmaAndCo" | "PragmaAndCo") as sexp) ->
2443 Conv_error.stag_takes_args _loc sexp
2444 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2445 Conv_error.nested_list_invalid_sum _loc sexp
2446 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2447 | sexp -> Conv_error.unexpected_stag _loc sexp
2448 and cpp_directive_of_sexp sexp = cpp_directive_of_sexp__ sexp
2449 and define_of_sexp__ =
2450 let _loc = "Xxx.define"
2451 in
2452 function
2453 | Sexp.List ([ v1; v2 ]) ->
2454 let v1 = wrap_of_sexp Conv.string_of_sexp v1
2455 and v2 =
2456 (match v2 with
2457 | Sexp.List ([ v1; v2 ]) ->
2458 let v1 = define_kind_of_sexp v1
2459 and v2 = define_val_of_sexp v2
2460 in (v1, v2)
2461 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
2462 in (v1, v2)
2463 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp
2464 and define_of_sexp sexp =
2465 try define_of_sexp__ sexp
2466 with
2467 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
2468 and define_kind_of_sexp__ =
2469 let _loc = "Xxx.define_kind"
2470 in
2471 function
2472 | Sexp.Atom ("defineVar" | "DefineVar") -> DefineVar
2473 | (Sexp.List
2474 (Sexp.Atom (("defineFunc" | "DefineFunc" as tag)) :: sexp_args)
2475 as sexp) ->
2476 (match sexp_args with
2477 | [ v1 ] ->
2478 let v1 =
2479 wrap_of_sexp
2480 (Conv.list_of_sexp
2481 (wrap2_of_sexp (wrap_of_sexp Conv.string_of_sexp)))
2482 v1
2483 in DefineFunc v1
2484 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2485 | (Sexp.List (Sexp.Atom ("defineVar" | "DefineVar") :: _) as sexp) ->
2486 Conv_error.stag_no_args _loc sexp
2487 | (Sexp.Atom ("defineFunc" | "DefineFunc") as sexp) ->
2488 Conv_error.stag_takes_args _loc sexp
2489 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2490 Conv_error.nested_list_invalid_sum _loc sexp
2491 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2492 | sexp -> Conv_error.unexpected_stag _loc sexp
2493 and define_kind_of_sexp sexp = define_kind_of_sexp__ sexp
2494 and define_val_of_sexp__ =
2495 let _loc = "Xxx.define_val"
2496 in
2497 function
2498 | (Sexp.List
2499 (Sexp.Atom (("defineExpr" | "DefineExpr" as tag)) :: sexp_args)
2500 as sexp) ->
2501 (match sexp_args with
2502 | [ v1 ] -> let v1 = expression_of_sexp v1 in DefineExpr v1
2503 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2504 | (Sexp.List
2505 (Sexp.Atom (("defineStmt" | "DefineStmt" as tag)) :: sexp_args)
2506 as sexp) ->
2507 (match sexp_args with
2508 | [ v1 ] -> let v1 = statement_of_sexp v1 in DefineStmt v1
2509 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2510 | (Sexp.List
2511 (Sexp.Atom (("defineType" | "DefineType" as tag)) :: sexp_args)
2512 as sexp) ->
2513 (match sexp_args with
2514 | [ v1 ] -> let v1 = fullType_of_sexp v1 in DefineType v1
2515 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2516 | (Sexp.List
2517 (Sexp.Atom (("defineDoWhileZero" | "DefineDoWhileZero" as tag)) ::
2518 sexp_args)
2519 as sexp) ->
2520 (match sexp_args with
2521 | [ v1 ] ->
2522 let v1 =
2523 wrap_of_sexp
2524 (function
2525 | Sexp.List ([ v1; v2 ]) ->
2526 let v1 = statement_of_sexp v1
2527 and v2 = expression_of_sexp v2
2528 in (v1, v2)
2529 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
2530 v1
2531 in DefineDoWhileZero v1
2532 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2533 | (Sexp.List
2534 (Sexp.Atom (("defineFunction" | "DefineFunction" as tag)) ::
2535 sexp_args)
2536 as sexp) ->
2537 (match sexp_args with
2538 | [ v1 ] -> let v1 = definition_of_sexp v1 in DefineFunction v1
2539 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2540 | (Sexp.List
2541 (Sexp.Atom (("defineInit" | "DefineInit" as tag)) :: sexp_args)
2542 as sexp) ->
2543 (match sexp_args with
2544 | [ v1 ] -> let v1 = initialiser_of_sexp v1 in DefineInit v1
2545 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2546 | (Sexp.List
2547 (Sexp.Atom (("defineText" | "DefineText" as tag)) :: sexp_args)
2548 as sexp) ->
2549 (match sexp_args with
2550 | [ v1 ] ->
2551 let v1 = wrap_of_sexp Conv.string_of_sexp v1 in DefineText v1
2552 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2553 | Sexp.Atom ("defineEmpty" | "DefineEmpty") -> DefineEmpty
2554 | Sexp.Atom ("defineTodo" | "DefineTodo") -> DefineTodo
2555 | (Sexp.Atom ("defineExpr" | "DefineExpr") as sexp) ->
2556 Conv_error.stag_takes_args _loc sexp
2557 | (Sexp.Atom ("defineStmt" | "DefineStmt") as sexp) ->
2558 Conv_error.stag_takes_args _loc sexp
2559 | (Sexp.Atom ("defineType" | "DefineType") as sexp) ->
2560 Conv_error.stag_takes_args _loc sexp
2561 | (Sexp.Atom ("defineDoWhileZero" | "DefineDoWhileZero") as sexp) ->
2562 Conv_error.stag_takes_args _loc sexp
2563 | (Sexp.Atom ("defineFunction" | "DefineFunction") as sexp) ->
2564 Conv_error.stag_takes_args _loc sexp
2565 | (Sexp.Atom ("defineInit" | "DefineInit") as sexp) ->
2566 Conv_error.stag_takes_args _loc sexp
2567 | (Sexp.Atom ("defineText" | "DefineText") as sexp) ->
2568 Conv_error.stag_takes_args _loc sexp
2569 | (Sexp.List (Sexp.Atom ("defineEmpty" | "DefineEmpty") :: _) as sexp) ->
2570 Conv_error.stag_no_args _loc sexp
2571 | (Sexp.List (Sexp.Atom ("defineTodo" | "DefineTodo") :: _) as sexp) ->
2572 Conv_error.stag_no_args _loc sexp
2573 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2574 Conv_error.nested_list_invalid_sum _loc sexp
2575 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2576 | sexp -> Conv_error.unexpected_stag _loc sexp
2577 and define_val_of_sexp sexp = define_val_of_sexp__ sexp
2578 and includ_of_sexp__ =
2579 let _loc = "Xxx.includ"
2580 in
2581 function
2582 | (Sexp.List field_sexps as sexp) ->
2583 let i_include_field = ref None and i_rel_pos_field = ref None
2584 and i_is_in_ifdef_field = ref None and i_content_field = ref None
2585 and duplicates = ref [] and extra = ref [] in
2586 let rec iter =
2587 (function
2588 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
2589 ((match field_name with
2590 | "i_include" ->
2591 (match !i_include_field with
2592 | None ->
2593 let fvalue =
2594 wrap_of_sexp inc_file_of_sexp field_sexp
2595 in i_include_field := Some fvalue
2596 | Some _ -> duplicates := field_name :: !duplicates)
2597 | "i_rel_pos" ->
2598 (match !i_rel_pos_field with
2599 | None ->
2600 let fvalue =
2601 Conv.ref_of_sexp
2602 (Conv.option_of_sexp include_rel_pos_of_sexp)
2603 field_sexp
2604 in i_rel_pos_field := Some fvalue
2605 | Some _ -> duplicates := field_name :: !duplicates)
2606 | "i_is_in_ifdef" ->
2607 (match !i_is_in_ifdef_field with
2608 | None ->
2609 let fvalue = Conv.bool_of_sexp field_sexp
2610 in i_is_in_ifdef_field := Some fvalue
2611 | Some _ -> duplicates := field_name :: !duplicates)
2612 | "i_content" ->
2613 (match !i_content_field with
2614 | None ->
2615 let fvalue =
2616 Conv.option_of_sexp
2617 (function
2618 | Sexp.List ([ v1; v2 ]) ->
2619 let v1 = Common.filename_of_sexp v1
2620 and v2 = program_of_sexp v2
2621 in (v1, v2)
2622 | sexp ->
2623 Conv_error.tuple_of_size_n_expected _loc 2
2624 sexp)
2625 field_sexp
2626 in i_content_field := Some fvalue
2627 | Some _ -> duplicates := field_name :: !duplicates)
2628 | _ ->
2629 if !Conv.record_check_extra_fields
2630 then extra := field_name :: !extra
2631 else ());
2632 iter tail)
2633 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
2634 | [] -> ())
2635 in
2636 (iter field_sexps;
2637 if !duplicates <> []
2638 then Conv_error.record_duplicate_fields _loc !duplicates sexp
2639 else
2640 if !extra <> []
2641 then Conv_error.record_extra_fields _loc !extra sexp
2642 else
2643 (match ((!i_include_field), (!i_rel_pos_field),
2644 (!i_is_in_ifdef_field), (!i_content_field))
2645 with
2646 | (Some i_include_value, Some i_rel_pos_value,
2647 Some i_is_in_ifdef_value, Some i_content_value) ->
2648 {
2649 i_include = i_include_value;
2650 i_rel_pos = i_rel_pos_value;
2651 i_is_in_ifdef = i_is_in_ifdef_value;
2652 i_content = i_content_value;
2653 }
2654 | _ ->
2655 Conv_error.record_undefined_elements _loc sexp
2656 [ ((!i_include_field = None), "i_include");
2657 ((!i_rel_pos_field = None), "i_rel_pos");
2658 ((!i_is_in_ifdef_field = None), "i_is_in_ifdef");
2659 ((!i_content_field = None), "i_content") ]))
2660 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
2661 and includ_of_sexp sexp = includ_of_sexp__ sexp
2662 and inc_file_of_sexp__ =
2663 let _loc = "Xxx.inc_file"
2664 in
2665 function
2666 | (Sexp.List (Sexp.Atom (("local" | "Local" as tag)) :: sexp_args) as
2667 sexp) ->
2668 (match sexp_args with
2669 | [ v1 ] ->
2670 let v1 = Conv.list_of_sexp inc_elem_of_sexp v1 in Local v1
2671 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2672 | (Sexp.List (Sexp.Atom (("nonLocal" | "NonLocal" as tag)) :: sexp_args)
2673 as sexp) ->
2674 (match sexp_args with
2675 | [ v1 ] ->
2676 let v1 = Conv.list_of_sexp inc_elem_of_sexp v1 in NonLocal v1
2677 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2678 | (Sexp.List (Sexp.Atom (("weird" | "Weird" as tag)) :: sexp_args) as
2679 sexp) ->
2680 (match sexp_args with
2681 | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in Weird v1
2682 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2683 | (Sexp.Atom ("local" | "Local") as sexp) ->
2684 Conv_error.stag_takes_args _loc sexp
2685 | (Sexp.Atom ("nonLocal" | "NonLocal") as sexp) ->
2686 Conv_error.stag_takes_args _loc sexp
2687 | (Sexp.Atom ("weird" | "Weird") as sexp) ->
2688 Conv_error.stag_takes_args _loc sexp
2689 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2690 Conv_error.nested_list_invalid_sum _loc sexp
2691 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2692 | sexp -> Conv_error.unexpected_stag _loc sexp
2693 and inc_file_of_sexp sexp = inc_file_of_sexp__ sexp
2694 and inc_elem_of_sexp__ =
2695 let _loc = "Xxx.inc_elem" in fun sexp -> Conv.string_of_sexp sexp
2696 and inc_elem_of_sexp sexp =
2697 try inc_elem_of_sexp__ sexp
2698 with
2699 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
2700 and include_rel_pos_of_sexp__ =
2701 let _loc = "Xxx.include_rel_pos"
2702 in
2703 function
2704 | (Sexp.List field_sexps as sexp) ->
2705 let first_of_field = ref None and last_of_field = ref None
2706 and duplicates = ref [] and extra = ref [] in
2707 let rec iter =
2708 (function
2709 | Sexp.List ([ Sexp.Atom field_name; field_sexp ]) :: tail ->
2710 ((match field_name with
2711 | "first_of" ->
2712 (match !first_of_field with
2713 | None ->
2714 let fvalue =
2715 Conv.list_of_sexp
2716 (Conv.list_of_sexp Conv.string_of_sexp)
2717 field_sexp
2718 in first_of_field := Some fvalue
2719 | Some _ -> duplicates := field_name :: !duplicates)
2720 | "last_of" ->
2721 (match !last_of_field with
2722 | None ->
2723 let fvalue =
2724 Conv.list_of_sexp
2725 (Conv.list_of_sexp Conv.string_of_sexp)
2726 field_sexp
2727 in last_of_field := Some fvalue
2728 | Some _ -> duplicates := field_name :: !duplicates)
2729 | _ ->
2730 if !Conv.record_check_extra_fields
2731 then extra := field_name :: !extra
2732 else ());
2733 iter tail)
2734 | sexp :: _ -> Conv_error.record_only_pairs_expected _loc sexp
2735 | [] -> ())
2736 in
2737 (iter field_sexps;
2738 if !duplicates <> []
2739 then Conv_error.record_duplicate_fields _loc !duplicates sexp
2740 else
2741 if !extra <> []
2742 then Conv_error.record_extra_fields _loc !extra sexp
2743 else
2744 (match ((!first_of_field), (!last_of_field)) with
2745 | (Some first_of_value, Some last_of_value) ->
2746 { first_of = first_of_value; last_of = last_of_value; }
2747 | _ ->
2748 Conv_error.record_undefined_elements _loc sexp
2749 [ ((!first_of_field = None), "first_of");
2750 ((!last_of_field = None), "last_of") ]))
2751 | (Sexp.Atom _ as sexp) -> Conv_error.record_list_instead_atom _loc sexp
2752 and include_rel_pos_of_sexp sexp = include_rel_pos_of_sexp__ sexp
2753 and ifdef_directive_of_sexp__ =
2754 let _loc = "Xxx.ifdef_directive"
2755 in
2756 function
2757 | (Sexp.List
2758 (Sexp.Atom (("ifdefDirective" | "IfdefDirective" as tag)) ::
2759 sexp_args)
2760 as sexp) ->
2761 (match sexp_args with
2762 | [ v1 ] ->
2763 let v1 =
2764 wrap_of_sexp
2765 (function
2766 | Sexp.List ([ v1; v2 ]) ->
2767 let v1 = ifdefkind_of_sexp v1
2768 and v2 = matching_tag_of_sexp v2
2769 in (v1, v2)
2770 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
2771 v1
2772 in IfdefDirective v1
2773 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2774 | (Sexp.Atom ("ifdefDirective" | "IfdefDirective") as sexp) ->
2775 Conv_error.stag_takes_args _loc sexp
2776 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2777 Conv_error.nested_list_invalid_sum _loc sexp
2778 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2779 | sexp -> Conv_error.unexpected_stag _loc sexp
2780 and ifdef_directive_of_sexp sexp = ifdef_directive_of_sexp__ sexp
2781 and ifdefkind_of_sexp__ =
2782 let _loc = "Xxx.ifdefkind"
2783 in
2784 function
2785 | Sexp.Atom ("ifdef" | "Ifdef") -> Ifdef
2786 | Sexp.Atom ("ifdefElseif" | "IfdefElseif") -> IfdefElseif
2787 | Sexp.Atom ("ifdefElse" | "IfdefElse") -> IfdefElse
2788 | Sexp.Atom ("ifdefEndif" | "IfdefEndif") -> IfdefEndif
2789 | (Sexp.List (Sexp.Atom ("ifdef" | "Ifdef") :: _) as sexp) ->
2790 Conv_error.stag_no_args _loc sexp
2791 | (Sexp.List (Sexp.Atom ("ifdefElseif" | "IfdefElseif") :: _) as sexp) ->
2792 Conv_error.stag_no_args _loc sexp
2793 | (Sexp.List (Sexp.Atom ("ifdefElse" | "IfdefElse") :: _) as sexp) ->
2794 Conv_error.stag_no_args _loc sexp
2795 | (Sexp.List (Sexp.Atom ("ifdefEndif" | "IfdefEndif") :: _) as sexp) ->
2796 Conv_error.stag_no_args _loc sexp
2797 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2798 Conv_error.nested_list_invalid_sum _loc sexp
2799 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2800 | sexp -> Conv_error.unexpected_stag _loc sexp
2801 and ifdefkind_of_sexp sexp = ifdefkind_of_sexp__ sexp
2802 and matching_tag_of_sexp__ =
2803 let _loc = "Xxx.matching_tag"
2804 in
2805 function
2806 | (Sexp.List (Sexp.Atom (("ifdefTag" | "IfdefTag" as tag)) :: sexp_args)
2807 as sexp) ->
2808 (match sexp_args with
2809 | [ v1 ] ->
2810 let v1 =
2811 (match v1 with
2812 | Sexp.List ([ v1; v2 ]) ->
2813 let v1 = Conv.int_of_sexp v1
2814 and v2 = Conv.int_of_sexp v2
2815 in (v1, v2)
2816 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
2817 in IfdefTag v1
2818 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2819 | (Sexp.Atom ("ifdefTag" | "IfdefTag") as sexp) ->
2820 Conv_error.stag_takes_args _loc sexp
2821 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2822 Conv_error.nested_list_invalid_sum _loc sexp
2823 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2824 | sexp -> Conv_error.unexpected_stag _loc sexp
2825 and matching_tag_of_sexp sexp = matching_tag_of_sexp__ sexp
2826 and toplevel_of_sexp__ =
2827 let _loc = "Xxx.toplevel"
2828 in
2829 function
2830 | (Sexp.List
2831 (Sexp.Atom (("declaration" | "Declaration" as tag)) :: sexp_args)
2832 as sexp) ->
2833 (match sexp_args with
2834 | [ v1 ] -> let v1 = declaration_of_sexp v1 in Declaration v1
2835 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2836 | (Sexp.List
2837 (Sexp.Atom (("definition" | "Definition" as tag)) :: sexp_args)
2838 as sexp) ->
2839 (match sexp_args with
2840 | [ v1 ] -> let v1 = definition_of_sexp v1 in Definition v1
2841 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2842 | (Sexp.List (Sexp.Atom (("cppTop" | "CppTop" as tag)) :: sexp_args) as
2843 sexp) ->
2844 (match sexp_args with
2845 | [ v1 ] -> let v1 = cpp_directive_of_sexp v1 in CppTop v1
2846 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2847 | (Sexp.List (Sexp.Atom (("ifdefTop" | "IfdefTop" as tag)) :: sexp_args)
2848 as sexp) ->
2849 (match sexp_args with
2850 | [ v1 ] -> let v1 = ifdef_directive_of_sexp v1 in IfdefTop v1
2851 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2852 | (Sexp.List (Sexp.Atom (("macroTop" | "MacroTop" as tag)) :: sexp_args)
2853 as sexp) ->
2854 (match sexp_args with
2855 | [ v1; v2; v3 ] ->
2856 let v1 = Conv.string_of_sexp v1
2857 and v2 = Conv.list_of_sexp (wrap2_of_sexp argument_of_sexp) v2
2858 and v3 = il_of_sexp v3
2859 in MacroTop ((v1, v2, v3))
2860 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2861 | (Sexp.List (Sexp.Atom (("emptyDef" | "EmptyDef" as tag)) :: sexp_args)
2862 as sexp) ->
2863 (match sexp_args with
2864 | [ v1 ] -> let v1 = il_of_sexp v1 in EmptyDef v1
2865 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2866 | (Sexp.List
2867 (Sexp.Atom (("notParsedCorrectly" | "NotParsedCorrectly" as tag)) ::
2868 sexp_args)
2869 as sexp) ->
2870 (match sexp_args with
2871 | [ v1 ] -> let v1 = il_of_sexp v1 in NotParsedCorrectly v1
2872 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2873 | (Sexp.List (Sexp.Atom (("finalDef" | "FinalDef" as tag)) :: sexp_args)
2874 as sexp) ->
2875 (match sexp_args with
2876 | [ v1 ] -> let v1 = info_of_sexp v1 in FinalDef v1
2877 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2878 | (Sexp.Atom ("declaration" | "Declaration") as sexp) ->
2879 Conv_error.stag_takes_args _loc sexp
2880 | (Sexp.Atom ("definition" | "Definition") as sexp) ->
2881 Conv_error.stag_takes_args _loc sexp
2882 | (Sexp.Atom ("cppTop" | "CppTop") as sexp) ->
2883 Conv_error.stag_takes_args _loc sexp
2884 | (Sexp.Atom ("ifdefTop" | "IfdefTop") as sexp) ->
2885 Conv_error.stag_takes_args _loc sexp
2886 | (Sexp.Atom ("macroTop" | "MacroTop") as sexp) ->
2887 Conv_error.stag_takes_args _loc sexp
2888 | (Sexp.Atom ("emptyDef" | "EmptyDef") as sexp) ->
2889 Conv_error.stag_takes_args _loc sexp
2890 | (Sexp.Atom ("notParsedCorrectly" | "NotParsedCorrectly") as sexp) ->
2891 Conv_error.stag_takes_args _loc sexp
2892 | (Sexp.Atom ("finalDef" | "FinalDef") as sexp) ->
2893 Conv_error.stag_takes_args _loc sexp
2894 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
2895 Conv_error.nested_list_invalid_sum _loc sexp
2896 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
2897 | sexp -> Conv_error.unexpected_stag _loc sexp
2898 and toplevel_of_sexp sexp = toplevel_of_sexp__ sexp
2899 and program_of_sexp__ =
2900 let _loc = "Xxx.program"
2901 in fun sexp -> Conv.list_of_sexp toplevel_of_sexp sexp
2902 and program_of_sexp sexp =
2903 try program_of_sexp__ sexp
2904 with
2905 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
2906
2907
2908
2909 (*
2910 and metavars_binding_of_sexp__ =
2911 let _loc = "Xxx.metavars_binding"
2912 in
2913 fun sexp ->
2914 (*
2915 Common.assoc_of_sexp Ast_cocci.meta_name_of_sexp metavar_binding_kind_of_sexp
2916 sexp
2917 *)
2918 failwith "Todo"
2919 and metavars_binding_of_sexp sexp =
2920 try metavars_binding_of_sexp__ sexp
2921 with
2922 | Conv_error.No_variant_match ((msg, sexp)) -> Conv.of_sexp_error msg sexp
2923 and metavar_binding_kind_of_sexp__ =
2924 let _loc = "Xxx.metavar_binding_kind"
2925 in
2926 function
2927 | (Sexp.List
2928 (Sexp.Atom (("metaIdVal" | "MetaIdVal" as tag)) :: sexp_args)
2929 as sexp) ->
2930 (match sexp_args with
2931 | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in MetaIdVal v1
2932 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2933 | (Sexp.List
2934 (Sexp.Atom (("metaFuncVal" | "MetaFuncVal" as tag)) :: sexp_args)
2935 as sexp) ->
2936 (match sexp_args with
2937 | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in MetaFuncVal v1
2938 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2939 | (Sexp.List
2940 (Sexp.Atom (("metaLocalFuncVal" | "MetaLocalFuncVal" as tag)) ::
2941 sexp_args)
2942 as sexp) ->
2943 (match sexp_args with
2944 | [ v1 ] -> let v1 = Conv.string_of_sexp v1 in MetaLocalFuncVal v1
2945 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2946 | (Sexp.List
2947 (Sexp.Atom (("metaExprVal" | "MetaExprVal" as tag)) :: sexp_args)
2948 as sexp) ->
2949 (match sexp_args with
2950 | [ v1 ] -> let v1 = expression_of_sexp v1 in MetaExprVal v1
2951 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2952 | (Sexp.List
2953 (Sexp.Atom (("metaExprListVal" | "MetaExprListVal" as tag)) ::
2954 sexp_args)
2955 as sexp) ->
2956 (match sexp_args with
2957 | [ v1 ] ->
2958 let v1 = Conv.list_of_sexp (wrap2_of_sexp argument_of_sexp) v1
2959 in MetaExprListVal v1
2960 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2961 | (Sexp.List
2962 (Sexp.Atom (("metaParamVal" | "MetaParamVal" as tag)) :: sexp_args)
2963 as sexp) ->
2964 (match sexp_args with
2965 | [ v1 ] -> let v1 = parameterType_of_sexp v1 in MetaParamVal v1
2966 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2967 | (Sexp.List
2968 (Sexp.Atom (("metaParamListVal" | "MetaParamListVal" as tag)) ::
2969 sexp_args)
2970 as sexp) ->
2971 (match sexp_args with
2972 | [ v1 ] ->
2973 let v1 =
2974 Conv.list_of_sexp (wrap2_of_sexp parameterType_of_sexp) v1
2975 in MetaParamListVal v1
2976 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2977 | (Sexp.List
2978 (Sexp.Atom (("metaTypeVal" | "MetaTypeVal" as tag)) :: sexp_args)
2979 as sexp) ->
2980 (match sexp_args with
2981 | [ v1 ] -> let v1 = fullType_of_sexp v1 in MetaTypeVal v1
2982 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2983 | (Sexp.List
2984 (Sexp.Atom (("metaInitVal" | "MetaInitVal" as tag)) :: sexp_args)
2985 as sexp) ->
2986 (match sexp_args with
2987 | [ v1 ] -> let v1 = initialiser_of_sexp v1 in MetaInitVal v1
2988 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2989 | (Sexp.List
2990 (Sexp.Atom (("metaStmtVal" | "MetaStmtVal" as tag)) :: sexp_args)
2991 as sexp) ->
2992 (match sexp_args with
2993 | [ v1 ] -> let v1 = statement_of_sexp v1 in MetaStmtVal v1
2994 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
2995 | (Sexp.List
2996 (Sexp.Atom (("metaPosVal" | "MetaPosVal" as tag)) :: sexp_args)
2997 as sexp) ->
2998 (match sexp_args with
2999 | [ v1 ] ->
3000 let v1 =
3001 (match v1 with
3002 | Sexp.List ([ v1; v2 ]) ->
3003 let v1 = Ast_cocci.fixpos_of_sexp v1
3004 and v2 = Ast_cocci.fixpos_of_sexp v2
3005 in (v1, v2)
3006 | sexp -> Conv_error.tuple_of_size_n_expected _loc 2 sexp)
3007 in MetaPosVal v1
3008 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
3009 | (Sexp.List
3010 (Sexp.Atom (("metaPosValList" | "MetaPosValList" as tag)) ::
3011 sexp_args)
3012 as sexp) ->
3013 (match sexp_args with
3014 | [ v1 ] ->
3015 let v1 =
3016 Conv.list_of_sexp
3017 (function
3018 | Sexp.List ([ v1; v2; v3; v4 ]) ->
3019 let v1 = Common.filename_of_sexp v1
3020 and v2 = Conv.string_of_sexp v2
3021 and v3 = posl_of_sexp v3
3022 and v4 = posl_of_sexp v4
3023 in (v1, v2, v3, v4)
3024 | sexp -> Conv_error.tuple_of_size_n_expected _loc 4 sexp)
3025 v1
3026 in MetaPosValList v1
3027 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
3028 | (Sexp.List
3029 (Sexp.Atom (("metaListlenVal" | "MetaListlenVal" as tag)) ::
3030 sexp_args)
3031 as sexp) ->
3032 (match sexp_args with
3033 | [ v1 ] -> let v1 = Conv.int_of_sexp v1 in MetaListlenVal v1
3034 | _ -> Conv_error.stag_incorrect_n_args _loc tag sexp)
3035 | (Sexp.Atom ("metaIdVal" | "MetaIdVal") as sexp) ->
3036 Conv_error.stag_takes_args _loc sexp
3037 | (Sexp.Atom ("metaFuncVal" | "MetaFuncVal") as sexp) ->
3038 Conv_error.stag_takes_args _loc sexp
3039 | (Sexp.Atom ("metaLocalFuncVal" | "MetaLocalFuncVal") as sexp) ->
3040 Conv_error.stag_takes_args _loc sexp
3041 | (Sexp.Atom ("metaExprVal" | "MetaExprVal") as sexp) ->
3042 Conv_error.stag_takes_args _loc sexp
3043 | (Sexp.Atom ("metaExprListVal" | "MetaExprListVal") as sexp) ->
3044 Conv_error.stag_takes_args _loc sexp
3045 | (Sexp.Atom ("metaParamVal" | "MetaParamVal") as sexp) ->
3046 Conv_error.stag_takes_args _loc sexp
3047 | (Sexp.Atom ("metaParamListVal" | "MetaParamListVal") as sexp) ->
3048 Conv_error.stag_takes_args _loc sexp
3049 | (Sexp.Atom ("metaTypeVal" | "MetaTypeVal") as sexp) ->
3050 Conv_error.stag_takes_args _loc sexp
3051 | (Sexp.Atom ("metaInitVal" | "MetaInitVal") as sexp) ->
3052 Conv_error.stag_takes_args _loc sexp
3053 | (Sexp.Atom ("metaStmtVal" | "MetaStmtVal") as sexp) ->
3054 Conv_error.stag_takes_args _loc sexp
3055 | (Sexp.Atom ("metaPosVal" | "MetaPosVal") as sexp) ->
3056 Conv_error.stag_takes_args _loc sexp
3057 | (Sexp.Atom ("metaPosValList" | "MetaPosValList") as sexp) ->
3058 Conv_error.stag_takes_args _loc sexp
3059 | (Sexp.Atom ("metaListlenVal" | "MetaListlenVal") as sexp) ->
3060 Conv_error.stag_takes_args _loc sexp
3061 | (Sexp.List (Sexp.List _ :: _) as sexp) ->
3062 Conv_error.nested_list_invalid_sum _loc sexp
3063 | (Sexp.List [] as sexp) -> Conv_error.empty_list_invalid_sum _loc sexp
3064 | sexp -> Conv_error.unexpected_stag _loc sexp
3065 and metavar_binding_kind_of_sexp sexp = metavar_binding_kind_of_sexp__ sexp
3066
3067 *)
3068
3069
3070
3071 let rec
3072 sexp_of_info {
3073 pinfo = v_pinfo;
3074 cocci_tag = v_cocci_tag;
3075 comments_tag = v_comments_tag
3076 } =
3077 if not !show_info then Sexp.Atom ""
3078 else
3079 let bnds = [] in
3080 let arg = Conv.sexp_of_ref sexp_of_comments_around v_comments_tag in
3081 let bnd = Sexp.List [ Sexp.Atom "comments_tag"; arg ] in
3082 let bnds = bnd :: bnds in
3083 let arg =
3084 Conv.sexp_of_ref
3085 (Conv.sexp_of_option
3086 (fun (v1, v2) ->
3087 let v1 = Ast_cocci.sexp_of_mcodekind v1
3088 and v2 = (* sexp_of_metavars_binding v2 *) failwith "todo"
3089 in Sexp.List [ v1; v2 ]))
3090 v_cocci_tag in
3091 let bnd = Sexp.List [ Sexp.Atom "cocci_tag"; arg ] in
3092 let bnds = bnd :: bnds in
3093 let arg = sexp_of_parse_info v_pinfo in
3094 let bnd = Sexp.List [ Sexp.Atom "pinfo"; arg ] in
3095 let bnds = bnd :: bnds in Sexp.List bnds
3096 and sexp_of_il v = Conv.sexp_of_list sexp_of_info v
3097 and sexp_of_wrap _of_a (v1, v2) =
3098 let v1 = _of_a v1 and v2 = sexp_of_il v2 in Sexp.List [ v1; v2 ]
3099 and sexp_of_wrap2 _of_a (v1, v2) =
3100 let v1 = _of_a v1 and v2 = sexp_of_il v2 in Sexp.List [ v1; v2 ]
3101
3102
3103 and
3104 sexp_of_comments_around {
3105 mbefore = v_mbefore;
3106 mafter = v_mafter;
3107 mbefore2 = v_mbefore2;
3108 mafter2 = v_mafter2
3109 } =
3110 let bnds = [] in
3111 let arg = Conv.sexp_of_list sexp_of_comment_and_relative_pos v_mafter2 in
3112 let bnd = Sexp.List [ Sexp.Atom "mafter2"; arg ] in
3113 let bnds = bnd :: bnds in
3114 let arg = Conv.sexp_of_list sexp_of_comment_and_relative_pos v_mbefore2 in
3115 let bnd = Sexp.List [ Sexp.Atom "mbefore2"; arg ] in
3116 let bnds = bnd :: bnds in
3117 let arg = Conv.sexp_of_list Token_c.sexp_of_comment_like_token v_mafter in
3118 let bnd = Sexp.List [ Sexp.Atom "mafter"; arg ] in
3119 let bnds = bnd :: bnds in
3120 let arg = Conv.sexp_of_list Token_c.sexp_of_comment_like_token v_mbefore in
3121 let bnd = Sexp.List [ Sexp.Atom "mbefore"; arg ] in
3122 let bnds = bnd :: bnds in Sexp.List bnds
3123 and sexp_of_comment_and_relative_pos { minfo = v_minfo; mpos = v_mpos } =
3124 let bnds = [] in
3125 let arg = Conv.sexp_of_int v_mpos in
3126 let bnd = Sexp.List [ Sexp.Atom "mpos"; arg ] in
3127 let bnds = bnd :: bnds in
3128 let arg = Common.sexp_of_parse_info v_minfo in
3129 let bnd = Sexp.List [ Sexp.Atom "minfo"; arg ] in
3130 let bnds = bnd :: bnds in Sexp.List bnds
3131 and sexp_of_comment v = Common.sexp_of_parse_info v
3132 and sexp_of_com v = Conv.sexp_of_ref (Conv.sexp_of_list sexp_of_comment) v
3133
3134
3135
3136
3137 (* break let rec *)
3138 let rec sexp_of_name =
3139 function
3140 | RegularName v1 ->
3141 let v1 = sexp_of_wrap Conv.sexp_of_string v1
3142 in Sexp.List [ Sexp.Atom "RegularName"; v1 ]
3143 | CppConcatenatedName v1 ->
3144 let v1 =
3145 Conv.sexp_of_list (sexp_of_wrap2 (sexp_of_wrap Conv.sexp_of_string))
3146 v1
3147 in Sexp.List [ Sexp.Atom "CppConcatenatedName"; v1 ]
3148 | CppVariadicName v1 ->
3149 let v1 = sexp_of_wrap Conv.sexp_of_string v1
3150 in Sexp.List [ Sexp.Atom "CppVariadicName"; v1 ]
3151 | CppIdentBuilder ((v1, v2)) ->
3152 let v1 = sexp_of_wrap Conv.sexp_of_string v1
3153 and v2 =
3154 Conv.sexp_of_list (sexp_of_wrap2 (sexp_of_wrap Conv.sexp_of_string))
3155 v2
3156 in Sexp.List [ Sexp.Atom "CppIdentBuilder"; v1; v2 ]
3157 and sexp_of_fullType (v1, v2) =
3158 let v1 = sexp_of_typeQualifier v1
3159 and v2 = sexp_of_typeC v2
3160 in Sexp.List [ v1; v2 ]
3161 and sexp_of_typeC v = sexp_of_wrap sexp_of_typeCbis v
3162 and sexp_of_typeCbis =
3163 function
3164 | BaseType v1 ->
3165 let v1 = sexp_of_baseType v1 in Sexp.List [ Sexp.Atom "BaseType"; v1 ]
3166 | Pointer v1 ->
3167 let v1 = sexp_of_fullType v1 in Sexp.List [ Sexp.Atom "Pointer"; v1 ]
3168 | Array ((v1, v2)) ->
3169 let v1 = Conv.sexp_of_option sexp_of_constExpression v1
3170 and v2 = sexp_of_fullType v2
3171 in Sexp.List [ Sexp.Atom "Array"; v1; v2 ]
3172 | FunctionType v1 ->
3173 let v1 = sexp_of_functionType v1
3174 in Sexp.List [ Sexp.Atom "FunctionType"; v1 ]
3175 | Enum ((v1, v2)) ->
3176 let v1 = Conv.sexp_of_option Conv.sexp_of_string v1
3177 and v2 = sexp_of_enumType v2
3178 in Sexp.List [ Sexp.Atom "Enum"; v1; v2 ]
3179 | StructUnion ((v1, v2, v3)) ->
3180 let v1 = sexp_of_structUnion v1
3181 and v2 = Conv.sexp_of_option Conv.sexp_of_string v2
3182 and v3 = sexp_of_structType v3
3183 in Sexp.List [ Sexp.Atom "StructUnion"; v1; v2; v3 ]
3184 | EnumName v1 ->
3185 let v1 = Conv.sexp_of_string v1
3186 in Sexp.List [ Sexp.Atom "EnumName"; v1 ]
3187 | StructUnionName ((v1, v2)) ->
3188 let v1 = sexp_of_structUnion v1
3189 and v2 = Conv.sexp_of_string v2
3190 in Sexp.List [ Sexp.Atom "StructUnionName"; v1; v2 ]
3191 | TypeName ((v1, v2)) ->
3192 let v1 = sexp_of_name v1
3193 and v2 = Conv.sexp_of_option sexp_of_fullType v2
3194 in Sexp.List [ Sexp.Atom "TypeName"; v1; v2 ]
3195 | ParenType v1 ->
3196 let v1 = sexp_of_fullType v1 in Sexp.List [ Sexp.Atom "ParenType"; v1 ]
3197 | TypeOfExpr v1 ->
3198 let v1 = sexp_of_expression v1
3199 in Sexp.List [ Sexp.Atom "TypeOfExpr"; v1 ]
3200 | TypeOfType v1 ->
3201 let v1 = sexp_of_fullType v1
3202 in Sexp.List [ Sexp.Atom "TypeOfType"; v1 ]
3203 and sexp_of_baseType =
3204 function
3205 | Void -> Sexp.Atom "Void"
3206 | IntType v1 ->
3207 let v1 = sexp_of_intType v1 in Sexp.List [ Sexp.Atom "IntType"; v1 ]
3208 | FloatType v1 ->
3209 let v1 = sexp_of_floatType v1
3210 in Sexp.List [ Sexp.Atom "FloatType"; v1 ]
3211 and sexp_of_intType =
3212 function
3213 | CChar -> Sexp.Atom "CChar"
3214 | Si v1 -> let v1 = sexp_of_signed v1 in Sexp.List [ Sexp.Atom "Si"; v1 ]
3215 and sexp_of_signed (v1, v2) =
3216 let v1 = sexp_of_sign v1 and v2 = sexp_of_base v2 in Sexp.List [ v1; v2 ]
3217 and sexp_of_base =
3218 function
3219 | CChar2 -> Sexp.Atom "CChar2"
3220 | CShort -> Sexp.Atom "CShort"
3221 | CInt -> Sexp.Atom "CInt"
3222 | CLong -> Sexp.Atom "CLong"
3223 | CLongLong -> Sexp.Atom "CLongLong"
3224 and sexp_of_sign =
3225 function | Signed -> Sexp.Atom "Signed" | UnSigned -> Sexp.Atom "UnSigned"
3226 and sexp_of_floatType =
3227 function
3228 | CFloat -> Sexp.Atom "CFloat"
3229 | CDouble -> Sexp.Atom "CDouble"
3230 | CLongDouble -> Sexp.Atom "CLongDouble"
3231 and sexp_of_structUnion =
3232 function | Struct -> Sexp.Atom "Struct" | Union -> Sexp.Atom "Union"
3233 and sexp_of_structType v = Conv.sexp_of_list sexp_of_field v
3234 and sexp_of_field =
3235 function
3236 | DeclarationField v1 ->
3237 let v1 = sexp_of_field_declaration v1
3238 in Sexp.List [ Sexp.Atom "DeclarationField"; v1 ]
3239 | EmptyField v1 ->
3240 let v1 = sexp_of_info v1 in Sexp.List [ Sexp.Atom "EmptyField"; v1 ]
3241 | MacroDeclField v1 ->
3242 let v1 =
3243 sexp_of_wrap
3244 (fun (v1, v2) ->
3245 let v1 = Conv.sexp_of_string v1
3246 and v2 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_argument) v2
3247 in Sexp.List [ v1; v2 ])
3248 v1
3249 in Sexp.List [ Sexp.Atom "MacroDeclField"; v1 ]
3250 | CppDirectiveStruct v1 ->
3251 let v1 = sexp_of_cpp_directive v1
3252 in Sexp.List [ Sexp.Atom "CppDirectiveStruct"; v1 ]
3253 | IfdefStruct v1 ->
3254 let v1 = sexp_of_ifdef_directive v1
3255 in Sexp.List [ Sexp.Atom "IfdefStruct"; v1 ]
3256 and sexp_of_field_declaration =
3257 function
3258 | FieldDeclList v1 ->
3259 let v1 =
3260 sexp_of_wrap (Conv.sexp_of_list (sexp_of_wrap2 sexp_of_fieldkind)) v1
3261 in Sexp.List [ Sexp.Atom "FieldDeclList"; v1 ]
3262 and sexp_of_fieldkind =
3263 function
3264 | Simple ((v1, v2)) ->
3265 let v1 = Conv.sexp_of_option sexp_of_name v1
3266 and v2 = sexp_of_fullType v2
3267 in Sexp.List [ Sexp.Atom "Simple"; v1; v2 ]
3268 | BitField ((v1, v2, v3, v4)) ->
3269 let v1 = Conv.sexp_of_option sexp_of_name v1
3270 and v2 = sexp_of_fullType v2
3271 and v3 = sexp_of_info v3
3272 and v4 = sexp_of_constExpression v4
3273 in Sexp.List [ Sexp.Atom "BitField"; v1; v2; v3; v4 ]
3274 and sexp_of_enumType v =
3275 Conv.sexp_of_list
3276 (sexp_of_wrap2
3277 (fun (v1, v2) ->
3278 let v1 = sexp_of_name v1
3279 and v2 =
3280 Conv.sexp_of_option
3281 (fun (v1, v2) ->
3282 let v1 = sexp_of_info v1
3283 and v2 = sexp_of_constExpression v2
3284 in Sexp.List [ v1; v2 ])
3285 v2
3286 in Sexp.List [ v1; v2 ]))
3287 v
3288 and sexp_of_functionType (v1, v2) =
3289 let v1 = sexp_of_fullType v1
3290 and v2 =
3291 match v2 with
3292 | (v1, v2) ->
3293 let v1 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_parameterType) v1
3294 and v2 = sexp_of_wrap Conv.sexp_of_bool v2
3295 in Sexp.List [ v1; v2 ]
3296 in Sexp.List [ v1; v2 ]
3297 and
3298 sexp_of_parameterType {
3299 p_namei = v_p_namei;
3300 p_register = v_p_register;
3301 p_type = v_p_type
3302 } =
3303 let bnds = [] in
3304 let arg = sexp_of_fullType v_p_type in
3305 let bnd = Sexp.List [ Sexp.Atom "p_type"; arg ] in
3306 let bnds = bnd :: bnds in
3307 let arg = sexp_of_wrap Conv.sexp_of_bool v_p_register in
3308 let bnd = Sexp.List [ Sexp.Atom "p_register"; arg ] in
3309 let bnds = bnd :: bnds in
3310 let arg = Conv.sexp_of_option sexp_of_name v_p_namei in
3311 let bnd = Sexp.List [ Sexp.Atom "p_namei"; arg ] in
3312 let bnds = bnd :: bnds in Sexp.List bnds
3313 and sexp_of_typeQualifier v = sexp_of_wrap sexp_of_typeQualifierbis v
3314 and sexp_of_typeQualifierbis { const = v_const; volatile = v_volatile } =
3315 if not !show_qualifier then Sexp.Atom ""
3316 else
3317 let bnds = [] in
3318 let arg = Conv.sexp_of_bool v_volatile in
3319 let bnd = Sexp.List [ Sexp.Atom "volatile"; arg ] in
3320 let bnds = bnd :: bnds in
3321 let arg = Conv.sexp_of_bool v_const in
3322 let bnd = Sexp.List [ Sexp.Atom "const"; arg ] in
3323 let bnds = bnd :: bnds in Sexp.List bnds
3324 and sexp_of_attribute v = sexp_of_wrap sexp_of_attributebis v
3325 and sexp_of_attributebis =
3326 function
3327 | Attribute v1 ->
3328 let v1 = Conv.sexp_of_string v1
3329 in Sexp.List [ Sexp.Atom "Attribute"; v1 ]
3330 and sexp_of_expression v =
3331 sexp_of_wrap
3332 (fun (v1, v2) ->
3333 let v1 = sexp_of_expressionbis v1
3334 and v2 =
3335 if not !show_expr_info then Sexp.Atom ""
3336 else Conv.sexp_of_ref sexp_of_exp_info v2
3337 in Sexp.List [ v1; v2 ])
3338 v
3339 and sexp_of_exp_info (v1, v2) =
3340 let v1 = Conv.sexp_of_option sexp_of_exp_type v1
3341 and v2 = sexp_of_test v2
3342 in Sexp.List [ v1; v2 ]
3343 and sexp_of_exp_type (v1, v2) =
3344 let v1 = sexp_of_fullType v1
3345 and v2 = sexp_of_local v2
3346 in Sexp.List [ v1; v2 ]
3347 and sexp_of_local =
3348 function
3349 | LocalVar v1 ->
3350 let v1 = sexp_of_parse_info v1
3351 in Sexp.List [ Sexp.Atom "LocalVar"; v1 ]
3352 | NotLocalVar -> Sexp.Atom "NotLocalVar"
3353 and sexp_of_test =
3354 function | Test -> Sexp.Atom "Test" | NotTest -> Sexp.Atom "NotTest"
3355 and sexp_of_expressionbis =
3356 function
3357 | Ident v1 ->
3358 let v1 = sexp_of_name v1 in Sexp.List [ Sexp.Atom "Ident"; v1 ]
3359 | Constant v1 ->
3360 let v1 = sexp_of_constant v1 in Sexp.List [ Sexp.Atom "Constant"; v1 ]
3361 | FunCall ((v1, v2)) ->
3362 let v1 = sexp_of_expression v1
3363 and v2 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_argument) v2
3364 in Sexp.List [ Sexp.Atom "FunCall"; v1; v2 ]
3365 | CondExpr ((v1, v2, v3)) ->
3366 let v1 = sexp_of_expression v1
3367 and v2 = Conv.sexp_of_option sexp_of_expression v2
3368 and v3 = sexp_of_expression v3
3369 in Sexp.List [ Sexp.Atom "CondExpr"; v1; v2; v3 ]
3370 | Sequence ((v1, v2)) ->
3371 let v1 = sexp_of_expression v1
3372 and v2 = sexp_of_expression v2
3373 in Sexp.List [ Sexp.Atom "Sequence"; v1; v2 ]
3374 | Assignment ((v1, v2, v3)) ->
3375 let v1 = sexp_of_expression v1
3376 and v2 = sexp_of_assignOp v2
3377 and v3 = sexp_of_expression v3
3378 in Sexp.List [ Sexp.Atom "Assignment"; v1; v2; v3 ]
3379 | Postfix ((v1, v2)) ->
3380 let v1 = sexp_of_expression v1
3381 and v2 = sexp_of_fixOp v2
3382 in Sexp.List [ Sexp.Atom "Postfix"; v1; v2 ]
3383 | Infix ((v1, v2)) ->
3384 let v1 = sexp_of_expression v1
3385 and v2 = sexp_of_fixOp v2
3386 in Sexp.List [ Sexp.Atom "Infix"; v1; v2 ]
3387 | Unary ((v1, v2)) ->
3388 let v1 = sexp_of_expression v1
3389 and v2 = sexp_of_unaryOp v2
3390 in Sexp.List [ Sexp.Atom "Unary"; v1; v2 ]
3391 | Binary ((v1, v2, v3)) ->
3392 let v1 = sexp_of_expression v1
3393 and v2 = sexp_of_binaryOp v2
3394 and v3 = sexp_of_expression v3
3395 in Sexp.List [ Sexp.Atom "Binary"; v1; v2; v3 ]
3396 | ArrayAccess ((v1, v2)) ->
3397 let v1 = sexp_of_expression v1
3398 and v2 = sexp_of_expression v2
3399 in Sexp.List [ Sexp.Atom "ArrayAccess"; v1; v2 ]
3400 | RecordAccess ((v1, v2)) ->
3401 let v1 = sexp_of_expression v1
3402 and v2 = sexp_of_name v2
3403 in Sexp.List [ Sexp.Atom "RecordAccess"; v1; v2 ]
3404 | RecordPtAccess ((v1, v2)) ->
3405 let v1 = sexp_of_expression v1
3406 and v2 = sexp_of_name v2
3407 in Sexp.List [ Sexp.Atom "RecordPtAccess"; v1; v2 ]
3408 | SizeOfExpr v1 ->
3409 let v1 = sexp_of_expression v1
3410 in Sexp.List [ Sexp.Atom "SizeOfExpr"; v1 ]
3411 | SizeOfType v1 ->
3412 let v1 = sexp_of_fullType v1
3413 in Sexp.List [ Sexp.Atom "SizeOfType"; v1 ]
3414 | Cast ((v1, v2)) ->
3415 let v1 = sexp_of_fullType v1
3416 and v2 = sexp_of_expression v2
3417 in Sexp.List [ Sexp.Atom "Cast"; v1; v2 ]
3418 | StatementExpr v1 ->
3419 let v1 = sexp_of_wrap sexp_of_compound v1
3420 in Sexp.List [ Sexp.Atom "StatementExpr"; v1 ]
3421 | Constructor ((v1, v2)) ->
3422 let v1 = sexp_of_fullType v1
3423 and v2 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_initialiser) v2
3424 in Sexp.List [ Sexp.Atom "Constructor"; v1; v2 ]
3425 | ParenExpr v1 ->
3426 let v1 = sexp_of_expression v1
3427 in Sexp.List [ Sexp.Atom "ParenExpr"; v1 ]
3428 and sexp_of_argument v =
3429 Common.sexp_of_either sexp_of_expression sexp_of_weird_argument v
3430 and sexp_of_weird_argument =
3431 function
3432 | ArgType v1 ->
3433 let v1 = sexp_of_parameterType v1
3434 in Sexp.List [ Sexp.Atom "ArgType"; v1 ]
3435 | ArgAction v1 ->
3436 let v1 = sexp_of_action_macro v1
3437 in Sexp.List [ Sexp.Atom "ArgAction"; v1 ]
3438 and sexp_of_action_macro =
3439 function
3440 | ActMisc v1 ->
3441 let v1 = sexp_of_il v1 in Sexp.List [ Sexp.Atom "ActMisc"; v1 ]
3442 and sexp_of_constant =
3443 function
3444 | String v1 ->
3445 let v1 =
3446 (match v1 with
3447 | (v1, v2) ->
3448 let v1 = Conv.sexp_of_string v1
3449 and v2 = sexp_of_isWchar v2
3450 in Sexp.List [ v1; v2 ])
3451 in Sexp.List [ Sexp.Atom "String"; v1 ]
3452 | MultiString v1 ->
3453 let v1 = Conv.sexp_of_list Conv.sexp_of_string v1
3454 in Sexp.List [ Sexp.Atom "MultiString"; v1 ]
3455 | Char v1 ->
3456 let v1 =
3457 (match v1 with
3458 | (v1, v2) ->
3459 let v1 = Conv.sexp_of_string v1
3460 and v2 = sexp_of_isWchar v2
3461 in Sexp.List [ v1; v2 ])
3462 in Sexp.List [ Sexp.Atom "Char"; v1 ]
3463 | Int (v1, _todo) ->
3464 let v1 = Conv.sexp_of_string v1 in Sexp.List [ Sexp.Atom "Int"; v1 ]
3465 | Float v1 ->
3466 let v1 =
3467 (match v1 with
3468 | (v1, v2) ->
3469 let v1 = Conv.sexp_of_string v1
3470 and v2 = sexp_of_floatType v2
3471 in Sexp.List [ v1; v2 ])
3472 in Sexp.List [ Sexp.Atom "Float"; v1 ]
3473 and sexp_of_isWchar =
3474 function | IsWchar -> Sexp.Atom "IsWchar" | IsChar -> Sexp.Atom "IsChar"
3475 and sexp_of_unaryOp =
3476 function
3477 | GetRef -> Sexp.Atom "GetRef"
3478 | DeRef -> Sexp.Atom "DeRef"
3479 | UnPlus -> Sexp.Atom "UnPlus"
3480 | UnMinus -> Sexp.Atom "UnMinus"
3481 | Tilde -> Sexp.Atom "Tilde"
3482 | Not -> Sexp.Atom "Not"
3483 | GetRefLabel -> Sexp.Atom "GetRefLabel"
3484 and sexp_of_assignOp =
3485 function
3486 | SimpleAssign -> Sexp.Atom "SimpleAssign"
3487 | OpAssign v1 ->
3488 let v1 = sexp_of_arithOp v1 in Sexp.List [ Sexp.Atom "OpAssign"; v1 ]
3489 and sexp_of_fixOp =
3490 function | Dec -> Sexp.Atom "Dec" | Inc -> Sexp.Atom "Inc"
3491 and sexp_of_binaryOp =
3492 function
3493 | Arith v1 ->
3494 let v1 = sexp_of_arithOp v1 in Sexp.List [ Sexp.Atom "Arith"; v1 ]
3495 | Logical v1 ->
3496 let v1 = sexp_of_logicalOp v1 in Sexp.List [ Sexp.Atom "Logical"; v1 ]
3497 and sexp_of_arithOp =
3498 function
3499 | Plus -> Sexp.Atom "Plus"
3500 | Minus -> Sexp.Atom "Minus"
3501 | Mul -> Sexp.Atom "Mul"
3502 | Div -> Sexp.Atom "Div"
3503 | Mod -> Sexp.Atom "Mod"
3504 | DecLeft -> Sexp.Atom "DecLeft"
3505 | DecRight -> Sexp.Atom "DecRight"
3506 | And -> Sexp.Atom "And"
3507 | Or -> Sexp.Atom "Or"
3508 | Xor -> Sexp.Atom "Xor"
3509 and sexp_of_logicalOp =
3510 function
3511 | Inf -> Sexp.Atom "Inf"
3512 | Sup -> Sexp.Atom "Sup"
3513 | InfEq -> Sexp.Atom "InfEq"
3514 | SupEq -> Sexp.Atom "SupEq"
3515 | Eq -> Sexp.Atom "Eq"
3516 | NotEq -> Sexp.Atom "NotEq"
3517 | AndLog -> Sexp.Atom "AndLog"
3518 | OrLog -> Sexp.Atom "OrLog"
3519 and sexp_of_constExpression v = sexp_of_expression v
3520 and sexp_of_statement v = sexp_of_wrap sexp_of_statementbis v
3521 and sexp_of_statementbis =
3522 function
3523 | Labeled v1 ->
3524 let v1 = sexp_of_labeled v1 in Sexp.List [ Sexp.Atom "Labeled"; v1 ]
3525 | Compound v1 ->
3526 let v1 = sexp_of_compound v1 in Sexp.List [ Sexp.Atom "Compound"; v1 ]
3527 | ExprStatement v1 ->
3528 let v1 = sexp_of_exprStatement v1
3529 in Sexp.List [ Sexp.Atom "ExprStatement"; v1 ]
3530 | Selection v1 ->
3531 let v1 = sexp_of_selection v1
3532 in Sexp.List [ Sexp.Atom "Selection"; v1 ]
3533 | Iteration v1 ->
3534 let v1 = sexp_of_iteration v1
3535 in Sexp.List [ Sexp.Atom "Iteration"; v1 ]
3536 | Jump v1 -> let v1 = sexp_of_jump v1 in Sexp.List [ Sexp.Atom "Jump"; v1 ]
3537 | Decl v1 ->
3538 let v1 = sexp_of_declaration v1 in Sexp.List [ Sexp.Atom "Decl"; v1 ]
3539 | Asm v1 ->
3540 let v1 = sexp_of_asmbody v1 in Sexp.List [ Sexp.Atom "Asm"; v1 ]
3541 | NestedFunc v1 ->
3542 let v1 = sexp_of_definition v1
3543 in Sexp.List [ Sexp.Atom "NestedFunc"; v1 ]
3544 | MacroStmt -> Sexp.Atom "MacroStmt"
3545 and sexp_of_labeled =
3546 function
3547 | Label ((v1, v2)) ->
3548 let v1 = sexp_of_name v1
3549 and v2 = sexp_of_statement v2
3550 in Sexp.List [ Sexp.Atom "Label"; v1; v2 ]
3551 | Case ((v1, v2)) ->
3552 let v1 = sexp_of_expression v1
3553 and v2 = sexp_of_statement v2
3554 in Sexp.List [ Sexp.Atom "Case"; v1; v2 ]
3555 | CaseRange ((v1, v2, v3)) ->
3556 let v1 = sexp_of_expression v1
3557 and v2 = sexp_of_expression v2
3558 and v3 = sexp_of_statement v3
3559 in Sexp.List [ Sexp.Atom "CaseRange"; v1; v2; v3 ]
3560 | Default v1 ->
3561 let v1 = sexp_of_statement v1 in Sexp.List [ Sexp.Atom "Default"; v1 ]
3562 and sexp_of_compound v = Conv.sexp_of_list sexp_of_statement_sequencable v
3563 and sexp_of_statement_sequencable =
3564 function
3565 | StmtElem v1 ->
3566 let v1 = sexp_of_statement v1 in Sexp.List [ Sexp.Atom "StmtElem"; v1 ]
3567 | CppDirectiveStmt v1 ->
3568 let v1 = sexp_of_cpp_directive v1
3569 in Sexp.List [ Sexp.Atom "CppDirectiveStmt"; v1 ]
3570 | IfdefStmt v1 ->
3571 let v1 = sexp_of_ifdef_directive v1
3572 in Sexp.List [ Sexp.Atom "IfdefStmt"; v1 ]
3573 | IfdefStmt2 ((v1, v2)) ->
3574 let v1 = Conv.sexp_of_list sexp_of_ifdef_directive v1
3575 and v2 =
3576 Conv.sexp_of_list (Conv.sexp_of_list sexp_of_statement_sequencable)
3577 v2
3578 in Sexp.List [ Sexp.Atom "IfdefStmt2"; v1; v2 ]
3579 and sexp_of_exprStatement v = Conv.sexp_of_option sexp_of_expression v
3580 and sexp_of_selection =
3581 function
3582 | If ((v1, v2, v3)) ->
3583 let v1 = sexp_of_expression v1
3584 and v2 = sexp_of_statement v2
3585 and v3 = sexp_of_statement v3
3586 in Sexp.List [ Sexp.Atom "If"; v1; v2; v3 ]
3587 | Switch ((v1, v2)) ->
3588 let v1 = sexp_of_expression v1
3589 and v2 = sexp_of_statement v2
3590 in Sexp.List [ Sexp.Atom "Switch"; v1; v2 ]
3591 and sexp_of_iteration =
3592 function
3593 | While ((v1, v2)) ->
3594 let v1 = sexp_of_expression v1
3595 and v2 = sexp_of_statement v2
3596 in Sexp.List [ Sexp.Atom "While"; v1; v2 ]
3597 | DoWhile ((v1, v2)) ->
3598 let v1 = sexp_of_statement v1
3599 and v2 = sexp_of_expression v2
3600 in Sexp.List [ Sexp.Atom "DoWhile"; v1; v2 ]
3601 | For ((v1, v2, v3, v4)) ->
3602 let v1 = sexp_of_wrap sexp_of_exprStatement v1
3603 and v2 = sexp_of_wrap sexp_of_exprStatement v2
3604 and v3 = sexp_of_wrap sexp_of_exprStatement v3
3605 and v4 = sexp_of_statement v4
3606 in Sexp.List [ Sexp.Atom "For"; v1; v2; v3; v4 ]
3607 | MacroIteration ((v1, v2, v3)) ->
3608 let v1 = Conv.sexp_of_string v1
3609 and v2 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_argument) v2
3610 and v3 = sexp_of_statement v3
3611 in Sexp.List [ Sexp.Atom "MacroIteration"; v1; v2; v3 ]
3612 and sexp_of_jump =
3613 function
3614 | Goto v1 -> let v1 = sexp_of_name v1 in Sexp.List [ Sexp.Atom "Goto"; v1 ]
3615 | Continue -> Sexp.Atom "Continue"
3616 | Break -> Sexp.Atom "Break"
3617 | Return -> Sexp.Atom "Return"
3618 | ReturnExpr v1 ->
3619 let v1 = sexp_of_expression v1
3620 in Sexp.List [ Sexp.Atom "ReturnExpr"; v1 ]
3621 | GotoComputed v1 ->
3622 let v1 = sexp_of_expression v1
3623 in Sexp.List [ Sexp.Atom "GotoComputed"; v1 ]
3624 and sexp_of_asmbody (v1, v2) =
3625 let v1 = sexp_of_il v1
3626 and v2 = Conv.sexp_of_list (sexp_of_wrap sexp_of_colon) v2
3627 in Sexp.List [ v1; v2 ]
3628 and sexp_of_colon =
3629 function
3630 | Colon v1 ->
3631 let v1 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_colon_option) v1
3632 in Sexp.List [ Sexp.Atom "Colon"; v1 ]
3633 and sexp_of_colon_option v = sexp_of_wrap sexp_of_colon_option_bis v
3634 and sexp_of_colon_option_bis =
3635 function
3636 | ColonMisc -> Sexp.Atom "ColonMisc"
3637 | ColonExpr v1 ->
3638 let v1 = sexp_of_expression v1
3639 in Sexp.List [ Sexp.Atom "ColonExpr"; v1 ]
3640 and sexp_of_declaration =
3641 function
3642 | DeclList v1 ->
3643 let v1 =
3644 sexp_of_wrap (Conv.sexp_of_list (sexp_of_wrap2 sexp_of_onedecl)) v1
3645 in Sexp.List [ Sexp.Atom "DeclList"; v1 ]
3646 | MacroDecl v1 ->
3647 let v1 =
3648 sexp_of_wrap
3649 (fun (v1, v2) ->
3650 let v1 = Conv.sexp_of_string v1
3651 and v2 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_argument) v2
3652 in Sexp.List [ v1; v2 ])
3653 v1
3654 in Sexp.List [ Sexp.Atom "MacroDecl"; v1 ]
3655 and
3656 sexp_of_onedecl {
3657 v_namei = v_v_namei;
3658 v_type = v_v_type;
3659 v_type_bis = v_v_type_bis;
3660 v_storage = v_v_storage;
3661 v_local = v_v_local;
3662 v_attr = v_v_attr
3663 } =
3664 let bnds = [] in
3665 let arg = Conv.sexp_of_list sexp_of_attribute v_v_attr in
3666 let bnd = Sexp.List [ Sexp.Atom "v_attr"; arg ] in
3667 let bnds = bnd :: bnds in
3668 let arg = sexp_of_local_decl v_v_local in
3669 let bnd = Sexp.List [ Sexp.Atom "v_local"; arg ] in
3670 let bnds = bnd :: bnds in
3671 let arg = sexp_of_storage v_v_storage in
3672 let bnd = Sexp.List [ Sexp.Atom "v_storage"; arg ] in
3673 let bnds = bnd :: bnds in
3674 let arg =
3675 Conv.sexp_of_ref (Conv.sexp_of_option sexp_of_fullType) v_v_type_bis in
3676 let bnd = Sexp.List [ Sexp.Atom "v_type_bis"; arg ] in
3677 let bnds = bnd :: bnds in
3678 let arg = sexp_of_fullType v_v_type in
3679 let bnd = Sexp.List [ Sexp.Atom "v_type"; arg ] in
3680 let bnds = bnd :: bnds in
3681 let arg =
3682 Conv.sexp_of_option
3683 (fun (v1, v2) ->
3684 let v1 = sexp_of_name v1
3685 and v2 =
3686 Conv.sexp_of_option
3687 (fun (v1, v2) ->
3688 let v1 = sexp_of_info v1
3689 and v2 = sexp_of_initialiser v2
3690 in Sexp.List [ v1; v2 ])
3691 v2
3692 in Sexp.List [ v1; v2 ])
3693 v_v_namei in
3694 let bnd = Sexp.List [ Sexp.Atom "v_namei"; arg ] in
3695 let bnds = bnd :: bnds in Sexp.List bnds
3696 and sexp_of_storage (v1, v2) =
3697 let v1 = sexp_of_storagebis v1
3698 and v2 = Conv.sexp_of_bool v2
3699 in Sexp.List [ v1; v2 ]
3700 and sexp_of_storagebis =
3701 function
3702 | NoSto -> Sexp.Atom "NoSto"
3703 | StoTypedef -> Sexp.Atom "StoTypedef"
3704 | Sto v1 ->
3705 let v1 = sexp_of_storageClass v1 in Sexp.List [ Sexp.Atom "Sto"; v1 ]
3706 and sexp_of_storageClass =
3707 function
3708 | Auto -> Sexp.Atom "Auto"
3709 | Static -> Sexp.Atom "Static"
3710 | Register -> Sexp.Atom "Register"
3711 | Extern -> Sexp.Atom "Extern"
3712 and sexp_of_local_decl =
3713 function
3714 | LocalDecl -> Sexp.Atom "LocalDecl"
3715 | NotLocalDecl -> Sexp.Atom "NotLocalDecl"
3716 and sexp_of_initialiser v = sexp_of_wrap sexp_of_initialiserbis v
3717 and sexp_of_initialiserbis =
3718 function
3719 | InitExpr v1 ->
3720 let v1 = sexp_of_expression v1
3721 in Sexp.List [ Sexp.Atom "InitExpr"; v1 ]
3722 | InitList v1 ->
3723 let v1 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_initialiser) v1
3724 in Sexp.List [ Sexp.Atom "InitList"; v1 ]
3725 | InitDesignators ((v1, v2)) ->
3726 let v1 = Conv.sexp_of_list sexp_of_designator v1
3727 and v2 = sexp_of_initialiser v2
3728 in Sexp.List [ Sexp.Atom "InitDesignators"; v1; v2 ]
3729 | InitFieldOld ((v1, v2)) ->
3730 let v1 = Conv.sexp_of_string v1
3731 and v2 = sexp_of_initialiser v2
3732 in Sexp.List [ Sexp.Atom "InitFieldOld"; v1; v2 ]
3733 | InitIndexOld ((v1, v2)) ->
3734 let v1 = sexp_of_expression v1
3735 and v2 = sexp_of_initialiser v2
3736 in Sexp.List [ Sexp.Atom "InitIndexOld"; v1; v2 ]
3737 and sexp_of_designator v = sexp_of_wrap sexp_of_designatorbis v
3738 and sexp_of_designatorbis =
3739 function
3740 | DesignatorField v1 ->
3741 let v1 = Conv.sexp_of_string v1
3742 in Sexp.List [ Sexp.Atom "DesignatorField"; v1 ]
3743 | DesignatorIndex v1 ->
3744 let v1 = sexp_of_expression v1
3745 in Sexp.List [ Sexp.Atom "DesignatorIndex"; v1 ]
3746 | DesignatorRange ((v1, v2)) ->
3747 let v1 = sexp_of_expression v1
3748 and v2 = sexp_of_expression v2
3749 in Sexp.List [ Sexp.Atom "DesignatorRange"; v1; v2 ]
3750 and sexp_of_definition v = sexp_of_wrap sexp_of_definitionbis v
3751 and
3752 sexp_of_definitionbis {
3753 f_name = v_f_name;
3754 f_type = v_f_type;
3755 f_storage = v_f_storage;
3756 f_body = v_f_body;
3757 f_attr = v_f_attr;
3758 f_old_c_style = v_f_old_c_style
3759 } =
3760 let bnds = [] in
3761 let arg =
3762 Conv.sexp_of_option (Conv.sexp_of_list sexp_of_declaration)
3763 v_f_old_c_style in
3764 let bnd = Sexp.List [ Sexp.Atom "f_old_c_style"; arg ] in
3765 let bnds = bnd :: bnds in
3766 let arg = Conv.sexp_of_list sexp_of_attribute v_f_attr in
3767 let bnd = Sexp.List [ Sexp.Atom "f_attr"; arg ] in
3768 let bnds = bnd :: bnds in
3769 let arg = sexp_of_compound v_f_body in
3770 let bnd = Sexp.List [ Sexp.Atom "f_body"; arg ] in
3771 let bnds = bnd :: bnds in
3772 let arg = sexp_of_storage v_f_storage in
3773 let bnd = Sexp.List [ Sexp.Atom "f_storage"; arg ] in
3774 let bnds = bnd :: bnds in
3775 let arg = sexp_of_functionType v_f_type in
3776 let bnd = Sexp.List [ Sexp.Atom "f_type"; arg ] in
3777 let bnds = bnd :: bnds in
3778 let arg = sexp_of_name v_f_name in
3779 let bnd = Sexp.List [ Sexp.Atom "f_name"; arg ] in
3780 let bnds = bnd :: bnds in Sexp.List bnds
3781 and sexp_of_cpp_directive =
3782 function
3783 | Define v1 ->
3784 let v1 = sexp_of_define v1 in Sexp.List [ Sexp.Atom "Define"; v1 ]
3785 | Include v1 ->
3786 let v1 = sexp_of_includ v1 in Sexp.List [ Sexp.Atom "Include"; v1 ]
3787 | Undef v1 ->
3788 let v1 = sexp_of_wrap Conv.sexp_of_string v1
3789 in Sexp.List [ Sexp.Atom "Undef"; v1 ]
3790 | PragmaAndCo v1 ->
3791 let v1 = sexp_of_il v1 in Sexp.List [ Sexp.Atom "PragmaAndCo"; v1 ]
3792 and sexp_of_define (v1, v2) =
3793 let v1 = sexp_of_wrap Conv.sexp_of_string v1
3794 and v2 =
3795 match v2 with
3796 | (v1, v2) ->
3797 let v1 = sexp_of_define_kind v1
3798 and v2 = sexp_of_define_val v2
3799 in Sexp.List [ v1; v2 ]
3800 in Sexp.List [ v1; v2 ]
3801 and sexp_of_define_kind =
3802 function
3803 | DefineVar -> Sexp.Atom "DefineVar"
3804 | DefineFunc v1 ->
3805 let v1 =
3806 sexp_of_wrap
3807 (Conv.sexp_of_list
3808 (sexp_of_wrap2 (sexp_of_wrap Conv.sexp_of_string)))
3809 v1
3810 in Sexp.List [ Sexp.Atom "DefineFunc"; v1 ]
3811 and sexp_of_define_val =
3812 function
3813 | DefineExpr v1 ->
3814 let v1 = sexp_of_expression v1
3815 in Sexp.List [ Sexp.Atom "DefineExpr"; v1 ]
3816 | DefineStmt v1 ->
3817 let v1 = sexp_of_statement v1
3818 in Sexp.List [ Sexp.Atom "DefineStmt"; v1 ]
3819 | DefineType v1 ->
3820 let v1 = sexp_of_fullType v1
3821 in Sexp.List [ Sexp.Atom "DefineType"; v1 ]
3822 | DefineDoWhileZero v1 ->
3823 let v1 =
3824 sexp_of_wrap
3825 (fun (v1, v2) ->
3826 let v1 = sexp_of_statement v1
3827 and v2 = sexp_of_expression v2
3828 in Sexp.List [ v1; v2 ])
3829 v1
3830 in Sexp.List [ Sexp.Atom "DefineDoWhileZero"; v1 ]
3831 | DefineFunction v1 ->
3832 let v1 = sexp_of_definition v1
3833 in Sexp.List [ Sexp.Atom "DefineFunction"; v1 ]
3834 | DefineInit v1 ->
3835 let v1 = sexp_of_initialiser v1
3836 in Sexp.List [ Sexp.Atom "DefineInit"; v1 ]
3837 | DefineText v1 ->
3838 let v1 = sexp_of_wrap Conv.sexp_of_string v1
3839 in Sexp.List [ Sexp.Atom "DefineText"; v1 ]
3840 | DefineEmpty -> Sexp.Atom "DefineEmpty"
3841 | DefineTodo -> Sexp.Atom "DefineTodo"
3842 and
3843 sexp_of_includ {
3844 i_include = v_i_include;
3845 i_rel_pos = v_i_rel_pos;
3846 i_is_in_ifdef = v_i_is_in_ifdef;
3847 i_content = v_i_content
3848 } =
3849 let bnds = [] in
3850 let arg =
3851 Conv.sexp_of_option
3852 (fun (v1, v2) ->
3853 let v1 = Common.sexp_of_filename v1
3854 and v2 = sexp_of_program v2
3855 in Sexp.List [ v1; v2 ])
3856 v_i_content in
3857 let bnd = Sexp.List [ Sexp.Atom "i_content"; arg ] in
3858 let bnds = bnd :: bnds in
3859 let arg = Conv.sexp_of_bool v_i_is_in_ifdef in
3860 let bnd = Sexp.List [ Sexp.Atom "i_is_in_ifdef"; arg ] in
3861 let bnds = bnd :: bnds in
3862 let arg =
3863 Conv.sexp_of_ref (Conv.sexp_of_option sexp_of_include_rel_pos)
3864 v_i_rel_pos in
3865 let bnd = Sexp.List [ Sexp.Atom "i_rel_pos"; arg ] in
3866 let bnds = bnd :: bnds in
3867 let arg = sexp_of_wrap sexp_of_inc_file v_i_include in
3868 let bnd = Sexp.List [ Sexp.Atom "i_include"; arg ] in
3869 let bnds = bnd :: bnds in Sexp.List bnds
3870 and sexp_of_inc_file =
3871 function
3872 | Local v1 ->
3873 let v1 = Conv.sexp_of_list sexp_of_inc_elem v1
3874 in Sexp.List [ Sexp.Atom "Local"; v1 ]
3875 | NonLocal v1 ->
3876 let v1 = Conv.sexp_of_list sexp_of_inc_elem v1
3877 in Sexp.List [ Sexp.Atom "NonLocal"; v1 ]
3878 | Weird v1 ->
3879 let v1 = Conv.sexp_of_string v1 in Sexp.List [ Sexp.Atom "Weird"; v1 ]
3880 and sexp_of_inc_elem v = Conv.sexp_of_string v
3881 and sexp_of_include_rel_pos { first_of = v_first_of; last_of = v_last_of } =
3882 let bnds = [] in
3883 let arg =
3884 Conv.sexp_of_list (Conv.sexp_of_list Conv.sexp_of_string) v_last_of in
3885 let bnd = Sexp.List [ Sexp.Atom "last_of"; arg ] in
3886 let bnds = bnd :: bnds in
3887 let arg =
3888 Conv.sexp_of_list (Conv.sexp_of_list Conv.sexp_of_string) v_first_of in
3889 let bnd = Sexp.List [ Sexp.Atom "first_of"; arg ] in
3890 let bnds = bnd :: bnds in Sexp.List bnds
3891 and sexp_of_ifdef_directive =
3892 function
3893 | IfdefDirective v1 ->
3894 let v1 =
3895 sexp_of_wrap
3896 (fun (v1, v2) ->
3897 let v1 = sexp_of_ifdefkind v1
3898 and v2 = sexp_of_matching_tag v2
3899 in Sexp.List [ v1; v2 ])
3900 v1
3901 in Sexp.List [ Sexp.Atom "IfdefDirective"; v1 ]
3902 and sexp_of_ifdefkind =
3903 function
3904 | Ifdef -> Sexp.Atom "Ifdef"
3905 | IfdefElseif -> Sexp.Atom "IfdefElseif"
3906 | IfdefElse -> Sexp.Atom "IfdefElse"
3907 | IfdefEndif -> Sexp.Atom "IfdefEndif"
3908 and sexp_of_matching_tag =
3909 function
3910 | IfdefTag v1 ->
3911 let v1 =
3912 (match v1 with
3913 | (v1, v2) ->
3914 let v1 = Conv.sexp_of_int v1
3915 and v2 = Conv.sexp_of_int v2
3916 in Sexp.List [ v1; v2 ])
3917 in Sexp.List [ Sexp.Atom "IfdefTag"; v1 ]
3918 and sexp_of_toplevel =
3919 function
3920 | Declaration v1 ->
3921 let v1 = sexp_of_declaration v1
3922 in Sexp.List [ Sexp.Atom "Declaration"; v1 ]
3923 | Definition v1 ->
3924 let v1 = sexp_of_definition v1
3925 in Sexp.List [ Sexp.Atom "Definition"; v1 ]
3926 | CppTop v1 ->
3927 let v1 = sexp_of_cpp_directive v1
3928 in Sexp.List [ Sexp.Atom "CppTop"; v1 ]
3929 | IfdefTop v1 ->
3930 let v1 = sexp_of_ifdef_directive v1
3931 in Sexp.List [ Sexp.Atom "IfdefTop"; v1 ]
3932 | MacroTop ((v1, v2, v3)) ->
3933 let v1 = Conv.sexp_of_string v1
3934 and v2 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_argument) v2
3935 and v3 = sexp_of_il v3
3936 in Sexp.List [ Sexp.Atom "MacroTop"; v1; v2; v3 ]
3937 | EmptyDef v1 ->
3938 let v1 = sexp_of_il v1 in Sexp.List [ Sexp.Atom "EmptyDef"; v1 ]
3939 | NotParsedCorrectly v1 ->
3940 let v1 = sexp_of_il v1
3941 in Sexp.List [ Sexp.Atom "NotParsedCorrectly"; v1 ]
3942 | FinalDef v1 ->
3943 let v1 = sexp_of_info v1 in Sexp.List [ Sexp.Atom "FinalDef"; v1 ]
3944 and sexp_of_program v = Conv.sexp_of_list sexp_of_toplevel v
3945
3946 (*
3947 and sexp_of_metavars_binding v =
3948 failwith "Todo"
3949 (*
3950 Common.sexp_of_assoc Ast_cocci.sexp_of_meta_name sexp_of_metavar_binding_kind v
3951 *)
3952 and sexp_of_metavar_binding_kind =
3953 function
3954 | MetaIdVal v1 ->
3955 let v1 = Conv.sexp_of_string v1
3956 in Sexp.List [ Sexp.Atom "MetaIdVal"; v1 ]
3957 | MetaFuncVal v1 ->
3958 let v1 = Conv.sexp_of_string v1
3959 in Sexp.List [ Sexp.Atom "MetaFuncVal"; v1 ]
3960 | MetaLocalFuncVal v1 ->
3961 let v1 = Conv.sexp_of_string v1
3962 in Sexp.List [ Sexp.Atom "MetaLocalFuncVal"; v1 ]
3963 | MetaExprVal v1 ->
3964 let v1 = sexp_of_expression v1
3965 in Sexp.List [ Sexp.Atom "MetaExprVal"; v1 ]
3966 | MetaExprListVal v1 ->
3967 let v1 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_argument) v1
3968 in Sexp.List [ Sexp.Atom "MetaExprListVal"; v1 ]
3969 | MetaParamVal v1 ->
3970 let v1 = sexp_of_parameterType v1
3971 in Sexp.List [ Sexp.Atom "MetaParamVal"; v1 ]
3972 | MetaParamListVal v1 ->
3973 let v1 = Conv.sexp_of_list (sexp_of_wrap2 sexp_of_parameterType) v1
3974 in Sexp.List [ Sexp.Atom "MetaParamListVal"; v1 ]
3975 | MetaTypeVal v1 ->
3976 let v1 = sexp_of_fullType v1
3977 in Sexp.List [ Sexp.Atom "MetaTypeVal"; v1 ]
3978 | MetaInitVal v1 ->
3979 let v1 = sexp_of_initialiser v1
3980 in Sexp.List [ Sexp.Atom "MetaInitVal"; v1 ]
3981 | MetaStmtVal v1 ->
3982 let v1 = sexp_of_statement v1
3983 in Sexp.List [ Sexp.Atom "MetaStmtVal"; v1 ]
3984 | MetaPosVal v1 ->
3985 let v1 =
3986 (match v1 with
3987 | (v1, v2) ->
3988 let v1 = Ast_cocci.sexp_of_fixpos v1
3989 and v2 = Ast_cocci.sexp_of_fixpos v2
3990 in Sexp.List [ v1; v2 ])
3991 in Sexp.List [ Sexp.Atom "MetaPosVal"; v1 ]
3992 | MetaPosValList v1 ->
3993 let v1 =
3994 Conv.sexp_of_list
3995 (fun (v1, v2, v3, v4) ->
3996 let v1 = Common.sexp_of_filename v1
3997 and v2 = Conv.sexp_of_string v2
3998 and v3 = sexp_of_posl v3
3999 and v4 = sexp_of_posl v4
4000 in Sexp.List [ v1; v2; v3; v4 ])
4001 v1
4002 in Sexp.List [ Sexp.Atom "MetaPosValList"; v1 ]
4003 | MetaListlenVal v1 ->
4004 let v1 = Conv.sexp_of_int v1
4005 in Sexp.List [ Sexp.Atom "MetaListlenVal"; v1 ]
4006
4007 *)
4008
4009 (* pad: *)
4010 let string_of_toplevel top =
4011 let sexp = sexp_of_toplevel top in
4012 let s = Sexp.to_string_hum sexp in
4013 s
4014
4015 let string_of_expression x =
4016 let sexp = sexp_of_expression x in
4017 let s = Sexp.to_string_hum sexp in
4018 s
4019
4020 let string_of_program xs =
4021 let sexp = sexp_of_program xs in
4022 let s = Sexp.to_string_hum sexp in
4023 s