package diffast-langs-fortran

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

Source file f_label.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
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
(*
   Copyright 2013-2018 RIKEN
   Copyright 2018-2025 Chiba Institude of Technology

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*)

(* Author: Masatomo Hashimoto <m.hashimoto@stair.center> *)

(* fortran/label.ml *)

module Xlist = Diffast_misc.Xlist
module Loc = Diffast_misc.Loc
module Lang_base = Diffast_core.Lang_base
module Spec = Diffast_core.Spec
module Charpool = Diffast_core.Charpool
module Astml = Diffast_core.Astml
module Ast = Fortran_parsing.Ast
module Label_common = Fortran_parsing.Label_common
module Labels = Fortran_parsing.Labels
module Label = Fortran_parsing.Label
module Pinfo = Fortran_parsing.Pinfo

let keyroot_depth_min = 4

type tie_id = Lang_base.tie_id

let null_tid      = Lang_base.null_tid
let mktid         = Lang_base.mktid
let tid_to_string = Lang_base.tid_to_string
let anonymize_tid = Lang_base.anonymize_tid
let mktidattr     = Lang_base.mktidattr



module type T = sig
  include Spec.LABEL_T

  val lang_prefix               : string

  val is_case_construct         : t -> bool
  val is_do_construct           : t -> bool
  val is_forall_construct       : t -> bool
  val is_if_construct           : t -> bool
  val is_where_construct        : t -> bool
  val is_derived_type_def       : t -> bool
  val is_interface_block        : t -> bool
  val is_select_type_construct  : t -> bool
  val is_associate_construct    : t -> bool
  val is_block_construct        : t -> bool
  val is_critical_construct     : t -> bool

  val is_primary                : t -> bool
  val is_expr                   : t -> bool
  val is_stmt                   : t -> bool

  val is_if_stmt                : t -> bool
  val is_arithmetic_if_stmt     : t -> bool
  val is_if_then_stmt           : t -> bool
  val is_else_if_stmt           : t -> bool
  val is_else_stmt              : t -> bool

  val is_pp_directive           : t -> bool
  val is_pp_define              : t -> bool
  val is_pp_include             : t -> bool
  val is_ocl_directive          : t -> bool
  val is_omp_directive          : t -> bool
  val is_acc_directive          : t -> bool
  val is_dec_directive          : t -> bool

  val is_program                : t -> bool

  val is_program_unit           : t -> bool

  val is_program_unit_or_fragment   : t -> bool
  val is_program_unit_or_subprogram : t -> bool

  val is_main_program           : t -> bool
  val is_function               : t -> bool
  val is_subroutine             : t -> bool
  val is_subprogram             : t -> bool

  val is_ext_function           : t -> bool
  val is_ext_subroutine         : t -> bool

  val is_int_function           : t -> bool
  val is_int_subroutine         : t -> bool

  val is_mod_function           : t -> bool
  val is_mod_subroutine         : t -> bool

  val is_module                 : t -> bool
  val is_block_data             : t -> bool

  val is_block                  : t -> bool

  val is_entity_decl            : t -> bool
  val is_type_decl_stmt         : t -> bool
  val is_var_name               : t -> bool
  val is_part_name              : t -> bool

  val is_if_then_block    : t -> bool
  val is_else_block       : t -> bool
  val is_else_if_block    : t -> bool
  val is_where_block      : t -> bool
  val is_case_block       : t -> bool
  val is_type_guard_block : t -> bool
  val is_do_block         : t -> bool

  val is_pp_branch            : t -> bool
  val is_pp_branch_do         : t -> bool
  val is_pp_branch_end_do     : t -> bool
  val is_pp_branch_if         : t -> bool
  val is_pp_branch_end_if     : t -> bool
  val is_pp_branch_forall     : t -> bool
  val is_pp_branch_end_forall : t -> bool
  val is_pp_branch_where      : t -> bool
  val is_pp_branch_end_where  : t -> bool
  val is_pp_branch_select     : t -> bool
  val is_pp_branch_end_select : t -> bool

  val is_pp_section_ifdef  : t -> bool
  val is_pp_section_ifndef : t -> bool
  val is_pp_section_if     : t -> bool
  val is_pp_section_elif   : t -> bool
  val is_pp_section_else   : t -> bool

  val is_omp_construct     : t -> bool
  val is_acc_construct     : t -> bool

  val is_fragment          : t -> bool

  val is_execution_part    : t -> bool
  val is_subprogram_part   : t -> bool

  val is_section_subscript_list : t -> bool
  val is_ambiguous              : t -> bool

  val is_container_unit         : t -> bool

  val getlab                    : Spec.node_t -> t

  val get_var                   : t -> string
  val get_pp_include_path       : t -> string
  val get_label                 : t -> string
  val get_stmt_label            : t -> string

end


let conv_loc
    { Ast.Loc.filename     = fn;
      Ast.Loc.start_offset = so;
      Ast.Loc.end_offset   = eo;
      Ast.Loc.start_line   = sl;
      Ast.Loc.start_char   = sc;
      Ast.Loc.end_line     = el;
      Ast.Loc.end_char     = ec;
    } =
  Loc.make ~fname:fn so eo sl sc el ec

open Charpool



include Label_common

module HeaderFile = struct
  include Labels.HeaderFile

  let to_short_string = function
    | User s   -> mkstr_str 0 s
    | System s -> mkstr_str 2 s
    | Macro(n, _) -> combo 4 [n]
    | Generated s -> mkstr_str 5 s
end

module PpDirective = struct
  include Labels.PpDirective

  let branch_to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in
    function
      | If c     -> mkstr_str 0 c
      | Elif c   -> mkstr_str 2 c
      | Ifdef n  -> combo 4 [n]
      | Ifndef n -> combo 5 [n]
      | Else     -> mkstr 6
      | Endif _  -> mkstr 7

  let message_to_short_string = function
    | Error m   -> mkstr_str 0 m
    | Warning m -> mkstr_str 2 m

  let _to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in
    function
      | Define(n, b)  -> mkstr_strs 0 [n;b]
      | Undef n       -> combo 2 [n]
      | Include h     -> mkstr_str 3 (HeaderFile.to_short_string h)
      | Branch b      -> mkstr_str 5 (branch_to_short_string ~ignore_identifiers_flag b)
      | Message m     -> mkstr_str 7 (message_to_short_string m)
      | Unknown(d, r) -> mkstr_strs 11 [d;r]

  let to_short_string x = _to_short_string x.pp_label

end

module ProgramUnit = struct
  include Labels.ProgramUnit

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in
    function
      | FunctionSubprogram n   -> combo 0 [n]
      | SubroutineSubprogram n -> combo 1 [n]
      | Module n               -> combo 2 [n]
      | MainProgram n_opt      -> combo 3 (opt_to_list n_opt)
      | BlockData n_opt        -> combo 4 (opt_to_list n_opt)
      | Submodule n            -> combo 5 [n]

end

module InternalSubprogram = struct
  include Labels.InternalSubprogram

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in
    function
      | FunctionSubprogram n   -> combo 0 [n]
      | SubroutineSubprogram n -> combo 1 [n]

end

module ModuleSubprogram = struct
  include Labels.ModuleSubprogram

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in
    function
      | FunctionSubprogram n       -> combo 0 [n]
      | SubroutineSubprogram n     -> combo 1 [n]
      | SeparateModuleSubprogram n -> combo 2 [n]

end

module IntentSpec = struct
  include Labels.IntentSpec

  let to_short_string = function
    | In    -> mkstr 0
    | Out   -> mkstr 1
    | Inout -> mkstr 2

end

module AttrSpec = struct
  include Labels.AttrSpec

  let to_short_string = function
    | Parameter   -> mkstr 0
    | Public      -> mkstr 1
    | Private     -> mkstr 2
    | Allocatable -> mkstr 3
    | Dimension   -> mkstr 4
    | External    -> mkstr 5
    | Intrinsic   -> mkstr 6
    | Optional    -> mkstr 7
    | Pointer     -> mkstr 8
    | Save        -> mkstr 9
    | Target      -> mkstr 10
    | Intent i    -> catstr [mkstr 11; IntentSpec.to_short_string i]

    | Asynchronous -> mkstr 13
    | Bind         -> mkstr 14
    | Protected    -> mkstr 15
    | Value        -> mkstr 16
    | Volatile     -> mkstr 17

    | Automatic    -> mkstr 18
    | Static       -> mkstr 19

    | Codimension  -> mkstr 20
    | Contiguous   -> mkstr 21

    | Device   -> mkstr 22
    | Managed  -> mkstr 23
    | Constant -> mkstr 24
    | Shared   -> mkstr 25
    | Pinned   -> mkstr 26
    | Texture  -> mkstr 27

end

module AccessSpec = struct
  include Labels.AccessSpec

  let to_short_string = function
    | Private -> mkstr 0
    | Public  -> mkstr 1

end

module TypeAttrSpec = struct
  include Labels.TypeAttrSpec

  let to_short_string = function
    | Abstract  -> mkstr 0
    | Bind      -> mkstr 1
    | Extends n -> combo 2 [n]
    | Private   -> mkstr 3
    | Public    -> mkstr 4

end

module Stmt = struct
  include Labels.Stmt

  let _to_short_string ?(ignore_identifiers_flag=false) =
    let combo2 = combo2 ~ignore_identifiers_flag in function
    | AllocatableStmt          -> mkstr2 0
    | AllocateStmt             -> mkstr2 1
    | ArithmeticIfStmt         -> mkstr2 2
    | AssignedGotoStmt         -> mkstr2 3
    | AssignmentStmt           -> mkstr2 4
    | BackspaceStmt            -> mkstr2 5
    | CloseStmt                -> mkstr2 6
    | CommonStmt               -> mkstr2 7
    | ComponentDefStmt         -> mkstr2 8
    | ComputedGotoStmt         -> mkstr2 9
    | ContainsStmt             -> mkstr2 10
    | ContinueStmt             -> mkstr2 11
    | DataStmt                 -> mkstr2 12
    | DeallocateStmt           -> mkstr2 13
    | DimensionStmt            -> mkstr2 14
    | EndStmt                  -> mkstr2 15
    | EndfileStmt              -> mkstr2 16
    | EndInterfaceStmt         -> mkstr2 17
    | EquivalenceStmt          -> mkstr2 18
    | ExternalStmt             -> mkstr2 19
    | ForallStmt               -> mkstr2 20
    | FormatStmt               -> mkstr2 21
    | GotoStmt                 -> mkstr2 22
    | IfStmt                   -> mkstr2 23
    | ImplicitStmt             -> mkstr2 24
    | InquireStmt              -> mkstr2 25
    | IntentStmt               -> mkstr2 26
    | InterfaceStmt n_opt      -> combo2 27 (opt_to_list n_opt)
    | IntrinsicStmt            -> mkstr2 28
    | ProcedureStmt            -> mkstr2 29
    | NamelistStmt             -> mkstr2 30
    | NullifyStmt              -> mkstr2 31
    | OpenStmt                 -> mkstr2 32
    | OptionalStmt             -> mkstr2 33
    | ParameterStmt            -> mkstr2 34
    | PauseStmt                -> mkstr2 35
    | PointerAssignmentStmt    -> mkstr2 36
    | PointerStmt              -> mkstr2 37
    | PrintStmt                -> mkstr2 38
    | PrivateStmt              -> mkstr2 39
    | SequenceStmt             -> mkstr2 40
    | ReadStmt                 -> mkstr2 41
    | ReturnStmt               -> mkstr2 42
    | RewindStmt               -> mkstr2 43
    | SaveStmt                 -> mkstr2 44
    | StopStmt                 -> mkstr2 45
    | TargetStmt               -> mkstr2 46
    | TypeDeclarationStmt ns   -> combo2 47 ns
    | WhereStmt                -> mkstr2 48
    | WriteStmt                -> mkstr2 49

    | CallStmt n               -> combo2 50 [n]
    | DerivedTypeStmt n        -> combo2 51 [n]
    | EntryStmt n              -> combo2 52 [n]
    | FunctionStmt n           -> combo2 53 [n]
    | ModuleStmt n             -> combo2 54 [n]
    | ProgramStmt n            -> combo2 55 [n]
    | StmtFunctionStmt n       -> combo2 56 [n]
    | SubroutineStmt n         -> combo2 57 [n]
    | UseStmt n                -> combo2 58 [n]

    | BlockDataStmt n_opt       -> combo2 59 (opt_to_list n_opt)
    | CaseStmt n_opt            -> combo2 60 (opt_to_list n_opt)
    | CycleStmt n_opt           -> combo2 61 (opt_to_list n_opt)
    | ElseIfStmt n_opt          -> combo2 62 (opt_to_list n_opt)
    | ElseStmt n_opt            -> combo2 63 (opt_to_list n_opt)
    | ElsewhereStmt n_opt       -> combo2 64 (opt_to_list n_opt)
    | EndBlockDataStmt n_opt    -> combo2 65 (opt_to_list n_opt)
    | EndDoStmt n_opt           -> combo2 66 (opt_to_list n_opt)
    | EndForallStmt n_opt       -> combo2 67 (opt_to_list n_opt)
    | EndFunctionStmt n_opt     -> combo2 68 (opt_to_list n_opt)
    | EndIfStmt n_opt           -> combo2 69 (opt_to_list n_opt)
    | EndModuleStmt n_opt       -> combo2 70 (opt_to_list n_opt)
    | EndProgramStmt n_opt      -> combo2 71 (opt_to_list n_opt)
    | EndSelectStmt n_opt       -> combo2 72 (opt_to_list n_opt)
    | EndSubroutineStmt n_opt   -> combo2 73 (opt_to_list n_opt)
    | EndTypeStmt n_opt         -> combo2 74 (opt_to_list n_opt)
    | EndWhereStmt n_opt        -> combo2 75 (opt_to_list n_opt)
    | ExitStmt n_opt            -> combo2 76 (opt_to_list n_opt)
    | ForallConstructStmt n_opt -> combo2 77 (opt_to_list n_opt)
    | IfThenStmt n_opt          -> combo2 78 (opt_to_list n_opt)
    | SelectCaseStmt n_opt      -> combo2 79 (opt_to_list n_opt)
    | WhereConstructStmt n_opt  -> combo2 80 (opt_to_list n_opt)

    | AccessStmt a                -> catstr [mkstr2 81; AccessSpec.to_short_string a]
    | AssignStmt l                -> combo2 82 [l]
    | DoStmt(n_opt, l_opt, v_opt) ->
        combo2 83 ((opt_to_list n_opt) @ (opt_to_list l_opt) @ (opt_to_list v_opt))

    | PpMacroStmt n               -> combo2 84 [n]

    | StructureStmt n_opt         -> combo2 85 (opt_to_list n_opt)
    | EndStructureStmt            -> mkstr2 86
    | UnionStmt                   -> mkstr2 87
    | EndUnionStmt                -> mkstr2 88
    | MapStmt                     -> mkstr2 89
    | EndMapStmt                  -> mkstr2 90
    | RecordStmt                  -> mkstr2 91

    | AsynchronousStmt -> mkstr2 92
    | BindStmt         -> mkstr2 93
    | ProtectedStmt    -> mkstr2 94
    | ValueStmt        -> mkstr2 95
    | VolatileStmt     -> mkstr2 96

    | AbstractInterfaceStmt -> mkstr2 97
    | ImportStmt            -> mkstr2 98

    | PpMacroId _           -> mkstr2 99

    | AcceptStmt     -> mkstr2 100
    | DecodeStmt     -> mkstr2 101
    | DefineFileStmt -> mkstr2 102
    | DeleteStmt     -> mkstr2 103
    | EncodeStmt     -> mkstr2 104
    | FindStmt       -> mkstr2 105
    | RewriteStmt    -> mkstr2 106
    | TypeStmt       -> mkstr2 107
    | UnlockStmt     -> mkstr2 108
    | VirtualStmt    -> mkstr2 109

    | AssociateStmt n_opt             -> combo2 110 (opt_to_list n_opt)
    | BlockStmt n_opt                 -> combo2 111 (opt_to_list n_opt)
    | CriticalStmt n_opt              -> combo2 112 (opt_to_list n_opt)
    | EndAssociateStmt n_opt          -> combo2 113 (opt_to_list n_opt)
    | EndEnumStmt                     -> mkstr2 114
    | EndBlockStmt n_opt              -> combo2 115 (opt_to_list n_opt)
    | EndCriticalStmt n_opt           -> combo2 116 (opt_to_list n_opt)
    | EnumDefStmt                     -> mkstr2 117
    | EnumeratorDefStmt               -> mkstr2 118
    | FlushStmt                       -> mkstr2 119
    | BindingPrivateStmt              -> mkstr2 120
    | FinalProcedureStmt              -> mkstr2 121
    | TypeBoundGenericStmt            -> mkstr2 122
    | ProcComponentDefStmt            -> mkstr2 123
    | ProcedureDeclarationStmt        -> mkstr2 124
    | SelectTypeStmt n_opt            -> combo2 125 (opt_to_list n_opt)
    | TypeIsTypeGuardStmt n_opt       -> combo2 126 (opt_to_list n_opt)
    | ClassIsTypeGuardStmt n_opt      -> combo2 127 (opt_to_list n_opt)
    | ClassDefaultTypeGuardStmt n_opt -> combo2 128 (opt_to_list n_opt)
    | EndSelectTypeStmt n_opt         -> combo2 129 (opt_to_list n_opt)
    | WaitStmt                        -> mkstr2 130
    | TypeBoundProcedureStmt n_opt    -> combo2 131 (opt_to_list n_opt)
    | ErrorStopStmt                   -> mkstr2 132
    | CodimensionStmt                 -> mkstr2 133
    | ContiguousStmt                  -> mkstr2 134
    | LockStmt                        -> mkstr2 135
    | SyncAllStmt                     -> mkstr2 136
    | SyncImagesStmt                  -> mkstr2 137
    | SyncMemoryStmt                  -> mkstr2 138
    | SubmoduleStmt(a, p_opt, n)      -> combo2 139 (a :: (opt_to_list p_opt) @ [n])
    | EndSubmoduleStmt n_opt          -> combo2 140 (opt_to_list n_opt)
    | AutomaticStmt                   -> mkstr2 141
    | StaticStmt                      -> mkstr2 142
    | MpSubprogramStmt n              -> combo2 143 [n]
    | EndMpSubprogramStmt n_opt       -> combo2 144 (opt_to_list n_opt)

  let to_short_string ?(ignore_identifiers_flag=false) = function
    | Labeled(lab, stmt) -> catstr ((_to_short_string stmt)::(encode_ids ~ignore_identifiers_flag [lab]))
    | Nonlabeled stmt -> _to_short_string stmt

end

module Ambiguous = struct
  include Labels.Ambiguous

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Tuple            -> mkstr 0
    | Primary          -> mkstr 1
    | Subobject        -> mkstr 2
    | TripletOrRange   -> mkstr 3
    | First            -> mkstr 4
    | Second           -> mkstr 5
    | DataStmtConstant -> mkstr 6
    | Assumed          -> mkstr 7
    | Deferred         -> mkstr 8
    | AssumedSize      -> mkstr 9

    | Designator n      -> combo 10 [n]
    | NamedTuple n      -> combo 11 [n]
    | NamedDataObject n -> combo 12 [n]

    | ArrayAccess n -> combo 13 [n]
(*
    | PpExpr n     -> combo 14 [n]
    | PpTypeSpec n -> combo 15 [n]
*)
    | GenericSpecOrUseName n -> combo 16 [n]

end

module Constant = struct
  include Labels.Constant

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | BozLiteralConstant s         -> catstr [mkstr 0; s]
    | CharLiteralConstant s        -> catstr [mkstr 1; s]
    | IntLiteralConstant s         -> catstr [mkstr 2; s]
    | LogicalLiteralConstant s     -> catstr [mkstr 3; s]
    | RealLiteralConstant s        -> catstr [mkstr 4; s]
    | ComplexLiteralConstant(r, i) -> catstr [mkstr 5; r; i]
    | NamedConstant n              -> combo 6 [n]
    | HollerithConstant s          -> catstr [mkstr 7; s]
    | PpMacroConstant n            -> combo 8 [n]
    | SignedIntLiteralConstant s   -> catstr [mkstr 9; s]
    | SignedRealLiteralConstant s  -> catstr [mkstr 10; s]

end

module IntrinsicOperator = struct
  include Labels.IntrinsicOperator

  let to_short_string = function
    | AND    -> mkstr 0
    | OR     -> mkstr 1
    | NOT    -> mkstr 2
    | EQV    -> mkstr 3
    | GE     -> mkstr 4
    | GT     -> mkstr 5
    | LE     -> mkstr 6
    | LT     -> mkstr 7
    | EQ     -> mkstr 8
    | NE     -> mkstr 9
    | NEQV   -> mkstr 10
    | Mult   -> mkstr 11
    | Div    -> mkstr 12
    | Power  -> mkstr 13
    | Add    -> mkstr 14
    | Subt   -> mkstr 15
    | Concat -> mkstr 16
    | Eq     -> mkstr 17
    | Neq    -> mkstr 18
    | Lt     -> mkstr 19
    | Le     -> mkstr 20
    | Gt     -> mkstr 21
    | Ge     -> mkstr 22
    | Id     -> mkstr 23
    | Neg    -> mkstr 24
end

module DefinedOperator = struct
  include Labels.DefinedOperator

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | DefinedOp s       -> combo 0 [s]
    | DefinedUnaryOp s  -> combo 1 [s]
    | DefinedBinaryOp s -> combo 2 [s]

end

module OclDirective = struct
  include Labels.OclDirective

  let align_to_short_string = function
    | Aaligned   -> mkstr 0
    | Aunaligned -> mkstr 1

  let prefetch_spec_to_short_string = function
    | Pauto -> mkstr 0
    | Psoft -> mkstr 1

  let listv_scope_to_short_string = function
    | Sall  -> mkstr 0
    | Sthen -> mkstr 1
    | Selse -> mkstr 2

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | ERROR                            -> mkstr 0
    | ArrayFusion                      -> mkstr 2
    | EndArrayFusion                   -> mkstr 3
    | Eval                             -> mkstr 4
    | Noeval                           -> mkstr 5
    | Fltld                            -> mkstr 6
    | Nofltld                          -> mkstr 7
    | FpRelaxed                        -> mkstr 8
    | NofpRelaxed                      -> mkstr 9
    | Nomfunc                          -> mkstr 10
    | LoopNofusion                     -> mkstr 11
    | Preex                            -> mkstr 12
    | Nopreex                          -> mkstr 13
    | Prefetch                         -> mkstr 14
    | Noprefetch                       -> mkstr 15
    | PrefetchInfer                    -> mkstr 16
    | PrefetchNoinfer                  -> mkstr 17
    | Nostriping                       -> mkstr 18
    | Swp                              -> mkstr 19
    | Noswp                            -> mkstr 20
    | UnrollFull                       -> mkstr 21
    | Nounroll                         -> mkstr 22
    | Nosimd                           -> mkstr 23
    | EndCacheSectorSize               -> mkstr 24
    | EndCacheSubsector                -> mkstr 25
    | LoopNofission                    -> mkstr 26
    | Noxfill                          -> mkstr 27
    | PrefetchStrong                   -> mkstr 28
    | PrefetchNostrong                 -> mkstr 29
    | PrefetchStrongL2                 -> mkstr 30
    | PrefetchNostrongL2               -> mkstr 31
    | FpContract                       -> mkstr 32
    | NofpContract                     -> mkstr 33
    | LoopNoblocking                   -> mkstr 34
    | Nouxsimd                         -> mkstr 35
    | ArrayPrivate                     -> mkstr 36
    | NoarrayPrivate                   -> mkstr 37
    | Noalias                          -> mkstr 38
    | Serial                           -> mkstr 39
    | Parallel                         -> mkstr 40
    | ParallelStrong                   -> mkstr 41
    | Reduction                        -> mkstr 42
    | Noreduction                      -> mkstr 43
    | LoopNointerchange                -> mkstr 44

    | Noarraypad n                     -> combo 45 [n]

    | ArraySubscript ns                -> combo 46 ns
    | LoopInterchange ns               -> combo 47 ns
    | Novrec ns                        -> combo 48 ns
    | CacheSubsectorAssign ns          -> combo 49 ns
    | Norecurrence ns                  -> combo 50 ns
    | Independent ns                   -> combo 51 ns
    | Temp ns                          -> combo 52 ns

    | PrefetchIteration i              -> catstr [mkstr 53; string_of_int i]
    | PrefetchIterationL2 i            -> catstr [mkstr 54; string_of_int i]
    | LoopBlocking i                   -> catstr [mkstr 55; string_of_int i]
    | Unroll i                         -> catstr [mkstr 56; string_of_int i]

    | CacheSectorSize is               -> catstr ((mkstr 57)::(List.map string_of_int is))

    | Mfunc i_opt                      -> catstr ((mkstr 58)::(opt_to_list_map string_of_int i_opt))
    | Striping i_opt                   -> catstr ((mkstr 59)::(opt_to_list_map string_of_int i_opt))
    | FissionPoint i_opt               -> catstr ((mkstr 60)::(opt_to_list_map string_of_int i_opt))
    | Xfill i_opt                      -> catstr ((mkstr 61)::(opt_to_list_map string_of_int i_opt))

    | Simd a_opt                       -> catstr ((mkstr 62)::(opt_to_list_map align_to_short_string a_opt))
    | Uxsimd a_opt                     -> catstr ((mkstr 63)::(opt_to_list_map align_to_short_string a_opt))

    | ArrayMerge(n_opt, ns)            -> catstr ((mkstr 64)::(string_opt_to_string n_opt)::ns)
    | PrefetchCacheLevel lv            -> combo 65 [num_or_name_to_string lv]
    | PrefetchRead(lv_opt, st_opt)     -> catstr ((mkstr 66)::((opt_to_list_map num_or_name_to_string lv_opt) @ (opt_to_list_map string_of_int st_opt)))
    | PrefetchWrite(lv_opt, st_opt)    -> catstr ((mkstr 67)::((opt_to_list_map num_or_name_to_string lv_opt) @ (opt_to_list_map string_of_int st_opt)))
    | PrefetchSequential s_opt         -> catstr ((mkstr 68)::(opt_to_list_map prefetch_spec_to_short_string s_opt))
    | RelOp op                         -> catstr [mkstr 69; IntrinsicOperator.to_short_string op]

    | LoopPartSimd                     -> mkstr 70
    | LoopNopartSimd                   -> mkstr 71
    | Shortloop i                      -> catstr [mkstr 72; string_of_int i]
    | Noshortloop                      -> mkstr 73
    | SimdListv s_opt                  -> catstr ((mkstr 74)::(opt_to_list_map listv_scope_to_short_string s_opt))
    | Unswitching                      -> mkstr 75

    | LoopPartParallel                 -> mkstr 76
    | LoopNopartParallel               -> mkstr 77
    | FirstPrivate ns                  -> combo 78 ns
    | LastPrivate ns                   -> combo 79 ns
    | TempPrivate ns                   -> combo 80 ns
    | ParallelCyclic i_opt             -> catstr ((mkstr 81)::(opt_to_list_map string_of_int i_opt))

end

module Dec = struct

  module Directive = struct
    include Labels.Dec.Directive

    let to_short_string = function
      | Alias(i, e)          -> combo 0 [i;e]
      | Assume               -> mkstr 1
      | Assume_aligned       -> mkstr 2
      | Attributes           -> mkstr 3
      | Declare              -> mkstr 4
      | Nodeclare            -> mkstr 5
      | Define n             -> combo 6 [n]
      | Undefine n           -> combo 7 [n]
      | DistributePoint      -> mkstr 8
      | Fixedformlinesize i  -> combo 9 [i]
      | Fma                  -> mkstr 10
      | Nofma                -> mkstr 11
      | Freeform             -> mkstr 12
      | Nofreeform           -> mkstr 13
      | Ident s              -> combo 14 [s]
      | If                   -> mkstr 15
      | IfDefined n          -> combo 16 [n]
      | Inline b             -> catstr [mkstr 17; (if b then mkstr 1 else mkstr 0)]
      | Forceinline b        -> catstr [mkstr 18; (if b then mkstr 1 else mkstr 0)]
      | Noinline             -> mkstr 19
      | Integer i            -> combo 20 [i]
      | Ivdep o              -> combo 21 [o]
      | Init_dep_fwd         -> mkstr 22
      | LoopCount il         -> combo 23 (List.map string_of_int il)
      | Message s            -> combo 24 [s]
      | Nofusion             -> mkstr 25
      | Objcomment s         -> combo 26 [s]
      | Optimize i           -> combo 27 [i]
      | Nooptimize           -> mkstr 28
      | Options ol           -> combo 29 ol
      | Pack i               -> combo 30 [i]
      | Parallel             -> mkstr 31
      | Noparallel           -> mkstr 32
      | Prefetch             -> mkstr 33
      | Noprefetch           -> mkstr 34
      | Psect n              -> combo 35 [n]
      | Real i               -> combo 36 [i]
      | Simd                 -> mkstr 37
      | Strict               -> mkstr 38
      | Nostrict             -> mkstr 39
      | Unroll i_opt         -> combo 40 [int_opt_to_string ~prefix:"" i_opt]
      | Nounroll             -> mkstr 41
      | Unroll_and_jam i_opt -> combo 42 [int_opt_to_string ~prefix:"" i_opt]
      | Nounroll_and_jam     -> mkstr 43
      | Vector               -> mkstr 44
      | Novector             -> mkstr 45
      | Elseif               -> mkstr 46
      | Else                 -> mkstr 47
      | Endif                -> mkstr 48
      | EndOptions           -> mkstr 49
      | Block_loop           -> mkstr 50
      | Noblock_loop         -> mkstr 51
      | Code_align i         -> combo 52 [string_of_int i]
  end

  module Clause = struct
    include Labels.Dec.Clause

    let to_short_string = function
      | Always          -> mkstr 0
      | Assert          -> mkstr 1
      | Aligned         -> mkstr 2
      | Unaligned       -> mkstr 3
      | Temporal        -> mkstr 4
      | Nontemporal     -> mkstr 5
      | Vecremainder    -> mkstr 6
      | Novecremainder  -> mkstr 7
      | Noassert        -> mkstr 8
      | Firstprivate    -> mkstr 9
      | Lastprivate     -> mkstr 10
      | Linear          -> mkstr 11
      | Private         -> mkstr 12
      | Reduction       -> mkstr 13
      | Vectorlength il -> combo 14 (List.map string_of_int il)
      | Vectorlengthfor -> mkstr 15
      | Num_threads     -> mkstr 16
      | Mask            -> mkstr 17
      | Nomask          -> mkstr 18
      | Processor p     -> combo 19 [p]
      | Uniform         -> mkstr 20
      | Profitable      -> mkstr 21
      | Cost            -> mkstr 22
      | Factor          -> mkstr 23
      | Level ll        -> combo 24 (List.map Labels.Dec.level_to_string ll)
  end

  module Attribute = struct
    include Labels.Dec.Attribute

    let to_short_string = function
      | Alias s                  -> combo 0 [s]
      | Align i                  -> combo 1 [string_of_int i]
      | Allocatable              -> mkstr 2
      | Array_null               -> mkstr 3
      | C                        -> mkstr 4
      | Code_align i             -> combo 5 [string_of_int i]
      | Concurrency_safe         -> mkstr 6
      | Cvf                      -> mkstr 7
      | Decorate                 -> mkstr 8
      | Default                  -> mkstr 9
      | Dllexport                -> mkstr 10
      | Dllimport                -> mkstr 11
      | Extern                   -> mkstr 12
      | Fastmem                  -> mkstr 13
      | Forceinline              -> mkstr 14
      | Ignore_loc               -> mkstr 15
      | Inline                   -> mkstr 16
      | Mixed_str_len_arg        -> mkstr 17
      | No_arg_check             -> mkstr 18
      | Noclone                  -> mkstr 19
      | Noinline                 -> mkstr 20
      | Offload n                -> combo 21 [n]
      | Optimization_parameter s -> combo 22 [s]
      | Reference                -> mkstr 23
      | Stdcall                  -> mkstr 24
      | Value                    -> mkstr 25
      | Varying                  -> mkstr 26
      | Vector                   -> mkstr 27

  end

  type t = Labels.Dec.t

  let to_string = Labels.Dec.to_string

  let to_simple_string = Labels.Dec.to_simple_string

  let to_tag = Labels.Dec.to_tag

  let get_name _ = raise Not_found

  let get_name_opt _ = None

  let to_short_string = function
    | Labels.Dec.VarExpr         -> mkstr 0
    | Labels.Dec.Align s         -> combo 1 [s]
    | Labels.Dec.Wrt             -> mkstr 2
    | Labels.Dec.Nowrt           -> mkstr 3
    | Labels.Dec.PrefetchHint    -> mkstr 4
    | Labels.Dec.PrefetchHintAll -> mkstr 5
    | Labels.Dec.Max i           -> combo 6 [string_of_int i]
    | Labels.Dec.Min i           -> combo 7 [string_of_int i]
    | Labels.Dec.Avg i           -> combo 8 [string_of_int i]

end

module Xlf = struct

  module Directive = struct
    include Labels.Xlf.Directive

    let high_or_low_to_short_string = function
      | VeryHigh -> mkstr 0
      | VeryLow  -> mkstr 1

    let source_to_short_string = function
      | Fixed i_opt -> catstr [mkstr 0; int_opt_to_string i_opt]
      | Free        -> mkstr 1
      | FreeF90     -> mkstr 2
      | FreeIBM     -> mkstr 3

    let to_short_string = function
      | Align i               -> combo 0 [i]
      | Assert                -> mkstr 1
      | BlockLoop             -> mkstr 2
      | Cncall                -> mkstr 3
      | Collapse              -> mkstr 4
      | Eject                 -> mkstr 5
      | ExecutionFrequency hl -> catstr [mkstr 6; high_or_low_to_short_string hl]
      | ExpectedValue n       -> combo 7 [n]
      | FunctraceXlfCatch     -> mkstr 8
      | FunctraceXlfEnter     -> mkstr 9
      | FunctraceXlfExit      -> mkstr 10
      | IgnoreTkr             -> mkstr 11
      | Independent           -> mkstr 12
      | Loopid n              -> combo 13 [n]
      | MemDelay c            -> combo 14 [c]
      | New                   -> mkstr 15
      | Nofunctrace           -> mkstr 16
      | Nosimd                -> mkstr 17
      | Novector              -> mkstr 18
      | Permutation           -> mkstr 19
      | Snapshot              -> mkstr 20
      | Sourceform s          -> catstr [mkstr 21; source_to_short_string s]
      | StreamUnroll          -> mkstr 22
      | Subscriptorder        -> mkstr 23
      | Unroll                -> mkstr 24
      | UnrollAndFuse         -> mkstr 25
      | Process               -> mkstr 26

  end

  module Assertion = struct
    include Labels.Xlf.Assertion

    let to_short_string = function
      | Itercnt    -> mkstr 0
      | Minitercnt -> mkstr 1
      | Maxitercnt -> mkstr 2
      | Nodeps     -> mkstr 3

  end

  type t = Labels.Xlf.t

  let to_string = Labels.Xlf.to_string

  let to_simple_string = Labels.Xlf.to_simple_string

  let to_tag = Labels.Xlf.to_tag

  let get_name = Labels.Xlf.get_name

  let get_name_opt = Labels.Xlf.get_name_opt

  let to_short_string = function
    | Labels.Xlf.ERROR                      -> mkstr 0
    | Labels.Xlf.CollapseArray n            -> combo 1 [n]
    | Labels.Xlf.SubscriptorderArray(n, il) -> combo 2 (n :: il)
    | Labels.Xlf.NewClause                  -> mkstr 3
    | Labels.Xlf.ReductionClause            -> mkstr 4
    | Labels.Xlf.Option n                   -> combo 5 [n]

end

module OmpClause = struct
  include Labels.OmpClause

  let data_sharing_attr_to_short_string = function
    | Private      -> mkstr 0
    | Firstprivate -> mkstr 1
    | Shared       -> mkstr 2
    | None_        -> mkstr 3

  let kind_to_short_string = function
    | Static  -> mkstr 0
    | Dynamic -> mkstr 1
    | Guided  -> mkstr 2
    | Auto    -> mkstr 3
    | Runtime -> mkstr 4

  let policy_to_short_string = function
    | Master -> mkstr 0
    | Close  -> mkstr 1
    | Spread -> mkstr 2

  let map_type_to_short_string = function
    | Alloc  -> mkstr 0
    | To     -> mkstr 1
    | From   -> mkstr 2
    | Tofrom -> mkstr 3

  let dependence_type_to_short_string = function
    | In    -> mkstr 0
    | Out   -> mkstr 1
    | Inout -> mkstr 2

  let to_short_string = function
    | If                -> mkstr 0
    | Num_threads       -> mkstr 1
    | Default _         -> mkstr 2
    | Lastprivate       -> mkstr 3
    | Copyin            -> mkstr 4
    | Reduction         -> mkstr 5
    | Collapse          -> mkstr 6
    | Ordered           -> mkstr 7
    | Copyprivate       -> mkstr 8
    | Nowait            -> mkstr 9
    | Final             -> mkstr 10
    | Untied            -> mkstr 11
    | Mergeable         -> mkstr 12
    | DataSharingAttr a -> catstr [mkstr 13; data_sharing_attr_to_simple_string a]
    | Schedule k        -> catstr [mkstr 14; kind_to_simple_string k]

    | Proc_bind p       -> catstr [mkstr 15; policy_to_short_string p]
    | Linear b          -> catstr [mkstr 16; if b then mkstr 1 else mkstr 0]
    | Map t_opt         -> catstr ((mkstr 17)::(opt_to_list_map map_type_to_simple_string t_opt))
    | Safelen           -> mkstr 18
    | Simdlen           -> mkstr 19
    | Aligned b         -> catstr [mkstr 20; if b then mkstr 1 else mkstr 0]
    | Uniform           -> mkstr 21
    | Inbranch          -> mkstr 22
    | Notinbranch       -> mkstr 23
    | Depend t          -> catstr [mkstr 24; dependence_type_to_short_string t]
    | Device            -> mkstr 25
    | Dist_schedule k   -> catstr [mkstr 26; kind_to_simple_string k]
    | Initializer       -> mkstr 27
    | Num_teams         -> mkstr 28
    | Thread_limit      -> mkstr 29

    | ERROR -> mkstr 30
end

module OmpDirective = struct
  include Labels.OmpDirective

  let atomic_sub_to_short_string = function
    | Read    -> mkstr 0
    | Write   -> mkstr 1
    | Capture -> mkstr 2
    | Update  -> mkstr 3

  let construct_type_to_short_string = function
    | C_parallel  -> mkstr 0
    | C_sections  -> mkstr 1
    | C_do        -> mkstr 2
    | C_taskgroup -> mkstr 3

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | ERROR                -> mkstr 0
    | Barrier              -> mkstr 1
    | Do false             -> mkstr 2
    | Flush                -> mkstr 3
    | Master               -> mkstr 4
    | Ordered              -> mkstr 5
    | Parallel             -> mkstr 6
    | ParallelDo false     -> mkstr 7
    | ParallelSections     -> mkstr 8
    | ParallelWorkshare    -> mkstr 9
    | Section              -> mkstr 10
    | Sections             -> mkstr 11
    | Single               -> mkstr 12
    | Task                 -> mkstr 13
    | Taskwait             -> mkstr 14
    | Taskyield            -> mkstr 15
    | Threadprivate        -> mkstr 16
    | Workshare            -> mkstr 17
    | EndAtomic            -> mkstr 18
    | EndDo false          -> mkstr 19
    | EndMaster            -> mkstr 20
    | EndOrdered           -> mkstr 21
    | EndParallel          -> mkstr 22
    | EndSections          -> mkstr 23
    | EndSingle            -> mkstr 24
    | EndTask              -> mkstr 25
    | EndWorkshare         -> mkstr 26
    | EndParallelDo false  -> mkstr 27
    | EndParallelSections  -> mkstr 28
    | EndParallelWorkshare -> mkstr 29
    | Atomic(a_opt, false) -> catstr ((mkstr 30)::(opt_to_list_map atomic_sub_to_simple_string a_opt))
    | Critical n_opt       -> combo 31 (opt_to_list n_opt)
    | EndCritical n_opt    -> combo 32 (opt_to_list n_opt)

    | Do true              -> mkstr 33
    | EndDo true           -> mkstr 34
    | ParallelDo true      -> mkstr 35
    | EndParallelDo true   -> mkstr 36
    | Atomic(a_opt, true)  -> catstr ((mkstr 37)::(opt_to_list_map atomic_sub_to_simple_string a_opt))
    | Simd                 -> mkstr 38
    | EndSimd              -> mkstr 39
    | DeclareSimd n        -> combo 40 [n]
    | Target               -> mkstr 41
    | EndTarget            -> mkstr 42
    | TargetData           -> mkstr 43
    | EndTargetData        -> mkstr 44
    | TargetUpdate         -> mkstr 45
    | DeclareTarget        -> mkstr 46
    | Teams                -> mkstr 47
    | EndTeams             -> mkstr 48
    | Taskgroup            -> mkstr 49
    | EndTaskgroup         -> mkstr 50
    | Cancel c             -> catstr [mkstr 51; construct_type_to_short_string c]
    | CancellationPoint c  -> catstr [mkstr 52; construct_type_to_short_string c]
    | DeclareReduction     -> mkstr 53
    | TargetTeams          -> mkstr 54
    | EndTargetTeams       -> mkstr 55
    | Distribute true                         -> mkstr 56
    | EndDistribute true                      -> mkstr 57
    | DistributeParallelDo true               -> mkstr 58
    | EndDistributeParallelDo true            -> mkstr 59
    | TeamsDistribute true                    -> mkstr 60
    | EndTeamsDistribute true                 -> mkstr 61
    | TargetTeamsDistribute true              -> mkstr 62
    | EndTargetTeamsDistribute true           -> mkstr 63
    | TeamsDistributeParallelDo true          -> mkstr 64
    | EndTeamsDistributeParallelDo true       -> mkstr 65
    | TargetTeamsDistributeParallelDo true    -> mkstr 66
    | EndTargetTeamsDistributeParallelDo true -> mkstr 67
    | Distribute false                         -> mkstr 68
    | EndDistribute false                      -> mkstr 69
    | DistributeParallelDo false               -> mkstr 70
    | EndDistributeParallelDo false            -> mkstr 71
    | TeamsDistribute false                    -> mkstr 72
    | EndTeamsDistribute false                 -> mkstr 73
    | TargetTeamsDistribute false              -> mkstr 74
    | EndTargetTeamsDistribute false           -> mkstr 75
    | TeamsDistributeParallelDo false          -> mkstr 76
    | EndTeamsDistributeParallelDo false       -> mkstr 77
    | TargetTeamsDistributeParallelDo false    -> mkstr 78
    | EndTargetTeamsDistributeParallelDo false -> mkstr 79

end

module OmpConstruct = struct
  include Labels.OmpConstruct

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
      | Atomic(a_opt, false) -> catstr ((mkstr 0)::(opt_to_list_map OmpDirective.atomic_sub_to_simple_string a_opt))
      | Critical n_opt    -> combo 1 (opt_to_list n_opt)
      | Do false          -> mkstr 2
      | Master            -> mkstr 3
      | Ordered           -> mkstr 4
      | Parallel          -> mkstr 5
      | Sections          -> mkstr 6
      | Single            -> mkstr 7
      | Task              -> mkstr 8
      | Workshare         -> mkstr 9
      | ParallelDo false  -> mkstr 10
      | ParallelSections  -> mkstr 11
      | ParallelWorkshare -> mkstr 12

      | Atomic(a_opt, true) -> catstr ((mkstr 13)::(opt_to_list_map OmpDirective.atomic_sub_to_simple_string a_opt))
      | Do true           -> mkstr 14
      | ParallelDo true   -> mkstr 15
      | Simd              -> mkstr 16
      | Target            -> mkstr 17
      | TargetData        -> mkstr 18
      | Teams             -> mkstr 19
      | TargetTeams       -> mkstr 20
      | Taskgroup         -> mkstr 21
      | Distribute true                      -> mkstr 23
      | DistributeParallelDo true            -> mkstr 24
      | TeamsDistribute true                 -> mkstr 25
      | TargetTeamsDistribute true           -> mkstr 26
      | TeamsDistributeParallelDo true       -> mkstr 27
      | TargetTeamsDistributeParallelDo true -> mkstr 28
      | Distribute false                      -> mkstr 30
      | DistributeParallelDo false            -> mkstr 31
      | TeamsDistribute false                 -> mkstr 32
      | TargetTeamsDistribute false           -> mkstr 33
      | TeamsDistributeParallelDo false       -> mkstr 34
      | TargetTeamsDistributeParallelDo false -> mkstr 35

end

module AccClause = struct
  include Labels.AccClause

  let to_short_string = function
    | Async              -> mkstr 0
    | Auto               -> mkstr 1
    | Bind               -> mkstr 2
    | Collapse           -> mkstr 3
    | Copy               -> mkstr 4
    | Copyin             -> mkstr 5
    | Copyout            -> mkstr 6
    | Create             -> mkstr 7
    | DefaultNone        -> mkstr 8
    | DefaultPresent     -> mkstr 9
    | Delete             -> mkstr 10
    | Device             -> mkstr 11
    | Deviceptr          -> mkstr 12
    | Device_resident    -> mkstr 13
    | Device_type        -> mkstr 14
    | Device_typeAny     -> mkstr 15
    | Dtype              -> mkstr 16
    | DtypeAny           -> mkstr 17
    | Firstprivate       -> mkstr 18
    | Gang               -> mkstr 19
    | Host               -> mkstr 20
    | If                 -> mkstr 21
    | Independent        -> mkstr 22
    | Link               -> mkstr 23
    | Nohost             -> mkstr 24
    | Num_gangs          -> mkstr 25
    | Num_workers        -> mkstr 26
    | Pcopy              -> mkstr 27
    | Pcopyin            -> mkstr 28
    | Pcopyout           -> mkstr 29
    | Pcreate            -> mkstr 30
    | Present            -> mkstr 31
    | Present_or_copy    -> mkstr 32
    | Present_or_copyin  -> mkstr 33
    | Present_or_copyout -> mkstr 34
    | Present_or_create  -> mkstr 35
    | Private            -> mkstr 36
    | Reduction          -> mkstr 37
    | Self               -> mkstr 38
    | Seq                -> mkstr 39
    | Tile               -> mkstr 40
    | Use_device         -> mkstr 41
    | Vector             -> mkstr 42
    | Vector_length      -> mkstr 43
    | Wait               -> mkstr 44
    | Worker             -> mkstr 45

end

module AccDirective = struct
  include Labels.AccDirective

  let atomic_sub_to_short_string = function
    | Read    -> mkstr 0
    | Write   -> mkstr 1
    | Capture -> mkstr 2
    | Update  -> mkstr 3

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
      | ERROR           -> mkstr 0
      | Atomic a_opt    -> catstr ((mkstr 1)::(opt_to_list_map atomic_sub_to_simple_string a_opt))
      | Parallel        -> mkstr 2
      | Kernels         -> mkstr 3
      | Data            -> mkstr 4
      | EnterData       -> mkstr 5
      | ExitData        -> mkstr 6
      | Host_data       -> mkstr 7
      | Loop            -> mkstr 8
      | Cache           -> mkstr 9
      | Update          -> mkstr 10
      | Wait            -> mkstr 11
      | Routine n_opt   -> combo 12 (opt_to_list n_opt)
      | Declare         -> mkstr 13
      | EndAtomic       -> mkstr 14
      | EndParallel     -> mkstr 15
      | EndKernels      -> mkstr 16
      | EndData         -> mkstr 17
      | EndHost_data    -> mkstr 18
      | ParallelLoop    -> mkstr 19
      | KernelsLoop     -> mkstr 20
      | EndParallelLoop -> mkstr 21
      | EndKernelsLoop  -> mkstr 22

end

module AccConstruct = struct
  include Labels.AccConstruct

  let to_short_string ?(ignore_identifiers_flag=false) =
    let _ = ignore_identifiers_flag in
    (*let combo = combo ~ignore_identifiers_flag in*) function
      | Atomic a_opt -> catstr ((mkstr 0)::(opt_to_list_map AccDirective.atomic_sub_to_simple_string a_opt))
      | Parallel     -> mkstr 1
      | Kernels      -> mkstr 2
      | Data         -> mkstr 3
      | Host_data    -> mkstr 4
      | ParallelLoop -> mkstr 5
      | KernelsLoop  -> mkstr 6
      | Loop         -> mkstr 7

end

module LindaCall = struct
  include Labels.LindaCall

  let to_short_string = function
    | In   -> mkstr 0
    | Inp  -> mkstr 1
    | Rd   -> mkstr 2
    | Rdp  -> mkstr 3
    | Out  -> mkstr 4
    | Eval -> mkstr 5

end

module TypeSpec = struct
  include Labels.TypeSpec

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Character         -> mkstr 0
    | Complex           -> mkstr 1
    | DoublePrecision   -> mkstr 2
    | Integer           -> mkstr 3
    | Logical           -> mkstr 4
    | Real              -> mkstr 5
    | Byte              -> mkstr 6
    | DoubleComplex     -> mkstr 7
    | Type n            -> combo 8 [n]
    | Derived n         -> combo 9 [n]

    | PpMacroTypeSpec n -> combo 10 [n]

    | Class n           -> combo 11 [n]

end

module GenericSpec = struct
  include Labels.GenericSpec

  let record_kind_to_short_string = function
    | RK_formatted   -> mkstr 1
    | RK_unformatted -> mkstr 2
    | RK_weird n     -> combo 3 [n]

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Assignment           -> mkstr 0
    | Name n               -> combo 1 [n]
    | DefinedOperator op   -> catstr [mkstr 2; DefinedOperator.to_short_string op]
    | IntrinsicOperator op -> catstr [mkstr 3; IntrinsicOperator.to_short_string op]
    | Read k               -> catstr [mkstr 4; record_kind_to_short_string k]
    | Write k              -> catstr [mkstr 5; record_kind_to_short_string k]

end

module IoControlSpec = struct
  include Labels.IoControlSpec

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Unit             -> mkstr 0
    | Fmt              -> mkstr 1
    | Rec              -> mkstr 2
    | Iostat           -> mkstr 3
    | Size             -> mkstr 4
    | Advance          -> mkstr 5
    | Nml n            -> combo 6 [n]
    | Err lab          -> combo 7 [lab]
    | End lab          -> combo 8 [lab]
    | Eor lab          -> combo 9 [lab]
    | Iomsg            -> mkstr 10
    | Pos              -> mkstr 11
    | PreconnectedUnit -> mkstr 12

    | Asynchronous     -> mkstr 13
    | Blank            -> mkstr 14
    | Decimal          -> mkstr 15
    | Delim            -> mkstr 16
    | Id               -> mkstr 17
    | Pad              -> mkstr 18
    | Round            -> mkstr 19
    | Sign             -> mkstr 20

    | Num              -> mkstr 21

end

module InquireSpec = struct
  include Labels.InquireSpec

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Unit            -> mkstr 0
    | File            -> mkstr 1
    | Iostat          -> mkstr 2
    | Exist           -> mkstr 3
    | Opened          -> mkstr 4
    | Number          -> mkstr 5
    | Named           -> mkstr 6
    | Name            -> mkstr 7
    | Access          -> mkstr 8
    | Sequential      -> mkstr 9
    | Direct          -> mkstr 10
    | Form            -> mkstr 11
    | Formatted       -> mkstr 12
    | Unformatted     -> mkstr 13
    | Recl            -> mkstr 14
    | Nextrec         -> mkstr 15
    | Blank           -> mkstr 16
    | Position        -> mkstr 17
    | Action          -> mkstr 18
    | Read            -> mkstr 19
    | Write           -> mkstr 20
    | Readwrite       -> mkstr 21
    | Delim           -> mkstr 22
    | Pad             -> mkstr 23
    | Err lab         -> combo 24 [lab]
    | Iomsg           -> mkstr 25
    | Pos             -> mkstr 26

    | Binary          -> mkstr 27
    | Blocksize       -> mkstr 28
    | Buffered        -> mkstr 29
    | Convert         -> mkstr 30
    | Carriagecontrol -> mkstr 31
    | Defaultfile     -> mkstr 32
    | Iofocus         -> mkstr 33
    | Mode            -> mkstr 34
    | Organization    -> mkstr 35
    | Recordsize      -> mkstr 36
    | Recordtype      -> mkstr 37
    | Share           -> mkstr 38

    | Asynchronous -> mkstr 39
    | Decimal      -> mkstr 40
    | Encoding     -> mkstr 41
    | Id           -> mkstr 42
    | Pending      -> mkstr 43
    | Round        -> mkstr 44
    | Sign         -> mkstr 45
    | Size         -> mkstr 46
    | Stream       -> mkstr 47

    | Asynch       -> mkstr 48
    | Strid        -> mkstr 49

end

module ConnectSpec = struct
  include Labels.ConnectSpec

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Unit            -> mkstr 0
    | Iostat          -> mkstr 1
    | File            -> mkstr 2
    | Status          -> mkstr 3
    | Access          -> mkstr 4
    | Form            -> mkstr 5
    | Recl            -> mkstr 6
    | Blank           -> mkstr 7
    | Position        -> mkstr 8
    | Action          -> mkstr 9
    | Delim           -> mkstr 10
    | Pad             -> mkstr 11
    | Err lab         -> combo 12 [lab]
    | Iomsg           -> mkstr 13

    | Associatevariable -> mkstr 14
    | Blocksize         -> mkstr 15
    | Buffercount       -> mkstr 16
    | Buffered          -> mkstr 17
    | Carriagecontrol   -> mkstr 18
    | Convert           -> mkstr 19
    | Defaultfile       -> mkstr 20
    | Dispose           -> mkstr 21
    | Iofocus           -> mkstr 22
    | Maxrec            -> mkstr 23
    | Mode              -> mkstr 24
    | Name              -> mkstr 25
    | Organization      -> mkstr 26
    | Readonly          -> mkstr 27
    | Recordsize        -> mkstr 28
    | Recordtype        -> mkstr 29
    | Share             -> mkstr 30
    | Shared            -> mkstr 31
    | Title             -> mkstr 32
    | Useropen          -> mkstr 33
    | Type              -> mkstr 34

    | Asynchronous -> mkstr 35
    | Decimal      -> mkstr 36
    | Encoding     -> mkstr 37
    | Newunit      -> mkstr 38
    | Round        -> mkstr 39
    | Sign         -> mkstr 40

    | Asynch       -> mkstr 41

end

module CloseSpec = struct
  include Labels.CloseSpec

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Unit    -> mkstr 0
    | Iostat  -> mkstr 1
    | Status  -> mkstr 2
    | Err lab -> combo 3 [lab]
    | Iomsg   -> mkstr 4

    | Dispose -> mkstr 5
    | Type    -> mkstr 6

end

module PositionSpec = struct
  include Labels.PositionSpec

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Unit        -> mkstr 0
    | Iostat      -> mkstr 1
    | Err lab     -> combo 2 [lab]
    | Iomsg       -> mkstr 3

end

module Format = struct
  include Labels.Format

  let to_short_string ?(ignore_identifiers_flag=false) =
    let combo = combo ~ignore_identifiers_flag in function
    | Expr         -> mkstr 0
    | ListDirected -> mkstr 1
    | Label lab    -> combo 2 [lab]

end

module PrefixSpec = struct
  include Labels.PrefixSpec

  let to_short_string = function
    | Recursive  -> mkstr 0
    | Pure       -> mkstr 1
    | Elemental  -> mkstr 2
    | TypeSpec t -> catstr [mkstr 3; TypeSpec.to_short_string t]
    | Impure     -> mkstr 4
    | Module     -> mkstr 5
    | Attributes a -> combo 6 [a]
end

module CaseSelector = struct
  include Labels.CaseSelector

  let to_short_string = function
    | CaseValueRangeList -> mkstr 0
    | Default            -> mkstr 1

end

module CaseValueRange = struct
  include Labels.CaseValueRange

  let to_short_string = function
    | Value      -> mkstr 0
    | Lower      -> mkstr 1
    | Upper      -> mkstr 2
    | LowerUpper -> mkstr 3

end

module ControlEditDesc = struct
  include Labels.ControlEditDesc

  let to_short_string = function
    | Terminate             -> mkstr 0
    | PositionEditDesc s    -> mkstr_str 1 s
    | SignEditDesc s        -> mkstr_str 3 s
    | BlankInterpEditDesc s -> mkstr_str 5 s
    | ScaleFactor i         -> catstr [mkstr 7; string_of_int i]
    | EndOfRecord i_opt     -> catstr ((mkstr 8)::(opt_to_list_map string_of_int i_opt))
    | Unknown s             -> mkstr_str 9 s

end

module FormatItem = struct
  include Labels.FormatItem

  let special_edit_desc_to_short_string = function
    | Dollar    -> mkstr 0
    | Backslash -> mkstr 1
    | Plus      -> mkstr 2
    | Zero      -> mkstr 3
    | One       -> mkstr 4
    | Blank     -> mkstr 5

  let to_short_string = function
    | DataEditDesc(i_opt, s)       -> catstr ((mkstr_str 0 s)::(opt_to_list_map string_of_int i_opt))
    | ControlEditDesc c            -> catstr [mkstr 2; ControlEditDesc.to_short_string c]
    | CharStringEditDesc s         -> mkstr_str 3 s
    | FormatItemList i_opt         -> catstr ((mkstr 5)::(opt_to_list_map string_of_int i_opt))
    | SpecialEditDesc sd           -> catstr [mkstr 6; special_edit_desc_to_short_string sd]
    | VariableFormatDesc(i_opt, s) -> catstr ((mkstr_str 7 s)::(opt_to_list_map string_of_int i_opt))
    | Macro(i_opt, id)             -> catstr ((mkstr_str 9 id)::(opt_to_list_map string_of_int i_opt))

end

module WaitSpec = struct
  include Labels.WaitSpec

  let to_short_string = function
    | End lab     -> combo 0 [lab]
    | Eor lab     -> combo 1 [lab]
    | Err lab     -> combo 2 [lab]
    | Id          -> mkstr 3
    | Iomsg       -> mkstr 4
    | Iostat      -> mkstr 5
    | Unit        -> mkstr 6

end

module FlushSpec = struct
  include Labels.FlushSpec

  let to_short_string = function
    | Err lab     -> combo 0 [lab]
    | Iomsg       -> mkstr 1
    | Iostat      -> mkstr 2
    | Unit        -> mkstr 3

end

module BindingAttr = struct
  include Labels.BindingAttr

  let to_short_string = function
    | Pass n         -> combo 0 [n]
    | Nopass         -> mkstr 1
    | NonOverridable -> mkstr 2
    | Deferred       -> mkstr 3
    | Private        -> mkstr 4
    | Public         -> mkstr 5

end

module ProcComponentAttrSpec = struct
  include Labels.ProcComponentAttrSpec

  let to_short_string = function
    | Pass n  -> combo 0 [n]
    | Pointer -> mkstr 1
    | Nopass  -> mkstr 2
    | Private -> mkstr 3
    | Public  -> mkstr 4

end

module ProcAttrSpec = struct
  include Labels.ProcAttrSpec

  let to_short_string = function
    | Public      -> mkstr 0
    | Private     -> mkstr 1
    | Bind        -> mkstr 2
    | Intent i    -> combo 3 [IntentSpec.to_short_string i]
    | Optional    -> mkstr 4
    | Pointer     -> mkstr 5
    | Protected   -> mkstr 6
    | Save        -> mkstr 7
    | Weird n     -> combo 8 [n]

end





include Label


let to_short_string ?(ignore_identifiers_flag=false) =
  let combo2 = combo2 ~ignore_identifiers_flag in function
  | DUMMY                             -> mkstr2 0
  | EMPTY                             -> mkstr2 1
  | ERROR _                           -> mkstr2 2
  | OCL                               -> mkstr2 3
  | Program                           -> mkstr2 4
  | Block                             -> mkstr2 5
  | InterfaceBlock n_opt              -> combo2 6 (opt_to_list n_opt)
  | InterfaceBody                     -> mkstr2 7
  | CaseConstruct                     -> mkstr2 8
  | DoConstruct v_opt                 -> combo2 9 (opt_to_list v_opt)
  | ForallConstruct                   -> mkstr2 10
  | IfConstruct                       -> mkstr2 11
  | WhereConstruct                    -> mkstr2 12
  | DerivedTypeDef n                  -> combo2 13 [n]
  | ArrayElement n                    -> combo2 14 [n]
  | ArraySection n                    -> combo2 15 [n]
  | StructureComponent n              -> combo2 16 [n]
  | Substring                         -> mkstr2 17
  | SectionSubscriptList n            -> combo2 18 [n]
  | SubscriptTriplet                  -> mkstr2 19
  | FirstSubscript                    -> mkstr2 20
  | SecondSubscript                   -> mkstr2 21
  | Stride                            -> mkstr2 22
  | SubstringRange                    -> mkstr2 23
  | StartingPoint                     -> mkstr2 24
  | EndingPoint                       -> mkstr2 25
  | PartRef                           -> mkstr2 26
  | ParenExpr                         -> mkstr2 27
  | ArrayConstructor                  -> mkstr2 28
  | LoopControl v                     -> combo2 29 [v]
  | LoopControlWhile                  -> mkstr2 30
  | Rename                            -> mkstr2 31
  | OnlyList                          -> mkstr2 32
  | KindSelector                      -> mkstr2 33
  | CharSelector                      -> mkstr2 34
  | LengthSelector                    -> mkstr2 35
  | LengthSelectorOverride            -> mkstr2 36
(*  | CharLenParamValueAsterisk         -> mkstr2 37 *)
  | TypeParamValueAsterisk            -> mkstr2 37
  | TypeParamValueColon               -> mkstr2 38

  | ExplicitShapeSpec                 -> mkstr2 39
  | AssumedShapeSpec                  -> mkstr2 40
  | DeferredShapeSpec                 -> mkstr2 41
(*| AssumedSizeSpec                   -> mkstr2 41 *)
(*
  | ComponentAttrSpecPointer          -> mkstr2 42
  | ComponentAttrSpecDimension        -> mkstr2 43
*)
  | ComponentAttrSpecs                -> mkstr2 44

  | AttrSpecs                         -> mkstr2 47
  | InputItemList                     -> mkstr2 48
  | OutputItemList                    -> mkstr2 49
  | IoLength                          -> mkstr2 50
  | IoImpliedDo                       -> mkstr2 51
  | EquivalenceSet                    -> mkstr2 52
  | DataStmtSet                       -> mkstr2 53
  | DataStmtValue                     -> mkstr2 54
(*  | NullInit                          -> mkstr2 55*)
  | DataImpliedDo                     -> mkstr2 56
  | DataIDoObject                     -> mkstr2 57
  | DataIDoObjectList                 -> mkstr2 58
  | DataStmtObjectList                -> mkstr2 59
  | DataStmtValueList                 -> mkstr2 60
  | Prefix                            -> mkstr2 61
  | DummyArgNameList n                -> combo2 62 [n]
  | DummyArgList n                    -> combo2 63 [n]
  | ActualArgSpecList n               -> combo2 64 [n]
  | AlternateReturnIndicator          -> mkstr2 65
  | ForallHeader                      -> mkstr2 66
  | ImplicitSpec                      -> mkstr2 67
  | FormatSpecification               -> mkstr2 68
  | AcImpliedDo                       -> mkstr2 69


  | PartName n                        -> combo2 71 [n]
  | Name n                            -> combo2 72 [n]
  | VariableName n                    -> combo2 73 [n]
  | FunctionReference n               -> combo2 74 [n]
  | StructureConstructor n            -> combo2 75 [n]
  | ComponentDecl n                   -> combo2 76 [n]
  | EntityDecl n                      -> combo2 77 [n]
  | CommonBlockObject n               -> combo2 78 [n]
  | NamedConstantDef n                -> combo2 79 [n]
  | IoImpliedDoControl n              -> combo2 80 [n]
  | Array n                           -> combo2 81 [n]
  | NamelistGroup n                   -> combo2 82 [n]
  | ObjectName n                      -> combo2 83 [n]
  | Result n                          -> combo2 84 [n]
  | ForallTripletSpec n               -> combo2 85 [n]
  | AcImpliedDoControl n              -> combo2 86 [n]

  | AltReturnSpec lab                 -> combo2 87 [lab]
  | Label lab                         -> combo2 89 [lab]

  | ActualArgSpec n_opt               -> combo2 90 (opt_to_list n_opt)
  | CommonSpec n_opt                  -> combo2 91 (opt_to_list n_opt)

  | ArraySpec i                       -> combo2 92 [string_of_int i]
  | ExplicitShapeArray i          -> combo2 93 [string_of_int i]
  | AssumedShapeArray i           -> combo2 94 [string_of_int i]
  | DeferredShapeArray i          -> combo2 95 [string_of_int i]
  | AssumedSizeArray i            -> combo2 96 [string_of_int i]
  | ComponentArraySpec i              -> combo2 97 [string_of_int i]
  | ExplicitShapeComponentArray i -> combo2 98 [string_of_int i]
  | DeferredShapeComponentArray i -> combo2 99 [string_of_int i]

  | Stmt s                            -> catstr [mkstr2 100; Stmt.to_short_string s]
  | PpDirective d                     -> catstr [mkstr2 101; PpDirective.to_short_string d]
  | OclDirective d                    -> catstr [mkstr2 102; OclDirective.to_short_string d]
  | ProgramUnit pu                    -> catstr [mkstr2 103; ProgramUnit.to_short_string pu]
  | TypeSpec t                        -> catstr [mkstr2 104; TypeSpec.to_short_string t]
  | Ambiguous a                       -> catstr [mkstr2 105; Ambiguous.to_short_string a]
  | Constant c                        -> catstr [mkstr2 106; Constant.to_short_string c]
  | GenericSpec g                     -> catstr [mkstr2 107; GenericSpec.to_short_string g]
  | IntrinsicOperator op              -> catstr [mkstr2 108; IntrinsicOperator.to_short_string op]
  | DefinedOperator op                -> catstr [mkstr2 109; DefinedOperator.to_short_string op]
  | AttrSpec a                        -> catstr [mkstr2 110; AttrSpec.to_short_string a]
  | StopCode c                        -> catstr [mkstr2 111; Constant.to_short_string c]
  | Format f                          -> catstr [mkstr2 112; Format.to_short_string f]
  | PrefixSpec p                      -> catstr [mkstr2 114; PrefixSpec.to_short_string p]
  | CaseSelector sel                  -> catstr [mkstr2 115; CaseSelector.to_short_string sel]
  | CaseValueRange r                  -> catstr [mkstr2 116; CaseValueRange.to_short_string r]
  | FormatItem i                      -> catstr [mkstr2 117; FormatItem.to_short_string i]
  | AccessSpec spec                   -> catstr [mkstr2 118; AccessSpec.to_short_string spec]
  | InquireSpec spec                  -> catstr [mkstr2 119; InquireSpec.to_short_string spec]
  | CloseSpec spec                    -> catstr [mkstr2 120; CloseSpec.to_short_string spec]
  | ConnectSpec spec                  -> catstr [mkstr2 121; ConnectSpec.to_short_string spec]
  | PositionSpec spec                 -> catstr [mkstr2 122; PositionSpec.to_short_string spec]
  | IoControlSpec spec                -> catstr [mkstr2 123; IoControlSpec.to_short_string spec]
  | IntentSpec spec                   -> catstr [mkstr2 124; IntentSpec.to_short_string spec]

  | Include s                         -> mkstr2_str 127 s

  | LetterSpec(l, l_opt)              -> catstr ((mkstr2 129)::l::(opt_to_list l_opt))

  | OmpClause c              -> catstr [mkstr2 130; OmpClause.to_short_string c]
  | OmpDirective d           -> catstr [mkstr2 131; OmpDirective.to_short_string d]
  | OMP                      -> mkstr2 132
  | CommonBlockName n        -> combo2 133 [n]
  | IntrinsicProcedureName n -> combo2 134 [n]

  | LindaCall lc             -> catstr [mkstr2 135; LindaCall.to_short_string lc]
  | LindaFormal              -> mkstr2 136
  | LindaActual              -> mkstr2 137
  | LindaLength              -> mkstr2 138
  | LindaTypeof              -> mkstr2 139

  | SpecificationPart        -> mkstr2 140
  | ExecutionPart            -> mkstr2 141
  | SubprogramPart           -> mkstr2 142
  | ImplicitPart             -> mkstr2 143

  | Variable                 -> mkstr2 144

  | InternalSubprogram is    -> catstr [mkstr2 145; InternalSubprogram.to_short_string is]
  | ModuleSubprogram is      -> catstr [mkstr2 146; ModuleSubprogram.to_short_string is]

  | XlfDirective d           -> catstr [mkstr2 147; Xlf.Directive.to_short_string d]
  | XlfAssertion a           -> catstr [mkstr2 148; Xlf.Assertion.to_short_string a]
  | XlfMisc x                -> catstr [mkstr2 149; Xlf.to_short_string x]
  | XLF                      -> mkstr2 150

  | StructureDecl n_opt      -> combo2 152 (opt_to_list n_opt)
  | UnionDecl                -> mkstr2 153
  | MapDecl                  -> mkstr2 154
  | RecordDecl n             -> combo2 155 [n]
  | RecordFieldRef n         -> combo2 156 [n]

  | EntityName n             -> combo2 157 [n]
  | DummyArgName n           -> combo2 158 [n]

  | LanguageBindingSpec      -> mkstr2 159
  | Suffix                   -> mkstr2 160

  | Fragment                 -> mkstr2 161

  | TypeAttrSpec spec        -> catstr [mkstr2 162; TypeAttrSpec.to_short_string spec]

  | InitializationExpr                -> mkstr2 163
  | InitializationNull                -> mkstr2 164
  | InitializationTarget              -> mkstr2 165
  | InitializationOldStyle            -> mkstr2 166

  | StatVariable                      -> mkstr2 167
  | ErrmsgVariable                    -> mkstr2 168
  | SourceExpr                        -> mkstr2 169
  | MoldExpr                          -> mkstr2 170

  | ModuleNatureIntrinsic    -> mkstr2 171
  | ModuleNatureNonIntrinsic -> mkstr2 172

  | PpMacroId n              -> combo2 173 [n]
  | PpMacroExpr n            -> combo2 174 [n]
  | PpMacroVariable n        -> combo2 175 [n]

  | PpBranch                 -> mkstr2 176
  | PpBranchDo               -> mkstr2 177
  | PpBranchForall           -> mkstr2 178
  | PpBranchIf               -> mkstr2 179
  | PpBranchSelect           -> mkstr2 180
  | PpBranchWhere            -> mkstr2 181

  | PpBranchEndDo            -> mkstr2 182
  | PpBranchEndForall        -> mkstr2 183
  | PpBranchEndIf            -> mkstr2 184
  | PpBranchEndSelect        -> mkstr2 185
  | PpBranchEndWhere         -> mkstr2 186

  | PpSectionIf s            -> combo2 187 [s]
  | PpSectionIfdef s         -> combo2 188 [s]
  | PpSectionIfndef s        -> combo2 189 [s]
  | PpSectionElif s          -> combo2 190 [s]
  | PpSectionElse            -> mkstr2 191

  | IfThenBlock              -> mkstr2 192
  | ElseIfBlock              -> mkstr2 193
  | ElseBlock                -> mkstr2 194

  | OmpConstruct c           -> catstr [mkstr2 195; OmpConstruct.to_short_string c]

  | CrayPointerSpec          -> mkstr2 196

  | CaseBlock                -> mkstr2 197

  | IoItemList               -> mkstr2 198

  | Allocation n             -> combo2 199 [n]
  | AllocateShapeSpec        -> mkstr2 200
  | AllocateShapeSpecList    -> mkstr2 201

  | PpBranchDerivedType          -> mkstr2 202
  | PpBranchEndType              -> mkstr2 203
  | SelectTypeConstruct          -> mkstr2 204
  | AssociateConstruct           -> mkstr2 205
  | BlockConstruct               -> mkstr2 206
  | CriticalConstruct            -> mkstr2 207
  | LoopControlConcurrent        -> mkstr2 208
  | AssumedRankArray             -> mkstr2 209
  | WaitSpec sp                  -> catstr [mkstr2 210; WaitSpec.to_short_string sp]
  | FlushSpec sp                 -> catstr [mkstr2 211; FlushSpec.to_short_string sp]
  | BindingAttr a                -> catstr [mkstr2 212; BindingAttr.to_short_string a]
  | ProcComponentAttrSpec sp     -> catstr [mkstr2 213; ProcComponentAttrSpec.to_short_string sp]
  | ProcAttrSpec sp              -> catstr [mkstr2 214; ProcAttrSpec.to_short_string sp]
  | ExternalName n               -> combo2 215 [n]
  | TypeBoundProcDecl(n, n_opt)  -> catstr ((mkstr2 216)::n::(opt_to_list n_opt))
  | TypeBoundProcedurePart       -> mkstr2 217
  | ProcedureDesignator n        -> combo2 218 [n]
  | ProcDecl n                   -> combo2 219 [n]
  | TypeGuardBlock               -> mkstr2 220
  | Association n                -> combo2 221 [n]
  | DeferredCoshapeSpec          -> mkstr2 222
  | ExplicitCoshapeSpec          -> mkstr2 223
(*  | ExplicitCoshapeSpecUpper     -> mkstr2 224*)
  | DeferredCoshapeCoarray       -> mkstr2 225
  | ExplicitCoshapeCoarray       -> mkstr2 226
  | CodimensionDecl n            -> combo2 227 [n]
  | Enumerator n                 -> combo2 228 [n]
  | EnumDef                      -> mkstr2 229
  | BoundsSpec                   -> mkstr2 230
  | BoundsRemapping              -> mkstr2 231
  | BoundsSpecList               -> mkstr2 232
  | BoundsRemappingList          -> mkstr2 233
  | DataPointerObject n          -> combo2 234 [n]
  | AllocateCoshapeSpec          -> mkstr2 235
(*  | AllocateCoshapeSpecUpper     -> mkstr2 236*)
  | AllocateCoarraySpec          -> mkstr2 237

  | WEIRD s                      -> combo2 238 [s]
  | AcquiredLock                 -> mkstr2 239
  | ImageSelector                -> mkstr2 240
  | AllImages                    -> mkstr2 241
  | WhereBlock                   -> mkstr2 242
  | SelectiveOp                  -> mkstr2 243

  | PpBranchFunction      -> mkstr2 244
  | PpBranchEndFunction   -> mkstr2 245
  | PpBranchSubroutine    -> mkstr2 244
  | PpBranchEndSubroutine -> mkstr2 245
  | PpBranchPu            -> mkstr2 246
  | PpBranchEndPu         -> mkstr2 247

  | DefineFileSpec        -> mkstr2 248
  | Options s             -> mkstr2_str 249 s

  | ApolloPointerSpec     -> mkstr2 251

  | PpMacroEntityDecl n -> combo2 252 [n]
  | PpMacroObject n     -> combo2 253 [n]

  | AccClause c              -> catstr [mkstr2 254; AccClause.to_short_string c]
  | AccDirective d           -> catstr [mkstr2 255; AccDirective.to_short_string d]
  | ACC                      -> mkstr2 256
  | AccConstruct c           -> catstr [mkstr2 257; AccConstruct.to_short_string c]

  | DecDirective d           -> catstr [mkstr2 258; Dec.Directive.to_short_string d]
  | DecClause c              -> catstr [mkstr2 259; Dec.Clause.to_short_string c]
  | DecAttribute a           -> catstr [mkstr2 260; Dec.Attribute.to_short_string a]
  | DecMisc x                -> catstr [mkstr2 261; Dec.to_short_string x]
  | DEC                      -> mkstr2 262

  | DoBlock                  -> mkstr2 263

  | FunctionStmtHead n   -> combo2 264 [n]
  | SubroutineStmtHead n -> combo2 265 [n]

  | ProcName n -> combo2 266 [n]

let strip lab = lab (* not yet *)

let anonymize2 = anonymize ~more:true

let anonymize3 = anonymize ~more:true


(*
type annotation = string option

let null_annotation = None

let annotation_to_string = function
  | None -> "<none>"
  | Some x -> x
*)

module Annotation = struct
  type spec =
    | Require of string list
    | Provide of string list
    | Spec of Pinfo.Name.Spec.t

  type t = spec list

  let null = ([] : t)

  let mkrequire ns = Require ns
  let mkprovide ns = Provide ns
  let mkspec nspec = Spec nspec

  let spec_to_string = function
    | Require ns -> Printf.sprintf "require %s" (Xlist.to_string (fun x -> x) ", " ns)
    | Provide ns -> Printf.sprintf "provide %s" (Xlist.to_string (fun x -> x) ", " ns)
    | Spec nspec -> Pinfo.Name.Spec.to_string nspec

  let to_string l = Xlist.to_string spec_to_string "\n" l

  let from_specs (l : spec list) = (l : t)

  let add_spec (a : t) (s : spec) = (s :: a : t)

  let iter f (a : t) =
    List.iter f a

end (* of module Annotation *)

type annotation = Annotation.t
let null_annotation = Annotation.null
let annotation_to_string = Annotation.to_string


let is_hunk_boundary _ _ = false (* not yet *)

(* These labels are collapsible whether they are leaves or not. *)
let forced_to_be_collapsible (*lab*)_ =
  false


let is_collapse_target options lab =
  if options#no_collapse_flag then
    false
  else
    match lab with
    | PpDirective _
    | OclDirective _
    | OmpClause _
    | OmpDirective _
    | OmpConstruct _
    | LindaCall _
    | ProgramUnit _
    | InternalSubprogram _
    | ModuleSubprogram _
    | Stmt _
    | CaseConstruct
    | DoConstruct _
    | ForallConstruct
    | IfConstruct
    | WhereConstruct
    | SelectTypeConstruct
    | AssociateConstruct
    | BlockConstruct
    | CriticalConstruct

    | DerivedTypeDef _
    | InterfaceBlock _
    | SpecificationPart
    | ExecutionPart
    | SubprogramPart
    | ImplicitPart
    | Block
    | LoopControl _
    | LoopControlWhile
    | LoopControlConcurrent
    | OnlyList
    | ComponentDecl _
    | Prefix
    | Suffix
    | EntityDecl _
    | DummyArgNameList _
    | DummyArgList _
    | ActualArgSpecList _
    | ExplicitShapeSpec
    | AssumedShapeSpec
    | DeferredShapeSpec
    | ArraySpec _
    | ExplicitShapeArray _
    | AssumedShapeArray _
    | DeferredShapeArray _
    | AssumedSizeArray _
    | ComponentArraySpec _
    | ExplicitShapeComponentArray _
    | DeferredShapeComponentArray _

    | StructureDecl _
    | UnionDecl
    | MapDecl
    | TypeBoundProcDecl _
    | EnumDef
    | CodimensionDecl _

(*    | TypeGuardBlock*)
    | Association _
    | BoundsSpec
    | BoundsRemapping
    | BoundsSpecList
    | BoundsRemappingList

(* expr *)
    | VariableName _
    | Constant _
    | DefinedOperator _
    | IntrinsicOperator _
    | FunctionReference _
    | ArrayConstructor
    | StructureConstructor _
    | ArrayElement _
    | ArraySection _
    | StructureComponent _
    | Substring
    | ParenExpr

    | Ambiguous _

      -> true

    | _ -> false


let is_to_be_notified = function
  | PpDirective _
  | OclDirective _
  | OmpDirective _
  | OmpConstruct _
  | LindaCall _
  | ProgramUnit _
  | InternalSubprogram _
  | ModuleSubprogram _
  | Stmt _
  | CaseConstruct
  | DoConstruct _
  | ForallConstruct
  | IfConstruct
  | WhereConstruct
  | SelectTypeConstruct
  | AssociateConstruct
  | BlockConstruct
  | CriticalConstruct
  | DerivedTypeDef _
  | InterfaceBlock _
  | EnumDef
    -> true
  | _ -> false

let is_partition = function
  | ProgramUnit _
    -> true
  | _ -> false

let is_sequence = function
  | Program
  | Block
  | InterfaceBody
  | SpecificationPart
  | ExecutionPart
  | SubprogramPart
  | ImplicitPart
  | Fragment
  | TypeBoundProcedurePart
    -> true
  | _ -> false

let is_ntuple = function
  (* not yet *)
  | _ -> false


let is_boundary = function
  | Program
  | ProgramUnit _
  | InternalSubprogram _
  | ModuleSubprogram _
  | DerivedTypeDef _
  | InterfaceBlock _
  | Fragment
  | EnumDef
    -> true
  | _ -> false


let is_primary = function
  | Constant _
  | Name _
  | FunctionReference _
  | ArrayConstructor
  | StructureConstructor _
  | ArrayElement _
  | ArraySection _
  | StructureComponent _
  | Substring
  | ParenExpr
  | RecordFieldRef _
    -> true
  | _ -> false

let is_expr = function
  | DefinedOperator _
  | IntrinsicOperator _
    -> true
  | lab -> is_primary lab

let is_op = function
  | DefinedOperator _
  | IntrinsicOperator _
    -> true
  | _ -> false

let is_scope_creating = function (* not yet *)
  | _ -> false

let is_compatible ?(weak=false) _ _ = ignore weak; false

let is_order_insensitive = function
  | _ -> false

let quasi_eq _ _ = false

let relabel_allowed = function
  | Stmt _, Stmt _
  | IfConstruct, CaseConstruct | CaseConstruct, IfConstruct
  | IfConstruct, WhereConstruct | WhereConstruct, IfConstruct
  | DoConstruct _, ForallConstruct | ForallConstruct, DoConstruct _
  | LoopControl _, LoopControlWhile | LoopControlWhile, LoopControl _
  | LoopControl _, LoopControlConcurrent | LoopControlConcurrent, LoopControl _
  | ExecutionPart, Block | Block, ExecutionPart (* only for mapping children *)
    -> true
  | l1, l2 ->
      (is_expr l1 && is_expr l2) ||
      (anonymize2 l1 = anonymize2 l2)

let move_disallowed _ = false

let is_common _ = false

let get_ident_use = function
  | Name n -> n
  | _ -> ""

let to_char (*lab*)_ = '0'

let has_names lab =
  try
    ignore (get_names lab);
    true
  with
    Not_found -> false

let has_a_name lab =
  try
    ignore (get_name lab);
    true
  with
    Not_found -> false

let is_named lab =
  has_a_name lab || has_names lab

let is_named_orig lab =
  match lab with
  | Stmt s -> Stmt.is_named_orig s

  | SectionSubscriptList _
  | DummyArgNameList _
  | DummyArgList _
  | ActualArgSpecList _
  | ArrayElement _
  | ArraySection _
  | StructureComponent _
    -> false

  | _ -> is_named lab


let to_elem_data = Astml.to_elem_data lang_prefix to_tag

let of_elem_data (*name*)_ (*attrs*)_ _ = DUMMY (* not yet *)



let getlab nd = (Obj.obj nd#data#_label : t)



let cannot_be_keyroot nd =
  match getlab nd with
  | Program
  | ProgramUnit _
  | InternalSubprogram _
  | ModuleSubprogram _
  | ExecutionPart
    -> true
  | _ -> false


let is_int_literal = function
  | Constant (Constant.IntLiteralConstant _) -> true
  | _ -> false

let is_real_literal = function
  | Constant (Constant.RealLiteralConstant _) -> true
  | _ -> false

let is_string_literal = function
  | Constant (Constant.CharLiteralConstant _) -> true
  | _ -> false

let is_phantom = function
  | Block
  | DoBlock
  | WhereBlock
  | TypeGuardBlock
  | CaseBlock
  | IfThenBlock
  | ElseIfBlock
  | ElseBlock
  | SpecificationPart
  | ExecutionPart
  | ImplicitPart
    -> true
  | _ -> false

let is_special _ = false

let is_pp_directive = function
  | PpDirective _ -> true
  | _ -> false

let is_pp_define = function
  | PpDirective {PpDirective.pp_label=PpDirective.Define _;_} -> true
  | _ -> false

let is_pp_include = function
  | PpDirective
      {PpDirective.pp_label=PpDirective.Include _;_} -> true
  | _ -> false

let get_pp_include_path = function
  | PpDirective
      {PpDirective.pp_label=PpDirective.Include h;_} -> HeaderFile.to_path h
  | _ -> raise Not_found

let is_ocl_directive = function
  | OclDirective _ -> true
  | _ -> false

let is_omp_clause = function
  | OmpClause _ -> true
  | _ -> false

let is_omp_directive = function
  | OmpDirective _ -> true
  | _ -> false

let is_omp_construct = function
  | OmpConstruct _ -> true
  | _ -> false

let is_acc_clause = function
  | AccClause _ -> true
  | _ -> false

let is_acc_directive = function
  | AccDirective _ -> true
  | _ -> false

let is_acc_construct = function
  | AccConstruct _ -> true
  | _ -> false

let is_dec_clause = function
  | DecClause _ -> true
  | _ -> false

let is_dec_directive = function
  | DecDirective _ -> true
  | _ -> false

let is_program_unit = function
  | ProgramUnit _ -> true
  | _ -> false

let is_program = function
  | Program -> true
  | _ -> false

let is_fragment = function
  | Fragment -> true
  | _ -> false

let is_execution_part = function
  | ExecutionPart -> true
  | _ -> false

let is_subprogram_part = function
  | SubprogramPart -> true
  | _ -> false

let is_external_subprogram = function
  | ProgramUnit
      (ProgramUnit.FunctionSubprogram _ |
      ProgramUnit.SubroutineSubprogram _) -> true
  | _ -> false

let is_main_program = function
  | ProgramUnit (ProgramUnit.MainProgram _) -> true
  | _ -> false

let is_function = function
  | ProgramUnit (ProgramUnit.FunctionSubprogram _)
  | InternalSubprogram (InternalSubprogram.FunctionSubprogram _)
  | ModuleSubprogram (ModuleSubprogram.FunctionSubprogram _)
    -> true
  | _ -> false

let is_ext_function = function
  | ProgramUnit (ProgramUnit.FunctionSubprogram _)
    -> true
  | _ -> false

let is_int_function = function
  | InternalSubprogram (InternalSubprogram.FunctionSubprogram _)
    -> true
  | _ -> false

let is_mod_function = function
  | ModuleSubprogram (ModuleSubprogram.FunctionSubprogram _)
    -> true
  | _ -> false

let is_subroutine = function
  | ProgramUnit (ProgramUnit.SubroutineSubprogram _)
  | InternalSubprogram (InternalSubprogram.SubroutineSubprogram _)
  | ModuleSubprogram (ModuleSubprogram.SubroutineSubprogram _)
    -> true
  | _ -> false

let is_ext_subroutine = function
  | ProgramUnit (ProgramUnit.SubroutineSubprogram _)
    -> true
  | _ -> false

let is_int_subroutine = function
  | InternalSubprogram (InternalSubprogram.SubroutineSubprogram _)
    -> true
  | _ -> false

let is_mod_subroutine = function
  | ModuleSubprogram (ModuleSubprogram.SubroutineSubprogram _)
    -> true
  | _ -> false

let is_subprogram = function
  | ProgramUnit
      (ProgramUnit.SubroutineSubprogram _|ProgramUnit.FunctionSubprogram _)
  | InternalSubprogram
      (InternalSubprogram.SubroutineSubprogram _|InternalSubprogram.FunctionSubprogram _)
  | ModuleSubprogram _
    -> true
  | _ -> false

let is_program_unit_or_fragment = function
  | ProgramUnit _
  | Fragment -> true
  | _ -> false

let is_program_unit_or_subprogram = function
  | ProgramUnit _
  | InternalSubprogram
      (InternalSubprogram.SubroutineSubprogram _|InternalSubprogram.FunctionSubprogram _)
  | ModuleSubprogram
      (ModuleSubprogram.SubroutineSubprogram _|ModuleSubprogram.FunctionSubprogram _)
    -> true
  | _ -> false

let is_module = function
  | ProgramUnit (ProgramUnit.Module _) -> true
  | _ -> false

let is_block_data = function
  | ProgramUnit (ProgramUnit.BlockData _) -> true
  | _ -> false

let is_case_construct = function
  | CaseConstruct -> true
  | _ -> false

let is_do_construct = function
  | DoConstruct _ -> true
  | _ -> false

let is_forall_construct = function
  | ForallConstruct -> true
  | _ -> false

let is_if_construct = function
  | IfConstruct -> true
  | _ -> false

let is_where_construct = function
  | WhereConstruct -> true
  | _ -> false

let is_select_type_construct = function
  | SelectTypeConstruct -> true
  | _ -> false

let is_associate_construct = function
  | AssociateConstruct -> true
  | _ -> false

let is_block_construct = function
  | BlockConstruct -> true
  | _ -> false

let is_critical_construct = function
  | CriticalConstruct -> true
  | _ -> false

let is_derived_type_def = function
  | DerivedTypeDef _ -> true
  | _ -> false

let is_interface_block = function
  | InterfaceBlock _ -> true
  | _ -> false

let is_block = function
  | Block -> true
  | _ -> false

let is_ambiguous = function
  | Ambiguous _ -> true
  | _ -> false

let is_array_access = function
  | ArrayElement _
  | ArraySection _
  | Ambiguous (Ambiguous.ArrayAccess _) -> true
  | _ -> false

let is_if_then_block = function
  | IfThenBlock -> true
  | _ -> false

let is_else_block = function
  | ElseBlock -> true
  | _ -> false

let is_else_if_block = function
  | ElseIfBlock -> true
  | _ -> false

let is_where_block = function
  | WhereBlock -> true
  | _ -> false

let is_case_block = function
  | CaseBlock -> true
  | _ -> false

let is_type_guard_block = function
  | TypeGuardBlock -> true
  | _ -> false

let is_do_block = function
  | DoBlock -> true
  | _ -> false

let is_pp_branch = function
  | PpBranch -> true
  | _ -> false

let is_pp_branch_do = function
  | PpBranchDo -> true
  | _ -> false

let is_pp_branch_if = function
  | PpBranchIf -> true
  | _ -> false

let is_pp_branch_forall = function
  | PpBranchForall -> true
  | _ -> false

let is_pp_branch_where = function
  | PpBranchWhere -> true
  | _ -> false

let is_pp_branch_select = function
  | PpBranchSelect -> true
  | _ -> false

let is_pp_branch_end_do = function
  | PpBranchEndDo -> true
  | _ -> false

let is_pp_branch_end_if = function
  | PpBranchEndIf -> true
  | _ -> false

let is_pp_branch_end_forall = function
  | PpBranchEndForall -> true
  | _ -> false

let is_pp_branch_end_where = function
  | PpBranchEndWhere -> true
  | _ -> false

let is_pp_branch_end_select = function
  | PpBranchEndSelect -> true
  | _ -> false

let is_pp_section_ifdef = function
  | PpSectionIfdef _ -> true
  | _ -> false

let is_pp_section_ifndef = function
  | PpSectionIfndef _ -> true
  | _ -> false

let is_pp_section_if = function
  | PpSectionIf _ -> true
  | _ -> false

let is_pp_section_elif = function
  | PpSectionElif _ -> true
  | _ -> false

let is_pp_section_else = function
  | PpSectionElse -> true
  | _ -> false

let is_container_unit = function
  | AccConstruct _
  | CaseBlock
  | ElseBlock
  | ElseIfBlock
  | IfThenBlock
  | TypeGuardBlock
  | WhereBlock
  | PpSectionIf _
  | PpSectionElif _
  | PpSectionElse
  | PpSectionIfdef _
  | PpSectionIfndef _
  | AssociateConstruct
  | BlockConstruct
  | CaseConstruct
  | IfConstruct
  | SelectTypeConstruct
  | WhereConstruct
  | CriticalConstruct
  | DoConstruct _
  | ForallConstruct
  | DoBlock
  | ExecutionPart
  | OmpConstruct _
  | PpBranch
  | PpBranchDo
  | PpBranchIf
  | PpBranchForall
  | PpBranchWhere
  | PpBranchSelect
  | PpBranchEndDo
  | PpBranchEndIf
  | PpBranchEndForall
  | PpBranchEndWhere
  | PpBranchEndSelect
    -> true

  | _ -> false
OCaml

Innovation. Community. Security.