summaryrefslogtreecommitdiff
path: root/tools/eqparsetree.ml
blob: c2571c3609ef87e4d0c6b0d5ac6179ed61f6edf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
(**************************************************************************)
(*                                                                        *)
(*                                OCaml                                   *)
(*                                                                        *)
(*    Hongbo Zhang (University of Pennsylvania)                           *)
(*                                                                        *)
(*   Copyright 2007 Institut National de Recherche en Informatique et     *)
(*   en Automatique.  All rights reserved.  This file is distributed      *)
(*   under the terms of the Q Public License version 1.0.                 *)
(*                                                                        *)
(**************************************************************************)


(*
  This module is mainly used to diff two parsetree, it helps to automate the
  test for parsing/pprintast.ml
 *)


open Parsetree
let curry f (g, h) = f g h
let eq_int : (int*int)->bool = curry (=)
let eq_char : (char*char)->bool=curry (=)
let eq_string : (string*string)->bool = curry (=)
let eq_int32 : (int32*int32)->bool=curry (=)
let eq_int64 : (int64*int64)->bool =curry (=)
let eq_nativeint : (nativeint*nativeint)->bool= curry (=)
let eq_bool :(bool*bool) -> bool = curry (=)
let eq_list mf_a (xs, ys) =
  let rec loop =
    function
      | ([], []) -> true
        | (x :: xs, y :: ys) -> (mf_a (x, y)) && (loop (xs, ys))
        | (_, _) -> false
  in loop (xs, ys)
let eq_option mf_a (x, y) =
  match (x, y) with
  | (None, None) -> true
  | (Some x, Some y) -> mf_a (x, y)
  | (_, _) -> false

module Location =struct
  include Location
  let eq_t : (t*t) -> bool = fun (_,_) -> true
end
module Longident = struct
  include Longident
  let rec eq_t : (t * t) -> 'result =
    function
    | (Lident a0, Lident b0) -> eq_string (a0, b0)
    | (Ldot (a0, a1), Ldot (b0, b1)) ->
      (eq_t (a0, b0)) && (eq_string (a1, b1))
    | (Lapply (a0, a1), Lapply (b0, b1)) ->
      (eq_t (a0, b0)) && (eq_t (a1, b1))
    | (_, _) -> false
end
module Asttypes = struct
  open Asttypes
  let eq_constant : (constant * constant) -> 'result =
    function
    | (Const_int a0, Const_int b0) -> eq_int (a0, b0)
    | (Const_char a0, Const_char b0) -> eq_char (a0, b0)
    | (Const_string a0, Const_string b0) -> eq_string (a0, b0)
    | (Const_float a0, Const_float b0) -> eq_string (a0, b0)
    | (Const_int32 a0, Const_int32 b0) -> eq_int32 (a0, b0)
    | (Const_int64 a0, Const_int64 b0) -> eq_int64 (a0, b0)
    | (Const_nativeint a0, Const_nativeint b0) -> eq_nativeint (a0, b0)
    | (_, _) -> false

  let eq_rec_flag : (rec_flag * rec_flag) -> 'result =
    function
    | (Nonrecursive, Nonrecursive) -> true
    | (Recursive, Recursive) -> true
    | (Default, Default) -> true
    | (_, _) -> false

  let eq_direction_flag :
    (direction_flag * direction_flag) -> 'result =
    function
    | (Upto, Upto) -> true
    | (Downto, Downto) -> true
    | (_, _) -> false

  let eq_private_flag : (private_flag * private_flag) -> 'result =
    function
    | (Private, Private) -> true
    | (Public, Public) -> true
    | (_, _) -> false

  let eq_mutable_flag : (mutable_flag * mutable_flag) -> 'result =
    function
    | (Immutable, Immutable) -> true
    | (Mutable, Mutable) -> true
    | (_, _) -> false

  let eq_virtual_flag : (virtual_flag * virtual_flag) -> 'result =
    function
    | (Virtual, Virtual) -> true
    | (Concrete, Concrete) -> true
    | (_, _) -> false

  let eq_override_flag : (override_flag * override_flag) -> 'result =
    function
    | (Override, Override) -> true
    | (Fresh, Fresh) -> true
    | (_, _) -> false

  let eq_closed_flag : (closed_flag * closed_flag) -> 'result =
    function
    | (Closed, Closed) -> true
    | (Open, Open) -> true
    | (_, _) -> false

  let eq_label : (label * label) -> 'result =
    fun (a0, a1) -> eq_string (a0, a1)

  let  eq_loc :
    'all_a0.
      (('all_a0 * 'all_a0) -> 'result) ->
        (('all_a0 loc) * ('all_a0 loc)) -> 'result =
    fun mf_a ({ txt = a0; loc = a1 }, { txt = b0; loc = b1 }) ->
      (mf_a (a0, b0)) && (Location.eq_t (a1, b1))

end

let rec eq_row_field : (row_field * row_field) -> 'result =
  function
  | (Rtag (a0, a1, a2), Rtag (b0, b1, b2)) ->
      ((Asttypes.eq_label (a0, b0)) && (eq_bool (a1, b1))) &&
        (eq_list eq_core_type (a2, b2))
  | (Rinherit a0, Rinherit b0) -> eq_core_type (a0, b0)
  | (_, _) -> false
and eq_core_field_desc :
  (core_field_desc * core_field_desc) -> 'result =
  function
  | (Pfield (a0, a1), Pfield (b0, b1)) ->
      (eq_string (a0, b0)) && (eq_core_type (a1, b1))
  | (Pfield_var, Pfield_var) -> true
  | (_, _) -> false
and eq_core_field_type :
  (core_field_type * core_field_type) -> 'result =
  fun
    ({ pfield_desc = a0; pfield_loc = a1 },
     { pfield_desc = b0; pfield_loc = b1 })
    -> (eq_core_field_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_package_type : (package_type * package_type) -> 'result =
  fun (a0, a1) ->
    (fun ((a0, a1), (b0, b1)) ->
       (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
         (eq_list
            (fun ((a0, a1), (b0, b1)) ->
               (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
                 (eq_core_type (a1, b1)))
            (a1, b1)))
      (a0, a1)
and eq_core_type_desc :
  (core_type_desc * core_type_desc) -> 'result =
  function
  | (Ptyp_any, Ptyp_any) -> true
  | (Ptyp_var a0, Ptyp_var b0) -> eq_string (a0, b0)
  | (Ptyp_arrow (a0, a1, a2), Ptyp_arrow (b0, b1, b2)) ->
      ((Asttypes.eq_label (a0, b0)) && (eq_core_type (a1, b1))) &&
        (eq_core_type (a2, b2))
  | (Ptyp_tuple a0, Ptyp_tuple b0) -> eq_list eq_core_type (a0, b0)
  | (Ptyp_constr (a0, a1), Ptyp_constr (b0, b1)) ->
      (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
        (eq_list eq_core_type (a1, b1))
  | (Ptyp_object a0, Ptyp_object b0) ->
      eq_list eq_core_field_type (a0, b0)
  | (Ptyp_class (a0, a1, a2), Ptyp_class (b0, b1, b2)) ->
      ((Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
         (eq_list eq_core_type (a1, b1)))
        && (eq_list Asttypes.eq_label (a2, b2))
  | (Ptyp_alias (a0, a1), Ptyp_alias (b0, b1)) ->
      (eq_core_type (a0, b0)) && (eq_string (a1, b1))
  | (Ptyp_variant (a0, a1, a2), Ptyp_variant (b0, b1, b2)) ->
      ((eq_list eq_row_field (a0, b0)) && (eq_bool (a1, b1))) &&
        (eq_option (eq_list Asttypes.eq_label) (a2, b2))
  | (Ptyp_poly (a0, a1), Ptyp_poly (b0, b1)) ->
      (eq_list eq_string (a0, b0)) && (eq_core_type (a1, b1))
  | (Ptyp_package a0, Ptyp_package b0) -> eq_package_type (a0, b0)
  | (_, _) -> false
and eq_core_type : (core_type * core_type) -> 'result =
  fun
    ({ ptyp_desc = a0; ptyp_loc = a1 },
     { ptyp_desc = b0; ptyp_loc = b1 })
    -> (eq_core_type_desc (a0, b0)) && (Location.eq_t (a1, b1))

let eq_class_infos :
  'all_a0.
    (('all_a0 * 'all_a0) -> 'result) ->
      (('all_a0 class_infos) * ('all_a0 class_infos)) -> 'result =
  fun mf_a
    ({
       pci_virt = a0;
       pci_params = a1;
       pci_name = a2;
       pci_expr = a3;
       pci_variance = a4;
       pci_loc = a5
     },
     {
       pci_virt = b0;
       pci_params = b1;
       pci_name = b2;
       pci_expr = b3;
       pci_variance = b4;
       pci_loc = b5
     })
    ->
    (((((Asttypes.eq_virtual_flag (a0, b0)) &&
          ((fun ((a0, a1), (b0, b1)) ->
              (eq_list (Asttypes.eq_loc eq_string) (a0, b0)) &&
                (Location.eq_t (a1, b1)))
             (a1, b1)))
         && (Asttypes.eq_loc eq_string (a2, b2)))
        && (mf_a (a3, b3)))
       &&
       (eq_list
          (fun ((a0, a1), (b0, b1)) ->
             (eq_bool (a0, b0)) && (eq_bool (a1, b1)))
          (a4, b4)))
      && (Location.eq_t (a5, b5))

let rec eq_pattern_desc : (pattern_desc * pattern_desc) -> 'result =
  function
  | (Ppat_any, Ppat_any) -> true
  | (Ppat_var a0, Ppat_var b0) -> Asttypes.eq_loc eq_string (a0, b0)
  | (Ppat_alias (a0, a1), Ppat_alias (b0, b1)) ->
      (eq_pattern (a0, b0)) && (Asttypes.eq_loc eq_string (a1, b1))
  | (Ppat_constant a0, Ppat_constant b0) ->
      Asttypes.eq_constant (a0, b0)
  | (Ppat_tuple a0, Ppat_tuple b0) -> eq_list eq_pattern (a0, b0)
  | (Ppat_construct (a0, a1), Ppat_construct (b0, b1)) ->
      ((Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
         (eq_option eq_pattern (a1, b1)))
  | (Ppat_variant (a0, a1), Ppat_variant (b0, b1)) ->
      (Asttypes.eq_label (a0, b0)) && (eq_option eq_pattern (a1, b1))
  | (Ppat_record (a0, a1), Ppat_record (b0, b1)) ->
      (eq_list
         (fun ((a0, a1), (b0, b1)) ->
            (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
              (eq_pattern (a1, b1)))
         (a0, b0))
        && (Asttypes.eq_closed_flag (a1, b1))
  | (Ppat_array a0, Ppat_array b0) -> eq_list eq_pattern (a0, b0)
  | (Ppat_or (a0, a1), Ppat_or (b0, b1)) ->
      (eq_pattern (a0, b0)) && (eq_pattern (a1, b1))
  | (Ppat_constraint (a0, a1), Ppat_constraint (b0, b1)) ->
      (eq_pattern (a0, b0)) && (eq_core_type (a1, b1))
  | (Ppat_type a0, Ppat_type b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (Ppat_lazy a0, Ppat_lazy b0) -> eq_pattern (a0, b0)
  | (Ppat_unpack a0, Ppat_unpack b0) ->
      Asttypes.eq_loc eq_string (a0, b0)
  | (_, _) -> false
and eq_pattern : (pattern * pattern) -> 'result =
  fun
    ({ ppat_desc = a0; ppat_loc = a1 },
     { ppat_desc = b0; ppat_loc = b1 })
    -> (eq_pattern_desc (a0, b0)) && (Location.eq_t (a1, b1))

let rec eq_structure_item_desc :
  (structure_item_desc * structure_item_desc) -> 'result =
  function
  | (Pstr_eval a0, Pstr_eval b0) -> eq_expression (a0, b0)
  | (Pstr_value (a0, a1), Pstr_value (b0, b1)) ->
      (Asttypes.eq_rec_flag (a0, b0)) &&
        (eq_list
           (fun ((a0, a1), (b0, b1)) ->
              (eq_pattern (a0, b0)) && (eq_expression (a1, b1)))
           (a1, b1))
  | (Pstr_primitive (a0, a1), Pstr_primitive (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_value_description (a1, b1))
  | (Pstr_type (a0, a1), Pstr_type (b0, b1)) ->
      (Asttypes.eq_rec_flag (a0, b0) &&
      eq_list
        (fun ((a0, a1), (b0, b1)) ->
           (Asttypes.eq_loc eq_string (a0, b0)) &&
             (eq_type_declaration (a1, b1)))
        (a1, b1)
  | (Pstr_exception (a0, a1), Pstr_exception (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_exception_declaration (a1, b1))
  | (Pstr_exn_rebind (a0, a1), Pstr_exn_rebind (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (Asttypes.eq_loc Longident.eq_t (a1, b1))
  | (Pstr_module (a0, a1), Pstr_module (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_module_expr (a1, b1))
  | (Pstr_recmodule a0, Pstr_recmodule b0) ->
      eq_list
        (fun ((a0, a1, a2), (b0, b1, b2)) ->
           ((Asttypes.eq_loc eq_string (a0, b0)) &&
              (eq_module_type (a1, b1)))
             && (eq_module_expr (a2, b2)))
        (a0, b0)
  | (Pstr_modtype (a0, a1), Pstr_modtype (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_module_type (a1, b1))
  | (Pstr_open a0, Pstr_open b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (Pstr_class a0, Pstr_class b0) ->
      eq_list eq_class_declaration (a0, b0)
  | (Pstr_class_type a0, Pstr_class_type b0) ->
      eq_list eq_class_type_declaration (a0, b0)
  | (Pstr_include a0, Pstr_include b0) -> eq_module_expr (a0, b0)
  | (_, _) -> false
and eq_structure_item :
  (structure_item * structure_item) -> 'result =
  fun
    ({ pstr_desc = a0; pstr_loc = a1 },
     { pstr_desc = b0; pstr_loc = b1 })
    -> (eq_structure_item_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_structure : (structure * structure) -> 'result =
  fun (a0, a1) -> eq_list eq_structure_item (a0, a1)
and eq_module_expr_desc :
  (module_expr_desc * module_expr_desc) -> 'result =
  function
  | (Pmod_ident a0, Pmod_ident b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (Pmod_structure a0, Pmod_structure b0) -> eq_structure (a0, b0)
  | (Pmod_functor (a0, a1, a2), Pmod_functor (b0, b1, b2)) ->
      ((Asttypes.eq_loc eq_string (a0, b0)) &&
         (eq_module_type (a1, b1)))
        && (eq_module_expr (a2, b2))
  | (Pmod_apply (a0, a1), Pmod_apply (b0, b1)) ->
      (eq_module_expr (a0, b0)) && (eq_module_expr (a1, b1))
  | (Pmod_constraint (a0, a1), Pmod_constraint (b0, b1)) ->
      (eq_module_expr (a0, b0)) && (eq_module_type (a1, b1))
  | (Pmod_unpack a0, Pmod_unpack b0) -> eq_expression (a0, b0)
  | (_, _) -> false
and eq_module_expr : (module_expr * module_expr) -> 'result =
  fun
    ({ pmod_desc = a0; pmod_loc = a1 },
     { pmod_desc = b0; pmod_loc = b1 })
    -> (eq_module_expr_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_with_constraint :
  (with_constraint * with_constraint) -> 'result =
  function
  | (Pwith_type a0, Pwith_type b0) -> eq_type_declaration (a0, b0)
  | (Pwith_module a0, Pwith_module b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (Pwith_typesubst a0, Pwith_typesubst b0) ->
      eq_type_declaration (a0, b0)
  | (Pwith_modsubst a0, Pwith_modsubst b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (_, _) -> false
and eq_modtype_declaration :
  (modtype_declaration * modtype_declaration) -> 'result =
  function
  | (Pmodtype_abstract, Pmodtype_abstract) -> true
  | (Pmodtype_manifest a0, Pmodtype_manifest b0) ->
      eq_module_type (a0, b0)
  | (_, _) -> false
and eq_signature_item_desc :
  (signature_item_desc * signature_item_desc) -> 'result =
  function
  | (Psig_value (a0, a1), Psig_value (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_value_description (a1, b1))
  | (Psig_type (a0, a1), Psig_type (b0, b1)) ->
      (Asttypes.eq_rec_flag (a0, b0) &&
      eq_list
        (fun ((a0, a1), (b0, b1)) ->
           (Asttypes.eq_loc eq_string (a0, b0)) &&
             (eq_type_declaration (a1, b1)))
        (a1, b1)
  | (Psig_exception (a0, a1), Psig_exception (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_exception_declaration (a1, b1))
  | (Psig_module (a0, a1), Psig_module (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_module_type (a1, b1))
  | (Psig_recmodule a0, Psig_recmodule b0) ->
      eq_list
        (fun ((a0, a1), (b0, b1)) ->
           (Asttypes.eq_loc eq_string (a0, b0)) &&
             (eq_module_type (a1, b1)))
        (a0, b0)
  | (Psig_modtype (a0, a1), Psig_modtype (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_modtype_declaration (a1, b1))
  | (Psig_open a0, Psig_open b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (Psig_include a0, Psig_include b0) -> eq_module_type (a0, b0)
  | (Psig_class a0, Psig_class b0) ->
      eq_list eq_class_description (a0, b0)
  | (Psig_class_type a0, Psig_class_type b0) ->
      eq_list eq_class_type_declaration (a0, b0)
  | (_, _) -> false
and eq_signature_item :
  (signature_item * signature_item) -> 'result =
  fun
    ({ psig_desc = a0; psig_loc = a1 },
     { psig_desc = b0; psig_loc = b1 })
    -> (eq_signature_item_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_signature : (signature * signature) -> 'result =
  fun (a0, a1) -> eq_list eq_signature_item (a0, a1)
and eq_module_type_desc :
  (module_type_desc * module_type_desc) -> 'result =
  function
  | (Pmty_ident a0, Pmty_ident b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (Pmty_signature a0, Pmty_signature b0) -> eq_signature (a0, b0)
  | (Pmty_functor (a0, a1, a2), Pmty_functor (b0, b1, b2)) ->
      ((Asttypes.eq_loc eq_string (a0, b0)) &&
         (eq_module_type (a1, b1)))
        && (eq_module_type (a2, b2))
  | (Pmty_with (a0, a1), Pmty_with (b0, b1)) ->
      (eq_module_type (a0, b0)) &&
        (eq_list
           (fun ((a0, a1), (b0, b1)) ->
              (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
                (eq_with_constraint (a1, b1)))
           (a1, b1))
  | (Pmty_typeof a0, Pmty_typeof b0) -> eq_module_expr (a0, b0)
  | (_, _) -> false
and eq_module_type : (module_type * module_type) -> 'result =
  fun
    ({ pmty_desc = a0; pmty_loc = a1 },
     { pmty_desc = b0; pmty_loc = b1 })
    -> (eq_module_type_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_class_declaration :
  (class_declaration * class_declaration) -> 'result =
  fun (a0, a1) -> eq_class_infos eq_class_expr (a0, a1)
and eq_class_field_desc :
  (class_field_desc * class_field_desc) -> 'result =
  function
  | (Pcf_inher (a0, a1, a2), Pcf_inher (b0, b1, b2)) ->
      ((Asttypes.eq_override_flag (a0, b0)) &&
         (eq_class_expr (a1, b1)))
        && (eq_option eq_string (a2, b2))
  | (Pcf_valvirt a0, Pcf_valvirt b0) ->
      (fun ((a0, a1, a2), (b0, b1, b2)) ->
         ((Asttypes.eq_loc eq_string (a0, b0)) &&
            (Asttypes.eq_mutable_flag (a1, b1)))
           && (eq_core_type (a2, b2)))
        (a0, b0)
  | (Pcf_val a0, Pcf_val b0) ->
      (fun ((a0, a1, a2, a3), (b0, b1, b2, b3)) ->
         (((Asttypes.eq_loc eq_string (a0, b0)) &&
             (Asttypes.eq_mutable_flag (a1, b1)))
            && (Asttypes.eq_override_flag (a2, b2)))
           && (eq_expression (a3, b3)))
        (a0, b0)
  | (Pcf_virt a0, Pcf_virt b0) ->
      (fun ((a0, a1, a2), (b0, b1, b2)) ->
         ((Asttypes.eq_loc eq_string (a0, b0)) &&
            (Asttypes.eq_private_flag (a1, b1)))
           && (eq_core_type (a2, b2)))
        (a0, b0)
  | (Pcf_meth a0, Pcf_meth b0) ->
      (fun ((a0, a1, a2, a3), (b0, b1, b2, b3)) ->
         (((Asttypes.eq_loc eq_string (a0, b0)) &&
             (Asttypes.eq_private_flag (a1, b1)))
            && (Asttypes.eq_override_flag (a2, b2)))
           && (eq_expression (a3, b3)))
        (a0, b0)
  | (Pcf_constr a0, Pcf_constr b0) ->
      (fun ((a0, a1), (b0, b1)) ->
         (eq_core_type (a0, b0)) && (eq_core_type (a1, b1)))
        (a0, b0)
  | (Pcf_init a0, Pcf_init b0) -> eq_expression (a0, b0)
  | (_, _) -> false
and eq_class_field : (class_field * class_field) -> 'result =
  fun
    ({ pcf_desc = a0; pcf_loc = a1 }, { pcf_desc = b0; pcf_loc = b1
     })
    -> (eq_class_field_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_class_structure :
  (class_structure * class_structure) -> 'result =
  fun
    ({ pcstr_self = a0; pcstr_fields = a1 },
     { pcstr_self = b0; pcstr_fields = b1 })
    -> (eq_pattern (a0, b0)) && (eq_list eq_class_field (a1, b1))
and eq_class_expr_desc :
  (class_expr_desc * class_expr_desc) -> 'result =
  function
  | (Pcl_constr (a0, a1), Pcl_constr (b0, b1)) ->
      (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
        (eq_list eq_core_type (a1, b1))
  | (Pcl_structure a0, Pcl_structure b0) ->
      eq_class_structure (a0, b0)
  | (Pcl_fun (a0, a1, a2, a3), Pcl_fun (b0, b1, b2, b3)) ->
      (((Asttypes.eq_label (a0, b0)) &&
          (eq_option eq_expression (a1, b1)))
         && (eq_pattern (a2, b2)))
        && (eq_class_expr (a3, b3))
  | (Pcl_apply (a0, a1), Pcl_apply (b0, b1)) ->
      (eq_class_expr (a0, b0)) &&
        (eq_list
           (fun ((a0, a1), (b0, b1)) ->
              (Asttypes.eq_label (a0, b0)) &&
                (eq_expression (a1, b1)))
           (a1, b1))
  | (Pcl_let (a0, a1, a2), Pcl_let (b0, b1, b2)) ->
      ((Asttypes.eq_rec_flag (a0, b0)) &&
         (eq_list
            (fun ((a0, a1), (b0, b1)) ->
               (eq_pattern (a0, b0)) && (eq_expression (a1, b1)))
            (a1, b1)))
        && (eq_class_expr (a2, b2))
  | (Pcl_constraint (a0, a1), Pcl_constraint (b0, b1)) ->
      (eq_class_expr (a0, b0)) && (eq_class_type (a1, b1))
  | (_, _) -> false
and eq_class_expr : (class_expr * class_expr) -> 'result =
  fun
    ({ pcl_desc = a0; pcl_loc = a1 }, { pcl_desc = b0; pcl_loc = b1
     })
    -> (eq_class_expr_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_class_type_declaration :
  (class_type_declaration * class_type_declaration) -> 'result =
  fun (a0, a1) -> eq_class_infos eq_class_type (a0, a1)
and eq_class_description :
  (class_description * class_description) -> 'result =
  fun (a0, a1) -> eq_class_infos eq_class_type (a0, a1)
and eq_class_type_field_desc :
  (class_type_field_desc * class_type_field_desc) -> 'result =
  function
  | (Pctf_inher a0, Pctf_inher b0) -> eq_class_type (a0, b0)
  | (Pctf_val a0, Pctf_val b0) ->
      (fun ((a0, a1, a2, a3), (b0, b1, b2, b3)) ->
         (((eq_string (a0, b0)) &&
             (Asttypes.eq_mutable_flag (a1, b1)))
            && (Asttypes.eq_virtual_flag (a2, b2)))
           && (eq_core_type (a3, b3)))
        (a0, b0)
  | (Pctf_virt a0, Pctf_virt b0) ->
      (fun ((a0, a1, a2), (b0, b1, b2)) ->
         ((eq_string (a0, b0)) && (Asttypes.eq_private_flag (a1, b1)))
           && (eq_core_type (a2, b2)))
        (a0, b0)
  | (Pctf_meth a0, Pctf_meth b0) ->
      (fun ((a0, a1, a2), (b0, b1, b2)) ->
         ((eq_string (a0, b0)) && (Asttypes.eq_private_flag (a1, b1)))
           && (eq_core_type (a2, b2)))
        (a0, b0)
  | (Pctf_cstr a0, Pctf_cstr b0) ->
      (fun ((a0, a1), (b0, b1)) ->
         (eq_core_type (a0, b0)) && (eq_core_type (a1, b1)))
        (a0, b0)
  | (_, _) -> false
and eq_class_type_field :
  (class_type_field * class_type_field) -> 'result =
  fun
    ({ pctf_desc = a0; pctf_loc = a1 },
     { pctf_desc = b0; pctf_loc = b1 })
    ->
    (eq_class_type_field_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_class_signature :
  (class_signature * class_signature) -> 'result =
  fun
    ({ pcsig_self = a0; pcsig_fields = a1; pcsig_loc = a2 },
     { pcsig_self = b0; pcsig_fields = b1; pcsig_loc = b2 })
    ->
    ((eq_core_type (a0, b0)) &&
       (eq_list eq_class_type_field (a1, b1)))
      && (Location.eq_t (a2, b2))
and eq_class_type_desc :
  (class_type_desc * class_type_desc) -> 'result =
  function
  | (Pcty_constr (a0, a1), Pcty_constr (b0, b1)) ->
      (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
        (eq_list eq_core_type (a1, b1))
  | (Pcty_signature a0, Pcty_signature b0) ->
      eq_class_signature (a0, b0)
  | (Pcty_arrow (a0, a1, a2), Pcty_arrow (b0, b1, b2)) ->
      ((Asttypes.eq_label (a0, b0)) && (eq_core_type (a1, b1))) &&
        (eq_class_type (a2, b2))
  | (_, _) -> false
and eq_class_type : (class_type * class_type) -> 'result =
  fun
    ({ pcty_desc = a0; pcty_loc = a1 },
     { pcty_desc = b0; pcty_loc = b1 })
    -> (eq_class_type_desc (a0, b0)) && (Location.eq_t (a1, b1))
and eq_exception_declaration :
  (exception_declaration * exception_declaration) -> 'result =
  fun (a0, a1) -> eq_list eq_core_type (a0, a1)
and eq_type_kind : (type_kind * type_kind) -> 'result =
  function
  | (Ptype_abstract, Ptype_abstract) -> true
  | (Ptype_variant a0, Ptype_variant b0) ->
      eq_list
        (fun ((a0, a1, a2, a3), (b0, b1, b2, b3)) ->
           (((Asttypes.eq_loc eq_string (a0, b0)) &&
               (eq_list eq_core_type (a1, b1)))
              && (eq_option eq_core_type (a2, b2)))
             && (Location.eq_t (a3, b3)))
        (a0, b0)
  | (Ptype_record a0, Ptype_record b0) ->
      eq_list
        (fun ((a0, a1, a2, a3), (b0, b1, b2, b3)) ->
           (((Asttypes.eq_loc eq_string (a0, b0)) &&
               (Asttypes.eq_mutable_flag (a1, b1)))
              && (eq_core_type (a2, b2)))
             && (Location.eq_t (a3, b3)))
        (a0, b0)
  | (_, _) -> false
and eq_type_declaration :
  (type_declaration * type_declaration) -> 'result =
  fun
    ({
       ptype_params = a0;
       ptype_cstrs = a1;
       ptype_kind = a2;
       ptype_private = a3;
       ptype_manifest = a4;
       ptype_variance = a5;
       ptype_loc = a6
     },
     {
       ptype_params = b0;
       ptype_cstrs = b1;
       ptype_kind = b2;
       ptype_private = b3;
       ptype_manifest = b4;
       ptype_variance = b5;
       ptype_loc = b6
     })
    ->
    ((((((eq_list (eq_option (Asttypes.eq_loc eq_string)) (a0, b0))
           &&
           (eq_list
              (fun ((a0, a1, a2), (b0, b1, b2)) ->
                 ((eq_core_type (a0, b0)) && (eq_core_type (a1, b1)))
                   && (Location.eq_t (a2, b2)))
              (a1, b1)))
          && (eq_type_kind (a2, b2)))
         && (Asttypes.eq_private_flag (a3, b3)))
        && (eq_option eq_core_type (a4, b4)))
       &&
       (eq_list
          (fun ((a0, a1), (b0, b1)) ->
             (eq_bool (a0, b0)) && (eq_bool (a1, b1)))
          (a5, b5)))
      && (Location.eq_t (a6, b6))
and eq_value_description :
  (value_description * value_description) -> 'result =
  fun
    ({ pval_type = a0; pval_prim = a1; pval_loc = a2 },
     { pval_type = b0; pval_prim = b1; pval_loc = b2 })
    ->
    ((eq_core_type (a0, b0)) && (eq_list eq_string (a1, b1))) &&
      (Location.eq_t (a2, b2))
and eq_expression_desc :
  (expression_desc * expression_desc) -> 'result =
  function
  | (Pexp_ident a0, Pexp_ident b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (Pexp_constant a0, Pexp_constant b0) ->
      Asttypes.eq_constant (a0, b0)
  | (Pexp_let (a0, a1, a2), Pexp_let (b0, b1, b2)) ->
      ((Asttypes.eq_rec_flag (a0, b0)) &&
         (eq_list
            (fun ((a0, a1), (b0, b1)) ->
               (eq_pattern (a0, b0)) && (eq_expression (a1, b1)))
            (a1, b1)))
        && (eq_expression (a2, b2))
  | Pexp_fun (a1, a1, a2, a3), Pexp_function (b0, b1, b2, b3) ->
      ((Asttypes.eq_label (a0, b0)) &&
       (eq_option eq_expression (a1, b1)) &&
       (eq_pattern a2 b2) &&
       (eq_expression (a3, b3)))
  | (Pexp_function (a0, a1, a2), Pexp_function (b0, b1, b2)) ->
      (* FIX *)
      eq_list
        (fun ((a0, a1), (b0, b1)) ->
          (eq_pattern (a0, b0)) && (eq_expression (a1, b1)))
        (a2, b2)
  | (Pexp_apply (a0, a1), Pexp_apply (b0, b1)) ->
      (eq_expression (a0, b0)) &&
        (eq_list
           (fun ((a0, a1), (b0, b1)) ->
              (Asttypes.eq_label (a0, b0)) &&
                (eq_expression (a1, b1)))
           (a1, b1))
  | (Pexp_match (a0, a1), Pexp_match (b0, b1)) ->
      (eq_expression (a0, b0)) &&
        (eq_list
           (fun ((a0, a1), (b0, b1)) ->
              (eq_pattern (a0, b0)) && (eq_expression (a1, b1)))
           (a1, b1))
  | (Pexp_try (a0, a1), Pexp_try (b0, b1)) ->
      (eq_expression (a0, b0)) &&
        (eq_list
           (fun ((a0, a1), (b0, b1)) ->
              (eq_pattern (a0, b0)) && (eq_expression (a1, b1)))
           (a1, b1))
  | (Pexp_tuple a0, Pexp_tuple b0) -> eq_list eq_expression (a0, b0)
  | (Pexp_construct (a0, a1), Pexp_construct (b0, b1)) ->
      ((Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
         (eq_option eq_expression (a1, b1)))
  | (Pexp_variant (a0, a1), Pexp_variant (b0, b1)) ->
      (Asttypes.eq_label (a0, b0)) &&
        (eq_option eq_expression (a1, b1))
  | (Pexp_record (a0, a1), Pexp_record (b0, b1)) ->
      (eq_list
         (fun ((a0, a1), (b0, b1)) ->
            (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
              (eq_expression (a1, b1)))
         (a0, b0))
        && (eq_option eq_expression (a1, b1))
  | (Pexp_field (a0, a1), Pexp_field (b0, b1)) ->
      (eq_expression (a0, b0)) &&
        (Asttypes.eq_loc Longident.eq_t (a1, b1))
  | (Pexp_setfield (a0, a1, a2), Pexp_setfield (b0, b1, b2)) ->
      ((eq_expression (a0, b0)) &&
         (Asttypes.eq_loc Longident.eq_t (a1, b1)))
        && (eq_expression (a2, b2))
  | (Pexp_array a0, Pexp_array b0) -> eq_list eq_expression (a0, b0)
  | (Pexp_ifthenelse (a0, a1, a2), Pexp_ifthenelse (b0, b1, b2)) ->
      ((eq_expression (a0, b0)) && (eq_expression (a1, b1))) &&
        (eq_option eq_expression (a2, b2))
  | (Pexp_sequence (a0, a1), Pexp_sequence (b0, b1)) ->
      (eq_expression (a0, b0)) && (eq_expression (a1, b1))
  | (Pexp_while (a0, a1), Pexp_while (b0, b1)) ->
      (eq_expression (a0, b0)) && (eq_expression (a1, b1))
  | (Pexp_for (a0, a1, a2, a3, a4), Pexp_for (b0, b1, b2, b3, b4)) ->
      ((((Asttypes.eq_loc eq_string (a0, b0)) &&
           (eq_expression (a1, b1)))
          && (eq_expression (a2, b2)))
         && (Asttypes.eq_direction_flag (a3, b3)))
        && (eq_expression (a4, b4))
  | (Pexp_constraint (a0, a1, a2), Pexp_constraint (b0, b1, b2)) ->
      ((eq_expression (a0, b0)) && (eq_option eq_core_type (a1, b1)))
        && (eq_option eq_core_type (a2, b2))
  | (Pexp_when (a0, a1), Pexp_when (b0, b1)) ->
      (eq_expression (a0, b0)) && (eq_expression (a1, b1))
  | (Pexp_send (a0, a1), Pexp_send (b0, b1)) ->
      (eq_expression (a0, b0)) && (eq_string (a1, b1))
  | (Pexp_new a0, Pexp_new b0) ->
      Asttypes.eq_loc Longident.eq_t (a0, b0)
  | (Pexp_setinstvar (a0, a1), Pexp_setinstvar (b0, b1)) ->
      (Asttypes.eq_loc eq_string (a0, b0)) &&
        (eq_expression (a1, b1))
  | (Pexp_override a0, Pexp_override b0) ->
      eq_list
        (fun ((a0, a1), (b0, b1)) ->
           (Asttypes.eq_loc eq_string (a0, b0)) &&
             (eq_expression (a1, b1)))
        (a0, b0)
  | (Pexp_letmodule (a0, a1, a2), Pexp_letmodule (b0, b1, b2)) ->
      ((Asttypes.eq_loc eq_string (a0, b0)) &&
         (eq_module_expr (a1, b1)))
        && (eq_expression (a2, b2))
  | (Pexp_assert a0, Pexp_assert b0) -> eq_expression (a0, b0)
  | (Pexp_lazy a0, Pexp_lazy b0) -> eq_expression (a0, b0)
  | (Pexp_poly (a0, a1), Pexp_poly (b0, b1)) ->
      (eq_expression (a0, b0)) && (eq_option eq_core_type (a1, b1))
  | (Pexp_object a0, Pexp_object b0) -> eq_class_structure (a0, b0)
  | (Pexp_newtype (a0, a1), Pexp_newtype (b0, b1)) ->
      (eq_string (a0, b0)) && (eq_expression (a1, b1))
  | (Pexp_pack a0, Pexp_pack b0) -> eq_module_expr (a0, b0)
  | (Pexp_open (a0, a1), Pexp_open (b0, b1)) ->
      (Asttypes.eq_loc Longident.eq_t (a0, b0)) &&
        (eq_expression (a1, b1))
  | (_, _) -> false
and eq_expression : (expression * expression) -> 'result =
  fun
    ({ pexp_desc = a0; pexp_loc = a1 },
     { pexp_desc = b0; pexp_loc = b1 })
    -> (eq_expression_desc (a0, b0)) && (Location.eq_t (a1, b1))

let rec eq_directive_argument :
  (directive_argument * directive_argument) -> 'result =
  function
  | (Pdir_none, Pdir_none) -> true
  | (Pdir_string a0, Pdir_string b0) -> eq_string (a0, b0)
  | (Pdir_int a0, Pdir_int b0) -> eq_int (a0, b0)
  | (Pdir_ident a0, Pdir_ident b0) -> Longident.eq_t (a0, b0)
  | (Pdir_bool a0, Pdir_bool b0) -> eq_bool (a0, b0)
  | (_, _) -> false
and eq_toplevel_phrase :
  (toplevel_phrase * toplevel_phrase) -> 'result =
  function
  | (Ptop_def a0, Ptop_def b0) -> eq_structure (a0, b0)
  | (Ptop_dir (a0, a1), Ptop_dir (b0, b1)) ->
      (eq_string (a0, b0)) && (eq_directive_argument (a1, b1))
  | (_, _) -> false