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