package pfff

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file meta_cst_js.ml

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
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
(* Yoann Padioleau
 *
 * Copyright (C) 2010 Facebook
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation, with the
 * special exception on linking described in file license.txt.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the file
 * license.txt for more details.
 *)

(* mostly autogenerated by ocamltarzan: ocamltarzan -choice vof ast_js.ml *)

(* pad: I've added a few tweaks because of module limitations in ocamltarzan *)

open Cst_js
module M = Meta_ast_generic
module Ast = Cst_js

let _current_precision = ref M.default_precision


let rec vof_info x =
  if !_current_precision.M.full_info
  then Parse_info.vof_info x
  else if !_current_precision.M.token_info
       then
        Ocaml.VDict [
          "line", Ocaml.VInt (PI.line_of_info x);
          "col", Ocaml.VInt (PI.col_of_info x);
        ]
      else Ocaml.VUnit

and vof_tok v = vof_info v
and vof_wrap _of_a (v1, v2) =
  let v1 = _of_a v1 and v2 = vof_info v2 in Ocaml.VTuple [ v1; v2 ]
and vof_paren _of_a (v1, v2, v3) =
  if !_current_precision.M.token_info then
  let v1 = vof_tok v1
  and v2 = _of_a v2
  and v3 = vof_tok v3
  in Ocaml.VTuple [ v1; v2; v3 ]
  else _of_a v2
and vof_brace _of_a (v1, v2, v3) =
  if !_current_precision.M.token_info then
  let v1 = vof_tok v1
  and v2 = _of_a v2
  and v3 = vof_tok v3
  in Ocaml.VTuple [ v1; v2; v3 ]
  else _of_a v2
and vof_bracket _of_a (v1, v2, v3) =
  if !_current_precision.M.token_info then
  let v1 = vof_tok v1
  and v2 = _of_a v2
  and v3 = vof_tok v3
  in Ocaml.VTuple [ v1; v2; v3 ]
  else _of_a v2
and vof_angle _of_a (v1, v2, v3) =
  let v1 = vof_tok v1
  and v2 = _of_a v2
  and v3 = vof_tok v3
  in Ocaml.VTuple [ v1; v2; v3 ]
and vof_comma_list _of_a xs =
  if !_current_precision.M.token_info
  then Ocaml.vof_list (Ocaml.vof_either _of_a vof_tok) xs
  else Ocaml.vof_list _of_a (Ast.uncomma xs)

and vof_sc v = Ocaml.vof_option vof_tok v

let vof_name v = vof_wrap Ocaml.vof_string v
let vof_module_path v = vof_wrap Ocaml.vof_string v

let rec vof_expr =
  function
  | L v1 -> let v1 = vof_litteral v1 in Ocaml.VSum (("L", [ v1 ]))
  | V v1 -> let v1 = vof_name v1 in Ocaml.VSum (("V", [ v1 ]))
  | This v1 -> let v1 = vof_tok v1 in Ocaml.VSum (("This", [ v1 ]))
  | Super v1 -> let v1 = vof_tok v1 in Ocaml.VSum (("Super", [ v1 ]))
  | NewTarget ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_tok v2
      and v3 = vof_tok v3
      in Ocaml.VSum (("NewTarget", [ v1; v2; v3 ]))
  | U ((v1, v2)) ->
      let v1 = vof_wrap vof_unop v1
      and v2 = vof_expr v2
      in Ocaml.VSum (("U", [ v1; v2 ]))
  | B ((v1, v2, v3)) ->
      let v1 = vof_expr v1
      and v2 = vof_wrap vof_binop v2
      and v3 = vof_expr v3
      in Ocaml.VSum (("B", [ v1; v2; v3 ]))
  | Bracket ((v1, v2)) ->
      let v1 = vof_expr v1
      and v2 = vof_bracket vof_expr v2
      in Ocaml.VSum (("Bracket", [ v1; v2 ]))
  | Period ((v1, v2, v3)) ->
      let v1 = vof_expr v1
      and v2 = vof_tok v2
      and v3 = vof_name v3
      in Ocaml.VSum (("Period", [ v1; v2; v3 ]))
  | Object v1 ->
      let v1 =
        vof_brace
          (vof_comma_list
             (function
             | P_field (v1, v2, v3) ->
                 let v1 = vof_property_name v1
                 and v2 = vof_tok v2
                 and v3 = vof_expr v3
                 in Ocaml.VSum (("P_field", [ v1; v2; v3 ]))
             | P_method v1 ->
                 let v1 = vof_func_decl v1
                 in Ocaml.VSum (("P_method", [v1]))
             | P_shorthand v1 ->
              let v1 = vof_name v1 in Ocaml.VSum (("P_shorthand", [ v1 ]))
             | P_spread (v1, v2) ->
                 let v1 = vof_tok v1 in
                 let v2 = vof_expr v2 in
                 Ocaml.VSum (("P_spread", [v1;v2]))
             ))
          v1
      in Ocaml.VSum (("Object", [ v1 ]))
  | Array v1 ->
      let v1 = vof_bracket (vof_comma_list vof_expr) v1
      in Ocaml.VSum (("Array", [ v1 ]))
  | Apply ((v1, v2)) ->
      let v1 = vof_expr v1
      and v2 = vof_paren (vof_comma_list vof_expr) v2
      in Ocaml.VSum (("Apply", [ v1; v2 ]))
  | Conditional ((v1, v2, v3, v4, v5)) ->
      let v1 = vof_expr v1
      and v2 = vof_tok v2
      and v3 = vof_expr v3
      and v4 = vof_tok v4
      and v5 = vof_expr v5
      in Ocaml.VSum (("Conditional", [ v1; v2; v3; v4; v5 ]))
  | Assign ((v1, v2, v3)) ->
      let v1 = vof_expr v1
      and v2 = vof_wrap vof_assignment_operator v2
      and v3 = vof_expr v3
      in Ocaml.VSum (("Assign", [ v1; v2; v3 ]))
  | Seq ((v1, v2, v3)) ->
      let v1 = vof_expr v1
      and v2 = vof_tok v2
      and v3 = vof_expr v3
      in Ocaml.VSum (("Seq", [ v1; v2; v3 ]))
  | Function v1 ->
      let v1 = vof_func_decl v1 in Ocaml.VSum (("Function", [ v1 ]))
  | Class v1 -> let v1 = vof_class_decl v1 in Ocaml.VSum (("Class", [ v1 ]))
  | Arrow v1 -> let v1 = vof_arrow_func v1 in Ocaml.VSum (("Arrow", [ v1 ]))
  | Paren v1 ->
      let v1 = vof_paren vof_expr v1 in Ocaml.VSum (("Paren", [ v1 ]))
  | XhpHtml v1 ->
      let v1 = vof_xhp_html v1 in Ocaml.VSum (("XhpHtml", [ v1 ]))
  | Encaps ((v1, v2, v3, v4)) ->
      let v1 = Ocaml.vof_option vof_name v1
      and v2 = vof_tok v2
      and v3 = Ocaml.vof_list vof_encaps v3
      and v4 = vof_tok v4
      in Ocaml.VSum (("Encaps", [ v1; v2; v3; v4 ]))
  | Yield ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = Ocaml.vof_option vof_tok v2
      and v3 = Ocaml.vof_option vof_expr v3
      in Ocaml.VSum (("Yield", [ v1; v2; v3 ]))
  | Await ((v1, v2)) ->
      let v1 = vof_tok v1
      and v2 = vof_expr v2
      in Ocaml.VSum (("Await", [ v1; v2 ]))

and vof_litteral =
  function
  | Bool v1 ->
      let v1 = vof_wrap Ocaml.vof_bool v1 in Ocaml.VSum (("Bool", [ v1 ]))
  | Num v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1 in Ocaml.VSum (("Num", [ v1 ]))
  | String v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1
      in Ocaml.VSum (("String", [ v1 ]))
  | Regexp v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1
      in Ocaml.VSum (("Regexp", [ v1 ]))
  | Null v1 -> let v1 = vof_tok v1 in Ocaml.VSum (("Null", [ v1 ]))
and vof_unop =
  function
  | U_new -> Ocaml.VSum (("U_new", []))
  | U_delete -> Ocaml.VSum (("U_delete", []))
  | U_void -> Ocaml.VSum (("U_void", []))
  | U_typeof -> Ocaml.VSum (("U_typeof", []))
  | U_bitnot -> Ocaml.VSum (("U_bitnot", []))
  | U_pre_increment -> Ocaml.VSum (("U_pre_increment", []))
  | U_pre_decrement -> Ocaml.VSum (("U_pre_decrement", []))
  | U_post_increment -> Ocaml.VSum (("U_post_increment", []))
  | U_post_decrement -> Ocaml.VSum (("U_post_decrement", []))
  | U_plus -> Ocaml.VSum (("U_plus", []))
  | U_minus -> Ocaml.VSum (("U_minus", []))
  | U_not -> Ocaml.VSum (("U_not", []))
  | U_spread -> Ocaml.VSum (("U_spread", []))
and vof_binop =
  function
  | B_instanceof -> Ocaml.VSum (("B_instanceof", []))
  | B_in -> Ocaml.VSum (("B_in", []))
  | B_mul -> Ocaml.VSum (("B_mul", []))
  | B_expo -> Ocaml.VSum (("B_expo", []))
  | B_div -> Ocaml.VSum (("B_div", []))
  | B_mod -> Ocaml.VSum (("B_mod", []))
  | B_add -> Ocaml.VSum (("B_add", []))
  | B_sub -> Ocaml.VSum (("B_sub", []))
  | B_le -> Ocaml.VSum (("B_le", []))
  | B_ge -> Ocaml.VSum (("B_ge", []))
  | B_lt -> Ocaml.VSum (("B_lt", []))
  | B_gt -> Ocaml.VSum (("B_gt", []))
  | B_lsr -> Ocaml.VSum (("B_lsr", []))
  | B_asr -> Ocaml.VSum (("B_asr", []))
  | B_lsl -> Ocaml.VSum (("B_lsl", []))
  | B_equal -> Ocaml.VSum (("B_equal", []))
  | B_notequal -> Ocaml.VSum (("B_notequal", []))
  | B_physequal -> Ocaml.VSum (("B_physequal", []))
  | B_physnotequal -> Ocaml.VSum (("B_physnotequal", []))
  | B_bitand -> Ocaml.VSum (("B_bitand", []))
  | B_bitor -> Ocaml.VSum (("B_bitor", []))
  | B_bitxor -> Ocaml.VSum (("B_bitxor", []))
  | B_and -> Ocaml.VSum (("B_and", []))
  | B_or -> Ocaml.VSum (("B_or", []))
and vof_property_name =
  function
  | PN_Id v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1
      in Ocaml.VSum (("PN_Id", [ v1 ]))
  | PN_String v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1
      in Ocaml.VSum (("PN_String", [ v1 ]))
  | PN_Num v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1
      in Ocaml.VSum (("PN_Num", [ v1 ]))
  | PN_Computed v1 ->
      let v1 = vof_bracket vof_expr v1
      in Ocaml.VSum (("PN_Computed", [ v1 ]))
and vof_assignment_operator =
  function
  | A_eq -> Ocaml.VSum (("A_eq", []))
  | A_mul -> Ocaml.VSum (("A_mul", []))
  | A_div -> Ocaml.VSum (("A_div", []))
  | A_mod -> Ocaml.VSum (("A_mod", []))
  | A_add -> Ocaml.VSum (("A_add", []))
  | A_sub -> Ocaml.VSum (("A_sub", []))
  | A_lsl -> Ocaml.VSum (("A_lsl", []))
  | A_lsr -> Ocaml.VSum (("A_lsr", []))
  | A_asr -> Ocaml.VSum (("A_asr", []))
  | A_and -> Ocaml.VSum (("A_and", []))
  | A_xor -> Ocaml.VSum (("A_xor", []))
  | A_or -> Ocaml.VSum (("A_or", []))
and vof_xhp_tag x = Ocaml.vof_string x
and vof_xhp_html =
  function
  | Xhp ((v1, v2, v3, v4, v5)) ->
      let v1 = vof_wrap vof_xhp_tag v1
      and v2 = Ocaml.vof_list vof_xhp_attribute v2
      and v3 = vof_tok v3
      and v4 = Ocaml.vof_list vof_xhp_body v4
      and v5 = vof_wrap (Ocaml.vof_option vof_xhp_tag) v5
      in Ocaml.VSum (("Xhp", [ v1; v2; v3; v4; v5 ]))
  | XhpSingleton ((v1, v2, v3)) ->
      let v1 = vof_wrap vof_xhp_tag v1
      and v2 = Ocaml.vof_list vof_xhp_attribute v2
      and v3 = vof_tok v3
      in Ocaml.VSum (("XhpSingleton", [ v1; v2; v3 ]))
and vof_xhp_attribute =
  function
  | XhpAttrValue ((v1, v2, v3)) ->
      let v1 = vof_xhp_attr_name v1
      and v2 = vof_tok v2
      and v3 = vof_xhp_attr_value v3
      in Ocaml.VSum (("XhpAttrValue", [ v1; v2; v3 ]))
  | XhpAttrNoValue ((v1)) ->
      let v1 = vof_xhp_attr_name v1
      in Ocaml.VSum (("XhpAttrNoValue", [ v1 ]))
  | XhpAttrSpread v1 ->
      let v1 =
        vof_brace
          (fun (v1, v2) ->
             let v1 = vof_tok v1
             and v2 = vof_expr v2
             in Ocaml.VTuple [ v1; v2 ])
          v1
      in Ocaml.VSum (("XhpAttrSpread", [ v1 ]))
and vof_xhp_attr_name v = vof_wrap Ocaml.vof_string v
and vof_xhp_attr_value =
  function
  | XhpAttrString v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1
      in Ocaml.VSum (("XhpAttrString", [ v1 ]))
  | XhpAttrExpr v1 ->
      let v1 = vof_brace vof_expr v1 in Ocaml.VSum (("XhpAttrExpr", [ v1 ]))
and vof_xhp_body =
  function
  | XhpText v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1
      in Ocaml.VSum (("XhpText", [ v1 ]))
  | XhpExpr v1 ->
      let v1 = vof_brace (Ocaml.vof_option vof_expr) v1 in Ocaml.VSum (("XhpExpr", [ v1 ]))
  | XhpNested v1 ->
      let v1 = vof_xhp_html v1 in Ocaml.VSum (("XhpNested", [ v1 ]))
and vof_encaps =
  function
  | EncapsString v1 ->
      let v1 = vof_wrap Ocaml.vof_string v1
      in Ocaml.VSum (("EncapsString", [ v1 ]))
  | EncapsExpr ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_expr v2
      and v3 = vof_tok v3
      in Ocaml.VSum (("EncapsExpr", [ v1; v2; v3 ]))

and vof_st =
  function
  | VarsDecl ((v1, v2, v3)) ->
      let v1 = vof_wrap vof_var_kind v1
      and v2 = vof_comma_list vof_var_binding v2
      and v3 = vof_sc v3
      in Ocaml.VSum (("Variable", [ v1; v2; v3 ]))
  | Block v1 ->
      let v1 = vof_brace (Ocaml.vof_list vof_item) v1
      in Ocaml.VSum (("Block", [ v1 ]))
  | Nop v1 -> let v1 = vof_sc v1 in Ocaml.VSum (("Nop", [ v1 ]))
  | ExprStmt ((v1, v2)) ->
      let v1 = vof_expr v1
      and v2 = vof_sc v2
      in Ocaml.VSum (("ExprStmt", [ v1; v2 ]))
  | If ((v1, v2, v3, v4)) ->
      let v1 = vof_tok v1
      and v2 = vof_paren vof_expr v2
      and v3 = vof_st v3
      and v4 =
        Ocaml.vof_option
          (fun (v1, v2) ->
             let v1 = vof_tok v1
             and v2 = vof_st v2
             in Ocaml.VTuple [ v1; v2 ])
          v4
      in Ocaml.VSum (("If", [ v1; v2; v3; v4 ]))
  | Do ((v1, v2, v3, v4, v5)) ->
      let v1 = vof_tok v1
      and v2 = vof_st v2
      and v3 = vof_tok v3
      and v4 = vof_paren vof_expr v4
      and v5 = vof_sc v5
      in Ocaml.VSum (("Do", [ v1; v2; v3; v4; v5 ]))
  | While ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_paren vof_expr v2
      and v3 = vof_st v3
      in Ocaml.VSum (("While", [ v1; v2; v3 ]))
  | For ((v1, v2, v3, v4, v5, v6, v7, v8, v9)) ->
      let v1 = vof_tok v1
      and v2 = vof_tok v2
      and v3 = Ocaml.vof_option vof_lhs_or_vars v3
      and v4 = vof_tok v4
      and v5 = Ocaml.vof_option vof_expr v5
      and v6 = vof_tok v6
      and v7 = Ocaml.vof_option vof_expr v7
      and v8 = vof_tok v8
      and v9 = vof_st v9
      in Ocaml.VSum (("For", [ v1; v2; v3; v4; v5; v6; v7; v8; v9 ]))
  | ForIn ((v1, v2, v3, v4, v5, v6, v7)) ->
      let v1 = vof_tok v1
      and v2 = vof_tok v2
      and v3 = vof_lhs_or_var v3
      and v4 = vof_tok v4
      and v5 = vof_expr v5
      and v6 = vof_tok v6
      and v7 = vof_st v7
      in Ocaml.VSum (("ForIn", [ v1; v2; v3; v4; v5; v6; v7 ]))
  | ForOf ((v1, v2, v3, v4, v5, v6, v7)) ->
      let v1 = vof_tok v1
      and v2 = vof_tok v2
      and v3 = vof_lhs_or_var v3
      and v4 = vof_tok v4
      and v5 = vof_expr v5
      and v6 = vof_tok v6
      and v7 = vof_st v7
      in Ocaml.VSum (("ForOf", [ v1; v2; v3; v4; v5; v6; v7 ]))
  | Switch ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_paren vof_expr v2
      and v3 = vof_brace (Ocaml.vof_list vof_case_clause) v3
      in Ocaml.VSum (("Switch", [ v1; v2; v3 ]))
  | Continue ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = Ocaml.vof_option vof_label v2
      and v3 = vof_sc v3
      in Ocaml.VSum (("Continue", [ v1; v2; v3 ]))
  | Break ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = Ocaml.vof_option vof_label v2
      and v3 = vof_sc v3
      in Ocaml.VSum (("Break", [ v1; v2; v3 ]))
  | Return ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = Ocaml.vof_option vof_expr v2
      and v3 = vof_sc v3
      in Ocaml.VSum (("Return", [ v1; v2; v3 ]))
  | With ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_paren vof_expr v2
      and v3 = vof_st v3
      in Ocaml.VSum (("With", [ v1; v2; v3 ]))
  | Labeled ((v1, v2, v3)) ->
      let v1 = vof_label v1
      and v2 = vof_tok v2
      and v3 = vof_st v3
      in Ocaml.VSum (("Labeled", [ v1; v2; v3 ]))
  | Throw ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_expr v2
      and v3 = vof_sc v3
      in Ocaml.VSum (("Throw", [ v1; v2; v3 ]))
  | Try ((v1, v2, v3, v4)) ->
      let v1 = vof_tok v1
      and v2 = vof_st v2
      and v3 =
        Ocaml.vof_option
          (fun (v1, v2, v3) ->
             let v1 = vof_tok v1
             and v2 = vof_paren vof_arg v2
             and v3 = vof_st v3
             in Ocaml.VTuple [ v1; v2; v3 ])
          v3
      and v4 =
        Ocaml.vof_option
          (fun (v1, v2) ->
             let v1 = vof_tok v1
             and v2 = vof_st v2
             in Ocaml.VTuple [ v1; v2 ])
          v4
      in Ocaml.VSum (("Try", [ v1; v2; v3; v4 ]))
and vof_label v = vof_wrap Ocaml.vof_string v
and vof_lhs_or_vars =
  function
  | LHS1 v1 -> let v1 = vof_expr v1 in Ocaml.VSum (("LHS1", [ v1 ]))
  | ForVars ((v1, v2)) ->
      let v1 = vof_wrap vof_var_kind v1
      and v2 = vof_comma_list vof_var_binding v2
      in Ocaml.VSum (("ForVars", [ v1; v2 ]))
and vof_lhs_or_var =
  function
  | LHS2 v1 -> let v1 = vof_expr v1 in Ocaml.VSum (("LHS2", [ v1 ]))
  | ForVar ((v1, v2)) ->
      let v1 = vof_wrap vof_var_kind v1
      and v2 = vof_var_binding v2
      in Ocaml.VSum (("ForVar", [ v1; v2 ]))
and vof_case_clause =
  function
  | Default ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_tok v2
      and v3 = Ocaml.vof_list vof_item v3
      in Ocaml.VSum (("Default", [ v1; v2; v3 ]))
  | Case ((v1, v2, v3, v4)) ->
      let v1 = vof_tok v1
      and v2 = vof_expr v2
      and v3 = vof_tok v3
      and v4 = Ocaml.vof_list vof_item v4
      in Ocaml.VSum (("Case", [ v1; v2; v3; v4 ]))
and vof_arg v = vof_wrap Ocaml.vof_string v
and vof_type_ =
  function
  | TTodo -> Ocaml.VSum (("TTodo", []))
  | TName v1 ->
      let v1 = vof_nominal_type v1 in
      Ocaml.VSum (("TName", [ v1 ]))
  | TQuestion ((v1, v2)) ->
      let v1 = vof_tok v1
      and v2 = vof_type_ v2
      in Ocaml.VSum (("TQuestion", [ v1; v2 ]))
  | TFun ((v1, v2, v3)) ->
      let v1 =
        vof_paren
          (vof_comma_list
             (fun (v1, v2) ->
               let v1 = vof_param_name v1
               and v2 = vof_annotation v2
               in Ocaml.VTuple [ v1; v2 ]))
          v1
      and v2 = vof_tok v2
      and v3 = vof_type_ v3
      in Ocaml.VSum (("TFun", [ v1; v2; v3 ]))
  | TObj v1 ->
      let v1 =
        vof_brace
          (Ocaml.vof_list
             (fun (v1, v2, v3) ->
                let v1 = vof_property_name v1
                and v2 = vof_annotation v2
                and v3 = vof_sc v3
                in Ocaml.VTuple [ v1; v2; v3 ]))
          v1
      in Ocaml.VSum (("TObj", [ v1 ]))
and vof_param_name = function
  | RequiredParam(v1) ->
      let v1 = vof_name v1
      in Ocaml.VSum (("RequiredParam", [v1]))
  | OptionalParam(v1,v2) ->
      let v1 = vof_name v1
      and v2 = vof_tok v2
      in Ocaml.VSum (("OptionalParam", [v1; v2]))
  | RestParam(v1,v2) ->
      let v1 = vof_tok v1
      and v2 = vof_name v2
      in Ocaml.VSum (("RestParam", [v1; v2]))

and vof_annotation = function
  | TAnnot(v1, v2) ->
      let v1 = vof_tok v1
      and v2 = vof_type_ v2
      in Ocaml.VSum (("TAnnot", [v1; v2]))
  | TFunAnnot(v1,v2,v3,v4) ->
      let v1 = Ocaml.vof_option
        (vof_angle (vof_comma_list vof_name)) v1 in
      let v2 =
        vof_paren
          (vof_comma_list
             (fun (v1, v2) ->
               let v1 = vof_param_name v1
               and v2 = vof_annotation v2
               in Ocaml.VTuple [ v1; v2 ]))
          v2
      and v3 = vof_tok v3
      and v4 = vof_type_ v4
      in Ocaml.VSum (("TFunAnnot", [ v1; v2; v3; v4 ]))

and vof_nominal_type ((v1,v2)) =
  let v1 = vof_expr v1 in
  let v2 = Ocaml.vof_option (vof_angle (vof_comma_list vof_type_)) v2 in
  Ocaml.VTuple [ v1; v2 ]
and vof_type_opt v =
  Ocaml.vof_option vof_annotation v
and vof_func_decl {
                  f_kind = v_f_kind;
                  f_properties = v_f_properties;
                  f_params = v_f_params;
                  f_body = v_f_body;
                  f_type_params = v_f_type_params;
                  f_return_type = v_f_return_type
                } =
  let bnds = [] in
  let arg = vof_type_opt v_f_return_type in
  let bnd = ("f_return_type", arg) in
  let bnds = bnd :: bnds in
  let arg = Ocaml.vof_option vof_type_parameters v_f_type_params in
  let bnd = ("f_type_params", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_brace (Ocaml.vof_list vof_item) v_f_body in
  let bnd = ("f_body", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_paren (vof_comma_list vof_parameter_binding) v_f_params in
  let bnd = ("f_params", arg) in
  let bnds = bnd :: bnds in
  let arg = Ocaml.vof_list vof_func_property v_f_properties in
  let bnd = ("f_properties", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_func_kind v_f_kind in
  let bnd = ("f_kind", arg) in let bnds = bnd :: bnds in Ocaml.VDict bnds

and vof_type_parameters v = vof_angle (vof_comma_list vof_type_parameter) v
and vof_type_parameter v = vof_name v

and vof_func_kind =
  function
  | F_func ((v1, v2)) ->
      let v1 = vof_tok v1
      and v2 = Ocaml.vof_option vof_name v2
      in Ocaml.VSum (("F_func", [ v1; v2 ]))
  | F_method v1 ->
      let v1 = vof_property_name v1 in Ocaml.VSum (("F_method", [ v1 ]))
  | F_get ((v1, v2)) ->
      let v1 = vof_tok v1
      and v2 = vof_property_name v2
      in Ocaml.VSum (("F_get", [ v1; v2 ]))
  | F_set ((v1, v2)) ->
      let v1 = vof_tok v1
      and v2 = vof_property_name v2
      in Ocaml.VSum (("F_set", [ v1; v2 ]))
and vof_func_property =
  function
  | Generator v1 -> let v1 = vof_tok v1 in Ocaml.VSum (("Generator", [ v1 ]))
  | Async v1 -> let v1 = vof_tok v1 in Ocaml.VSum (("Async", [ v1 ]))
and vof_parameter_binding =
  function
  | ParamClassic v1 ->
      let v1 = vof_parameter v1 in Ocaml.VSum (("ParamClassic", [ v1 ]))
  | ParamPattern v1 ->
      let v1 = vof_parameter_pattern v1
      in Ocaml.VSum (("ParamPattern", [ v1 ]))

and
  vof_parameter_pattern {
                          ppat = v_ppat;
                          ppat_type = v_ppat_type;
                          ppat_default = v_ppat_default
                        } =
  let bnds = [] in
  let arg =
    Ocaml.vof_option
      (fun (v1, v2) ->
         let v1 = vof_tok v1 and v2 = vof_expr v2 in Ocaml.VTuple [ v1; v2 ])
      v_ppat_default in
  let bnd = ("ppat_default", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_type_opt v_ppat_type in
  let bnd = ("ppat_type", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_pattern v_ppat in
  let bnd = ("ppat", arg) in let bnds = bnd :: bnds in Ocaml.VDict bnds

and vof_parameter { p_name = v_p_name; p_type = v_p_type; p_default = v_default;
  p_dots = v_dots } =
  let bnds = [] in
  let arg = vof_type_opt v_p_type in
  let bnd = ("p_type", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_name v_p_name in
  let bnd = ("p_name", arg) in
  let bnds = bnd :: bnds in
  let arg = Ocaml.vof_option vof_default v_default in
  let bnd = ("p_default", arg) in
  let bnds = bnd :: bnds in
  let arg = Ocaml.vof_option vof_tok v_dots in
  let bnd = ("p_dots", arg) in
  let bnds = bnd :: bnds in
  Ocaml.VDict bnds
and vof_default = function
  | DNone (v1) -> let v1 = vof_tok v1 in Ocaml.VSum (("DNone", [v1]))
  | DSome (v1,v2) -> let v1 = vof_tok v1 and v2 = vof_expr v2 in Ocaml.VSum (("DSome", [v1; v2]))

and
  vof_arrow_func { a_params = v_a_params; a_return_type = v_a_return_type;
                   a_tok = v_a_tok; a_body = v_a_body
                 } =
  let bnds = [] in
  let arg = vof_arrow_body v_a_body in
  let bnd = ("a_body", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_tok v_a_tok in
  let bnd = ("a_tok", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_type_opt v_a_return_type in
  let bnd = ("a_return_type", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_arrow_params v_a_params in
  let bnd = ("a_params", arg) in let bnds = bnd :: bnds in Ocaml.VDict bnds
and vof_arrow_params =
  function
  | ASingleParam v1 ->
      let v1 = vof_parameter_binding v1 in Ocaml.VSum (("ASingleParam", [ v1 ]))
  | AParams v1 ->
      let v1 = vof_paren (vof_comma_list vof_parameter_binding) v1
      in Ocaml.VSum (("AParams", [ v1 ]))
and vof_arrow_body =
  function
  | AExpr v1 -> let v1 = vof_expr v1 in Ocaml.VSum (("AExpr", [ v1 ]))
  | ABody v1 ->
      let v1 = vof_brace (Ocaml.vof_list vof_item) v1
      in Ocaml.VSum (("ABody", [ v1 ]))
and vof_var_kind =
  function
  | Var -> Ocaml.VSum (("Var", []))
  | Const -> Ocaml.VSum (("Const", []))
  | Let -> Ocaml.VSum (("Let", []))

and vof_var_binding =
  function
  | VarClassic v1 ->
      let v1 = vof_variable_declaration v1
      in Ocaml.VSum (("VarClassic", [ v1 ]))
  | VarPattern v1 ->
      let v1 = vof_variable_declaration_pattern v1
      in Ocaml.VSum (("VarPattern", [ v1 ]))

and
  vof_variable_declaration_pattern {
                                     vpat = v_vpat;
                                     vpat_init = v_vpat_init;
                                     vpat_type = v_vpat_type
                                   } =
  let bnds = [] in
  let arg = vof_type_opt v_vpat_type in
  let bnd = ("vpat_type", arg) in
  let bnds = bnd :: bnds in
  let arg = Ocaml.vof_option vof_init v_vpat_init in
  let bnd = ("vpat_init", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_pattern v_vpat in
  let bnd = ("vpat", arg) in let bnds = bnd :: bnds in Ocaml.VDict bnds

and vof_init (v1, v2) =
  let v1 = vof_tok v1 and v2 = vof_expr v2 in Ocaml.VTuple [ v1; v2 ]

and vof_pattern =
  function
  | PatObj v1 ->
      let v1 = vof_brace (vof_comma_list vof_pattern) v1
      in Ocaml.VSum (("PatObj", [ v1 ]))
  | PatArr v1 ->
      let v1 = vof_bracket (vof_comma_list vof_pattern) v1
      in Ocaml.VSum (("PatArr", [ v1 ]))
  | PatId ((v1, v2)) ->
      let v1 = vof_name v1
      and v2 = Ocaml.vof_option vof_init v2
      in Ocaml.VSum (("PatId", [ v1; v2 ]))
  | PatProp ((v1, v2, v3)) ->
      let v1 = vof_property_name v1
      and v2 = vof_tok v2
      and v3 = vof_pattern v3
      in Ocaml.VSum (("PatProp", [ v1; v2; v3 ]))
  | PatDots ((v1, v2)) ->
      let v1 = vof_tok v1
      and v2 = vof_pattern v2
      in Ocaml.VSum (("PatDots", [ v1; v2 ]))
  | PatNest ((v1, v2)) ->
      let v1 = vof_pattern v1
      and v2 = Ocaml.vof_option vof_init v2
      in Ocaml.VSum (("PatNest", [ v1; v2 ]))

and vof_variable_declaration {
                             v_name = v_v_name;
                             v_init = v_v_init;
                             v_type = v_v_type
                           } =
  let bnds = [] in
  let arg = vof_type_opt v_v_type in
  let bnd = ("v_type", arg) in
  let bnds = bnd :: bnds in
  let arg =
    Ocaml.vof_option
      (fun (v1, v2) ->
         let v1 = vof_tok v1 and v2 = vof_expr v2 in Ocaml.VTuple [ v1; v2 ])
      v_v_init in
  let bnd = ("v_init", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_name v_v_name in
  let bnd = ("v_name", arg) in let bnds = bnd :: bnds in Ocaml.VDict bnds

and vof_item =
  function
  | ItemTodo v1 -> let v1 = vof_tok v1 in Ocaml.VSum (("ItemTodo", [v1]))
  | St v1 -> let v1 = vof_st v1 in Ocaml.VSum (("St", [ v1 ]))
  | FunDecl v1 ->
      let v1 = vof_func_decl v1 in Ocaml.VSum (("FunDecl", [ v1 ]))
  | ClassDecl v1 ->
      let v1 = vof_class_decl v1 in Ocaml.VSum (("ClassDecl", [ v1 ]))
  | InterfaceDecl v1 ->
      let v1 = vof_interface_decl v1 in Ocaml.VSum (("InterfaceDecl", [ v1 ]))

and  vof_class_decl {
                   c_tok = v_c_tok;
                   c_name = v_c_name;
                   c_type_params = v_c_type_params;
                   c_extends = v_c_extends;
                   c_body = v_c_body
                 } =
  let bnds = [] in
  let arg = vof_brace (Ocaml.vof_list vof_class_stmt) v_c_body in
  let bnd = ("c_body", arg) in
  let bnds = bnd :: bnds in
  let arg =
    Ocaml.vof_option
      (fun (v1, v2) ->
         let v1 = vof_tok v1
         and v2 = vof_nominal_type v2
         in Ocaml.VTuple [ v1; v2 ])
      v_c_extends in
  let bnd = ("c_extends", arg) in
  let bnds = bnd :: bnds in
  let arg =
    Ocaml.vof_option
      (vof_angle (vof_comma_list vof_name)) v_c_type_params
  in
  let bnd = ("c_type_params", arg) in
  let bnds = bnd :: bnds in
  let arg = Ocaml.vof_option vof_name v_c_name in
  let bnd = ("c_name", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_tok v_c_tok in
  let bnd = ("c_tok", arg) in let bnds = bnd :: bnds in Ocaml.VDict bnds
and  vof_interface_decl {
                   i_tok = v_i_tok;
                   i_name = v_i_name;
                   i_type_params = v_i_type_params;
                   i_type = v_i_type;
                 } =
  let bnds = [] in
  let arg = vof_type_ v_i_type in
  let bnd = ("i_type", arg) in
  let bnds = bnd :: bnds in
  let arg =
    Ocaml.vof_option
      (vof_angle (vof_comma_list vof_name)) v_i_type_params
  in
  let bnd = ("i_type_params", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_name v_i_name in
  let bnd = ("i_name", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_tok v_i_tok in
  let bnd = ("i_tok", arg) in let bnds = bnd :: bnds in Ocaml.VDict bnds

and  vof_field_decl {
                   fld_static = v_fld_static;
                   fld_name = v_fld_name;
                   fld_type = v_fld_type;
                   fld_init = v_fld_init
                 } =
  let bnds = [] in
  let arg = Ocaml.vof_option vof_init v_fld_init in
  let bnd = ("fld_init", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_type_opt v_fld_type in
  let bnd = ("fld_type", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_property_name v_fld_name in
  let bnd = ("fld_name", arg) in
  let bnds = bnd :: bnds in
  let arg = vof_static_opt v_fld_static in
  let bnd = ("fld_static", arg) in let bnds = bnd :: bnds in Ocaml.VDict bnds

and vof_static_opt v = Ocaml.vof_option vof_tok v

and vof_class_stmt =
  function
  | C_field ((v1, v2)) ->
      let v1 = vof_field_decl v1
      and v2 = vof_sc v2
      in Ocaml.VSum (("C_field", [ v1; v2 ]))
  | C_method ((v1, v2)) ->
      let v1 = Ocaml.vof_option vof_tok v1
      and v2 = vof_func_decl v2
      in Ocaml.VSum (("C_method", [ v1; v2 ]))
  | C_extrasemicolon v1 ->
      let v1 = vof_sc v1 in Ocaml.VSum (("C_extrasemicolon", [ v1 ]))

and vof_import =
  function
  | ImportFrom v1 ->
      let v1 =
        (match v1 with
         | (v1, v2) ->
             let v1 = vof_import_clause v1
             and v2 =
               (match v2 with
                | (v1, v2) ->
                    let v1 = vof_tok v1
                    and v2 = vof_module_path v2
                    in Ocaml.VTuple [ v1; v2 ])
             in Ocaml.VTuple [ v1; v2 ])
      in Ocaml.VSum (("ImportFrom", [ v1 ]))
  | ImportEffect v1 ->
      let v1 = vof_module_path v1 in Ocaml.VSum (("ImportEffect", [ v1 ]))
and vof_import_clause (v1, v2) =
  let v1 = Ocaml.vof_option vof_import_default v1
  and v2 = Ocaml.vof_option vof_name_import v2
  in Ocaml.VTuple [ v1; v2 ]
and vof_name_import =
  function
  | ImportNamespace ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_tok v2
      and v3 = vof_name v3
      in Ocaml.VSum (("ImportNamespace", [ v1; v2; v3 ]))
  | ImportNames v1 ->
      let v1 = vof_brace (vof_comma_list vof_import_name) v1
      in Ocaml.VSum (("ImportNames", [ v1 ]))
  | ImportTypes (v1, v2) ->
      let v1 = vof_tok v1 in
      let v2 = vof_brace (vof_comma_list vof_import_name) v2
      in Ocaml.VSum (("ImportTypes", [ v1; v2 ]))
and vof_import_default v = vof_name v
and vof_import_name (v1, v2) =
  let v1 = vof_name v1
  and v2 =
    Ocaml.vof_option
      (fun (v1, v2) ->
         let v1 = vof_tok v1 and v2 = vof_name v2 in Ocaml.VTuple [ v1; v2 ])
      v2
  in Ocaml.VTuple [ v1; v2 ]

and vof_export =
  function
  | ExportDecl v1 ->
      let v1 = vof_item v1 in Ocaml.VSum (("ExportDecl", [ v1 ]))
  | ExportDefaultDecl ((v1, v2)) ->
      let v1 = vof_tok v1
      and v2 = vof_item v2
      in Ocaml.VSum (("ExportDefaultDecl", [ v1; v2 ]))
  | ExportDefaultExpr ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 = vof_expr v2
      and v3 = vof_sc v3
      in Ocaml.VSum (("ExportDefaultExpr", [ v1; v2; v3 ]))
  | ExportNames ((v1, v2)) ->
      let v1 = vof_brace (vof_comma_list vof_import_name) v1
      and v2 = vof_sc v2
      in Ocaml.VSum (("ExportNames", [ v1; v2 ]))
  | ReExportNamespace ((v1, v2, v3)) ->
      let v1 = vof_tok v1
      and v2 =
        (match v2 with
         | (v1, v2) ->
             let v1 = vof_tok v1
             and v2 = vof_module_path v2
             in Ocaml.VTuple [ v1; v2 ])
      and v3 = vof_sc v3
      in Ocaml.VSum (("ReExportNamespace", [ v1; v2; v3 ]))
  | ReExportNames ((v1, v2, v3)) ->
      let v1 = vof_brace (vof_comma_list vof_import_name) v1
      and v2 =
        (match v2 with
         | (v1, v2) ->
             let v1 = vof_tok v1
             and v2 = vof_module_path v2
             in Ocaml.VTuple [ v1; v2 ])
      and v3 = vof_sc v3
      in Ocaml.VSum (("ReExportNames", [ v1; v2; v3 ]))

and vof_module_item =
  function
  | Import v1 ->
      let v1 =
        (match v1 with
         | (v1, v2, v3) ->
             let v1 = vof_tok v1
             and v2 = vof_import v2
             and v3 = vof_sc v3
             in Ocaml.VTuple [ v1; v2; v3 ])
      in Ocaml.VSum (("Import", [ v1 ]))
  | Export v1 ->
      let v1 =
        (match v1 with
         | (v1, v2) ->
             let v1 = vof_tok v1
             and v2 = vof_export v2
             in Ocaml.VTuple [ v1; v2 ])
      in Ocaml.VSum (("Export", [ v1 ]))

  | It v1 -> let v1 = vof_item v1 in Ocaml.VSum (("It", [ v1 ]))

and vof_program_orig v = Ocaml.vof_list vof_module_item v

let vof_any_orig =
  function
  | Expr v1 -> let v1 = vof_expr v1 in Ocaml.VSum (("Expr", [ v1 ]))
  | Stmt v1 -> let v1 = vof_st v1 in Ocaml.VSum (("Stmt", [ v1 ]))
  | Item v1 -> let v1 = vof_item v1 in Ocaml.VSum (("Item",[v1 ]))
  | Pattern v1 -> let v1 = vof_pattern v1 in Ocaml.VSum (("Pattern",[v1 ]))
  | Program v1 -> let v1 = vof_program_orig v1 in Ocaml.VSum (("Program",[v1]))


(* end auto generation *)

let vof_any ?(precision=M.default_precision) x =
  Common.save_excursion _current_precision precision (fun () ->
    vof_any_orig x
  )

let vof_program ?(precision=M.default_precision) x =
  Common.save_excursion _current_precision precision (fun () ->
    vof_program_orig x
  )
OCaml

Innovation. Community. Security.