| 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
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092 |
1156x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
42x
6x
1x
1x
1x
1x
1x
1x
3641x
272x
272x
751x
751x
4392x
3641x
3641x
3171x
272x
2899x
86x
4392x
751x
272x
272x
272x
272x
751x
751x
3641x
3263x
272x
272x
479x
272x
479x
479x
272x
272x
272x
1654x
1654x
1x
1x
1x
1x
1654x
1654x
84x
84x
3x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
1x
1x
1x
1x
1x
1x
1x
1x
53x
51x
5x
5x
5x
5x
50x
50x
50x
50x
50x
2x
48x
48x
46x
2x
1x
10x
10x
1x
10x
10x
10x
1x
1x
10x
10x
10x
6x
6x
4x
4x
4x
4x
4x
3x
3x
1x
10x
1x
1x
4x
4x
4x
4x
4x
4x
4x
4x
4x
1x
1x
1x
1x
1x
1x
1x
1x
117x
1x
1x
1x
1x
1x
89x
89x
1x
1x
1x
1x
1x
1x
1x
1x
1x
151x
151x
151x
2020x
2020x
1878x
1878x
141x
141x
1x
151x
1x
176x
176x
2456x
2456x
224x
224x
5418x
10x
10x
1026x
1026x
400x
400x
626x
10x
1x
208x
208x
188x
20x
20x
1662x
20x
223x
223x
15x
208x
208x
208x
12x
12x
12x
12x
12x
210x
210x
209x
209x
209x
209x
12x
859x
859x
859x
859x
11x
11x
11x
55x
11x
11x
11x
11x
2x
11x
11x
11x
2x
2x
2x
2x
2x
2x
2x
9x
9x
9x
16x
16x
16x
16x
16x
7x
7x
7x
5x
3x
2x
2x
2x
7x
16x
16x
16x
3x
3x
3x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
112x
112x
112x
42x
42x
42x
23x
23x
23x
42x
42x
42x
42x
43x
43x
43x
1x
42x
42x
47x
47x
47x
32x
15x
47x
12x
12x
12x
212x
212x
212x
48x
48x
48x
44x
44x
44x
47x
47x
47x
47x
2x
2x
2x
62x
62x
62x
1x
1x
1x
2x
2x
2x
7x
7x
7x
6x
6x
2x
4x
6x
26x
26x
26x
3x
3x
3x
1x
2x
2x
8x
7x
2x
2x
2x
5x
4x
5x
5x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
15x
1x
16x
16x
16x
2586x
16x
16x
1069x
977x
977x
5106x
5106x
977x
92x
467x
2287x
32x
521x
521x
484x
521x
16x
16x
16x
16x
16x
4x
4x
4x
4x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
4x
4x
4x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
598x
598x
598x
598x
598x
590x
443x
567x
567x
443x
598x
590x
443x
445x
445x
443x
598x
147x
147x
147x
147x
451x
451x
451x
451x
451x
451x
451x
451x
451x
451x
451x
451x
16x
6x
2x
2x
44x
2x
6x
6x
16x
6x
6x
6x
6x
6x
6x
6x
6x
6x
6x
6x
6x
6x
6x
6x
6x
440x
439x
439x
16x
16x
16x
8x
8x
8x
21x
21x
8x
8x
13x
13x
13x
13x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
16x
1272x
1272x
627x
627x
645x
426x
644x
644x
644x
644x
8x
8x
8x
8x
8x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
8x
8x
6x
6x
6x
6x
6x
6x
6x
6x
8x
8x
8x
8x
8x
8x
2x
6x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
13x
13x
13x
13x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
24x
24x
8x
8x
16x
8x
8x
16x
16x
16x
16x
6x
6x
6x
18x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
10x
10x
10x
8x
8x
8x
8x
8x
8x
8x
8x
8x
8x
6x
6x
6x
1263x
422x
422x
422x
422x
422x
422x
422x
422x
422x
422x
841x
841x
841x
841x
841x
839x
11x
11x
828x
828x
828x
828x
828x
828x
828x
828x
828x
11x
5x
4x
1x
1x
16x
16x
11x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
16x
16x
16x
586x
586x
586x
586x
586x
586x
586x
586x
32x
32x
1x
1x
109x
109x
1x
1x
11x
11x
11x
11x
11x
11x
280x
280x
280x
280x
11x
11x
11x
1x
32x
32x
32x
32x
32x
32x
32x
32x
32x
32x
32x
51x
51x
51x
51x
51x
51x
51x
51x
51x
37x
37x
37x
37x
37x
37x
37x
37x
14x
51x
51x
51x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
2x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
5x
18x
18x
18x
18x
18x
18x
18x
5x
5x
13x
3x
10x
18x
8x
8x
8x
8x
8x
18x
18x
5x
5x
543x
543x
543x
543x
543x
122x
122x
122x
421x
543x
543x
543x
543x
543x
543x
543x
543x
543x
543x
543x
542x
542x
428x
114x
114x
114x
554x
11x
11x
543x
16x
543x
543x
543x
543x
147x
147x
543x
543x
543x
543x
5815x
5815x
543x
543x
543x
543x
543x
543x
543x
542x
428x
114x
440x
440x
440x
440x
554x
439x
439x
439x
439x
439x
16x
16x
82x
82x
82x
64x
64x
64x
64x
147x
147x
543x
543x
14x
14x
14x
14x
14x
14x
15x
15x
15x
2x
2x
32x
32x
72x
72x
33x
33x
33x
32x
32x
32x
32x
1x
1x
37x
37x
37x
37x
37x
13x
13x
1x
12x
12x
12x
20x
49x
36x
36x
36x
36x
3x
3x
3x
1x
3x
3x
5x
5x
22x
18x
9x
9x
17x
17x
7x
7x
2x
2x
3x
3x
16x
16x
7x
7x
1x
73x
1x
1x
26x
26x
26x
26x
26x
26x
1x
1x
1x
1x
1x
1x
26x
26x
26x
26x
1x
1x
1x
16x
1x
16x
1x
439x
1x
1x
16x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
30751x
30x
31x
33x
40x
28x
28x
63x
12x
30486x
425x
425x
425x
425x
30061x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
3x
3x
3x
3x
21x
21x
2x
19x
19x
1245184x
590559x
590559x
196608x
393951x
19x
3x
3x
3x
3x
196608x
196608x
3x
21x
21x
2x
19x
19x
19x
19x
19x
1245184x
590559x
590559x
20x
20x
20x
19x
19x
19x
3x
34x
34x
34x
34x
34x
3x
131x
131x
4070x
4070x
1188460x
37x
2424832x
599112x
6869x
134x
134x
76x
76x
76x
76x
76x
14x
14x
4x
4x
12x
4x
6x
6735x
131x
131x
25x
25x
25x
25x
131x
4107x
4107x
4107x
4107x
14x
14x
14x
14x
14x
14x
14x
14x
2x
2x
2x
2x
2x
2x
14x
14x
23x
23x
23x
23x
23x
4070x
4070x
4070x
4070x
4070x
2799x
2799x
2799x
2799x
2799x
2799x
2799x
2799x
2799x
2799x
2799x
1271x
131x
25x
1638400x
982863x
131x
332x
332x
332x
332x
332x
114x
114x
7471104x
5024148x
114x
2x
112x
6x
106x
53x
53x
318x
318x
216x
216x
216x
216x
4467297x
1515073x
1514925x
148x
148x
148x
216x
68x
68x
49x
49x
3211264x
49x
49x
49x
19x
1245184x
106x
106x
6328x
3560757x
6328x
35x
6293x
6293x
6293x
4289x
6293x
218x
218x
14286848x
3978879x
218x
8x
210x
4x
206x
73x
73x
442x
442x
100x
100x
100x
100x
2821217x
135673x
135616x
57x
57x
57x
100x
43x
43x
41x
41x
2686976x
41x
41x
41x
2x
131072x
206x
206x
11110x
10180272x
11110x
185x
10925x
10925x
21x
10925x
10925x
9244x
10925x
312x
312x
312x
312x
312x
16x
296x
44x
44x
44x
44x
44x
65x
65x
65x
65x
65x
46x
46x
92x
92x
46x
46x
46x
46x
46x
46x
46x
46x
46x
46x
46x
46x
46x
46x
45x
45x
45x
46x
4x
4x
4x
11x
3x
3x
3x
11x
40x
40x
40x
40x
40x
40x
40x
40x
40x
40x
77x
77x
20x
57x
57x
57x
3x
3x
54x
57x
57x
57x
57x
57x
57x
3x
3x
54x
57x
57x
18x
57x
57x
6x
57x
1x
1x
1x
1x
1x
85x
85x
3x
1x
1x
1x
1x
1x
1x
1x
85x
85x
85x
85x
85x
85x
255x
255x
196x
196x
2334x
1654x
196x
85x
196x
196x
111x
196x
1654x
1654x
1654x
85x
89x
89x
85x
4x
89x
90x
90x
16x
2x
2x
2x
16x
16x
16x
5x
5x
5x
5x
74x
85x
85x
85x
85x
85x
85x
85x
85x
85x
84x
85x
2x
85x
24x
272x
610x
305x
610x
610x
85x
85x
305x
305x
305x
305x
291x
313x
295x
295x
14x
3x
3x
6x
3x
3x
11x
11x
11x
11x
1x
1x
11x
11x
305x
305x
305x
305x
305x
305x
10x
305x
305x
305x
305x
305x
305x
305x
305x
305x
249x
249x
56x
56x
85x
81x
81x
85x
85x
82x
3x
85x
347x
347x
347x
347x
412x
412x
412x
412x
412x
77x
77x
77x
154x
154x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
77x
2x
77x
77x
4x
4x
4x
4x
4x
4x
26x
26x
26x
26x
26x
26x
26x
26x
26x
26x
26x
26x
26x
26x
305x
305x
70x
70x
70x
235x
305x
347x
347x
347x
347x
347x
347x
24x
89x
42x
42x
23x
23x
105x
82x
5x
82x
82x
25x
25x
25x
25x
42x
42x
4x
38x
38x
42x
47x
47x
47x
89x
47x
42x
42x
42x
42x
42x
5x
5x
5x
47x
44x
21x
57x
57x
57x
22x
22x
22x
22x
57x
14x
44x
5x
5x
6x
6x
6x
5x
5x
5x
5x
6x
5x
5x
24x
24x
42x
42x
24x
42x
42x
24x
24x
305x
33x
15x
33x
33x
33x
33x
13x
13x
13x
13x
13x
13x
33x
13x
33x
21x
21x
40x
40x
40x
40x
21x
21x
21x
21x
21x
40x
19x
21x
305x
305x
305x
38x
267x
5x
305x
85x
85x
7x
7x
85x
85x
85x
85x
85x
3x
3x
3x
85x
85x
85x
425x
85x
1x
1x
1x
84x
89x
89x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
84x
2x
84x
2x
84x
6x
6x
84x
89x
84x
84x
84x
2x
84x
1x
84x
84x
1x
84x
7x
84x
88x
1x
1x
5x
5x
5x
5x
1x
1x
90x
90x
90x
85x
85x
85x
85x
85x
85x
85x
85x
85x
85x
85x
85x
85x
85x
85x
85x
85x
1x
1x
1x
1x
1x
86x
86x
86x
86x
86x
317x
317x
317x
315x
2x
2x
86x
86x
86x
86x
86x
86x
86x
1638x
104x
104x
86x
86x
86x
2x
86x
2x
86x
86x
86x
2x
86x
2x
86x
89x
86x
86x
86x
86x
86x
86x
86x
86x
86x
86x
86x
86x
86x
86x
3x
3x
3x
3x
3x
3x
89x
5x
5x
5x
5x
5x
5x
5x
5x
2x
2x
2x
2x
2x
2x
1x
1x
1x
1x
1x
1x
2x
2x
2x
2x
2x
2x
1x
1x
1x
1x
1x
1x
1x
1x
| 'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _templateObject = _taggedTemplateLiteral(['\n There\'s an error in your lexer regex rules or epilogue.\n Maybe you did not correctly separate the lexer sections with a \'%%\'\n on an otherwise empty line?\n The lexer spec file should have this structure:\n \n definitions\n %%\n rules\n %% // <-- optional!\n extra_module_code // <-- optional epilogue!\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n There\'s an error in your lexer regex rules or epilogue.\n Maybe you did not correctly separate the lexer sections with a \'%%\'\n on an otherwise empty line?\n The lexer spec file should have this structure:\n \n definitions\n %%\n rules\n %% // <-- optional!\n extra_module_code // <-- optional epilogue!\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject2 = _taggedTemplateLiteral(['\n There\'s probably an error in one or more of your lexer regex rules.\n The lexer rule spec should have this structure:\n \n regex action_code\n \n where \'regex\' is a lex-style regex expression (see the\n jison and jison-lex documentation) which is intended to match a chunk\n of the input to lex, while the \'action_code\' block is the JS code\n which will be invoked when the regex is matched. The \'action_code\' block\n may be any (indented!) set of JS statements, optionally surrounded\n by \'{...}\' curly braces or otherwise enclosed in a \'%{...%}\' block.\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n There\'s probably an error in one or more of your lexer regex rules.\n The lexer rule spec should have this structure:\n \n regex action_code\n \n where \'regex\' is a lex-style regex expression (see the\n jison and jison-lex documentation) which is intended to match a chunk\n of the input to lex, while the \'action_code\' block is the JS code\n which will be invoked when the regex is matched. The \'action_code\' block\n may be any (indented!) set of JS statements, optionally surrounded\n by \'{...}\' curly braces or otherwise enclosed in a \'%{...%}\' block.\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject3 = _taggedTemplateLiteral(['\n There\'s an error in your lexer epilogue a.k.a. \'extra_module_code\' block.\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n There\'s an error in your lexer epilogue a.k.a. \'extra_module_code\' block.\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject4 = _taggedTemplateLiteral(['\n Encountered an unsupported definition type: ', '.\n \n Erroneous area:\n ', '\n '], ['\n Encountered an unsupported definition type: ', '.\n \n Erroneous area:\n ', '\n ']),
_templateObject5 = _taggedTemplateLiteral(['\n The \'%{...%}\' lexer setup action code section does not compile: ', '\n \n Erroneous area:\n ', '\n '], ['\n The \'%{...%}\' lexer setup action code section does not compile: ', '\n \n Erroneous area:\n ', '\n ']),
_templateObject6 = _taggedTemplateLiteral(['\n You did not specify a legal file path for the \'%import\' initialization code statement, which must have the format:\n %import qualifier_name file_path\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n You did not specify a legal file path for the \'%import\' initialization code statement, which must have the format:\n %import qualifier_name file_path\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject7 = _taggedTemplateLiteral(['\n %import name or source filename missing maybe?\n \n Note: each \'%import\'-ed initialization code section must be qualified by a name, e.g. \'required\' before the import path itself:\n %import qualifier_name file_path\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n %import name or source filename missing maybe?\n \n Note: each \'%import\'-ed initialization code section must be qualified by a name, e.g. \'required\' before the import path itself:\n %import qualifier_name file_path\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject8 = _taggedTemplateLiteral(['\n The \'%code ', '\' action code section does not compile: ', '\n \n ', '\n \n Erroneous area:\n ', '\n '], ['\n The \'%code ', '\' action code section does not compile: ', '\n \n ', '\n \n Erroneous area:\n ', '\n ']),
_templateObject9 = _taggedTemplateLiteral(['\n Each \'%code\' initialization code section must be qualified by a name, e.g. \'required\' before the action code itself:\n %code qualifier_name {action code}\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Each \'%code\' initialization code section must be qualified by a name, e.g. \'required\' before the action code itself:\n %code qualifier_name {action code}\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject10 = _taggedTemplateLiteral(['\n Seems you made a mistake while specifying one of the lexer rules inside\n the start condition\n <', '> { rules... }\n block.\n \n Erroneous area:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Seems you made a mistake while specifying one of the lexer rules inside\n the start condition\n <', '> { rules... }\n block.\n \n Erroneous area:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject11 = _taggedTemplateLiteral(['\n Seems you did not correctly bracket a lexer rules set inside\n the start condition\n <', '> { rules... }\n as a terminating curly brace \'}\' could not be found.\n \n Erroneous area:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Seems you did not correctly bracket a lexer rules set inside\n the start condition\n <', '> { rules... }\n as a terminating curly brace \'}\' could not be found.\n \n Erroneous area:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject12 = _taggedTemplateLiteral(['\n The rule\'s action code section does not compile: ', '\n \n Erroneous area:\n ', '\n '], ['\n The rule\'s action code section does not compile: ', '\n \n Erroneous area:\n ', '\n ']),
_templateObject13 = _taggedTemplateLiteral(['\n Lexer rule regex action code declaration error?\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Lexer rule regex action code declaration error?\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject14 = _taggedTemplateLiteral(['\n Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: \'{ ... }\'.\n \n Offending action body:\n ', '\n '], ['\n Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: \'{ ... }\'.\n \n Offending action body:\n ', '\n ']),
_templateObject15 = _taggedTemplateLiteral(['\n Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: \'{ ... }\'.\n \n Offending action body:\n ', '\n '], ['\n Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: \'{ ... }\'.\n \n Offending action body:\n ', '\n ']),
_templateObject16 = _taggedTemplateLiteral(['\n You may place the \'%include\' instruction only at the start/front of a line.\n \n Its use is not permitted at this position:\n ', '\n '], ['\n You may place the \'%include\' instruction only at the start/front of a line.\n \n Its use is not permitted at this position:\n ', '\n ']),
_templateObject17 = _taggedTemplateLiteral(['\n Seems you did not correctly match curly braces \'{ ... }\' in a lexer rule action block.\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Seems you did not correctly match curly braces \'{ ... }\' in a lexer rule action block.\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject18 = _taggedTemplateLiteral(['\n Seems you did not correctly terminate the start condition set <', ',???> with a terminating \'>\'\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Seems you did not correctly terminate the start condition set <', ',???> with a terminating \'>\'\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject19 = _taggedTemplateLiteral(['\n Seems you did not correctly bracket a lex rule regex part in \'(...)\' braces.\n \n Unterminated regex part:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Seems you did not correctly bracket a lex rule regex part in \'(...)\' braces.\n \n Unterminated regex part:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject20 = _taggedTemplateLiteral(['\n Seems you did not correctly bracket a lex rule regex set in \'[...]\' brackets.\n \n Unterminated regex set:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Seems you did not correctly bracket a lex rule regex set in \'[...]\' brackets.\n \n Unterminated regex set:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject21 = _taggedTemplateLiteral(['\n Internal error: option "', '" value assignment failure.\n \n Erroneous area:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Internal error: option "', '" value assignment failure.\n \n Erroneous area:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject22 = _taggedTemplateLiteral(['\n Expected a valid option name (with optional value assignment).\n \n Erroneous area:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Expected a valid option name (with optional value assignment).\n \n Erroneous area:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject23 = _taggedTemplateLiteral(['\n The extra lexer module code section (a.k.a. \'epilogue\') does not compile: ', '\n \n Erroneous area:\n ', '\n '], ['\n The extra lexer module code section (a.k.a. \'epilogue\') does not compile: ', '\n \n Erroneous area:\n ', '\n ']),
_templateObject24 = _taggedTemplateLiteral(['\n The source code %include-d into the extra lexer module code section (a.k.a. \'epilogue\') does not compile: ', '\n \n Erroneous area:\n ', '\n '], ['\n The source code %include-d into the extra lexer module code section (a.k.a. \'epilogue\') does not compile: ', '\n \n Erroneous area:\n ', '\n ']),
_templateObject25 = _taggedTemplateLiteral(['\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n ', '\n \n Technical error report:\n ', '\n '], ['\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject26 = _taggedTemplateLiteral(['\n Module code declaration error?\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n '], ['\n Module code declaration error?\n \n Erroneous code:\n ', '\n \n Technical error report:\n ', '\n ']),
_templateObject27 = _taggedTemplateLiteral(['\n %include statements must occur on a line on their own and cannot occur inside an %{...%} action code block.\n Its use is not permitted at this position.\n\n Erroneous area:\n '], ['\n %include statements must occur on a line on their own and cannot occur inside an %{...%} action code block.\n Its use is not permitted at this position.\n\n Erroneous area:\n ']),
_templateObject28 = _taggedTemplateLiteral(['\n too many closing curly braces in lexer rule action block.\n\n Note: the action code chunk may be too complex for jison to parse\n easily; we suggest you wrap the action code chunk in \'%{...%}\'\n to help jison grok more or less complex action code chunks.\n\n Erroneous area:\n '], ['\n too many closing curly braces in lexer rule action block.\n\n Note: the action code chunk may be too complex for jison to parse\n easily; we suggest you wrap the action code chunk in \'%{...%}\'\n to help jison grok more or less complex action code chunks.\n\n Erroneous area:\n ']),
_templateObject29 = _taggedTemplateLiteral(['\n missing ', ' closing curly braces in lexer rule action block.\n\n Note: the action code chunk may be too complex for jison to parse\n easily; we suggest you wrap the action code chunk in \'%{...%}\'\n to help jison grok more or less complex action code chunks.\n\n Erroneous area:\n '], ['\n missing ', ' closing curly braces in lexer rule action block.\n\n Note: the action code chunk may be too complex for jison to parse\n easily; we suggest you wrap the action code chunk in \'%{...%}\'\n to help jison grok more or less complex action code chunks.\n\n Erroneous area:\n ']),
_templateObject30 = _taggedTemplateLiteral(['\n LEX: ignoring unsupported lexer option ', '\n while lexing in ', ' state.\n\n Erroneous area:\n '], ['\n LEX: ignoring unsupported lexer option ', '\n while lexing in ', ' state.\n\n Erroneous area:\n ']),
_templateObject31 = _taggedTemplateLiteral(['\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n '], ['\n unterminated string constant in lexer rule action block.\n\n Erroneous area:\n ']),
_templateObject32 = _taggedTemplateLiteral(['\n unterminated string constant in %options entry.\n\n Erroneous area:\n '], ['\n unterminated string constant in %options entry.\n\n Erroneous area:\n ']),
_templateObject33 = _taggedTemplateLiteral(['\n unterminated string constant encountered while lexing\n ', '.\n\n Erroneous area:\n '], ['\n unterminated string constant encountered while lexing\n ', '.\n\n Erroneous area:\n ']),
_templateObject34 = _taggedTemplateLiteral(['\n unsupported lexer input encountered while lexing\n ', ' (i.e. jison lex regexes).\n\n NOTE: When you want this input to be interpreted as a LITERAL part\n of a lex rule regex, you MUST enclose it in double or\n single quotes.\n\n If not, then know that this input is not accepted as a valid\n regex expression here in jison-lex ', '.\n\n Erroneous area:\n '], ['\n unsupported lexer input encountered while lexing\n ', ' (i.e. jison lex regexes).\n\n NOTE: When you want this input to be interpreted as a LITERAL part\n of a lex rule regex, you MUST enclose it in double or\n single quotes.\n\n If not, then know that this input is not accepted as a valid\n regex expression here in jison-lex ', '.\n\n Erroneous area:\n ']),
_templateObject35 = _taggedTemplateLiteral(['\n unsupported lexer input: ', '\n while lexing in ', ' state.\n\n Erroneous area:\n '], ['\n unsupported lexer input: ', '\n while lexing in ', ' state.\n\n Erroneous area:\n ']),
_templateObject36 = _taggedTemplateLiteral(['\n var __hacky_counter__ = 0;\n\n /**\n * @constructor\n * @nocollapse\n */\n function XRegExp(re, f) {\n this.re = re;\n this.flags = f;\n this._getUnicodeProperty = function (k) {};\n var fake = /./; // WARNING: this exact \'fake\' is also depended upon by the xregexp unit test!\n __hacky_counter__++;\n fake.__hacky_backy__ = __hacky_counter__;\n return fake;\n }\n '], ['\n var __hacky_counter__ = 0;\n\n /**\n * @constructor\n * @nocollapse\n */\n function XRegExp(re, f) {\n this.re = re;\n this.flags = f;\n this._getUnicodeProperty = function (k) {};\n var fake = /./; // WARNING: this exact \'fake\' is also depended upon by the xregexp unit test!\n __hacky_counter__++;\n fake.__hacky_backy__ = __hacky_counter__;\n return fake;\n }\n ']),
_templateObject37 = _taggedTemplateLiteral(['\n return ', ';\n'], ['\n return ', ';\n']),
_templateObject38 = _taggedTemplateLiteral(['\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ', '\n // location.ranges: ................. ', '\n // location line+column tracking: ... ', '\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ', '\n // uses yylineno: ................... ', '\n // uses yytext: ..................... ', '\n // uses yylloc: ..................... ', '\n // uses lexer values: ............... ', ' / ', '\n // location tracking: ............... ', '\n // location assignment: ............. ', '\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ', '\n // uses yylineno: ................... ', '\n // uses yytext: ..................... ', '\n // uses yylloc: ..................... ', '\n // uses ParseError API: ............. ', '\n // uses yyerror: .................... ', '\n // uses location tracking & editing: ', '\n // uses more() API: ................. ', '\n // uses unput() API: ................ ', '\n // uses reject() API: ............... ', '\n // uses less() API: ................. ', '\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ', '\n // uses describeYYLLOC() API: ....... ', '\n //\n // --------- END OF REPORT -----------\n\n '], ['\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ', '\n // location.ranges: ................. ', '\n // location line+column tracking: ... ', '\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ', '\n // uses yylineno: ................... ', '\n // uses yytext: ..................... ', '\n // uses yylloc: ..................... ', '\n // uses lexer values: ............... ', ' / ', '\n // location tracking: ............... ', '\n // location assignment: ............. ', '\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ', '\n // uses yylineno: ................... ', '\n // uses yytext: ..................... ', '\n // uses yylloc: ..................... ', '\n // uses ParseError API: ............. ', '\n // uses yyerror: .................... ', '\n // uses location tracking & editing: ', '\n // uses more() API: ................. ', '\n // uses unput() API: ................ ', '\n // uses reject() API: ............... ', '\n // uses less() API: ................. ', '\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ', '\n // uses describeYYLLOC() API: ....... ', '\n //\n // --------- END OF REPORT -----------\n\n ']),
_templateObject39 = _taggedTemplateLiteral(['\n var lexer = {\n '], ['\n var lexer = {\n ']),
_templateObject40 = _taggedTemplateLiteral([',\n JisonLexerError: JisonLexerError,\n performAction: ', ',\n simpleCaseActionClusters: ', ',\n rules: [\n ', '\n ],\n conditions: ', '\n };\n '], [',\n JisonLexerError: JisonLexerError,\n performAction: ', ',\n simpleCaseActionClusters: ', ',\n rules: [\n ', '\n ],\n conditions: ', '\n };\n ']),
_templateObject41 = _taggedTemplateLiteral(['\n /* lexer generated by jison-lex ', ' */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called "shared state" or rather the *source* of it;\n * the real "shared state" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This "shared context" object was passed to the lexer by way of \n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This "shared context" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world \n * and/or other lexer rules\' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall "shared context" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance. \n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` "shared state" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer "start condition" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \'hash object\' which can be passed into `parseError()`.\n * See it\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\'fail!\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer\'s additional `args...` parameters (via lexer\'s `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time; \n * when such a collision is detected an exception is thrown to prevent the generated run-time \n * from silently accepting this confusing and potentially hazardous situation! \n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired. \n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a \'hash\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal "shared state" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer\'s `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n * \n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are "extended regex format" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n '], ['\n /* lexer generated by jison-lex ', ' */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called "shared state" or rather the *source* of it;\n * the real "shared state" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This "shared context" object was passed to the lexer by way of \n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This "shared context" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world \n * and/or other lexer rules\' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall "shared context" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance. \n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` "shared state" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer "start condition" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\\'hash object\\\' which can be passed into \\`parseError()\\`.\n * See it\\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\\'fail!\\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer\'s additional \\`args...\\` parameters (via lexer\'s \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time; \n * when such a collision is detected an exception is thrown to prevent the generated run-time \n * from silently accepting this confusing and potentially hazardous situation! \n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired. \n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\\'hash\\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal "shared state" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n * \n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are "extended regex format" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n ']),
_templateObject42 = _taggedTemplateLiteral(['\n export {\n lexer,\n yylex as lex\n };\n '], ['\n export {\n lexer,\n yylex as lex\n };\n ']);
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
function _interopDefault(ex) {
return ex && (typeof ex === 'undefined' ? 'undefined' : _typeof(ex)) === 'object' && 'default' in ex ? ex['default'] : ex;
}
var XRegExp = _interopDefault(require('@gerhobbelt/xregexp'));
var json5 = _interopDefault(require('@gerhobbelt/json5'));
var fs = _interopDefault(require('fs'));
var path = _interopDefault(require('path'));
var recast = _interopDefault(require('@gerhobbelt/recast'));
var assert$1 = _interopDefault(require('assert'));
// Return TRUE if `src` starts with `searchString`.
function startsWith(src, searchString) {
return src.substr(0, searchString.length) === searchString;
}
// tagged template string helper which removes the indentation common to all
// non-empty lines: that indentation was added as part of the source code
// formatting of this lexer spec file and must be removed to produce what
// we were aiming for.
//
// Each template string starts with an optional empty line, which should be
// removed entirely, followed by a first line of error reporting content text,
// which should not be indented at all, i.e. the indentation of the first
// non-empty line should be treated as the 'common' indentation and thus
// should also be removed from all subsequent lines in the same template string.
//
// See also: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals
function rmCommonWS$2(strings) {
// As `strings[]` is an array of strings, each potentially consisting
// of multiple lines, followed by one(1) value, we have to split each
// individual string into lines to keep that bit of information intact.
//
// We assume clean code style, hence no random mix of tabs and spaces, so every
// line MUST have the same indent style as all others, so `length` of indent
// should suffice, but the way we coded this is stricter checking as we look
// for the *exact* indenting=leading whitespace in each line.
var indent_str = null;
var src = strings.map(function splitIntoLines(s) {
var a = s.split('\n');
indent_str = a.reduce(function analyzeLine(indent_str, line, index) {
// only check indentation of parts which follow a NEWLINE:
if (index !== 0) {
var m = /^(\s*)\S/.exec(line);
// only non-empty ~ content-carrying lines matter re common indent calculus:
if (m) {
if (!indent_str) {
indent_str = m[1];
} else if (m[1].length < indent_str.length) {
indent_str = m[1];
}
}
}
return indent_str;
}, indent_str);
return a;
});
// Also note: due to the way we format the template strings in our sourcecode,
// the last line in the entire template must be empty when it has ANY trailing
// whitespace:
var a = src[src.length - 1];
a[a.length - 1] = a[a.length - 1].replace(/\s+$/, '');
// Done removing common indentation.
//
// Process template string partials now, but only when there's
// some actual UNindenting to do:
Eif (indent_str) {
for (var i = 0, len = src.length; i < len; i++) {
var a = src[i];
// only correct indentation at start of line, i.e. only check for
// the indent after every NEWLINE ==> start at j=1 rather than j=0
for (var j = 1, linecnt = a.length; j < linecnt; j++) {
if (startsWith(a[j], indent_str)) {
a[j] = a[j].substr(indent_str.length);
}
}
}
}
// now merge everything to construct the template result:
var rv = [];
for (var _len = arguments.length, values = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
values[_key - 1] = arguments[_key];
}
for (var i = 0, len = values.length; i < len; i++) {
rv.push(src[i].join('\n'));
rv.push(values[i]);
}
// the last value is always followed by a last template string partial:
rv.push(src[i].join('\n'));
var sv = rv.join('');
return sv;
}
// Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'`
/** @public */
function camelCase(s) {
// Convert first character to lowercase
return s.replace(/^\w/, function (match) {
return match.toLowerCase();
}).replace(/-\w/g, function (match) {
var c = match.charAt(1);
var rv = c.toUpperCase();
// do not mutate 'a-2' to 'a2':
Iif (c === rv && c.match(/\d/)) {
return match;
}
return rv;
});
}
// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers
/** @public */
function mkIdentifier$1(s) {
s = camelCase('' + s);
// cleanup: replace any non-suitable character series to a single underscore:
return s.replace(/^[^\w_]/, '_')
// do not accept numerics at the leading position, despite those matching regex `\w`:
.replace(/^\d/, '_').replace(/[^\w\d_]+/g, '_')
// and only accept multiple (double, not triple) underscores at start or end of identifier name:
.replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__');
}
// properly quote and escape the given input string
function dquote(s) {
var sq = s.indexOf('\'') >= 0;
var dq = s.indexOf('"') >= 0;
if (sq && dq) {
s = s.replace(/"/g, '\\"');
dq = false;
}
if (dq) {
s = '\'' + s + '\'';
} else {
s = '"' + s + '"';
}
return s;
}
//
// Helper library for safe code execution/compilation, including dumping offending code to file for further error analysis
// (the idea was originally coded in https://github.com/GerHobbelt/jison/commit/85e367d03b977780516d2b643afbe6f65ee758f2 )
//
// MIT Licensed
//
//
// This code is intended to help test and diagnose arbitrary chunks of code, answering questions like this:
//
// the given code fails, but where exactly and why? It's precise failure conditions are 'hidden' due to
// the stuff running inside an `eval()` or `Function(...)` call, so we want the code dumped to file so that
// we can test the code in a different environment so that we can see what precisely is causing the failure.
//
function chkBugger$1(src) {
src = String(src);
if (src.match(/\bcov_\w+/)) {
console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n', src);
}
}
// Helper function: pad number with leading zeroes
function pad(n, p) {
p = p || 2;
var rv = '0000' + n;
return rv.slice(-p);
}
// attempt to dump in one of several locations: first winner is *it*!
function dumpSourceToFile(sourcecode, errname, err_id, options, ex) {
var dumpfile;
try {
var dumpPaths = [options.outfile ? path.dirname(options.outfile) : null, options.inputPath, process.cwd()];
var dumpName = path.basename(options.inputFilename || options.moduleName || (options.outfile ? path.dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever
.replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator.
if (dumpName === '' || dumpName === '_') {
dumpName = '__bugger__';
}
err_id = err_id || 'XXX';
var ts = new Date();
var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z';
dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js';
for (var i = 0, l = dumpPaths.length; i < l; i++) {
if (!dumpPaths[i]) {
continue;
}
try {
dumpfile = path.normalize(dumpPaths[i] + '/' + dumpName);
fs.writeFileSync(dumpfile, sourcecode, 'utf8');
console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile);
break; // abort loop once a dump action was successful!
} catch (ex3) {
//console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack);
if (i === l - 1) {
throw ex3;
}
}
}
} catch (ex2) {
console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack);
}
// augment the exception info, when available:
if (ex) {
ex.offending_source_code = sourcecode;
ex.offending_source_title = errname;
ex.offending_source_dumpfile = dumpfile;
}
}
//
// `code_execution_rig` is a function which gets executed, while it is fed the `sourcecode` as a parameter.
// When the `code_execution_rig` crashes, its failure is caught and (using the `options`) the sourcecode
// is dumped to file for later diagnosis.
//
// Two options drive the internal behaviour:
//
// - options.dumpSourceCodeOnFailure -- default: FALSE
// - options.throwErrorOnCompileFailure -- default: FALSE
//
// Dumpfile naming and path are determined through these options:
//
// - options.outfile
// - options.inputPath
// - options.inputFilename
// - options.moduleName
// - options.defaultModuleName
//
function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) {
options = options || {};
var errname = "" + (title || "exec_test");
var err_id = errname.replace(/[^a-z0-9_]/ig, "_");
Iif (err_id.length === 0) {
err_id = "exec_crash";
}
var debug = 0;
Iif (debug) console.warn('generated ' + errname + ' code under EXEC TEST.');
Iif (debug > 1) console.warn('\n ######################## source code ##########################\n ' + sourcecode + '\n ######################## source code ##########################\n ');
var p;
try {
// p = eval(sourcecode);
Iif (typeof code_execution_rig !== 'function') {
throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function");
}
chkBugger$1(sourcecode);
p = code_execution_rig.call(this, sourcecode, options, errname, debug);
} catch (ex) {
if (debug > 1) console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
if (debug) console.log("generated " + errname + " source code fatal error: ", ex.message);
if (debug > 1) console.log("exec-and-diagnose options:", options);
if (debug > 1) console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
if (options.dumpSourceCodeOnFailure) {
dumpSourceToFile(sourcecode, errname, err_id, options, ex);
}
if (options.throwErrorOnCompileFailure) {
throw ex;
}
}
return p;
}
var code_exec$1 = {
exec: exec_and_diagnose_this_stuff,
dump: dumpSourceToFile
};
//
// Parse a given chunk of code to an AST.
//
// MIT Licensed
//
//
// This code is intended to help test and diagnose arbitrary chunks of code, answering questions like this:
//
// would the given code compile and possibly execute correctly, when included in a lexer, parser or other engine?
//
//import astUtils from '@gerhobbelt/ast-util';
assert$1(recast);
var types = recast.types;
assert$1(types);
var namedTypes = types.namedTypes;
assert$1(namedTypes);
var b = types.builders;
assert$1(b);
// //assert(astUtils);
function parseCodeChunkToAST(src, options) {
// src = src
// .replace(/@/g, '\uFFDA')
// .replace(/#/g, '\uFFDB')
// ;
var ast = recast.parse(src);
return ast;
}
function prettyPrintAST(ast, options) {
var new_src;
var s = recast.prettyPrint(ast, {
tabWidth: 2,
quote: 'single',
arrowParensAlways: true,
// Do not reuse whitespace (or anything else, for that matter)
// when printing generically.
reuseWhitespace: false
});
new_src = s.code;
new_src = new_src.replace(/\r\n|\n|\r/g, '\n') // platform dependent EOL fixup
// // backpatch possible jison variables extant in the prettified code:
// .replace(/\uFFDA/g, '@')
// .replace(/\uFFDB/g, '#')
;
return new_src;
}
// validate the given JavaScript snippet: does it compile?
//
// Return either the parsed AST (object) or an error message (string).
function checkActionBlock$1(src, yylloc) {
// make sure reasonable line numbers, etc. are reported in any
// potential parse errors by pushing the source code down:
Eif (yylloc && yylloc.first_line > 0) {
var cnt = yylloc.first_line;
var lines = new Array(cnt);
src = lines.join('\n') + src;
}
if (!src.trim()) {
return false;
}
try {
var rv = parseCodeChunkToAST(src);
return false;
} catch (ex) {
return ex.message || "code snippet cannot be parsed";
}
}
var parse2AST = {
parseCodeChunkToAST: parseCodeChunkToAST,
prettyPrintAST: prettyPrintAST,
checkActionBlock: checkActionBlock$1
};
function chkBugger$2(src) {
src = String(src);
if (src.match(/\bcov_\w+/)) {
console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n', src);
}
}
/// HELPER FUNCTION: print the function in source code form, properly indented.
/** @public */
function printFunctionSourceCode(f) {
var src = String(f);
chkBugger$2(src);
return src;
}
var funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;
var arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;
/// HELPER FUNCTION: print the function **content** in source code form, properly indented,
/// ergo: produce the code for inlining the function.
///
/// Also supports ES6's Arrow Functions:
///
/// ```
/// function a(x) { return x; } ==> 'return x;'
/// function (x) { return x; } ==> 'return x;'
/// (x) => { return x; } ==> 'return x;'
/// (x) => x; ==> 'return x;'
/// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);'
///
/** @public */
function printFunctionSourceCodeContainer(f) {
var action = printFunctionSourceCode(f).trim();
var args;
// Also cope with Arrow Functions (and inline those as well?).
// See also https://github.com/zaach/jison-lex/issues/23
var m = funcRe.exec(action);
if (m) {
args = m[1].trim();
action = m[2].trim();
} else {
m = arrowFuncRe.exec(action);
Eif (m) {
Iif (m[2]) {
// non-bracketed arguments:
args = m[2].trim();
} else {
// bracketed arguments: may be empty args list!
args = m[1].trim();
}
if (m[5]) {
// non-bracketed version: implicit `return` statement!
//
// Q: Must we make sure we have extra braces around the return value
// to prevent JavaScript from inserting implit EOS (End Of Statement)
// markers when parsing this, when there are newlines in the code?
// A: No, we don't have to as arrow functions rvalues suffer from this
// same problem, hence the arrow function's programmer must already
// have formatted the code correctly.
action = m[4].trim();
action = 'return ' + action + ';';
} else {
action = m[3].trim();
}
} else {
var e = new Error('Cannot extract code from function');
e.subject = action;
throw e;
}
}
return {
args: args,
code: action
};
}
var stringifier = {
printFunctionSourceCode: printFunctionSourceCode,
printFunctionSourceCodeContainer: printFunctionSourceCodeContainer
};
//
//
//
function detectIstanbulGlobal() {
var gcv = "__coverage__";
var globalvar = new Function('return this')();
var coverage = globalvar[gcv];
return coverage || false;
}
var helpers = {
rmCommonWS: rmCommonWS$2,
camelCase: camelCase,
mkIdentifier: mkIdentifier$1,
dquote: dquote,
exec: code_exec$1.exec,
dump: code_exec$1.dump,
parseCodeChunkToAST: parse2AST.parseCodeChunkToAST,
prettyPrintAST: parse2AST.prettyPrintAST,
checkActionBlock: parse2AST.checkActionBlock,
printFunctionSourceCode: stringifier.printFunctionSourceCode,
printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer,
detectIstanbulGlobal: detectIstanbulGlobal
};
/* parser generated by jison 0.6.1-215 */
/*
* Returns a Parser object of the following structure:
*
* Parser: {
* yy: {} The so-called "shared state" or rather the *source* of it;
* the real "shared state" `yy` passed around to
* the rule actions, etc. is a derivative/copy of this one,
* not a direct reference!
* }
*
* Parser.prototype: {
* yy: {},
* EOF: 1,
* TERROR: 2,
*
* trace: function(errorMessage, ...),
*
* JisonParserError: function(msg, hash),
*
* quoteName: function(name),
* Helper function which can be overridden by user code later on: put suitable
* quotes around literal IDs in a description string.
*
* originalQuoteName: function(name),
* The basic quoteName handler provided by JISON.
* `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function
* at the end of the `parse()`.
*
* describeSymbol: function(symbol),
* Return a more-or-less human-readable description of the given symbol, when
* available, or the symbol itself, serving as its own 'description' for lack
* of something better to serve up.
*
* Return NULL when the symbol is unknown to the parser.
*
* symbols_: {associative list: name ==> number},
* terminals_: {associative list: number ==> name},
* nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},
* terminal_descriptions_: (if there are any) {associative list: number ==> description},
* productions_: [...],
*
* performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),
*
* The function parameters and `this` have the following value/meaning:
* - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)
* to store/reference the rule value `$$` and location info `@$`.
*
* One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets
* to see the same object via the `this` reference, i.e. if you wish to carry custom
* data from one reduce action through to the next within a single parse run, then you
* may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.
*
* `this.yy` is a direct reference to the `yy` shared state object.
*
* `%parse-param`-specified additional `parse()` arguments have been added to this `yy`
* object at `parse()` start and are therefore available to the action code via the
* same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from
* the %parse-param` list.
*
* - `yytext` : reference to the lexer value which belongs to the last lexer token used
* to match this rule. This is *not* the look-ahead token, but the last token
* that's actually part of this rule.
*
* Formulated another way, `yytext` is the value of the token immediately preceeding
* the current look-ahead token.
* Caveats apply for rules which don't require look-ahead, such as epsilon rules.
*
* - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.
*
* - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.
*
* - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.
*
* WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead
* of an empty object when no suitable location info can be provided.
*
* - `yystate` : the current parser state number, used internally for dispatching and
* executing the action code chunk matching the rule currently being reduced.
*
* - `yysp` : the current state stack position (a.k.a. 'stack pointer')
*
* This one comes in handy when you are going to do advanced things to the parser
* stacks, all of which are accessible from your action code (see the next entries below).
*
* Also note that you can access this and other stack index values using the new double-hash
* syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things
* related to the first rule term, just like you have `$1`, `@1` and `#1`.
* This is made available to write very advanced grammar action rules, e.g. when you want
* to investigate the parse state stack in your action code, which would, for example,
* be relevant when you wish to implement error diagnostics and reporting schemes similar
* to the work described here:
*
* + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.
* In Journées Francophones des Languages Applicatifs.
*
* + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.
* ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631–640.
*
* - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.
*
* This one comes in handy when you are going to do advanced things to the parser
* stacks, all of which are accessible from your action code (see the next entries below).
*
* - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.
* constructs.
*
* - `yylstack`: reference to the parser token location stack. Also accessed via
* the `@1` etc. constructs.
*
* WARNING: since jison 0.4.18-186 this array MAY contain slots which are
* UNDEFINED rather than an empty (location) object, when the lexer/parser
* action code did not provide a suitable location info object when such a
* slot was filled!
*
* - `yystack` : reference to the parser token id stack. Also accessed via the
* `#1` etc. constructs.
*
* Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to
* its numeric token id value, hence that code wouldn't need the `yystack` but *you* might
* want access this array for your own purposes, such as error analysis as mentioned above!
*
* Note that this stack stores the current stack of *tokens*, that is the sequence of
* already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*
* (lexer tokens *shifted* onto the stack until the rule they belong to is found and
* *reduced*.
*
* - `yysstack`: reference to the parser state stack. This one carries the internal parser
* *states* such as the one in `yystate`, which are used to represent
* the parser state machine in the *parse table*. *Very* *internal* stuff,
* what can I say? If you access this one, you're clearly doing wicked things
*
* - `...` : the extra arguments you specified in the `%parse-param` statement in your
* grammar definition file.
*
* table: [...],
* State transition table
* ----------------------
*
* index levels are:
* - `state` --> hash table
* - `symbol` --> action (number or array)
*
* If the `action` is an array, these are the elements' meaning:
* - index [0]: 1 = shift, 2 = reduce, 3 = accept
* - index [1]: GOTO `state`
*
* If the `action` is a number, it is the GOTO `state`
*
* defaultActions: {...},
*
* parseError: function(str, hash, ExceptionClass),
* yyError: function(str, ...),
* yyRecovering: function(),
* yyErrOk: function(),
* yyClearIn: function(),
*
* constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),
* Helper function **which will be set up during the first invocation of the `parse()` method**.
* Produces a new errorInfo 'hash object' which can be passed into `parseError()`.
* See it's use in this parser kernel in many places; example usage:
*
* var infoObj = parser.constructParseErrorInfo('fail!', null,
* parser.collect_expected_token_set(state), true);
* var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);
*
* originalParseError: function(str, hash, ExceptionClass),
* The basic `parseError` handler provided by JISON.
* `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function
* at the end of the `parse()`.
*
* options: { ... parser %options ... },
*
* parse: function(input[, args...]),
* Parse the given `input` and return the parsed value (or `true` when none was provided by
* the root action, in which case the parser is acting as a *matcher*).
* You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:
* these extra `args...` are added verbatim to the `yy` object reference as member variables.
*
* WARNING:
* Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with
* any attributes already added to `yy` by the jison run-time;
* when such a collision is detected an exception is thrown to prevent the generated run-time
* from silently accepting this confusing and potentially hazardous situation!
*
* The lexer MAY add its own set of additional parameters (via the `%parse-param` line in
* the lexer section of the grammar spec): these will be inserted in the `yy` shared state
* object and any collision with those will be reported by the lexer via a thrown exception.
*
* cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),
* Helper function **which will be set up during the first invocation of the `parse()` method**.
* This helper API is invoked at the end of the `parse()` call, unless an exception was thrown
* and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY
* be invoked by calling user code to ensure the `post_parse` callbacks are invoked and
* the internal parser gets properly garbage collected under these particular circumstances.
*
* yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),
* Helper function **which will be set up during the first invocation of the `parse()` method**.
* This helper API can be invoked to calculate a spanning `yylloc` location info object.
*
* Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case
* this function will attempt to obtain a suitable location marker by inspecting the location stack
* backwards.
*
* For more info see the documentation comment further below, immediately above this function's
* implementation.
*
* lexer: {
* yy: {...}, A reference to the so-called "shared state" `yy` once
* received via a call to the `.setInput(input, yy)` lexer API.
* EOF: 1,
* ERROR: 2,
* JisonLexerError: function(msg, hash),
* parseError: function(str, hash, ExceptionClass),
* setInput: function(input, [yy]),
* input: function(),
* unput: function(str),
* more: function(),
* reject: function(),
* less: function(n),
* pastInput: function(n),
* upcomingInput: function(n),
* showPosition: function(),
* test_match: function(regex_match_array, rule_index, ...),
* next: function(...),
* lex: function(...),
* begin: function(condition),
* pushState: function(condition),
* popState: function(),
* topState: function(),
* _currentRules: function(),
* stateStackSize: function(),
* cleanupAfterLex: function()
*
* options: { ... lexer %options ... },
*
* performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),
* rules: [...],
* conditions: {associative list: name ==> set},
* }
* }
*
*
* token location info (@$, _$, etc.): {
* first_line: n,
* last_line: n,
* first_column: n,
* last_column: n,
* range: [start_number, end_number]
* (where the numbers are indexes into the input string, zero-based)
* }
*
* ---
*
* The `parseError` function receives a 'hash' object with these members for lexer and
* parser errors:
*
* {
* text: (matched text)
* token: (the produced terminal token, if any)
* token_id: (the produced terminal token numeric ID, if any)
* line: (yylineno)
* loc: (yylloc)
* }
*
* parser (grammar) errors will also provide these additional members:
*
* {
* expected: (array describing the set of expected tokens;
* may be UNDEFINED when we cannot easily produce such a set)
* state: (integer (or array when the table includes grammar collisions);
* represents the current internal state of the parser kernel.
* can, for example, be used to pass to the `collect_expected_token_set()`
* API to obtain the expected token set)
* action: (integer; represents the current internal action which will be executed)
* new_state: (integer; represents the next/planned internal state, once the current
* action has executed)
* recoverable: (boolean: TRUE when the parser MAY have an error recovery rule
* available for this particular error)
* state_stack: (array: the current parser LALR/LR internal state stack; this can be used,
* for instance, for advanced error analysis and reporting)
* value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,
* for instance, for advanced error analysis and reporting)
* location_stack: (array: the current parser LALR/LR internal location stack; this can be used,
* for instance, for advanced error analysis and reporting)
* yy: (object: the current parser internal "shared state" `yy`
* as is also available in the rule actions; this can be used,
* for instance, for advanced error analysis and reporting)
* lexer: (reference to the current lexer instance used by the parser)
* parser: (reference to the current parser instance)
* }
*
* while `this` will reference the current parser instance.
*
* When `parseError` is invoked by the lexer, `this` will still reference the related *parser*
* instance, while these additional `hash` fields will also be provided:
*
* {
* lexer: (reference to the current lexer instance which reported the error)
* }
*
* When `parseError` is invoked by the parser due to a **JavaScript exception** being fired
* from either the parser or lexer, `this` will still reference the related *parser*
* instance, while these additional `hash` fields will also be provided:
*
* {
* exception: (reference to the exception thrown)
* }
*
* Please do note that in the latter situation, the `expected` field will be omitted as
* this type of failure is assumed not to be due to *parse errors* but rather due to user
* action code in either parser or lexer failing unexpectedly.
*
* ---
*
* You can specify parser options by setting / modifying the `.yy` object of your Parser instance.
* These options are available:
*
* ### options which are global for all parser instances
*
* Parser.pre_parse: function(yy)
* optional: you can specify a pre_parse() function in the chunk following
* the grammar, i.e. after the last `%%`.
* Parser.post_parse: function(yy, retval, parseInfo) { return retval; }
* optional: you can specify a post_parse() function in the chunk following
* the grammar, i.e. after the last `%%`. When it does not return any value,
* the parser will return the original `retval`.
*
* ### options which can be set up per parser instance
*
* yy: {
* pre_parse: function(yy)
* optional: is invoked before the parse cycle starts (and before the first
* invocation of `lex()`) but immediately after the invocation of
* `parser.pre_parse()`).
* post_parse: function(yy, retval, parseInfo) { return retval; }
* optional: is invoked when the parse terminates due to success ('accept')
* or failure (even when exceptions are thrown).
* `retval` contains the return value to be produced by `Parser.parse()`;
* this function can override the return value by returning another.
* When it does not return any value, the parser will return the original
* `retval`.
* This function is invoked immediately before `parser.post_parse()`.
*
* parseError: function(str, hash, ExceptionClass)
* optional: overrides the default `parseError` function.
* quoteName: function(name),
* optional: overrides the default `quoteName` function.
* }
*
* parser.lexer.options: {
* pre_lex: function()
* optional: is invoked before the lexer is invoked to produce another token.
* `this` refers to the Lexer object.
* post_lex: function(token) { return token; }
* optional: is invoked when the lexer has produced a token `token`;
* this function can override the returned token value by returning another.
* When it does not return any (truthy) value, the lexer will return
* the original `token`.
* `this` refers to the Lexer object.
*
* ranges: boolean
* optional: `true` ==> token location info will include a .range[] member.
* flex: boolean
* optional: `true` ==> flex-like lexing behaviour where the rules are tested
* exhaustively to find the longest match.
* backtrack_lexer: boolean
* optional: `true` ==> lexer regexes are tested in order and for invoked;
* the lexer terminates the scan when a token is returned by the action code.
* xregexp: boolean
* optional: `true` ==> lexer rule regexes are "extended regex format" requiring the
* `XRegExp` library. When this `%option` has not been specified at compile time, all lexer
* rule regexes have been written as standard JavaScript RegExp expressions.
* }
*/
// See also:
// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility
// with userland code which might access the derived class in a 'classic' way.
function JisonParserError(msg, hash) {
Object.defineProperty(this, 'name', {
enumerable: false,
writable: false,
value: 'JisonParserError'
});
Iif (msg == null) msg = '???';
Object.defineProperty(this, 'message', {
enumerable: false,
writable: true,
value: msg
});
this.hash = hash;
var stacktrace;
Iif (hash && hash.exception instanceof Error) {
var ex2 = hash.exception;
this.message = ex2.message || msg;
stacktrace = ex2.stack;
}
Eif (!stacktrace) {
Eif (Error.hasOwnProperty('captureStackTrace')) {
// V8/Chrome engine
Error.captureStackTrace(this, this.constructor);
} else {
stacktrace = new Error(msg).stack;
}
}
Iif (stacktrace) {
Object.defineProperty(this, 'stack', {
enumerable: false,
writable: false,
value: stacktrace
});
}
}
Eif (typeof Object.setPrototypeOf === 'function') {
Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);
} else {
JisonParserError.prototype = Object.create(Error.prototype);
}
JisonParserError.prototype.constructor = JisonParserError;
JisonParserError.prototype.name = 'JisonParserError';
// helper: reconstruct the productions[] table
function bp(s) {
var rv = [];
var p = s.pop;
var r = s.rule;
for (var i = 0, l = p.length; i < l; i++) {
rv.push([p[i], r[i]]);
}
return rv;
}
// helper: reconstruct the defaultActions[] table
function bda(s) {
var rv = {};
var d = s.idx;
var g = s.goto;
for (var i = 0, l = d.length; i < l; i++) {
var j = d[i];
rv[j] = g[i];
}
return rv;
}
// helper: reconstruct the 'goto' table
function bt(s) {
var rv = [];
var d = s.len;
var y = s.symbol;
var t = s.type;
var a = s.state;
var m = s.mode;
var g = s.goto;
for (var i = 0, l = d.length; i < l; i++) {
var n = d[i];
var q = {};
for (var j = 0; j < n; j++) {
var z = y.shift();
switch (t.shift()) {
case 2:
q[z] = [m.shift(), g.shift()];
break;
case 0:
q[z] = a.shift();
break;
default:
// type === 1: accept
q[z] = [3];
}
}
rv.push(q);
}
return rv;
}
// helper: runlength encoding with increment step: code, length: step (default step = 0)
// `this` references an array
function s(c, l, a) {
a = a || 0;
for (var i = 0; i < l; i++) {
this.push(c);
c += a;
}
}
// helper: duplicate sequence from *relative* offset and length.
// `this` references an array
function c(i, l) {
i = this.length - i;
for (l += i; i < l; i++) {
this.push(this[i]);
}
}
// helper: unpack an array using helpers and data, all passed in an array argument 'a'.
function u(a) {
var rv = [];
for (var i = 0, l = a.length; i < l; i++) {
var e = a[i];
// Is this entry a helper function?
if (typeof e === 'function') {
i++;
e.apply(rv, a[i]);
} else {
rv.push(e);
}
}
return rv;
}
var parser = {
// Code Generator Information Report
// ---------------------------------
//
// Options:
//
// default action mode: ............. ["classic","merge"]
// test-compile action mode: ........ "parser:*,lexer:*"
// try..catch: ...................... true
// default resolve on conflict: ..... true
// on-demand look-ahead: ............ false
// error recovery token skip maximum: 3
// yyerror in parse actions is: ..... NOT recoverable,
// yyerror in lexer actions and other non-fatal lexer are:
// .................................. NOT recoverable,
// debug grammar/output: ............ false
// has partial LR conflict upgrade: true
// rudimentary token-stack support: false
// parser table compression mode: ... 2
// export debug tables: ............. false
// export *all* tables: ............. false
// module type: ..................... es
// parser engine type: .............. lalr
// output main() in the module: ..... true
// has user-specified main(): ....... false
// has user-specified require()/import modules for main():
// .................................. false
// number of expected conflicts: .... 0
//
//
// Parser Analysis flags:
//
// no significant actions (parser is a language matcher only):
// .................................. false
// uses yyleng: ..................... false
// uses yylineno: ................... false
// uses yytext: ..................... false
// uses yylloc: ..................... false
// uses ParseError API: ............. false
// uses YYERROR: .................... true
// uses YYRECOVERING: ............... false
// uses YYERROK: .................... false
// uses YYCLEARIN: .................. false
// tracks rule values: .............. true
// assigns rule values: ............. true
// uses location tracking: .......... true
// assigns location: ................ true
// uses yystack: .................... false
// uses yysstack: ................... false
// uses yysp: ....................... true
// uses yyrulelength: ............... false
// uses yyMergeLocationInfo API: .... true
// has error recovery: .............. true
// has error reporting: ............. true
//
// --------- END OF REPORT -----------
trace: function no_op_trace() {},
JisonParserError: JisonParserError,
yy: {},
options: {
type: "lalr",
hasPartialLrUpgradeOnConflict: true,
errorRecoveryTokenDiscardCount: 3
},
symbols_: {
"$": 17,
"$accept": 0,
"$end": 1,
"%%": 19,
"(": 10,
")": 11,
"*": 7,
"+": 12,
",": 8,
".": 15,
"/": 14,
"/!": 39,
"<": 5,
"=": 18,
">": 6,
"?": 13,
"ACTION": 32,
"ACTION_BODY": 33,
"ACTION_BODY_CPP_COMMENT": 35,
"ACTION_BODY_C_COMMENT": 34,
"ACTION_BODY_WHITESPACE": 36,
"ACTION_END": 31,
"ACTION_START": 28,
"BRACKET_MISSING": 29,
"BRACKET_SURPLUS": 30,
"CHARACTER_LIT": 46,
"CODE": 53,
"EOF": 1,
"ESCAPE_CHAR": 44,
"IMPORT": 24,
"INCLUDE": 51,
"INCLUDE_PLACEMENT_ERROR": 37,
"INIT_CODE": 25,
"NAME": 20,
"NAME_BRACE": 40,
"OPTIONS": 47,
"OPTIONS_END": 48,
"OPTION_STRING_VALUE": 49,
"OPTION_VALUE": 50,
"PATH": 52,
"RANGE_REGEX": 45,
"REGEX_SET": 43,
"REGEX_SET_END": 42,
"REGEX_SET_START": 41,
"SPECIAL_GROUP": 38,
"START_COND": 27,
"START_EXC": 22,
"START_INC": 21,
"STRING_LIT": 26,
"UNKNOWN_DECL": 23,
"^": 16,
"action": 68,
"action_body": 69,
"any_group_regex": 78,
"definition": 58,
"definitions": 57,
"error": 2,
"escape_char": 81,
"extra_lexer_module_code": 87,
"import_name": 60,
"import_path": 61,
"include_macro_code": 88,
"init": 56,
"init_code_name": 59,
"lex": 54,
"module_code_chunk": 89,
"name_expansion": 77,
"name_list": 71,
"names_exclusive": 63,
"names_inclusive": 62,
"nonempty_regex_list": 74,
"option": 86,
"option_list": 85,
"optional_module_code_chunk": 90,
"options": 84,
"range_regex": 82,
"regex": 72,
"regex_base": 76,
"regex_concat": 75,
"regex_list": 73,
"regex_set": 79,
"regex_set_atom": 80,
"rule": 67,
"rule_block": 66,
"rules": 64,
"rules_and_epilogue": 55,
"rules_collective": 65,
"start_conditions": 70,
"string": 83,
"{": 3,
"|": 9,
"}": 4
},
terminals_: {
1: "EOF",
2: "error",
3: "{",
4: "}",
5: "<",
6: ">",
7: "*",
8: ",",
9: "|",
10: "(",
11: ")",
12: "+",
13: "?",
14: "/",
15: ".",
16: "^",
17: "$",
18: "=",
19: "%%",
20: "NAME",
21: "START_INC",
22: "START_EXC",
23: "UNKNOWN_DECL",
24: "IMPORT",
25: "INIT_CODE",
26: "STRING_LIT",
27: "START_COND",
28: "ACTION_START",
29: "BRACKET_MISSING",
30: "BRACKET_SURPLUS",
31: "ACTION_END",
32: "ACTION",
33: "ACTION_BODY",
34: "ACTION_BODY_C_COMMENT",
35: "ACTION_BODY_CPP_COMMENT",
36: "ACTION_BODY_WHITESPACE",
37: "INCLUDE_PLACEMENT_ERROR",
38: "SPECIAL_GROUP",
39: "/!",
40: "NAME_BRACE",
41: "REGEX_SET_START",
42: "REGEX_SET_END",
43: "REGEX_SET",
44: "ESCAPE_CHAR",
45: "RANGE_REGEX",
46: "CHARACTER_LIT",
47: "OPTIONS",
48: "OPTIONS_END",
49: "OPTION_STRING_VALUE",
50: "OPTION_VALUE",
51: "INCLUDE",
52: "PATH",
53: "CODE"
},
TERROR: 2,
EOF: 1,
// internals: defined here so the object *structure* doesn't get modified by parse() et al,
// thus helping JIT compilers like Chrome V8.
originalQuoteName: null,
originalParseError: null,
cleanupAfterParse: null,
constructParseErrorInfo: null,
yyMergeLocationInfo: null,
__reentrant_call_depth: 0, // INTERNAL USE ONLY
__error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup
__error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup
// APIs which will be set up depending on user action code analysis:
//yyRecovering: 0,
//yyErrOk: 0,
//yyClearIn: 0,
// Helper APIs
// -----------
// Helper function which can be overridden by user code later on: put suitable quotes around
// literal IDs in a description string.
quoteName: function parser_quoteName(id_str) {
return '"' + id_str + '"';
},
// Return the name of the given symbol (terminal or non-terminal) as a string, when available.
//
// Return NULL when the symbol is unknown to the parser.
getSymbolName: function parser_getSymbolName(symbol) {
if (this.terminals_[symbol]) {
return this.terminals_[symbol];
}
// Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.
//
// An example of this may be where a rule's action code contains a call like this:
//
// parser.getSymbolName(#$)
//
// to obtain a human-readable name of the current grammar rule.
var s = this.symbols_;
for (var key in s) {
if (s[key] === symbol) {
return key;
}
}
return null;
},
// Return a more-or-less human-readable description of the given symbol, when available,
// or the symbol itself, serving as its own 'description' for lack of something better to serve up.
//
// Return NULL when the symbol is unknown to the parser.
describeSymbol: function parser_describeSymbol(symbol) {
Iif (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {
return this.terminal_descriptions_[symbol];
} else if (symbol === this.EOF) {
return 'end of input';
}
var id = this.getSymbolName(symbol);
Eif (id) {
return this.quoteName(id);
}
return null;
},
// Produce a (more or less) human-readable list of expected tokens at the point of failure.
//
// The produced list may contain token or token set descriptions instead of the tokens
// themselves to help turning this output into something that easier to read by humans
// unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,
// expected terminals and nonterminals is produced.
//
// The returned list (array) will not contain any duplicate entries.
collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {
var TERROR = this.TERROR;
var tokenset = [];
var check = {};
// Has this (error?) state been outfitted with a custom expectations description text for human consumption?
// If so, use that one instead of the less palatable token set.
Iif (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {
return [this.state_descriptions_[state]];
}
for (var p in this.table[state]) {
p = +p;
if (p !== TERROR) {
var d = do_not_describe ? p : this.describeSymbol(p);
Eif (d && !check[d]) {
tokenset.push(d);
check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.
}
}
}
return tokenset;
},
productions_: bp({
pop: u([54, 54, s, [55, 6], 56, 57, 57, s, [58, 11], 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, s, [65, 4], 66, 66, 67, 67, s, [68, 3], s, [69, 9], s, [70, 4], 71, 71, 72, s, [73, 4], s, [74, 4], 75, 75, s, [76, 17], 77, 78, 78, 79, 79, 80, s, [80, 4, 1], 83, 84, 85, 85, s, [86, 6], 87, 87, 88, 88, s, [89, 3], 90, 90]),
rule: u([s, [4, 3], s, [5, 4, -1], 0, 0, 2, 0, s, [2, 3], s, [1, 3], 3, 3, 2, 3, 3, s, [1, 7], 2, 1, 2, c, [23, 3], 4, c, [32, 4], 2, c, [22, 3], 3, s, [2, 8], 0, s, [3, 3], 0, 1, 3, 1, s, [3, 4, -1], c, [21, 3], c, [40, 3], s, [3, 4], s, [2, 5], c, [12, 3], s, [1, 6], c, [16, 3], c, [10, 8], c, [9, 3], s, [3, 4], c, [10, 4], c, [82, 4], 1, 0])
}),
performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yysp, yyvstack, yylstack) {
/* this == yyval */
// the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!
var yy = this.yy;
var yyparser = yy.parser;
var yylexer = yy.lexer;
switch (yystate) {
case 0:
/*! Production:: $accept : lex $end */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 1];
this._$ = yylstack[yysp - 1];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-)
break;
case 1:
/*! Production:: lex : init definitions rules_and_epilogue EOF */
// default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp);
// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1];
for (var key in yyvstack[yysp - 2]) {
this.$[key] = yyvstack[yysp - 2][key];
}
// if there are any options, add them all, otherwise set options to NULL:
// can't check for 'empty object' by `if (yy.options) ...` so we do it this way:
for (key in yy.options) {
this.$.options = yy.options;
break;
}
Eif (yy.actionInclude) {
var asrc = yy.actionInclude.join('\n\n');
// Only a non-empty action code chunk should actually make it through:
if (asrc.trim() !== '') {
this.$.actionInclude = asrc;
}
}
delete yy.options;
delete yy.actionInclude;
return this.$;
break;
case 2:
/*! Production:: lex : init definitions error EOF */
// default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 3];
this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp);
// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp - 1].errStr));
break;
case 3:
/*! Production:: rules_and_epilogue : "%%" rules "%%" extra_lexer_module_code */
// default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp);
// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-)
Iif (yyvstack[yysp].trim() !== '') {
this.$ = { rules: yyvstack[yysp - 2], moduleInclude: yyvstack[yysp] };
} else {
this.$ = { rules: yyvstack[yysp - 2] };
}
break;
case 4:
/*! Production:: rules_and_epilogue : "%%" error rules "%%" extra_lexer_module_code */
// default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 4];
this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp);
// END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject2, yylexer.prettyPrintRange(yylstack[yysp - 3]), yyvstack[yysp - 3].errStr));
break;
case 5:
/*! Production:: rules_and_epilogue : "%%" rules "%%" error */
// default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 3];
this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp);
// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject3, yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr));
break;
case 6:
/*! Production:: rules_and_epilogue : "%%" error rules */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject2, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp - 1].errStr));
break;
case 7:
/*! Production:: rules_and_epilogue : "%%" rules */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = { rules: yyvstack[yysp] };
break;
case 8:
/*! Production:: rules_and_epilogue : %epsilon */
// default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);
// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-)
this.$ = { rules: [] };
break;
case 9:
/*! Production:: init : %epsilon */
// default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-):
this.$ = undefined;
this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);
// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-)
yy.actionInclude = [];
Eif (!yy.options) yy.options = {};
break;
case 10:
/*! Production:: definitions : definitions definition */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1];
if (yyvstack[yysp] != null) {
if ('length' in yyvstack[yysp]) {
this.$.macros[yyvstack[yysp][0]] = yyvstack[yysp][1];
} else {
switch (yyvstack[yysp].type) {
case 'names':
for (var name in yyvstack[yysp].names) {
this.$.startConditions[name] = yyvstack[yysp].names[name];
}
break;
case 'unknown':
this.$.unknownDecls.push(yyvstack[yysp].body);
break;
case 'imports':
this.$.importDecls.push(yyvstack[yysp].body);
break;
case 'codeSection':
this.$.codeSections.push(yyvstack[yysp].body);
break;
default:
yyparser.yyError(rmCommonWS$1(_templateObject4, yyvstack[yysp].type, yylexer.prettyPrintRange(yylstack[yysp])));
break;
}
}
}
break;
case 11:
/*! Production:: definitions : %epsilon */
// default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);
// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-)
this.$ = {
macros: {}, // { hash table }
startConditions: {}, // { hash table }
codeSections: [], // [ array of {qualifier,include} pairs ]
importDecls: [], // [ array of {name,path} pairs ]
unknownDecls: [] // [ array of {name,value} pairs ]
};
break;
case 12:
/*! Production:: definition : NAME regex */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = [yyvstack[yysp - 1], yyvstack[yysp]];
break;
case 13:
/*! Production:: definition : START_INC names_inclusive */
case 14:
/*! Production:: definition : START_EXC names_exclusive */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp];
break;
case 15:
/*! Production:: definition : action */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]);
Iif (rv) {
yyparser.yyError(rmCommonWS$1(_templateObject5, rv, yylexer.prettyPrintRange(yylstack[yysp])));
}
yy.actionInclude.push(yyvstack[yysp]);
this.$ = null;
break;
case 16:
/*! Production:: definition : options */
case 102:
/*! Production:: option_list : option */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = null;
break;
case 17:
/*! Production:: definition : UNKNOWN_DECL */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = {
type: 'unknown',
body: yyvstack[yysp]
};
break;
case 18:
/*! Production:: definition : IMPORT import_name import_path */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = {
type: 'imports',
body: {
name: yyvstack[yysp - 1],
path: yyvstack[yysp]
}
};
break;
case 19:
/*! Production:: definition : IMPORT import_name error */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject6, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr));
break;
case 20:
/*! Production:: definition : IMPORT error */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 1];
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject7, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr));
break;
case 21:
/*! Production:: definition : INIT_CODE init_code_name action */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]);
var name = yyvstack[yysp - 1];
var code = yyvstack[yysp];
Iif (rv) {
yyparser.yyError(rmCommonWS$1(_templateObject8, name, rv, code, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])));
}
this.$ = {
type: 'codeSection',
body: {
qualifier: yyvstack[yysp - 1],
include: yyvstack[yysp]
}
};
break;
case 22:
/*! Production:: definition : INIT_CODE error action */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject9, yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]), yyvstack[yysp - 1].errStr));
break;
case 23:
/*! Production:: init_code_name : NAME */
case 24:
/*! Production:: init_code_name : STRING_LIT */
case 25:
/*! Production:: import_name : NAME */
case 26:
/*! Production:: import_name : STRING_LIT */
case 27:
/*! Production:: import_path : NAME */
case 28:
/*! Production:: import_path : STRING_LIT */
case 64:
/*! Production:: regex_list : regex_concat */
case 69:
/*! Production:: nonempty_regex_list : regex_concat */
case 71:
/*! Production:: regex_concat : regex_base */
case 96:
/*! Production:: escape_char : ESCAPE_CHAR */
case 97:
/*! Production:: range_regex : RANGE_REGEX */
case 113:
/*! Production:: module_code_chunk : CODE */
case 116:
/*! Production:: optional_module_code_chunk : module_code_chunk */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp];
break;
case 29:
/*! Production:: names_inclusive : START_COND */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = { type: 'names', names: {} };this.$.names[yyvstack[yysp]] = 0;
break;
case 30:
/*! Production:: names_inclusive : names_inclusive START_COND */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1];this.$.names[yyvstack[yysp]] = 0;
break;
case 31:
/*! Production:: names_exclusive : START_COND */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = { type: 'names', names: {} };this.$.names[yyvstack[yysp]] = 1;
break;
case 32:
/*! Production:: names_exclusive : names_exclusive START_COND */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1];this.$.names[yyvstack[yysp]] = 1;
break;
case 33:
/*! Production:: rules : rules rules_collective */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]);
break;
case 34:
/*! Production:: rules : %epsilon */
case 40:
/*! Production:: rule_block : %epsilon */
// default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);
// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-)
this.$ = [];
break;
case 35:
/*! Production:: rules_collective : start_conditions rule */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
Iif (yyvstack[yysp - 1]) {
yyvstack[yysp].unshift(yyvstack[yysp - 1]);
}
this.$ = [yyvstack[yysp]];
break;
case 36:
/*! Production:: rules_collective : start_conditions "{" rule_block "}" */
// default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp);
// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-)
if (yyvstack[yysp - 3]) {
yyvstack[yysp - 1].forEach(function (d) {
d.unshift(yyvstack[yysp - 3]);
});
}
this.$ = yyvstack[yysp - 1];
break;
case 37:
/*! Production:: rules_collective : start_conditions "{" error "}" */
// default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 3];
this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp);
// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject10, yyvstack[yysp - 3].join(','), yylexer.prettyPrintRange(yylexer.mergeLocationInfo(yysp - 3, yysp), yylstack[yysp - 3]), yyvstack[yysp - 1].errStr));
break;
case 38:
/*! Production:: rules_collective : start_conditions "{" error */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject11, yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr));
break;
case 39:
/*! Production:: rule_block : rule_block rule */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1];this.$.push(yyvstack[yysp]);
break;
case 41:
/*! Production:: rule : regex action */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]);
if (rv) {
yyparser.yyError(rmCommonWS$1(_templateObject12, rv, yylexer.prettyPrintRange(yylstack[yysp])));
}
this.$ = [yyvstack[yysp - 1], yyvstack[yysp]];
break;
case 42:
/*! Production:: rule : regex error */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = [yyvstack[yysp - 1], yyvstack[yysp]];
yyparser.yyError(rmCommonWS$1(_templateObject13, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr));
break;
case 43:
/*! Production:: action : ACTION_START action_body BRACKET_MISSING */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject14, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])));
break;
case 44:
/*! Production:: action : ACTION_START action_body BRACKET_SURPLUS */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject15, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2])));
break;
case 45:
/*! Production:: action : ACTION_START action_body ACTION_END */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
var s = yyvstack[yysp - 1].trim();
// remove outermost set of braces UNLESS there's
// a curly brace in there anywhere: in that case
// we should leave it up to the sophisticated
// code analyzer to simplify the code!
//
// This is a very rough check as it will also look
// inside code comments, which should not have
// any influence.
//
// Nevertheless: this is a *safe* transform!
if (s[0] === '{' && s.indexOf('}') === s.length - 1) {
this.$ = s.substring(1, s.length - 1).trim();
} else {
this.$ = s;
}
break;
case 46:
/*! Production:: action_body : action_body ACTION */
case 51:
/*! Production:: action_body : action_body include_macro_code */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n';
break;
case 47:
/*! Production:: action_body : action_body ACTION_BODY */
case 48:
/*! Production:: action_body : action_body ACTION_BODY_C_COMMENT */
case 49:
/*! Production:: action_body : action_body ACTION_BODY_CPP_COMMENT */
case 50:
/*! Production:: action_body : action_body ACTION_BODY_WHITESPACE */
case 70:
/*! Production:: regex_concat : regex_concat regex_base */
case 82:
/*! Production:: regex_base : regex_base range_regex */
case 92:
/*! Production:: regex_set : regex_set regex_set_atom */
case 114:
/*! Production:: module_code_chunk : module_code_chunk CODE */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1] + yyvstack[yysp];
break;
case 52:
/*! Production:: action_body : action_body INCLUDE_PLACEMENT_ERROR */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 1];
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject16, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])));
break;
case 53:
/*! Production:: action_body : action_body error */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 1];
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject17, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr));
break;
case 54:
/*! Production:: action_body : %epsilon */
case 65:
/*! Production:: regex_list : %epsilon */
case 117:
/*! Production:: optional_module_code_chunk : %epsilon */
// default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);
// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-)
this.$ = '';
break;
case 55:
/*! Production:: start_conditions : "<" name_list ">" */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1];
break;
case 56:
/*! Production:: start_conditions : "<" name_list error */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject18, yyvstack[yysp - 1].join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr));
break;
case 57:
/*! Production:: start_conditions : "<" "*" ">" */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = ['*'];
break;
case 58:
/*! Production:: start_conditions : %epsilon */
// default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-):
this.$ = undefined;
this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);
// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-)
break;
case 59:
/*! Production:: name_list : NAME */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = [yyvstack[yysp]];
break;
case 60:
/*! Production:: name_list : name_list "," NAME */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 2];this.$.push(yyvstack[yysp]);
break;
case 61:
/*! Production:: regex : nonempty_regex_list */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
// Detect if the regex ends with a pure (Unicode) word;
// we *do* consider escaped characters which are 'alphanumeric'
// to be equivalent to their non-escaped version, hence these are
// all valid 'words' for the 'easy keyword rules' option:
//
// - hello_kitty
// - γεια_σου_γατούλα
// - \u03B3\u03B5\u03B9\u03B1_\u03C3\u03BF\u03C5_\u03B3\u03B1\u03C4\u03BF\u03CD\u03BB\u03B1
//
// http://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#12869914
//
// As we only check the *tail*, we also accept these as
// 'easy keywords':
//
// - %options
// - %foo-bar
// - +++a:b:c1
//
// Note the dash in that last example: there the code will consider
// `bar` to be the keyword, which is fine with us as we're only
// interested in the trailing boundary and patching that one for
// the `easy_keyword_rules` option.
this.$ = yyvstack[yysp];
Iif (yy.options.easy_keyword_rules) {
// We need to 'protect' `eval` here as keywords are allowed
// to contain double-quotes and other leading cruft.
// `eval` *does* gobble some escapes (such as `\b`) but
// we protect against that through a simple replace regex:
// we're not interested in the special escapes' exact value
// anyway.
// It will also catch escaped escapes (`\\`), which are not
// word characters either, so no need to worry about
// `eval(str)` 'correctly' converting convoluted constructs
// like '\\\\\\\\\\b' in here.
this.$ = this.$.replace(/\\\\/g, '.').replace(/"/g, '.').replace(/\\c[A-Z]/g, '.').replace(/\\[^xu0-9]/g, '.');
try {
// Convert Unicode escapes and other escapes to their literal characters
// BEFORE we go and check whether this item is subject to the
// `easy_keyword_rules` option.
this.$ = JSON.parse('"' + this.$ + '"');
} catch (ex) {
yyparser.warn('easy-keyword-rule FAIL on eval: ', ex);
// make the next keyword test fail:
this.$ = '.';
}
// a 'keyword' starts with an alphanumeric character,
// followed by zero or more alphanumerics or digits:
var re = new XRegExp('\\w[\\w\\d]*$');
if (XRegExp.match(this.$, re)) {
this.$ = yyvstack[yysp] + "\\b";
} else {
this.$ = yyvstack[yysp];
}
}
break;
case 62:
/*! Production:: regex_list : regex_list "|" regex_concat */
case 66:
/*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp];
break;
case 63:
/*! Production:: regex_list : regex_list "|" */
case 67:
/*! Production:: nonempty_regex_list : nonempty_regex_list "|" */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1] + '|';
break;
case 68:
/*! Production:: nonempty_regex_list : "|" regex_concat */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = '|' + yyvstack[yysp];
break;
case 72:
/*! Production:: regex_base : "(" regex_list ")" */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = '(' + yyvstack[yysp - 1] + ')';
break;
case 73:
/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')';
break;
case 74:
/*! Production:: regex_base : "(" regex_list error */
case 75:
/*! Production:: regex_base : SPECIAL_GROUP regex_list error */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject19, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr));
break;
case 76:
/*! Production:: regex_base : regex_base "+" */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1] + '+';
break;
case 77:
/*! Production:: regex_base : regex_base "*" */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1] + '*';
break;
case 78:
/*! Production:: regex_base : regex_base "?" */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 1] + '?';
break;
case 79:
/*! Production:: regex_base : "/" regex_base */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = '(?=' + yyvstack[yysp] + ')';
break;
case 80:
/*! Production:: regex_base : "/!" regex_base */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = '(?!' + yyvstack[yysp] + ')';
break;
case 81:
/*! Production:: regex_base : name_expansion */
case 83:
/*! Production:: regex_base : any_group_regex */
case 87:
/*! Production:: regex_base : string */
case 88:
/*! Production:: regex_base : escape_char */
case 89:
/*! Production:: name_expansion : NAME_BRACE */
case 93:
/*! Production:: regex_set : regex_set_atom */
case 94:
/*! Production:: regex_set_atom : REGEX_SET */
case 99:
/*! Production:: string : CHARACTER_LIT */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp];
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-)
break;
case 84:
/*! Production:: regex_base : "." */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = '.';
break;
case 85:
/*! Production:: regex_base : "^" */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = '^';
break;
case 86:
/*! Production:: regex_base : "$" */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = '$';
break;
case 90:
/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp];
break;
case 91:
/*! Production:: any_group_regex : REGEX_SET_START regex_set error */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject20, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr));
break;
case 95:
/*! Production:: regex_set_atom : name_expansion */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
if (XRegExp._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) && yyvstack[yysp].toUpperCase() !== yyvstack[yysp]) {
// treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories
this.$ = yyvstack[yysp];
} else {
this.$ = yyvstack[yysp];
}
//yyparser.log("name expansion for: ", { name: $name_expansion, redux: $name_expansion.replace(/[{}]/g, ''), output: $$ });
break;
case 98:
/*! Production:: string : STRING_LIT */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
this.$ = prepareString(yyvstack[yysp]);
break;
case 100:
/*! Production:: options : OPTIONS option_list OPTIONS_END */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
this.$ = null;
break;
case 101:
/*! Production:: option_list : option option_list */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
this.$ = null;
break;
case 103:
/*! Production:: option : NAME */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp];
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-)
yy.options[yyvstack[yysp]] = true;
break;
case 104:
/*! Production:: option : NAME "=" OPTION_STRING_VALUE */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yy.options[yyvstack[yysp - 2]] = yyvstack[yysp];
break;
case 105:
/*! Production:: option : NAME "=" OPTION_VALUE */
case 106:
/*! Production:: option : NAME "=" NAME */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
yy.options[yyvstack[yysp - 2]] = parseValue(yyvstack[yysp]);
break;
case 107:
/*! Production:: option : NAME "=" error */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 2];
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-)
// TODO ...
yyparser.yyError(rmCommonWS$1(_templateObject21, $option, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr));
break;
case 108:
/*! Production:: option : error */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp];
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-)
// TODO ...
yyparser.yyError(rmCommonWS$1(_templateObject22, yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr));
break;
case 109:
/*! Production:: extra_lexer_module_code : optional_module_code_chunk */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-):
this._$ = yylstack[yysp];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-)
var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]);
if (rv) {
yyparser.yyError(rmCommonWS$1(_templateObject23, rv, yylexer.prettyPrintRange(yylstack[yysp])));
}
this.$ = yyvstack[yysp];
break;
case 110:
/*! Production:: extra_lexer_module_code : extra_lexer_module_code include_macro_code optional_module_code_chunk */
// default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp);
// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-)
// Each of the 3 chunks should be parse-able as a JS snippet on its own.
//
// Note: we have already checked the first section in a previous reduction
// of this rule, so we don't need to check that one again!
var rv = checkActionBlock(yyvstack[yysp - 1], yylstack[yysp - 1]);
if (rv) {
yyparser.yyError(rmCommonWS$1(_templateObject24, rv, yylexer.prettyPrintRange(yylstack[yysp - 1])));
}
rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]);
if (rv) {
yyparser.yyError(rmCommonWS$1(_templateObject23, rv, yylexer.prettyPrintRange(yylstack[yysp])));
}
this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp];
break;
case 111:
/*! Production:: include_macro_code : INCLUDE PATH */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-):
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-)
var fileContent = fs.readFileSync(yyvstack[yysp], { encoding: 'utf-8' });
// And no, we don't support nested '%include':
this.$ = '\n// Included by Jison: ' + yyvstack[yysp] + ':\n\n' + fileContent + '\n\n// End Of Include by Jison: ' + yyvstack[yysp] + '\n\n';
break;
case 112:
/*! Production:: include_macro_code : INCLUDE error */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 1];
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-)
yyparser.yyError(rmCommonWS$1(_templateObject25, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr));
break;
case 115:
/*! Production:: module_code_chunk : error CODE */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-):
this.$ = yyvstack[yysp - 1];
this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp);
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-)
// TODO ...
yyparser.yyError(rmCommonWS$1(_templateObject26, yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp - 1].errStr));
break;
case 151:
// === NO_ACTION[1] :: ensures that anyone (but us) using this new state will fail dramatically!
// error recovery reduction action (action generated by jison,
// using the user-specified `%code error_recovery_reduction` %{...%}
// code chunk below.
break;
}
},
table: bt({
len: u([13, 1, 12, 15, 1, 1, 11, 19, 21, 2, 2, s, [11, 3], 4, 4, 12, 4, 1, 1, 19, 18, 11, 12, 18, 29, 30, 22, 22, 17, 17, s, [29, 7], 31, 5, s, [29, 3], s, [12, 4], 4, 11, 3, 3, 2, 2, 1, 1, 12, 1, 5, 4, 3, 7, 17, 23, 3, 19, 30, 29, 30, s, [29, 5], 3, 20, 3, 30, 30, 6, s, [4, 3], 12, 12, s, [11, 6], s, [27, 3], s, [11, 8], 2, 11, 1, 4, c, [55, 3], 3, 3, 17, 16, 3, 3, 1, 3, 7, s, [29, 3], 21, s, [29, 4], 4, 13, 13, s, [3, 4], 6, 3, 3, 23, s, [18, 3], 14, 14, 1, 14, 3, 1, 20, 2, 17, 14, 17, 3]),
symbol: u([1, 2, s, [19, 7, 1], 28, 47, 54, 56, 1, c, [14, 11], 57, c, [12, 11], 55, 58, 68, 84, s, [1, 3], c, [17, 10], 1, 2, 3, 5, 9, 10, s, [14, 4, 1], 19, 26, s, [38, 4, 1], 44, 46, 64, c, [15, 6], c, [14, 7], 72, s, [74, 5, 1], 81, 83, 27, 62, 27, 63, c, [55, 13], c, [11, 20], 2, 20, 26, 60, c, [4, 3], 59, 2, s, [29, 9, 1], 51, 69, 2, 20, 85, 86, s, [1, 3], c, [102, 16], 65, 70, c, [19, 17], 64, c, [85, 13], 9, c, [12, 9], c, [143, 12], c, [141, 6], c, [30, 3], c, [58, 6], s, [20, 7, 1], 28, c, [29, 6], 47, c, [29, 7], 7, s, [9, 9, 1], c, [33, 14], 45, 46, 47, 82, c, [58, 3], 11, c, [80, 11], 73, c, [81, 6], c, [22, 22], c, [121, 12], c, [17, 22], c, [108, 29], c, [29, 199], s, [42, 6, 1], 40, 43, 77, 79, 80, c, [123, 89], c, [19, 7], 27, c, [590, 11], c, [12, 27], c, [611, 3], 61, c, [630, 14], c, [3, 3], 28, 68, 28, 68, 28, 28, c, [634, 11], 88, 48, 2, 20, 48, 85, 86, 2, 18, 20, c, [9, 4], 1, 2, 51, 53, 87, 89, 90, c, [629, 17], 3, c, [750, 13], 67, c, [751, 8], 7, 20, 71, c, [691, 20], c, [632, 23], c, [662, 65], c, [526, 145], 2, 9, 11, c, [788, 15], c, [808, 7], 11, c, [201, 59], 82, 2, 40, 42, 43, 77, 80, c, [6, 4], c, [4, 8], c, [495, 33], c, [11, 59], 3, 4, c, [449, 8], c, [401, 15], c, [27, 54], c, [603, 11], c, [11, 78], 52, c, [182, 11], c, [683, 3], 49, 50, 1, 51, 88, 1, 53, 1, 51, 1, 51, c, [5, 3], 53, c, [647, 17], 2, 4, c, [691, 13], 66, 2, 28, 68, 2, 6, 8, 6, c, [4, 3], c, [740, 8], c, [648, 57], c, [531, 31], c, [528, 13], c, [756, 8], c, [668, 115], c, [568, 5], c, [321, 10], 53, c, [13, 13], c, [1004, 3], c, [3, 9], c, [273, 4], c, [272, 3], c, [328, 5], c, [310, 14], c, [1001, 9], 1, c, [496, 10], c, [27, 7], c, [18, 36], c, [1078, 14], c, [14, 14], 20, c, [15, 14], c, [461, 3], 53, c, [843, 20], c, [480, 3], c, [474, 16], c, [163, 14], c, [505, 18], 6, 8]),
type: u([s, [2, 11], 0, 0, 1, c, [14, 12], c, [26, 13], 0, c, [15, 12], s, [2, 20], c, [32, 14], s, [0, 8], c, [23, 3], c, [57, 32], c, [62, 9], c, [113, 13], c, [67, 4], c, [40, 20], c, [21, 18], c, [96, 36], c, [141, 7], c, [30, 28], c, [221, 43], c, [223, 9], c, [22, 34], c, [17, 34], s, [2, 224], c, [239, 141], c, [139, 19], c, [673, 16], c, [14, 5], c, [180, 13], c, [764, 35], c, [751, 9], c, [98, 19], c, [632, 31], c, [662, 75], c, [511, 151], c, [513, 34], c, [231, 35], c, [821, 238], c, [735, 74], c, [43, 27], c, [740, 39], c, [1202, 78], c, [756, 30], c, [696, 140], c, [1001, 31], c, [461, 114], c, [121, 58]]),
state: u([s, [1, 4, 1], 6, 11, 12, 20, 22, 23, 25, 26, 31, 32, 37, 36, 43, 45, 47, 51, 55, 56, 57, 61, 62, 64, 66, c, [16, 5], 67, c, [5, 4], 71, 73, 74, c, [13, 5], 75, c, [7, 6], 76, c, [5, 4], 77, c, [5, 4], 81, 78, 79, 84, 88, 89, 98, 103, 57, 105, 108, 107, 110, 112, c, [67, 7], 113, 61, 62, 117, c, [60, 11], c, [6, 6], 71, 81, 125, 132, 135, 137, 143, 108, 107, c, [15, 5], 145, c, [32, 5], 108, 146, 148, c, [52, 8], 132, c, [23, 5]]),
mode: u([s, [2, 23], s, [1, 12], c, [24, 13], c, [41, 28], c, [44, 15], c, [89, 27], c, [17, 13], c, [88, 11], c, [64, 34], c, [38, 14], c, [123, 15], c, [92, 12], 1, c, [107, 10], c, [27, 6], c, [72, 23], c, [40, 8], c, [45, 7], c, [15, 13], s, [1, 24], s, [2, 234], c, [236, 98], c, [97, 24], c, [24, 15], c, [374, 20], c, [432, 5], c, [409, 15], c, [585, 9], c, [47, 20], c, [45, 25], c, [36, 14], c, [578, 18], c, [602, 53], c, [459, 145], c, [735, 19], c, [797, 33], c, [29, 25], c, [776, 238], c, [813, 51], c, [289, 5], c, [648, 7], c, [298, 21], c, [738, 18], c, [621, 8], c, [376, 7], c, [651, 22], c, [874, 59], c, [1219, 170], c, [960, 9], c, [947, 23], c, [1151, 89], c, [805, 17], s, [2, 53]]),
goto: u([s, [9, 11], s, [11, 11], 8, 5, s, [7, 4, 1], s, [13, 7, 1], s, [10, 11], 34, 21, s, [34, 16], 24, 27, 29, 33, 34, 35, 40, 28, 30, 38, 39, 42, 41, 44, 46, s, [15, 11], s, [16, 11], s, [17, 11], 48, 49, 50, 52, 53, s, [54, 12], 59, 58, 1, 2, 7, 58, 63, s, [58, 6], 60, s, [58, 7], s, [34, 17], s, [12, 11], 61, 61, 65, s, [61, 9], c, [125, 12], s, [69, 3], c, [15, 5], s, [69, 7], 40, 69, c, [23, 7], 71, 71, c, [3, 3], 71, 68, 70, s, [71, 18], 72, 71, 71, 65, 65, 27, 65, c, [68, 11], c, [15, 15], c, [95, 12], c, [12, 12], s, [81, 29], s, [83, 29], s, [84, 29], s, [85, 29], s, [86, 29], s, [87, 29], s, [88, 29], s, [89, 31], 38, 80, s, [98, 29], s, [99, 29], s, [96, 29], s, [13, 9], 82, 13, 13, s, [29, 12], s, [14, 9], 83, 14, 14, s, [31, 12], 85, 86, 87, s, [20, 11], s, [25, 3], s, [26, 3], 16, 16, 23, 24, 100, s, [90, 8, 1], 99, 101, 102, 59, 58, 102, 103, 104, 103, 103, s, [108, 3], 117, 106, 117, 109, s, [33, 17], 111, c, [684, 13], 114, 115, 6, c, [630, 8], 116, s, [58, 7], s, [67, 3], c, [34, 5], s, [67, 7], 40, 67, c, [42, 6], 67, s, [68, 3], c, [24, 5], s, [68, 7], 40, 68, c, [24, 6], 68, 70, 70, 69, s, [70, 3], c, [7, 3], s, [70, 17], 72, 70, 70, s, [76, 29], s, [77, 29], s, [78, 29], s, [82, 29], s, [97, 29], 119, 120, 118, 64, 64, 27, 64, c, [259, 11], 122, 120, 121, 79, 79, 69, s, [79, 3], 68, 70, s, [79, 18], 72, 79, 79, 80, 80, 69, s, [80, 3], 68, 70, s, [80, 18], 72, 80, 80, 124, 38, 123, 80, s, [93, 4], s, [94, 4], s, [95, 4], s, [30, 12], s, [32, 12], s, [18, 11], s, [19, 11], s, [27, 11], s, [28, 11], s, [21, 11], s, [22, 11], s, [43, 27], s, [44, 27], s, [45, 27], s, [46, 11], s, [47, 11], s, [48, 11], s, [49, 11], s, [50, 11], s, [51, 11], s, [52, 11], s, [53, 11], 127, 126, s, [100, 11], 101, 131, 130, 128, 129, 3, 101, 5, 133, 109, 109, 116, 116, 134, s, [113, 3], s, [35, 17], 136, s, [40, 14], 138, 16, 140, 139, 141, 142, s, [59, 3], 117, 144, 117, 109, s, [66, 3], c, [627, 5], s, [66, 7], 40, 66, c, [434, 6], 66, s, [72, 29], s, [74, 29], 63, 63, 27, 63, c, [508, 11], s, [73, 29], s, [75, 29], s, [90, 29], s, [91, 29], s, [92, 4], s, [111, 13], s, [112, 13], s, [104, 3], s, [105, 3], s, [106, 3], s, [107, 3], c, [259, 4], s, [115, 3], s, [114, 3], 147, c, [949, 13], 38, 38, 149, s, [38, 15], s, [41, 18], s, [42, 18], s, [55, 14], s, [56, 14], 150, s, [57, 14], 4, 101, 133, 62, 62, 27, 62, c, [115, 11], 110, 110, s, [36, 17], s, [39, 14], s, [37, 17], s, [60, 3]])
}),
defaultActions: bda({
idx: u([0, 2, 6, 11, 12, 13, 16, 18, 19, 21, 22, s, [31, 8, 1], 40, 41, s, [42, 4, 2], 49, 50, 53, 54, 59, 61, s, [68, 5, 1], s, [79, 22, 1], 102, 103, 107, 109, 110, 115, 118, 119, s, [121, 11, 1], 133, 134, s, [137, 4, 1], 142, s, [146, 5, 1]]),
goto: u([9, 11, 10, 15, 16, 17, 54, 1, 2, 34, 12, 81, s, [83, 7, 1], 98, 99, 96, 29, 31, 20, 25, 26, 23, 24, 108, 33, 76, 77, 78, 82, 97, 93, 94, 95, 30, 32, 18, 19, 27, 28, 21, 22, s, [43, 11, 1], 100, 101, 109, 113, 35, 59, 72, 74, 73, 75, 90, 91, 92, 111, 112, s, [104, 4, 1], 115, 114, 41, 42, 55, 56, 57, 110, 36, 39, 37, 60])
}),
parseError: function parseError(str, hash, ExceptionClass) {
if (hash.recoverable) {
Eif (typeof this.trace === 'function') {
this.trace(str);
}
hash.destroy(); // destroy... well, *almost*!
} else {
if (typeof this.trace === 'function') {
this.trace(str);
}
Iif (!ExceptionClass) {
ExceptionClass = this.JisonParserError;
}
throw new ExceptionClass(str, hash);
}
},
parse: function parse(input) {
var self = this;
var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)
var sstack = new Array(128); // state stack: stores states (column storage)
var vstack = new Array(128); // semantic value stack
var lstack = new Array(128); // location stack
var table = this.table;
var sp = 0; // 'stack pointer': index into the stacks
var yyloc;
var symbol = 0;
var preErrorSymbol = 0;
var lastEofErrorStateDepth = Infinity;
var recoveringErrorInfo = null;
var recovering = 0; // (only used when the grammar contains error recovery rules)
var TERROR = this.TERROR;
var EOF = this.EOF;
var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = this.options.errorRecoveryTokenDiscardCount | 0 || 3;
var NO_ACTION = [0, 151 /* === table.length :: ensures that anyone using this new state will fail dramatically! */];
var lexer;
if (this.__lexer__) {
lexer = this.__lexer__;
} else {
lexer = this.__lexer__ = Object.create(this.lexer);
}
var sharedState_yy = {
parseError: undefined,
quoteName: undefined,
lexer: undefined,
parser: undefined,
pre_parse: undefined,
post_parse: undefined,
pre_lex: undefined,
post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes!
};
var ASSERT;
Eif (typeof assert !== 'function') {
ASSERT = function JisonAssert(cond, msg) {
Iif (!cond) {
throw new Error('assertion failed: ' + (msg || '***'));
}
};
} else {
ASSERT = assert;
}
this.yyGetSharedState = function yyGetSharedState() {
return sharedState_yy;
};
this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {
return recoveringErrorInfo;
};
// shallow clone objects, straight copy of simple `src` values
// e.g. `lexer.yytext` MAY be a complex value object,
// rather than a simple string/value.
function shallow_copy(src) {
if ((typeof src === 'undefined' ? 'undefined' : _typeof(src)) === 'object') {
var dst = {};
for (var k in src) {
Eif (Object.prototype.hasOwnProperty.call(src, k)) {
dst[k] = src[k];
}
}
return dst;
}
return src;
}
function shallow_copy_noclobber(dst, src) {
for (var k in src) {
if (typeof dst[k] === 'undefined' && Object.prototype.hasOwnProperty.call(src, k)) {
dst[k] = src[k];
}
}
}
function copy_yylloc(loc) {
var rv = shallow_copy(loc);
if (rv && rv.range) {
rv.range = rv.range.slice(0);
}
return rv;
}
// copy state
shallow_copy_noclobber(sharedState_yy, this.yy);
sharedState_yy.lexer = lexer;
sharedState_yy.parser = this;
// *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount
// to have *their* closure match ours -- if we only set them up once,
// any subsequent `parse()` runs will fail in very obscure ways when
// these functions are invoked in the user action code block(s) as
// their closure will still refer to the `parse()` instance which set
// them up. Hence we MUST set them up at the start of every `parse()` run!
Eif (this.yyError) {
this.yyError = function yyError(str /*, ...args */) {
var error_rule_depth = this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1;
var expected = this.collect_expected_token_set(state);
var hash = this.constructParseErrorInfo(str, null, expected, error_rule_depth >= 0);
// append to the old one?
if (recoveringErrorInfo) {
var esp = recoveringErrorInfo.info_stack_pointer;
recoveringErrorInfo.symbol_stack[esp] = symbol;
var v = this.shallowCopyErrorInfo(hash);
v.yyError = true;
v.errorRuleDepth = error_rule_depth;
v.recovering = recovering;
// v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;
recoveringErrorInfo.value_stack[esp] = v;
recoveringErrorInfo.location_stack[esp] = copy_yylloc(lexer.yylloc);
recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];
++esp;
recoveringErrorInfo.info_stack_pointer = esp;
} else {
recoveringErrorInfo = this.shallowCopyErrorInfo(hash);
recoveringErrorInfo.yyError = true;
recoveringErrorInfo.errorRuleDepth = error_rule_depth;
recoveringErrorInfo.recovering = recovering;
}
// Add any extra args to the hash under the name `extra_error_attributes`:
var args = Array.prototype.slice.call(arguments, 1);
Iif (args.length) {
hash.extra_error_attributes = args;
}
return this.parseError(str, hash, this.JisonParserError);
};
}
// Does the shared state override the default `parseError` that already comes with this instance?
Iif (typeof sharedState_yy.parseError === 'function') {
this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {
if (!ExceptionClass) {
ExceptionClass = this.JisonParserError;
}
return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);
};
} else {
this.parseError = this.originalParseError;
}
// Does the shared state override the default `quoteName` that already comes with this instance?
Iif (typeof sharedState_yy.quoteName === 'function') {
this.quoteName = function quoteNameAlt(id_str) {
return sharedState_yy.quoteName.call(this, id_str);
};
} else {
this.quoteName = this.originalQuoteName;
}
// set up the cleanup function; make it an API so that external code can re-use this one in case of
// calamities or when the `%options no-try-catch` option has been specified for the grammar, in which
// case this parse() API method doesn't come with a `finally { ... }` block any more!
//
// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,
// or else your `sharedState`, etc. references will be *wrong*!
this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {
var rv;
Eif (invoke_post_methods) {
var hash;
Iif (sharedState_yy.post_parse || this.post_parse) {
// create an error hash info instance: we re-use this API in a **non-error situation**
// as this one delivers all parser internals ready for access by userland code.
hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);
}
Iif (sharedState_yy.post_parse) {
rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);
if (typeof rv !== 'undefined') resultValue = rv;
}
Iif (this.post_parse) {
rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);
if (typeof rv !== 'undefined') resultValue = rv;
}
// cleanup:
Iif (hash && hash.destroy) {
hash.destroy();
}
}
Iif (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.
// clean up the lingering lexer structures as well:
Eif (lexer.cleanupAfterLex) {
lexer.cleanupAfterLex(do_not_nuke_errorinfos);
}
// prevent lingering circular references from causing memory leaks:
Eif (sharedState_yy) {
sharedState_yy.lexer = undefined;
sharedState_yy.parser = undefined;
Iif (lexer.yy === sharedState_yy) {
lexer.yy = undefined;
}
}
sharedState_yy = undefined;
this.parseError = this.originalParseError;
this.quoteName = this.originalQuoteName;
// nuke the vstack[] array at least as that one will still reference obsoleted user values.
// To be safe, we nuke the other internal stack columns as well...
stack.length = 0; // fastest way to nuke an array without overly bothering the GC
sstack.length = 0;
lstack.length = 0;
vstack.length = 0;
sp = 0;
// nuke the error hash info instances created during this run.
// Userland code must COPY any data/references
// in the error hash instance(s) it is more permanently interested in.
Iif (!do_not_nuke_errorinfos) {
for (var i = this.__error_infos.length - 1; i >= 0; i--) {
var el = this.__error_infos[i];
if (el && typeof el.destroy === 'function') {
el.destroy();
}
}
this.__error_infos.length = 0;
for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) {
var el = this.__error_recovery_infos[i];
if (el && typeof el.destroy === 'function') {
el.destroy();
}
}
this.__error_recovery_infos.length = 0;
// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,
// hence has been destroyed already: no need to do that *twice*.
if (recoveringErrorInfo) {
recoveringErrorInfo = undefined;
}
}
return resultValue;
};
// merge yylloc info into a new yylloc instance.
//
// `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.
//
// `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which
// case these override the corresponding first/last indexes.
//
// `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search
// through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)
// yylloc info.
//
// Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.
this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {
var i1 = first_index | 0,
i2 = last_index | 0;
var l1 = first_yylloc,
l2 = last_yylloc;
var rv;
// rules:
// - first/last yylloc entries override first/last indexes
if (!l1) {
if (first_index != null) {
for (var i = i1; i <= i2; i++) {
l1 = lstack[i];
if (l1) {
break;
}
}
}
}
if (!l2) {
if (last_index != null) {
for (var i = i2; i >= i1; i--) {
l2 = lstack[i];
if (l2) {
break;
}
}
}
}
// - detect if an epsilon rule is being processed and act accordingly:
if (!l1 && first_index == null) {
// epsilon rule span merger. With optional look-ahead in l2.
Iif (!dont_look_back) {
for (var i = (i1 || sp) - 1; i >= 0; i--) {
l1 = lstack[i];
if (l1) {
break;
}
}
}
Eif (!l1) {
Eif (!l2) {
// when we still don't have any valid yylloc info, we're looking at an epsilon rule
// without look-ahead and no preceding terms and/or `dont_look_back` set:
// in that case we ca do nothing but return NULL/UNDEFINED:
return undefined;
} else {
// shallow-copy L2: after all, we MAY be looking
// at unconventional yylloc info objects...
rv = shallow_copy(l2);
if (rv.range) {
// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:
rv.range = rv.range.slice(0);
}
return rv;
}
} else {
// shallow-copy L1, then adjust first col/row 1 column past the end.
rv = shallow_copy(l1);
rv.first_line = rv.last_line;
rv.first_column = rv.last_column;
if (rv.range) {
// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:
rv.range = rv.range.slice(0);
rv.range[0] = rv.range[1];
}
if (l2) {
// shallow-mixin L2, then adjust last col/row accordingly.
shallow_copy_noclobber(rv, l2);
rv.last_line = l2.last_line;
rv.last_column = l2.last_column;
if (rv.range && l2.range) {
rv.range[1] = l2.range[1];
}
}
return rv;
}
}
Iif (!l1) {
l1 = l2;
l2 = null;
}
Iif (!l1) {
return undefined;
}
// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking
// at unconventional yylloc info objects...
rv = shallow_copy(l1);
// first_line: ...,
// first_column: ...,
// last_line: ...,
// last_column: ...,
Eif (rv.range) {
// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:
rv.range = rv.range.slice(0);
}
Eif (l2) {
shallow_copy_noclobber(rv, l2);
rv.last_line = l2.last_line;
rv.last_column = l2.last_column;
Eif (rv.range && l2.range) {
rv.range[1] = l2.range[1];
}
}
return rv;
};
// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,
// or else your `lexer`, `sharedState`, etc. references will be *wrong*!
this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {
var pei = {
errStr: msg,
exception: ex,
text: lexer.match,
value: lexer.yytext,
token: this.describeSymbol(symbol) || symbol,
token_id: symbol,
line: lexer.yylineno,
loc: copy_yylloc(lexer.yylloc),
expected: expected,
recoverable: recoverable,
state: state,
action: action,
new_state: newState,
symbol_stack: stack,
state_stack: sstack,
value_stack: vstack,
location_stack: lstack,
stack_pointer: sp,
yy: sharedState_yy,
lexer: lexer,
parser: this,
// and make sure the error info doesn't stay due to potential
// ref cycle via userland code manipulations.
// These would otherwise all be memory leak opportunities!
//
// Note that only array and object references are nuked as those
// constitute the set of elements which can produce a cyclic ref.
// The rest of the members is kept intact as they are harmless.
destroy: function destructParseErrorInfo() {
// remove cyclic references added to error info:
// info.yy = null;
// info.lexer = null;
// info.value = null;
// info.value_stack = null;
// ...
var rec = !!this.recoverable;
for (var key in this) {
Iif (this.hasOwnProperty(key) && (typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object') {
this[key] = undefined;
}
}
this.recoverable = rec;
}
};
// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
this.__error_infos.push(pei);
return pei;
};
// clone some parts of the (possibly enhanced!) errorInfo object
// to give them some persistence.
this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {
var rv = shallow_copy(p);
// remove the large parts which can only cause cyclic references
// and are otherwise available from the parser kernel anyway.
delete rv.sharedState_yy;
delete rv.parser;
delete rv.lexer;
// lexer.yytext MAY be a complex value object, rather than a simple string/value:
rv.value = shallow_copy(rv.value);
// yylloc info:
rv.loc = copy_yylloc(rv.loc);
// the 'expected' set won't be modified, so no need to clone it:
//rv.expected = rv.expected.slice(0);
//symbol stack is a simple array:
rv.symbol_stack = rv.symbol_stack.slice(0);
// ditto for state stack:
rv.state_stack = rv.state_stack.slice(0);
// clone the yylloc's in the location stack?:
rv.location_stack = rv.location_stack.map(copy_yylloc);
// and the value stack may carry both simple and complex values:
// shallow-copy the latter.
rv.value_stack = rv.value_stack.map(shallow_copy);
// and we don't bother with the sharedState_yy reference:
//delete rv.yy;
// now we prepare for tracking the COMBINE actions
// in the error recovery code path:
//
// as we want to keep the maximum error info context, we
// *scan* the state stack to find the first *empty* slot.
// This position will surely be AT OR ABOVE the current
// stack pointer, but we want to keep the 'used but discarded'
// part of the parse stacks *intact* as those slots carry
// error context that may be useful when you want to produce
// very detailed error diagnostic reports.
//
// ### Purpose of each stack pointer:
//
// - stack_pointer: points at the top of the parse stack
// **as it existed at the time of the error
// occurrence, i.e. at the time the stack
// snapshot was taken and copied into the
// errorInfo object.**
// - base_pointer: the bottom of the **empty part** of the
// stack, i.e. **the start of the rest of
// the stack space /above/ the existing
// parse stack. This section will be filled
// by the error recovery process as it
// travels the parse state machine to
// arrive at the resolving error recovery rule.**
// - info_stack_pointer:
// this stack pointer points to the **top of
// the error ecovery tracking stack space**, i.e.
// this stack pointer takes up the role of
// the `stack_pointer` for the error recovery
// process. Any mutations in the **parse stack**
// are **copy-appended** to this part of the
// stack space, keeping the bottom part of the
// stack (the 'snapshot' part where the parse
// state at the time of error occurrence was kept)
// intact.
// - root_failure_pointer:
// copy of the `stack_pointer`...
//
for (var i = rv.stack_pointer; typeof rv.state_stack[i] !== 'undefined'; i++) {
// empty
}
rv.base_pointer = i;
rv.info_stack_pointer = i;
rv.root_failure_pointer = rv.stack_pointer;
// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
this.__error_recovery_infos.push(rv);
return rv;
};
function stdLex() {
var token = lexer.lex();
// if token isn't its numeric value, convert
Iif (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token || EOF;
}
function fastLex() {
var token = lexer.fastLex();
// if token isn't its numeric value, convert
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token || EOF;
}
var lex = stdLex;
var state, action, r, t;
var yyval = {
$: true,
_$: undefined,
yy: sharedState_yy
};
var p;
var yyrulelen;
var this_production;
var newState;
var retval = false;
// Return the rule stack depth where the nearest error rule can be found.
// Return -1 when no error recovery rule was found.
function locateNearestErrorRecoveryRule(state) {
var stack_probe = sp - 1;
var depth = 0;
// try to recover from error
while (stack_probe >= 0) {
// check for error recovery rule in this state
var t = table[state][TERROR] || NO_ACTION;
if (t[0]) {
// We need to make sure we're not cycling forever:
// once we hit EOF, even when we `yyerrok()` an error, we must
// prevent the core from running forever,
// e.g. when parent rules are still expecting certain input to
// follow after this, for example when you handle an error inside a set
// of braces which are matched by a parent rule in your grammar.
//
// Hence we require that every error handling/recovery attempt
// *after we've hit EOF* has a diminishing state stack: this means
// we will ultimately have unwound the state stack entirely and thus
// terminate the parse in a controlled fashion even when we have
// very complex error/recovery code interplay in the core + user
// action code blocks:
Iif (symbol === EOF) {
if (lastEofErrorStateDepth > sp - 1 - depth) {
lastEofErrorStateDepth = sp - 1 - depth;
} else {
--stack_probe; // popStack(1): [symbol, action]
state = sstack[stack_probe];
++depth;
continue;
}
}
return depth;
}
Iif (state === 0 /* $accept rule */ || stack_probe < 1) {
return -1; // No suitable error recovery rule available.
}
--stack_probe; // popStack(1): [symbol, action]
state = sstack[stack_probe];
++depth;
}
return -1; // No suitable error recovery rule available.
}
try {
this.__reentrant_call_depth++;
lexer.setInput(input, sharedState_yy);
// NOTE: we *assume* no lexer pre/post handlers are set up *after*
// this initial `setInput()` call: hence we can now check and decide
// whether we'll go with the standard, slower, lex() API or the
// `fast_lex()` one:
Eif (typeof lexer.canIUse === 'function') {
var lexerInfo = lexer.canIUse();
Iif (lexerInfo.fastLex && typeof fastLex === 'function') {
lex = fastLex;
}
}
yyloc = lexer.yylloc;
lstack[sp] = yyloc;
vstack[sp] = null;
sstack[sp] = 0;
stack[sp] = 0;
++sp;
Eif (this.pre_parse) {
this.pre_parse.call(this, sharedState_yy);
}
Eif (sharedState_yy.pre_parse) {
sharedState_yy.pre_parse.call(this, sharedState_yy);
}
newState = sstack[sp - 1];
for (;;) {
// retrieve state number from top of stack
state = newState; // sstack[sp - 1];
// use default actions if available
if (this.defaultActions[state]) {
action = 2;
newState = this.defaultActions[state];
} else {
// The single `==` condition below covers both these `===` comparisons in a single
// operation:
//
// if (symbol === null || typeof symbol === 'undefined') ...
if (!symbol) {
symbol = lex();
}
// read action for current state and first input
t = table[state] && table[state][symbol] || NO_ACTION;
newState = t[1];
action = t[0];
// handle parse error
if (!action) {
// first see if there's any chance at hitting an error recovery rule:
var error_rule_depth = locateNearestErrorRecoveryRule(state);
var errStr = null;
var errSymbolDescr = this.describeSymbol(symbol) || symbol;
var expected = this.collect_expected_token_set(state);
if (!recovering) {
// Report error
Eif (typeof lexer.yylineno === 'number') {
errStr = 'Parse error on line ' + (lexer.yylineno + 1) + ': ';
} else {
errStr = 'Parse error: ';
}
Eif (typeof lexer.showPosition === 'function') {
errStr += '\n' + lexer.showPosition(79 - 10, 10) + '\n';
}
Eif (expected.length) {
errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;
} else {
errStr += 'Unexpected ' + errSymbolDescr;
}
p = this.constructParseErrorInfo(errStr, null, expected, error_rule_depth >= 0);
// DO NOT cleanup the old one before we start the new error info track:
// the old one will *linger* on the error stack and stay alive until we
// invoke the parser's cleanup API!
recoveringErrorInfo = this.shallowCopyErrorInfo(p);
r = this.parseError(p.errStr, p, this.JisonParserError);
Iif (typeof r !== 'undefined') {
retval = r;
break;
}
// Protect against overly blunt userland `parseError` code which *sets*
// the `recoverable` flag without properly checking first:
// we always terminate the parse when there's no recovery rule available anyhow!
Iif (!p.recoverable || error_rule_depth < 0) {
break;
} else {
// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...
}
}
var esp = recoveringErrorInfo.info_stack_pointer;
// just recovered from another error
if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {
// SHIFT current lookahead and grab another
recoveringErrorInfo.symbol_stack[esp] = symbol;
recoveringErrorInfo.value_stack[esp] = shallow_copy(lexer.yytext);
recoveringErrorInfo.location_stack[esp] = copy_yylloc(lexer.yylloc);
recoveringErrorInfo.state_stack[esp] = newState; // push state
++esp;
// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:
yyloc = lexer.yylloc;
preErrorSymbol = 0;
symbol = lex();
}
// try to recover from error
Iif (error_rule_depth < 0) {
ASSERT(recovering > 0, "line 897");
recoveringErrorInfo.info_stack_pointer = esp;
// barf a fatal hairball when we're out of look-ahead symbols and none hit a match
// while we are still busy recovering from another error:
var po = this.__error_infos[this.__error_infos.length - 1];
// Report error
if (typeof lexer.yylineno === 'number') {
errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';
} else {
errStr = 'Parsing halted while starting to recover from another error';
}
if (po) {
errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;
} else {
errStr += ': ';
}
if (typeof lexer.showPosition === 'function') {
errStr += '\n' + lexer.showPosition(79 - 10, 10) + '\n';
}
if (expected.length) {
errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;
} else {
errStr += 'Unexpected ' + errSymbolDescr;
}
p = this.constructParseErrorInfo(errStr, null, expected, false);
if (po) {
p.extra_error_attributes = po;
}
r = this.parseError(p.errStr, p, this.JisonParserError);
if (typeof r !== 'undefined') {
retval = r;
}
break;
}
preErrorSymbol = symbol === TERROR ? 0 : symbol; // save the lookahead token
symbol = TERROR; // insert generic error symbol as new lookahead
var EXTRA_STACK_SAMPLE_DEPTH = 3;
// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:
recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;
if (errStr) {
recoveringErrorInfo.value_stack[esp] = {
yytext: shallow_copy(lexer.yytext),
errorRuleDepth: error_rule_depth,
errStr: errStr,
errorSymbolDescr: errSymbolDescr,
expectedStr: expected,
stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH
};
} else {
recoveringErrorInfo.value_stack[esp] = {
yytext: shallow_copy(lexer.yytext),
errorRuleDepth: error_rule_depth,
stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH
};
}
recoveringErrorInfo.location_stack[esp] = copy_yylloc(lexer.yylloc);
recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];
++esp;
recoveringErrorInfo.info_stack_pointer = esp;
yyval.$ = recoveringErrorInfo;
yyval._$ = undefined;
yyrulelen = error_rule_depth;
r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack);
Iif (typeof r !== 'undefined') {
retval = r;
break;
}
// pop off stack
sp -= yyrulelen;
// and move the top entries + discarded part of the parse stacks onto the error info stack:
for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {
recoveringErrorInfo.symbol_stack[esp] = stack[idx];
recoveringErrorInfo.value_stack[esp] = shallow_copy(vstack[idx]);
recoveringErrorInfo.location_stack[esp] = copy_yylloc(lstack[idx]);
recoveringErrorInfo.state_stack[esp] = sstack[idx];
}
recoveringErrorInfo.symbol_stack[esp] = TERROR;
recoveringErrorInfo.value_stack[esp] = shallow_copy(yyval.$);
recoveringErrorInfo.location_stack[esp] = copy_yylloc(yyval._$);
// goto new state = table[STATE][NONTERMINAL]
newState = sstack[sp - 1];
Iif (this.defaultActions[newState]) {
recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];
} else {
t = table[newState] && table[newState][symbol] || NO_ACTION;
recoveringErrorInfo.state_stack[esp] = t[1];
}
++esp;
recoveringErrorInfo.info_stack_pointer = esp;
// allow N (default: 3) real symbols to be shifted before reporting a new error
recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;
// Now duplicate the standard parse machine here, at least its initial
// couple of rounds until the TERROR symbol is **pushed onto the parse stack**,
// as we wish to push something special then!
//
// Run the state machine in this copy of the parser state machine
// until we *either* consume the error symbol (and its related information)
// *or* we run into another error while recovering from this one
// *or* we execute a `reduce` action which outputs a final parse
// result (yes, that MAY happen!).
//
// We stay in this secondary parse loop until we have completed
// the *error recovery phase* as the main parse loop (further below)
// is optimized for regular parse operation and DOES NOT cope with
// error recovery *at all*.
//
// We call the secondary parse loop just below the "slow parse loop",
// while the main parse loop, which is an almost-duplicate of this one,
// yet optimized for regular parse operation, is called the "fast
// parse loop".
//
// Compare this to `bison` & (vanilla) `jison`, both of which have
// only a single parse loop, which handles everything. Our goal is
// to eke out every drop of performance in the main parse loop...
ASSERT(recoveringErrorInfo, "line 1049");
ASSERT(symbol === TERROR, "line 1050");
ASSERT(!action, "line 1051");
var errorSymbolFromParser = true;
for (;;) {
// retrieve state number from top of stack
state = newState; // sstack[sp - 1];
// use default actions if available
if (this.defaultActions[state]) {
action = 2;
newState = this.defaultActions[state];
} else {
// The single `==` condition below covers both these `===` comparisons in a single
// operation:
//
// if (symbol === null || typeof symbol === 'undefined') ...
if (!symbol) {
symbol = lex();
// **Warning: Edge Case**: the *lexer* may produce
// TERROR tokens of its own volition: *those* TERROR
// tokens should be treated like *regular tokens*
// i.e. tokens which have a lexer-provided `yyvalue`
// and `yylloc`:
errorSymbolFromParser = false;
}
// read action for current state and first input
t = table[state] && table[state][symbol] || NO_ACTION;
newState = t[1];
action = t[0];
// encountered another parse error? If so, break out to main loop
// and take it from there!
if (!action) {
ASSERT(recoveringErrorInfo, "line 1087");
// Prep state variables so that upon breaking out of
// this "slow parse loop" and hitting the `continue;`
// statement in the outer "fast parse loop" we redo
// the exact same state table lookup as the one above
// so that the outer=main loop will also correctly
// detect the 'parse error' state (`!action`) we have
// just encountered above.
newState = state;
break;
}
}
switch (action) {
// catch misc. parse failures:
default:
// this shouldn't happen, unless resolve defaults are off
//
// SILENTLY SIGNAL that the outer "fast parse loop" should
// take care of this internal error condition:
// prevent useless code duplication now/here.
break;
// shift:
case 1:
stack[sp] = symbol;
// ### Note/Warning ###
//
// The *lexer* may also produce TERROR tokens on its own,
// so we specifically test for the TERROR we did set up
// in the error recovery logic further above!
Eif (symbol === TERROR && errorSymbolFromParser) {
// Push a special value onto the stack when we're
// shifting the `error` symbol that is related to the
// error we're recovering from.
ASSERT(recoveringErrorInfo, "line 1131");
vstack[sp] = recoveringErrorInfo;
lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);
} else {
ASSERT(symbol !== 0, "line 1135");
ASSERT(preErrorSymbol === 0, "line 1136");
vstack[sp] = lexer.yytext;
lstack[sp] = copy_yylloc(lexer.yylloc);
}
sstack[sp] = newState; // push state
++sp;
symbol = 0;
// **Warning: Edge Case**: the *lexer* may have produced
// TERROR tokens of its own volition: *those* TERROR
// tokens should be treated like *regular tokens*
// i.e. tokens which have a lexer-provided `yyvalue`
// and `yylloc`:
errorSymbolFromParser = false;
Iif (!preErrorSymbol) {
// normal execution / no error
// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:
yyloc = lexer.yylloc;
if (recovering > 0) {
recovering--;
}
} else {
// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:
ASSERT(recovering > 0, "line 1163");
symbol = preErrorSymbol;
preErrorSymbol = 0;
// read action for current state and first input
t = table[newState] && table[newState][symbol] || NO_ACTION;
Eif (!t[0] || symbol === TERROR) {
// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where
// (simple) stuff might have been missing before the token which caused the error we're
// recovering from now...
//
// Also check if the LookAhead symbol isn't the ERROR token we set as part of the error
// recovery, for then this we would we idling (cycling) on the error forever.
// Yes, this does not take into account the possibility that the *lexer* may have
// produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!
symbol = 0;
}
}
// once we have pushed the special ERROR token value,
// we REMAIN in this inner, "slow parse loop" until
// the entire error recovery phase has completed.
//
// ### Note About Edge Case ###
//
// Userland action code MAY already have 'reset' the
// error recovery phase marker `recovering` to ZERO(0)
// while the error symbol hasn't been shifted onto
// the stack yet. Hence we only exit this "slow parse loop"
// when *both* conditions are met!
ASSERT(preErrorSymbol === 0, "line 1194");
Iif (recovering === 0) {
break;
}
continue;
// reduce:
case 2:
this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...
yyrulelen = this_production[1];
r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack);
Iif (typeof r !== 'undefined') {
// signal end of error recovery loop AND end of outer parse loop
action = 3;
sp = -2; // magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value.
retval = r;
break;
}
// pop off stack
sp -= yyrulelen;
// don't overwrite the `symbol` variable: use a local var to speed things up:
var ntsymbol = this_production[0]; // push nonterminal (reduce)
stack[sp] = ntsymbol;
vstack[sp] = yyval.$;
lstack[sp] = yyval._$;
// goto new state = table[STATE][NONTERMINAL]
newState = table[sstack[sp - 1]][ntsymbol];
sstack[sp] = newState;
++sp;
continue;
// accept:
case 3:
retval = true;
// Return the `$accept` rule's `$$` result, if available.
//
// Also note that JISON always adds this top-most `$accept` rule (with implicit,
// default, action):
//
// $accept: <startSymbol> $end
// %{ $$ = $1; @$ = @1; %}
//
// which, combined with the parse kernel's `$accept` state behaviour coded below,
// will produce the `$$` value output of the <startSymbol> rule as the parse result,
// IFF that result is *not* `undefined`. (See also the parser kernel code.)
//
// In code:
//
// %{
// @$ = @1; // if location tracking support is included
// if (typeof $1 !== 'undefined')
// return $1;
// else
// return true; // the default parse result if the rule actions don't produce anything
// %}
sp--;
if (sp >= 0 && typeof vstack[sp] !== 'undefined') {
retval = vstack[sp];
}
sp = -2; // magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value.
break;
}
// break out of loop: we accept or fail with error
break;
}
// should we also break out of the regular/outer parse loop,
// i.e. did the parser already produce a parse result in here?!
// *or* did we hit an unsupported parse state, to be handled
// in the `switch/default` code further below?
ASSERT(action !== 2, "line 1272");
Eif (!action || action === 1) {
continue;
}
}
}
switch (action) {
// catch misc. parse failures:
default:
// this shouldn't happen, unless resolve defaults are off
if (action instanceof Array) {
p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);
r = this.parseError(p.errStr, p, this.JisonParserError);
if (typeof r !== 'undefined') {
retval = r;
}
break;
}
// Another case of better safe than sorry: in case state transitions come out of another error recovery process
// or a buggy LUT (LookUp Table):
p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);
r = this.parseError(p.errStr, p, this.JisonParserError);
if (typeof r !== 'undefined') {
retval = r;
}
break;
// shift:
case 1:
stack[sp] = symbol;
vstack[sp] = lexer.yytext;
lstack[sp] = copy_yylloc(lexer.yylloc);
sstack[sp] = newState; // push state
++sp;
symbol = 0;
ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error
ASSERT(recovering === 0, "line 1353"); // normal execution / no error
// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:
yyloc = lexer.yylloc;
continue;
// reduce:
case 2:
ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error
ASSERT(recovering === 0, "line 1365"); // normal execution / no error
this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...
yyrulelen = this_production[1];
r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack);
if (typeof r !== 'undefined') {
retval = r;
break;
}
// pop off stack
sp -= yyrulelen;
// don't overwrite the `symbol` variable: use a local var to speed things up:
var ntsymbol = this_production[0]; // push nonterminal (reduce)
stack[sp] = ntsymbol;
vstack[sp] = yyval.$;
lstack[sp] = yyval._$;
// goto new state = table[STATE][NONTERMINAL]
newState = table[sstack[sp - 1]][ntsymbol];
sstack[sp] = newState;
++sp;
continue;
// accept:
case 3:
if (sp !== -2) {
retval = true;
// Return the `$accept` rule's `$$` result, if available.
//
// Also note that JISON always adds this top-most `$accept` rule (with implicit,
// default, action):
//
// $accept: <startSymbol> $end
// %{ $$ = $1; @$ = @1; %}
//
// which, combined with the parse kernel's `$accept` state behaviour coded below,
// will produce the `$$` value output of the <startSymbol> rule as the parse result,
// IFF that result is *not* `undefined`. (See also the parser kernel code.)
//
// In code:
//
// %{
// @$ = @1; // if location tracking support is included
// if (typeof $1 !== 'undefined')
// return $1;
// else
// return true; // the default parse result if the rule actions don't produce anything
// %}
sp--;
if (typeof vstack[sp] !== 'undefined') {
retval = vstack[sp];
}
}
break;
}
// break out of loop: we accept or fail with error
break;
}
} catch (ex) {
// report exceptions through the parseError callback too, but keep the exception intact
// if it is a known parser or lexer error which has been thrown by parseError() already:
if (ex instanceof this.JisonParserError) {
throw ex;
} else Eif (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {
throw ex;
}
p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);
retval = false;
r = this.parseError(p.errStr, p, this.JisonParserError);
if (typeof r !== 'undefined') {
retval = r;
}
} finally {
retval = this.cleanupAfterParse(retval, true, true);
this.__reentrant_call_depth--;
} // /finally
return retval;
},
yyError: 1
};
parser.originalParseError = parser.parseError;
parser.originalQuoteName = parser.quoteName;
/* lexer generated by jison-lex 0.6.1-215 */
/*
* Returns a Lexer object of the following structure:
*
* Lexer: {
* yy: {} The so-called "shared state" or rather the *source* of it;
* the real "shared state" `yy` passed around to
* the rule actions, etc. is a direct reference!
*
* This "shared context" object was passed to the lexer by way of
* the `lexer.setInput(str, yy)` API before you may use it.
*
* This "shared context" object is passed to the lexer action code in `performAction()`
* so userland code in the lexer actions may communicate with the outside world
* and/or other lexer rules' actions in more or less complex ways.
*
* }
*
* Lexer.prototype: {
* EOF: 1,
* ERROR: 2,
*
* yy: The overall "shared context" object reference.
*
* JisonLexerError: function(msg, hash),
*
* performAction: function lexer__performAction(yy, yyrulenumber, YY_START),
*
* The function parameters and `this` have the following value/meaning:
* - `this` : reference to the `lexer` instance.
* `yy_` is an alias for `this` lexer instance reference used internally.
*
* - `yy` : a reference to the `yy` "shared state" object which was passed to the lexer
* by way of the `lexer.setInput(str, yy)` API before.
*
* Note:
* The extra arguments you specified in the `%parse-param` statement in your
* **parser** grammar definition file are passed to the lexer via this object
* reference as member variables.
*
* - `yyrulenumber` : index of the matched lexer rule (regex), used internally.
*
* - `YY_START`: the current lexer "start condition" state.
*
* parseError: function(str, hash, ExceptionClass),
*
* constructLexErrorInfo: function(error_message, is_recoverable),
* Helper function.
* Produces a new errorInfo 'hash object' which can be passed into `parseError()`.
* See it's use in this lexer kernel in many places; example usage:
*
* var infoObj = lexer.constructParseErrorInfo('fail!', true);
* var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);
*
* options: { ... lexer %options ... },
*
* lex: function(),
* Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.
* You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:
* these extra `args...` are added verbatim to the `yy` object reference as member variables.
*
* WARNING:
* Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with
* any attributes already added to `yy` by the **parser** or the jison run-time;
* when such a collision is detected an exception is thrown to prevent the generated run-time
* from silently accepting this confusing and potentially hazardous situation!
*
* cleanupAfterLex: function(do_not_nuke_errorinfos),
* Helper function.
*
* This helper API is invoked when the **parse process** has completed: it is the responsibility
* of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.
*
* This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.
*
* setInput: function(input, [yy]),
*
*
* input: function(),
*
*
* unput: function(str),
*
*
* more: function(),
*
*
* reject: function(),
*
*
* less: function(n),
*
*
* pastInput: function(n),
*
*
* upcomingInput: function(n),
*
*
* showPosition: function(),
*
*
* test_match: function(regex_match_array, rule_index),
*
*
* next: function(),
*
*
* begin: function(condition),
*
*
* pushState: function(condition),
*
*
* popState: function(),
*
*
* topState: function(),
*
*
* _currentRules: function(),
*
*
* stateStackSize: function(),
*
*
* performAction: function(yy, yy_, yyrulenumber, YY_START),
*
*
* rules: [...],
*
*
* conditions: {associative list: name ==> set},
* }
*
*
* token location info (`yylloc`): {
* first_line: n,
* last_line: n,
* first_column: n,
* last_column: n,
* range: [start_number, end_number]
* (where the numbers are indexes into the input string, zero-based)
* }
*
* ---
*
* The `parseError` function receives a 'hash' object with these members for lexer errors:
*
* {
* text: (matched text)
* token: (the produced terminal token, if any)
* token_id: (the produced terminal token numeric ID, if any)
* line: (yylineno)
* loc: (yylloc)
* recoverable: (boolean: TRUE when the parser MAY have an error recovery rule
* available for this particular error)
* yy: (object: the current parser internal "shared state" `yy`
* as is also available in the rule actions; this can be used,
* for instance, for advanced error analysis and reporting)
* lexer: (reference to the current lexer instance used by the parser)
* }
*
* while `this` will reference the current lexer instance.
*
* When `parseError` is invoked by the lexer, the default implementation will
* attempt to invoke `yy.parser.parseError()`; when this callback is not provided
* it will try to invoke `yy.parseError()` instead. When that callback is also not
* provided, a `JisonLexerError` exception will be thrown containing the error
* message and `hash`, as constructed by the `constructLexErrorInfo()` API.
*
* Note that the lexer's `JisonLexerError` error class is passed via the
* `ExceptionClass` argument, which is invoked to construct the exception
* instance to be thrown, so technically `parseError` will throw the object
* produced by the `new ExceptionClass(str, hash)` JavaScript expression.
*
* ---
*
* You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.
* These options are available:
*
* (Options are permanent.)
*
* yy: {
* parseError: function(str, hash, ExceptionClass)
* optional: overrides the default `parseError` function.
* }
*
* lexer.options: {
* pre_lex: function()
* optional: is invoked before the lexer is invoked to produce another token.
* `this` refers to the Lexer object.
* post_lex: function(token) { return token; }
* optional: is invoked when the lexer has produced a token `token`;
* this function can override the returned token value by returning another.
* When it does not return any (truthy) value, the lexer will return
* the original `token`.
* `this` refers to the Lexer object.
*
* WARNING: the next set of options are not meant to be changed. They echo the abilities of
* the lexer as per when it was compiled!
*
* ranges: boolean
* optional: `true` ==> token location info will include a .range[] member.
* flex: boolean
* optional: `true` ==> flex-like lexing behaviour where the rules are tested
* exhaustively to find the longest match.
* backtrack_lexer: boolean
* optional: `true` ==> lexer regexes are tested in order and for invoked;
* the lexer terminates the scan when a token is returned by the action code.
* xregexp: boolean
* optional: `true` ==> lexer rule regexes are "extended regex format" requiring the
* `XRegExp` library. When this %option has not been specified at compile time, all lexer
* rule regexes have been written as standard JavaScript RegExp expressions.
* }
*/
var lexer = function () {
/**
* See also:
* http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
* but we keep the prototype.constructor and prototype.name assignment lines too for compatibility
* with userland code which might access the derived class in a 'classic' way.
*
* @public
* @constructor
* @nocollapse
*/
function JisonLexerError(msg, hash) {
Object.defineProperty(this, 'name', {
enumerable: false,
writable: false,
value: 'JisonLexerError'
});
Iif (msg == null) msg = '???';
Object.defineProperty(this, 'message', {
enumerable: false,
writable: true,
value: msg
});
this.hash = hash;
var stacktrace;
Iif (hash && hash.exception instanceof Error) {
var ex2 = hash.exception;
this.message = ex2.message || msg;
stacktrace = ex2.stack;
}
Eif (!stacktrace) {
Eif (Error.hasOwnProperty('captureStackTrace')) {
// V8
Error.captureStackTrace(this, this.constructor);
} else {
stacktrace = new Error(msg).stack;
}
}
Iif (stacktrace) {
Object.defineProperty(this, 'stack', {
enumerable: false,
writable: false,
value: stacktrace
});
}
}
Eif (typeof Object.setPrototypeOf === 'function') {
Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);
} else {
JisonLexerError.prototype = Object.create(Error.prototype);
}
JisonLexerError.prototype.constructor = JisonLexerError;
JisonLexerError.prototype.name = 'JisonLexerError';
var lexer = {
// Code Generator Information Report
// ---------------------------------
//
// Options:
//
// backtracking: .................... false
// location.ranges: ................. true
// location line+column tracking: ... true
//
//
// Forwarded Parser Analysis flags:
//
// uses yyleng: ..................... false
// uses yylineno: ................... false
// uses yytext: ..................... false
// uses yylloc: ..................... false
// uses lexer values: ............... true / true
// location tracking: ............... true
// location assignment: ............. true
//
//
// Lexer Analysis flags:
//
// uses yyleng: ..................... ???
// uses yylineno: ................... ???
// uses yytext: ..................... ???
// uses yylloc: ..................... ???
// uses ParseError API: ............. ???
// uses yyerror: .................... ???
// uses location tracking & editing: ???
// uses more() API: ................. ???
// uses unput() API: ................ ???
// uses reject() API: ............... ???
// uses less() API: ................. ???
// uses display APIs pastInput(), upcomingInput(), showPosition():
// ............................. ???
// uses describeYYLLOC() API: ....... ???
//
// --------- END OF REPORT -----------
EOF: 1,
ERROR: 2,
// JisonLexerError: JisonLexerError, /// <-- injected by the code generator
// options: {}, /// <-- injected by the code generator
// yy: ..., /// <-- injected by setInput()
__currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state
__error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup
__decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use
done: false, /// INTERNAL USE ONLY
_backtrack: false, /// INTERNAL USE ONLY
_input: '', /// INTERNAL USE ONLY
_more: false, /// INTERNAL USE ONLY
_signaled_error_token: false, /// INTERNAL USE ONLY
conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`
match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!
matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far
matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt
yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.
offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far
yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)
yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located
yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction
/**
* INTERNAL USE: construct a suitable error info hash object instance for `parseError`.
*
* @public
* @this {RegExpLexer}
*/
constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {
msg = '' + msg;
// heuristic to determine if the error message already contains a (partial) source code dump
// as produced by either `showPosition()` or `prettyPrintRange()`:
Eif (show_input_position == undefined) {
show_input_position = !(msg.indexOf('\n') > 0 && msg.indexOf('^') > 0);
}
Iif (this.yylloc && show_input_position) {
if (typeof this.prettyPrintRange === 'function') {
var pretty_src = this.prettyPrintRange(this.yylloc);
if (!/\n\s*$/.test(msg)) {
msg += '\n';
}
msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc);
} else if (typeof this.showPosition === 'function') {
var pos_str = this.showPosition();
if (pos_str) {
if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') {
msg += '\n' + pos_str;
} else {
msg += pos_str;
}
}
}
}
/** @constructor */
var pei = {
errStr: msg,
recoverable: !!recoverable,
text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...
token: null,
line: this.yylineno,
loc: this.yylloc,
yy: this.yy,
lexer: this,
/**
* and make sure the error info doesn't stay due to potential
* ref cycle via userland code manipulations.
* These would otherwise all be memory leak opportunities!
*
* Note that only array and object references are nuked as those
* constitute the set of elements which can produce a cyclic ref.
* The rest of the members is kept intact as they are harmless.
*
* @public
* @this {LexErrorInfo}
*/
destroy: function destructLexErrorInfo() {
// remove cyclic references added to error info:
// info.yy = null;
// info.lexer = null;
// ...
var rec = !!this.recoverable;
for (var key in this) {
if (this.hasOwnProperty(key) && (typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object') {
this[key] = undefined;
}
}
this.recoverable = rec;
}
};
// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
this.__error_infos.push(pei);
return pei;
},
/**
* handler which is invoked when a lexer error occurs.
*
* @public
* @this {RegExpLexer}
*/
parseError: function lexer_parseError(str, hash, ExceptionClass) {
Iif (!ExceptionClass) {
ExceptionClass = this.JisonLexerError;
}
Eif (this.yy) {
Eif (this.yy.parser && typeof this.yy.parser.parseError === 'function') {
return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;
} else if (typeof this.yy.parseError === 'function') {
return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;
}
}
throw new ExceptionClass(str, hash);
},
/**
* method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.
*
* @public
* @this {RegExpLexer}
*/
yyerror: function yyError(str /*, ...args */) {
var lineno_msg = '';
Eif (this.yylloc) {
lineno_msg = ' on line ' + (this.yylineno + 1);
}
var p = this.constructLexErrorInfo('Lexical error' + lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);
// Add any extra args to the hash under the name `extra_error_attributes`:
var args = Array.prototype.slice.call(arguments, 1);
Iif (args.length) {
p.extra_error_attributes = args;
}
return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
},
/**
* final cleanup function for when we have completed lexing the input;
* make it an API so that external code can use this one once userland
* code has decided it's time to destroy any lingering lexer error
* hash object instances and the like: this function helps to clean
* up these constructs, which *may* carry cyclic references which would
* otherwise prevent the instances from being properly and timely
* garbage-collected, i.e. this function helps prevent memory leaks!
*
* @public
* @this {RegExpLexer}
*/
cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {
// prevent lingering circular references from causing memory leaks:
this.setInput('', {});
// nuke the error hash info instances created during this run.
// Userland code must COPY any data/references
// in the error hash instance(s) it is more permanently interested in.
Iif (!do_not_nuke_errorinfos) {
for (var i = this.__error_infos.length - 1; i >= 0; i--) {
var el = this.__error_infos[i];
if (el && typeof el.destroy === 'function') {
el.destroy();
}
}
this.__error_infos.length = 0;
}
return this;
},
/**
* clear the lexer token context; intended for internal use only
*
* @public
* @this {RegExpLexer}
*/
clear: function lexer_clear() {
this.yytext = '';
this.yyleng = 0;
this.match = '';
// - DO NOT reset `this.matched`
this.matches = false;
this._more = false;
this._backtrack = false;
var col = this.yylloc ? this.yylloc.last_column : 0;
this.yylloc = {
first_line: this.yylineno + 1,
first_column: col,
last_line: this.yylineno + 1,
last_column: col,
range: [this.offset, this.offset]
};
},
/**
* resets the lexer, sets new input
*
* @public
* @this {RegExpLexer}
*/
setInput: function lexer_setInput(input, yy) {
this.yy = yy || this.yy || {};
// also check if we've fully initialized the lexer instance,
// including expansion work to be done to go from a loaded
// lexer to a usable lexer:
if (!this.__decompressed) {
// step 1: decompress the regex list:
var rules = this.rules;
for (var i = 0, len = rules.length; i < len; i++) {
var rule_re = rules[i];
// compression: is the RE an xref to another RE slot in the rules[] table?
Iif (typeof rule_re === 'number') {
rules[i] = rules[rule_re];
}
}
// step 2: unfold the conditions[] set to make these ready for use:
var conditions = this.conditions;
for (var k in conditions) {
var spec = conditions[k];
var rule_ids = spec.rules;
var len = rule_ids.length;
var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!
var rule_new_ids = new Array(len + 1);
for (var i = 0; i < len; i++) {
var idx = rule_ids[i];
var rule_re = rules[idx];
rule_regexes[i + 1] = rule_re;
rule_new_ids[i + 1] = idx;
}
spec.rules = rule_new_ids;
spec.__rule_regexes = rule_regexes;
spec.__rule_count = len;
}
this.__decompressed = true;
}
this._input = input || '';
this.clear();
this._signaled_error_token = false;
this.done = false;
this.yylineno = 0;
this.matched = '';
this.conditionStack = ['INITIAL'];
this.__currentRuleSet__ = null;
this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0,
range: [0, 0]
};
this.offset = 0;
return this;
},
/**
* edit the remaining input via user-specified callback.
* This can be used to forward-adjust the input-to-parse,
* e.g. inserting macro expansions and alike in the
* input which has yet to be lexed.
* The behaviour of this API contrasts the `unput()` et al
* APIs as those act on the *consumed* input, while this
* one allows one to manipulate the future, without impacting
* the current `yyloc` cursor location or any history.
*
* Use this API to help implement C-preprocessor-like
* `#include` statements, etc.
*
* The provided callback must be synchronous and is
* expected to return the edited input (string).
*
* The `cpsArg` argument value is passed to the callback
* as-is.
*
* `callback` interface:
* `function callback(input, cpsArg)`
*
* - `input` will carry the remaining-input-to-lex string
* from the lexer.
* - `cpsArg` is `cpsArg` passed into this API.
*
* The `this` reference for the callback will be set to
* reference this lexer instance so that userland code
* in the callback can easily and quickly access any lexer
* API.
*
* When the callback returns a non-string-type falsey value,
* we assume the callback did not edit the input and we
* will using the input as-is.
*
* When the callback returns a non-string-type value, it
* is converted to a string for lexing via the `"" + retval`
* operation. (See also why: http://2ality.com/2012/03/converting-to-string.html
* -- that way any returned object's `toValue()` and `toString()`
* methods will be invoked in a proper/desirable order.)
*
* @public
* @this {RegExpLexer}
*/
editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {
var rv = callback.call(this, this._input, cpsArg);
if (typeof rv !== 'string') {
if (rv) {
this._input = '' + rv;
}
// else: keep `this._input` as is.
} else {
this._input = rv;
}
return this;
},
/**
* consumes and returns one char from the input
*
* @public
* @this {RegExpLexer}
*/
input: function lexer_input() {
if (!this._input) {
//this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <<EOF>> tokens and perform user action code for a <<EOF>> match, but only does so *once*)
return null;
}
var ch = this._input[0];
this.yytext += ch;
this.yyleng++;
this.offset++;
this.match += ch;
this.matched += ch;
// Count the linenumber up when we hit the LF (or a stand-alone CR).
// On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo
// and we advance immediately past the LF as well, returning both together as if
// it was all a single 'character' only.
var slice_len = 1;
var lines = false;
if (ch === '\n') {
lines = true;
} else if (ch === '\r') {
lines = true;
var ch2 = this._input[1];
if (ch2 === '\n') {
slice_len++;
ch += ch2;
this.yytext += ch2;
this.yyleng++;
this.offset++;
this.match += ch2;
this.matched += ch2;
this.yylloc.range[1]++;
}
}
if (lines) {
this.yylineno++;
this.yylloc.last_line++;
this.yylloc.last_column = 0;
} else {
this.yylloc.last_column++;
}
this.yylloc.range[1]++;
this._input = this._input.slice(slice_len);
return ch;
},
/**
* unshifts one char (or an entire string) into the input
*
* @public
* @this {RegExpLexer}
*/
unput: function lexer_unput(ch) {
var len = ch.length;
var lines = ch.split(/(?:\r\n?|\n)/g);
this._input = ch + this._input;
this.yytext = this.yytext.substr(0, this.yytext.length - len);
this.yyleng = this.yytext.length;
this.offset -= len;
this.match = this.match.substr(0, this.match.length - len);
this.matched = this.matched.substr(0, this.matched.length - len);
if (lines.length > 1) {
this.yylineno -= lines.length - 1;
this.yylloc.last_line = this.yylineno + 1;
// Get last entirely matched line into the `pre_lines[]` array's
// last index slot; we don't mind when other previously
// matched lines end up in the array too.
var pre = this.match;
var pre_lines = pre.split(/(?:\r\n?|\n)/g);
Eif (pre_lines.length === 1) {
pre = this.matched;
pre_lines = pre.split(/(?:\r\n?|\n)/g);
}
this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;
} else {
this.yylloc.last_column -= len;
}
this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;
this.done = false;
return this;
},
/**
* cache matched text and append it on next action
*
* @public
* @this {RegExpLexer}
*/
more: function lexer_more() {
this._more = true;
return this;
},
/**
* signal the lexer that this rule fails to match the input, so the
* next matching rule (regex) should be tested instead.
*
* @public
* @this {RegExpLexer}
*/
reject: function lexer_reject() {
if (this.options.backtrack_lexer) {
this._backtrack = true;
} else {
// when the `parseError()` call returns, we MUST ensure that the error is registered.
// We accomplish this by signaling an 'error' token to be produced for the current
// `.lex()` run.
var lineno_msg = '';
if (this.yylloc) {
lineno_msg = ' on line ' + (this.yylineno + 1);
}
var p = this.constructLexErrorInfo('Lexical error' + lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);
this._signaled_error_token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
}
return this;
},
/**
* retain first n characters of the match
*
* @public
* @this {RegExpLexer}
*/
less: function lexer_less(n) {
return this.unput(this.match.slice(n));
},
/**
* return (part of the) already matched input, i.e. for error
* messages.
*
* Limit the returned string length to `maxSize` (default: 20).
*
* Limit the returned string to the `maxLines` number of lines of
* input (default: 1).
*
* Negative limit values equal *unlimited*.
*
* @public
* @this {RegExpLexer}
*/
pastInput: function lexer_pastInput(maxSize, maxLines) {
var past = this.matched.substring(0, this.matched.length - this.match.length);
Iif (maxSize < 0) maxSize = past.length;else Iif (!maxSize) maxSize = 20;
Iif (maxLines < 0) maxLines = past.length; // can't ever have more input lines than this!
else Eif (!maxLines) maxLines = 1;
// `substr` anticipation: treat \r\n as a single character and take a little
// more than necessary so that we can still properly check against maxSize
// after we've transformed and limited the newLines in here:
past = past.substr(-maxSize * 2 - 2);
// now that we have a significantly reduced string to process, transform the newlines
// and chop them, then limit them:
var a = past.replace(/\r\n|\r/g, '\n').split('\n');
a = a.slice(-maxLines);
past = a.join('\n');
// When, after limiting to maxLines, we still have too much to return,
// do add an ellipsis prefix...
Iif (past.length > maxSize) {
past = '...' + past.substr(-maxSize);
}
return past;
},
/**
* return (part of the) upcoming input, i.e. for error messages.
*
* Limit the returned string length to `maxSize` (default: 20).
*
* Limit the returned string to the `maxLines` number of lines of input (default: 1).
*
* Negative limit values equal *unlimited*.
*
* > ### NOTE ###
* >
* > *"upcoming input"* is defined as the whole of the both
* > the *currently lexed* input, together with any remaining input
* > following that. *"currently lexed"* input is the input
* > already recognized by the lexer but not yet returned with
* > the lexer token. This happens when you are invoking this API
* > from inside any lexer rule action code block.
* >
*
* @public
* @this {RegExpLexer}
*/
upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {
var next = this.match;
Iif (maxSize < 0) maxSize = next.length + this._input.length;else Iif (!maxSize) maxSize = 20;
Iif (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!
else Eif (!maxLines) maxLines = 1;
// `substring` anticipation: treat \r\n as a single character and take a little
// more than necessary so that we can still properly check against maxSize
// after we've transformed and limited the newLines in here:
Eif (next.length < maxSize * 2 + 2) {
next += this._input.substring(0, maxSize * 2 + 2); // substring is faster on Chrome/V8
}
// now that we have a significantly reduced string to process, transform the newlines
// and chop them, then limit them:
var a = next.replace(/\r\n|\r/g, '\n').split('\n');
a = a.slice(0, maxLines);
next = a.join('\n');
// When, after limiting to maxLines, we still have too much to return,
// do add an ellipsis postfix...
Eif (next.length > maxSize) {
next = next.substring(0, maxSize) + '...';
}
return next;
},
/**
* return a string which displays the character position where the
* lexing error occurred, i.e. for error messages
*
* @public
* @this {RegExpLexer}
*/
showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {
var pre = this.pastInput(maxPrefix).replace(/\s/g, ' ');
var c = new Array(pre.length + 1).join('-');
return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^';
},
/**
* return an YYLLOC info object derived off the given context (actual, preceding, following, current).
* Use this method when the given `actual` location is not guaranteed to exist (i.e. when
* it MAY be NULL) and you MUST have a valid location info object anyway:
* then we take the given context of the `preceding` and `following` locations, IFF those are available,
* and reconstruct the `actual` location info from those.
* If this fails, the heuristic is to take the `current` location, IFF available.
* If this fails as well, we assume the sought location is at/around the current lexer position
* and then produce that one as a response. DO NOTE that these heuristic/derived location info
* values MAY be inaccurate!
*
* NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just
* a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).
*
* @public
* @this {RegExpLexer}
*/
deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {
var loc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0,
range: [0, 0]
};
Eif (actual) {
loc.first_line = actual.first_line | 0;
loc.last_line = actual.last_line | 0;
loc.first_column = actual.first_column | 0;
loc.last_column = actual.last_column | 0;
Eif (actual.range) {
loc.range[0] = actual.range[0] | 0;
loc.range[1] = actual.range[1] | 0;
}
}
Iif (loc.first_line <= 0 || loc.last_line < loc.first_line) {
// plan B: heuristic using preceding and following:
if (loc.first_line <= 0 && preceding) {
loc.first_line = preceding.last_line | 0;
loc.first_column = preceding.last_column | 0;
if (preceding.range) {
loc.range[0] = actual.range[1] | 0;
}
}
if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {
loc.last_line = following.first_line | 0;
loc.last_column = following.first_column | 0;
if (following.range) {
loc.range[1] = actual.range[0] | 0;
}
}
// plan C?: see if the 'current' location is useful/sane too:
if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {
loc.first_line = current.first_line | 0;
loc.first_column = current.first_column | 0;
if (current.range) {
loc.range[0] = current.range[0] | 0;
}
}
if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {
loc.last_line = current.last_line | 0;
loc.last_column = current.last_column | 0;
if (current.range) {
loc.range[1] = current.range[1] | 0;
}
}
}
// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter
// or plan D heuristics to produce a 'sensible' last_line value:
Iif (loc.last_line <= 0) {
if (loc.first_line <= 0) {
loc.first_line = this.yylloc.first_line;
loc.last_line = this.yylloc.last_line;
loc.first_column = this.yylloc.first_column;
loc.last_column = this.yylloc.last_column;
loc.range[0] = this.yylloc.range[0];
loc.range[1] = this.yylloc.range[1];
} else {
loc.last_line = this.yylloc.last_line;
loc.last_column = this.yylloc.last_column;
loc.range[1] = this.yylloc.range[1];
}
}
Iif (loc.first_line <= 0) {
loc.first_line = loc.last_line;
loc.first_column = 0; // loc.last_column;
loc.range[1] = loc.range[0];
}
Iif (loc.first_column < 0) {
loc.first_column = 0;
}
Iif (loc.last_column < 0) {
loc.last_column = loc.first_column > 0 ? loc.first_column : 80;
}
return loc;
},
/**
* return a string which displays the lines & columns of input which are referenced
* by the given location info range, plus a few lines of context.
*
* This function pretty-prints the indicated section of the input, with line numbers
* and everything!
*
* This function is very useful to provide highly readable error reports, while
* the location range may be specified in various flexible ways:
*
* - `loc` is the location info object which references the area which should be
* displayed and 'marked up': these lines & columns of text are marked up by `^`
* characters below each character in the entire input range.
*
* - `context_loc` is the *optional* location info object which instructs this
* pretty-printer how much *leading* context should be displayed alongside
* the area referenced by `loc`. This can help provide context for the displayed
* error, etc.
*
* When this location info is not provided, a default context of 3 lines is
* used.
*
* - `context_loc2` is another *optional* location info object, which serves
* a similar purpose to `context_loc`: it specifies the amount of *trailing*
* context lines to display in the pretty-print output.
*
* When this location info is not provided, a default context of 1 line only is
* used.
*
* Special Notes:
*
* - when the `loc`-indicated range is very large (about 5 lines or more), then
* only the first and last few lines of this block are printed while a
* `...continued...` message will be printed between them.
*
* This serves the purpose of not printing a huge amount of text when the `loc`
* range happens to be huge: this way a manageable & readable output results
* for arbitrary large ranges.
*
* - this function can display lines of input which whave not yet been lexed.
* `prettyPrintRange()` can access the entire input!
*
* @public
* @this {RegExpLexer}
*/
prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {
loc = this.deriveLocationInfo(loc, context_loc, context_loc2);
var CONTEXT = 3;
var CONTEXT_TAIL = 1;
var MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;
var input = this.matched + this._input;
var lines = input.split('\n');
var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT);
var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL);
var lineno_display_width = 1 + Math.log10(l1 | 1) | 0;
var ws_prefix = new Array(lineno_display_width).join(' ');
var nonempty_line_indexes = [];
var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {
var lno = index + l0;
var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);
var rv = lno_pfx + ': ' + line;
var errpfx = new Array(lineno_display_width + 1).join('^');
var offset = 2 + 1;
var len = 0;
if (lno === loc.first_line) {
offset += loc.first_column;
len = Math.max(2, (lno === loc.last_line ? loc.last_column : line.length) - loc.first_column + 1);
} else if (lno === loc.last_line) {
len = Math.max(2, loc.last_column + 1);
} else Iif (lno > loc.first_line && lno < loc.last_line) {
len = Math.max(2, line.length + 1);
}
if (len) {
var lead = new Array(offset).join('.');
var mark = new Array(len).join('^');
rv += '\n' + errpfx + lead + mark;
Eif (line.trim().length > 0) {
nonempty_line_indexes.push(index);
}
}
rv = rv.replace(/\t/g, ' ');
return rv;
});
// now make sure we don't print an overly large amount of error area: limit it
// to the top and bottom line count:
Iif (nonempty_line_indexes.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {
var clip_start = nonempty_line_indexes[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;
var clip_end = nonempty_line_indexes[nonempty_line_indexes.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;
var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)';
intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)';
rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);
}
return rv.join('\n');
},
/**
* helper function, used to produce a human readable description as a string, given
* the input `yylloc` location object.
*
* Set `display_range_too` to TRUE to include the string character index position(s)
* in the description if the `yylloc.range` is available.
*
* @public
* @this {RegExpLexer}
*/
describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {
var l1 = yylloc.first_line;
var l2 = yylloc.last_line;
var c1 = yylloc.first_column;
var c2 = yylloc.last_column;
var dl = l2 - l1;
var dc = c2 - c1;
var rv;
if (dl === 0) {
rv = 'line ' + l1 + ', ';
if (dc <= 1) {
rv += 'column ' + c1;
} else {
rv += 'columns ' + c1 + ' .. ' + c2;
}
} else {
rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';
}
if (yylloc.range && display_range_too) {
var r1 = yylloc.range[0];
var r2 = yylloc.range[1] - 1;
if (r2 <= r1) {
rv += ' {String Offset: ' + r1 + '}';
} else {
rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';
}
}
return rv;
},
/**
* test the lexed token: return FALSE when not a match, otherwise return token.
*
* `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`
* contains the actually matched text string.
*
* Also move the input cursor forward and update the match collectors:
*
* - `yytext`
* - `yyleng`
* - `match`
* - `matches`
* - `yylloc`
* - `offset`
*
* @public
* @this {RegExpLexer}
*/
test_match: function lexer_test_match(match, indexed_rule) {
var token, lines, backup, match_str, match_str_len;
Iif (this.options.backtrack_lexer) {
// save context
backup = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.yylloc.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column,
range: this.yylloc.range.slice(0)
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
//_signaled_error_token: this._signaled_error_token,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
};
}
match_str = match[0];
match_str_len = match_str.length;
// if (match_str.indexOf('\n') !== -1 || match_str.indexOf('\r') !== -1) {
lines = match_str.split(/(?:\r\n?|\n)/g);
if (lines.length > 1) {
this.yylineno += lines.length - 1;
this.yylloc.last_line = this.yylineno + 1;
this.yylloc.last_column = lines[lines.length - 1].length;
} else {
this.yylloc.last_column += match_str_len;
}
// }
this.yytext += match_str;
this.match += match_str;
this.matched += match_str;
this.matches = match;
this.yyleng = this.yytext.length;
this.yylloc.range[1] += match_str_len;
// previous lex rules MAY have invoked the `more()` API rather than producing a token:
// those rules will already have moved this `offset` forward matching their match lengths,
// hence we must only add our own match length now:
this.offset += match_str_len;
this._more = false;
this._backtrack = false;
this._input = this._input.slice(match_str_len);
// calling this method:
//
// function lexer__performAction(yy, yyrulenumber, YY_START) {...}
token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */
);
// otherwise, when the action codes are all simple return token statements:
//token = this.simpleCaseActionClusters[indexed_rule];
Iif (this.done && this._input) {
this.done = false;
}
if (token) {
return token;
} else Iif (this._backtrack) {
// recover context
for (var k in backup) {
this[k] = backup[k];
}
this.__currentRuleSet__ = null;
return false; // rule action called reject() implying the next rule should be tested instead.
} else Iif (this._signaled_error_token) {
// produce one 'error' token as `.parseError()` in `reject()`
// did not guarantee a failure signal by throwing an exception!
token = this._signaled_error_token;
this._signaled_error_token = false;
return token;
}
return false;
},
/**
* return next match in input
*
* @public
* @this {RegExpLexer}
*/
next: function lexer_next() {
if (this.done) {
this.clear();
return this.EOF;
}
if (!this._input) {
this.done = true;
}
var token, match, tempMatch, index;
Eif (!this._more) {
this.clear();
}
var spec = this.__currentRuleSet__;
if (!spec) {
// Update the ruleset cache as we apparently encountered a state change or just started lexing.
// The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will
// invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps
// speed up those activities a tiny bit.
spec = this.__currentRuleSet__ = this._currentRules();
// Check whether a *sane* condition has been pushed before: this makes the lexer robust against
// user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19
Iif (!spec || !spec.rules) {
var lineno_msg = '';
if (this.options.trackPosition) {
lineno_msg = ' on line ' + (this.yylineno + 1);
}
var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false);
// produce one 'error' token until this situation has been resolved, most probably by parse termination!
return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
}
}
var rule_ids = spec.rules;
var regexes = spec.__rule_regexes;
var len = spec.__rule_count;
// Note: the arrays are 1-based, while `len` itself is a valid index,
// hence the non-standard less-or-equal check in the next loop condition!
for (var i = 1; i <= len; i++) {
tempMatch = this._input.match(regexes[i]);
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
match = tempMatch;
index = i;
Iif (this.options.backtrack_lexer) {
token = this.test_match(tempMatch, rule_ids[i]);
if (token !== false) {
return token;
} else if (this._backtrack) {
match = undefined;
continue; // rule action called reject() implying a rule MISmatch.
} else {
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
} else Eif (!this.options.flex) {
break;
}
}
}
Eif (match) {
token = this.test_match(match, rule_ids[index]);
if (token !== false) {
return token;
}
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
if (!this._input) {
this.done = true;
this.clear();
return this.EOF;
} else {
var lineno_msg = '';
if (this.options.trackPosition) {
lineno_msg = ' on line ' + (this.yylineno + 1);
}
var p = this.constructLexErrorInfo('Lexical error' + lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);
var pendingInput = this._input;
var activeCondition = this.topState();
var conditionStackDepth = this.conditionStack.length;
token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
if (token === this.ERROR) {
// we can try to recover from a lexer error that `parseError()` did not 'recover' for us
// by moving forward at least one character at a time IFF the (user-specified?) `parseError()`
// has not consumed/modified any pending input or changed state in the error handler:
if (!this.matches && // and make sure the input has been modified/consumed ...
pendingInput === this._input && // ...or the lexer state has been modified significantly enough
// to merit a non-consuming error handling action right now.
activeCondition === this.topState() && conditionStackDepth === this.conditionStack.length) {
this.input();
}
}
return token;
}
},
/**
* return next match that has a token
*
* @public
* @this {RegExpLexer}
*/
lex: function lexer_lex() {
var r;
// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:
Iif (typeof this.pre_lex === 'function') {
r = this.pre_lex.call(this, 0);
}
Iif (typeof this.options.pre_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.options.pre_lex.call(this, r) || r;
}
Iif (this.yy && typeof this.yy.pre_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.yy.pre_lex.call(this, r) || r;
}
while (!r) {
r = this.next();
}
Eif (this.yy && typeof this.yy.post_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.yy.post_lex.call(this, r) || r;
}
Iif (typeof this.options.post_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.options.post_lex.call(this, r) || r;
}
Iif (typeof this.post_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.post_lex.call(this, r) || r;
}
return r;
},
/**
* return next match that has a token. Identical to the `lex()` API but does not invoke any of the
* `pre_lex()` nor any of the `post_lex()` callbacks.
*
* @public
* @this {RegExpLexer}
*/
fastLex: function lexer_fastLex() {
var r;
while (!r) {
r = this.next();
}
return r;
},
/**
* return info about the lexer state that can help a parser or other lexer API user to use the
* most efficient means available. This API is provided to aid run-time performance for larger
* systems which employ this lexer.
*
* @public
* @this {RegExpLexer}
*/
canIUse: function lexer_canIUse() {
var rv = {
fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function'
};
return rv;
},
/**
* backwards compatible alias for `pushState()`;
* the latter is symmetrical with `popState()` and we advise to use
* those APIs in any modern lexer code, rather than `begin()`.
*
* @public
* @this {RegExpLexer}
*/
begin: function lexer_begin(condition) {
return this.pushState(condition);
},
/**
* activates a new lexer condition state (pushes the new lexer
* condition state onto the condition stack)
*
* @public
* @this {RegExpLexer}
*/
pushState: function lexer_pushState(condition) {
this.conditionStack.push(condition);
this.__currentRuleSet__ = null;
return this;
},
/**
* pop the previously active lexer condition state off the condition
* stack
*
* @public
* @this {RegExpLexer}
*/
popState: function lexer_popState() {
var n = this.conditionStack.length - 1;
Eif (n > 0) {
this.__currentRuleSet__ = null;
return this.conditionStack.pop();
} else {
return this.conditionStack[0];
}
},
/**
* return the currently active lexer condition state; when an index
* argument is provided it produces the N-th previous condition state,
* if available
*
* @public
* @this {RegExpLexer}
*/
topState: function lexer_topState(n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0);
if (n >= 0) {
return this.conditionStack[n];
} else {
return 'INITIAL';
}
},
/**
* (internal) determine the lexer rule set which is active for the
* currently active lexer condition state
*
* @public
* @this {RegExpLexer}
*/
_currentRules: function lexer__currentRules() {
Eif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
return this.conditions[this.conditionStack[this.conditionStack.length - 1]];
} else {
return this.conditions['INITIAL'];
}
},
/**
* return the number of states currently on the stack
*
* @public
* @this {RegExpLexer}
*/
stateStackSize: function lexer_stateStackSize() {
return this.conditionStack.length;
},
options: {
xregexp: true,
ranges: true,
trackPosition: true,
easy_keyword_rules: true
},
JisonLexerError: JisonLexerError,
performAction: function lexer__performAction(yy, yyrulenumber, YY_START) {
var yy_ = this;
switch (yyrulenumber) {
case 0:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: %\{ */
yy.depth = 0;
yy.include_command_allowed = false;
this.pushState('action');
this.unput(yy_.yytext);
yy_.yytext = '';
return 28;
break;
case 1:
/*! Conditions:: action */
/*! Rule:: %\{([^]*?)%\} */
yy_.yytext = this.matches[1].replace(/%\\\}/g, '%}'); // unescape any literal '%\}' that exists within the action code block
yy.include_command_allowed = true;
return 32;
break;
case 2:
/*! Conditions:: action */
/*! Rule:: %include\b */
if (yy.include_command_allowed) {
// This is an include instruction in place of an action:
//
// - one %include per action chunk
// - one %include replaces an entire action chunk
this.pushState('path');
return 51;
} else {
// TODO
yy_.yyerror(rmCommonWS(_templateObject27) + this.prettyPrintRange(yy_.yylloc));
return 37;
}
break;
case 3:
/*! Conditions:: action */
/*! Rule:: {WS}*\/\*[^]*?\*\/ */
//yy.include_command_allowed = false; -- doesn't impact include-allowed state
return 34;
break;
case 4:
/*! Conditions:: action */
/*! Rule:: {WS}*\/\/.* */
yy.include_command_allowed = false;
return 35;
break;
case 6:
/*! Conditions:: action */
/*! Rule:: \| */
if (yy.include_command_allowed) {
this.popState();
this.unput(yy_.yytext);
yy_.yytext = '';
return 31;
} else {
return 33;
}
break;
case 7:
/*! Conditions:: action */
/*! Rule:: %% */
if (yy.include_command_allowed) {
this.popState();
this.unput(yy_.yytext);
yy_.yytext = '';
return 31;
} else {
return 33;
}
break;
case 9:
/*! Conditions:: action */
/*! Rule:: \/[^\s/]*?(?:['"`{}][^\s/]*?)*\/ */
yy.include_command_allowed = false;
return 33;
break;
case 10:
/*! Conditions:: action */
/*! Rule:: \/[^}{BR}]* */
yy.include_command_allowed = false;
return 33;
break;
case 11:
/*! Conditions:: action */
/*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */
yy.include_command_allowed = false;
return 33;
break;
case 12:
/*! Conditions:: action */
/*! Rule:: '{QUOTED_STRING_CONTENT}' */
yy.include_command_allowed = false;
return 33;
break;
case 13:
/*! Conditions:: action */
/*! Rule:: `{ES2017_STRING_CONTENT}` */
yy.include_command_allowed = false;
return 33;
break;
case 14:
/*! Conditions:: action */
/*! Rule:: [^{}/"'`|%\{\}{BR}{WS}]+ */
yy.include_command_allowed = false;
return 33;
break;
case 15:
/*! Conditions:: action */
/*! Rule:: \{ */
yy.depth++;
yy.include_command_allowed = false;
return 33;
break;
case 16:
/*! Conditions:: action */
/*! Rule:: \} */
yy.include_command_allowed = false;
Iif (yy.depth <= 0) {
yy_.yyerror(rmCommonWS(_templateObject28) + this.prettyPrintRange(yy_.yylloc));
return 30;
} else {
yy.depth--;
}
return 33;
break;
case 17:
/*! Conditions:: action */
/*! Rule:: (?:{BR}{WS}+)+(?=[^{WS}{BR}|]) */
yy.include_command_allowed = true;
return 36; // keep empty lines as-is inside action code blocks.
break;
case 18:
/*! Conditions:: action */
/*! Rule:: {BR} */
Iif (yy.depth > 0) {
yy.include_command_allowed = true;
return 36; // keep empty lines as-is inside action code blocks.
} else {
// end of action code chunk
this.popState();
this.unput(yy_.yytext);
yy_.yytext = '';
return 31;
}
break;
case 19:
/*! Conditions:: action */
/*! Rule:: $ */
yy.include_command_allowed = false;
if (yy.depth !== 0) {
yy_.yyerror(rmCommonWS(_templateObject29, yy.depth) + this.prettyPrintRange(yy_.yylloc));
yy_.yytext = '';
return 29;
}
this.popState();
yy_.yytext = '';
return 31;
break;
case 21:
/*! Conditions:: conditions */
/*! Rule:: > */
this.popState();
return 6;
break;
case 24:
/*! Conditions:: INITIAL start_condition macro path options */
/*! Rule:: {WS}*\/\/[^\r\n]* */
/* skip single-line comment */
break;
case 25:
/*! Conditions:: INITIAL start_condition macro path options */
/*! Rule:: {WS}*\/\*[^]*?\*\/ */
/* skip multi-line comment */
break;
case 26:
/*! Conditions:: rules */
/*! Rule:: {BR}+ */
/* empty */
break;
case 27:
/*! Conditions:: rules */
/*! Rule:: {WS}+{BR}+ */
/* empty */
break;
case 28:
/*! Conditions:: rules */
/*! Rule:: \/\/[^\r\n]* */
/* skip single-line comment */
break;
case 29:
/*! Conditions:: rules */
/*! Rule:: \/\*[^]*?\*\/ */
/* skip multi-line comment */
break;
case 30:
/*! Conditions:: rules */
/*! Rule:: {WS}+(?=[^{WS}{BR}|%]) */
yy.depth = 0;
yy.include_command_allowed = true;
this.pushState('action');
return 28;
break;
case 31:
/*! Conditions:: rules */
/*! Rule:: %% */
this.popState();
this.pushState('code');
return 19;
break;
case 32:
/*! Conditions:: rules */
/*! Rule:: {ANY_LITERAL_CHAR}+ */
// accept any non-regex, non-lex, non-string-delim,
// non-escape-starter, non-space character as-is
return 46;
break;
case 35:
/*! Conditions:: options */
/*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */
yy_.yytext = unescQuote(this.matches[1], /\\"/g);
return 49; // value is always a string type
break;
case 36:
/*! Conditions:: options */
/*! Rule:: '{QUOTED_STRING_CONTENT}' */
yy_.yytext = unescQuote(this.matches[1], /\\'/g);
return 49; // value is always a string type
break;
case 37:
/*! Conditions:: options */
/*! Rule:: `{ES2017_STRING_CONTENT}` */
yy_.yytext = unescQuote(this.matches[1], /\\`/g);
return 49; // value is always a string type
break;
case 39:
/*! Conditions:: options */
/*! Rule:: {BR}{WS}+(?=\S) */
/* skip leading whitespace on the next line of input, when followed by more options */
break;
case 40:
/*! Conditions:: options */
/*! Rule:: {BR} */
this.popState();
return 48;
break;
case 41:
/*! Conditions:: options */
/*! Rule:: {WS}+ */
/* skip whitespace */
break;
case 43:
/*! Conditions:: start_condition */
/*! Rule:: {BR}+ */
this.popState();
break;
case 44:
/*! Conditions:: start_condition */
/*! Rule:: {WS}+ */
/* empty */
break;
case 46:
/*! Conditions:: INITIAL */
/*! Rule:: {ID} */
this.pushState('macro');
return 20;
break;
case 47:
/*! Conditions:: macro named_chunk */
/*! Rule:: {BR}+ */
this.popState();
break;
case 48:
/*! Conditions:: macro */
/*! Rule:: {ANY_LITERAL_CHAR}+ */
// accept any non-regex, non-lex, non-string-delim,
// non-escape-starter, non-space character as-is
return 46;
break;
case 49:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: {BR}+ */
/* empty */
break;
case 50:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \s+ */
/* empty */
break;
case 51:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */
yy_.yytext = unescQuote(this.matches[1], /\\"/g);
return 26;
break;
case 52:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: '{QUOTED_STRING_CONTENT}' */
yy_.yytext = unescQuote(this.matches[1], /\\'/g);
return 26;
break;
case 53:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \[ */
this.pushState('set');
return 41;
break;
case 66:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: < */
this.pushState('conditions');
return 5;
break;
case 67:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \/! */
return 39; // treated as `(?!atom)`
break;
case 68:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \/ */
return 14; // treated as `(?=atom)`
break;
case 70:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \\. */
yy_.yytext = yy_.yytext.replace(/^\\/g, '');
return 44;
break;
case 73:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: %option[s]? */
this.pushState('options');
return 47;
break;
case 74:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: %s\b */
this.pushState('start_condition');
return 21;
break;
case 75:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: %x\b */
this.pushState('start_condition');
return 22;
break;
case 76:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: %code\b */
this.pushState('named_chunk');
return 25;
break;
case 77:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: %import\b */
this.pushState('named_chunk');
return 24;
break;
case 78:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: %include\b */
yy.depth = 0;
yy.include_command_allowed = true;
this.pushState('action');
this.unput(yy_.yytext);
yy_.yytext = '';
return 28;
break;
case 79:
/*! Conditions:: code */
/*! Rule:: %include\b */
this.pushState('path');
return 51;
break;
case 80:
/*! Conditions:: INITIAL rules code */
/*! Rule:: %{NAME}([^\r\n]*) */
/* ignore unrecognized decl */
this.warn(rmCommonWS(_templateObject30, dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc));
yy_.yytext = {
name: this.matches[1], // {NAME}
value: this.matches[2].trim() // optional value/parameters
};
return 23;
break;
case 81:
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: %% */
this.pushState('rules');
return 19;
break;
case 89:
/*! Conditions:: set */
/*! Rule:: \] */
this.popState();
return 42;
break;
case 91:
/*! Conditions:: code */
/*! Rule:: [^\r\n]+ */
return 53; // the bit of CODE just before EOF...
break;
case 92:
/*! Conditions:: path */
/*! Rule:: {BR} */
this.popState();
this.unput(yy_.yytext);
break;
case 93:
/*! Conditions:: path */
/*! Rule:: "{DOUBLEQUOTED_STRING_CONTENT}" */
yy_.yytext = unescQuote(this.matches[1]);
this.popState();
return 52;
break;
case 94:
/*! Conditions:: path */
/*! Rule:: '{QUOTED_STRING_CONTENT}' */
yy_.yytext = unescQuote(this.matches[1]);
this.popState();
return 52;
break;
case 95:
/*! Conditions:: path */
/*! Rule:: {WS}+ */
// skip whitespace in the line
break;
case 96:
/*! Conditions:: path */
/*! Rule:: [^\s\r\n]+ */
this.popState();
return 52;
break;
case 97:
/*! Conditions:: action */
/*! Rule:: " */
yy_.yyerror(rmCommonWS(_templateObject31) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 98:
/*! Conditions:: action */
/*! Rule:: ' */
yy_.yyerror(rmCommonWS(_templateObject31) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 99:
/*! Conditions:: action */
/*! Rule:: ` */
yy_.yyerror(rmCommonWS(_templateObject31) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 100:
/*! Conditions:: options */
/*! Rule:: " */
yy_.yyerror(rmCommonWS(_templateObject32) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 101:
/*! Conditions:: options */
/*! Rule:: ' */
yy_.yyerror(rmCommonWS(_templateObject32) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 102:
/*! Conditions:: options */
/*! Rule:: ` */
yy_.yyerror(rmCommonWS(_templateObject32) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 103:
/*! Conditions:: * */
/*! Rule:: " */
var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState();
yy_.yyerror(rmCommonWS(_templateObject33, rules) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 104:
/*! Conditions:: * */
/*! Rule:: ' */
var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState();
yy_.yyerror(rmCommonWS(_templateObject33, rules) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 105:
/*! Conditions:: * */
/*! Rule:: ` */
var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState();
yy_.yyerror(rmCommonWS(_templateObject33, rules) + this.prettyPrintRange(yy_.yylloc));
return 2;
break;
case 106:
/*! Conditions:: macro rules */
/*! Rule:: . */
/* b0rk on bad characters */
var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState();
yy_.yyerror(rmCommonWS(_templateObject34, rules, rules) + this.prettyPrintRange(yy_.yylloc));
break;
case 107:
/*! Conditions:: * */
/*! Rule:: . */
yy_.yyerror(rmCommonWS(_templateObject35, dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc));
break;
default:
return this.simpleCaseActionClusters[yyrulenumber];
}
},
simpleCaseActionClusters: {
/*! Conditions:: action */
/*! Rule:: {WS}+ */
5: 36,
/*! Conditions:: action */
/*! Rule:: % */
8: 33,
/*! Conditions:: conditions */
/*! Rule:: {NAME} */
20: 20,
/*! Conditions:: conditions */
/*! Rule:: , */
22: 8,
/*! Conditions:: conditions */
/*! Rule:: \* */
23: 7,
/*! Conditions:: options */
/*! Rule:: {NAME} */
33: 20,
/*! Conditions:: options */
/*! Rule:: = */
34: 18,
/*! Conditions:: options */
/*! Rule:: [^\s\r\n]+ */
38: 50,
/*! Conditions:: start_condition */
/*! Rule:: {ID} */
42: 27,
/*! Conditions:: named_chunk */
/*! Rule:: {ID} */
45: 20,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \| */
54: 9,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \(\?: */
55: 38,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \(\?= */
56: 38,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \(\?! */
57: 38,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \( */
58: 10,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \) */
59: 11,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \+ */
60: 12,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \* */
61: 7,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \? */
62: 13,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \^ */
63: 16,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: , */
64: 8,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: <<EOF>> */
65: 17,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \\([0-7]{1,3}|[rfntvsSbBwWdD\\*+()${}|[\]\/.^?]|c[A-Z]|x[0-9A-F]{2}|u[a-fA-F0-9]{4}) */
69: 44,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \$ */
71: 17,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \. */
72: 15,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \{\d+(,\s*\d+|,)?\} */
82: 45,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \{{ID}\} */
83: 40,
/*! Conditions:: set options */
/*! Rule:: \{{ID}\} */
84: 40,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \{ */
85: 3,
/*! Conditions:: rules macro named_chunk INITIAL */
/*! Rule:: \} */
86: 4,
/*! Conditions:: set */
/*! Rule:: (?:\\\\|\\\]|[^\]{])+ */
87: 43,
/*! Conditions:: set */
/*! Rule:: \{ */
88: 43,
/*! Conditions:: code */
/*! Rule:: [^\r\n]*(\r|\n)+ */
90: 53,
/*! Conditions:: * */
/*! Rule:: $ */
108: 1
},
rules: [
/* 0: *//^(?:%\{)/,
/* 1: */new XRegExp('^(?:%\\{([^]*?)%\\})', ''),
/* 2: *//^(?:%include\b)/,
/* 3: */new XRegExp('^(?:([^\\S\\n\\r])*\\/\\*[^]*?\\*\\/)', ''),
/* 4: *//^(?:([^\S\n\r])*\/\/.*)/,
/* 5: *//^(?:([^\S\n\r])+)/,
/* 6: *//^(?:\|)/,
/* 7: *//^(?:%%)/,
/* 8: *//^(?:%)/,
/* 9: *//^(?:\/[^\s\/]*?(?:['"`{}][^\s\/]*?)*\/)/,
/* 10: *//^(?:\/[^\n\r}]*)/,
/* 11: *//^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,
/* 12: *//^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,
/* 13: *//^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,
/* 14: *//^(?:[^\s"%'\/`{-}]+)/,
/* 15: *//^(?:\{)/,
/* 16: *//^(?:\})/,
/* 17: *//^(?:(?:(\r\n|\n|\r)([^\S\n\r])+)+(?=[^\s|]))/,
/* 18: *//^(?:(\r\n|\n|\r))/,
/* 19: *//^(?:$)/,
/* 20: */new XRegExp('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?))', ''),
/* 21: *//^(?:>)/,
/* 22: *//^(?:,)/,
/* 23: *//^(?:\*)/,
/* 24: *//^(?:([^\S\n\r])*\/\/[^\n\r]*)/,
/* 25: */new XRegExp('^(?:([^\\S\\n\\r])*\\/\\*[^]*?\\*\\/)', ''),
/* 26: *//^(?:(\r\n|\n|\r)+)/,
/* 27: *//^(?:([^\S\n\r])+(\r\n|\n|\r)+)/,
/* 28: *//^(?:\/\/[^\r\n]*)/,
/* 29: */new XRegExp('^(?:\\/\\*[^]*?\\*\\/)', ''),
/* 30: *//^(?:([^\S\n\r])+(?=[^\s%|]))/,
/* 31: *//^(?:%%)/,
/* 32: *//^(?:([^\s!"$%'-,.\/:-?\[-\^{-}])+)/,
/* 33: */new XRegExp('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?))', ''),
/* 34: *//^(?:=)/,
/* 35: *//^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,
/* 36: *//^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,
/* 37: *//^(?:`((?:\\`|\\[^`]|[^\\`])*)`)/,
/* 38: *//^(?:\S+)/,
/* 39: *//^(?:(\r\n|\n|\r)([^\S\n\r])+(?=\S))/,
/* 40: *//^(?:(\r\n|\n|\r))/,
/* 41: *//^(?:([^\S\n\r])+)/,
/* 42: */new XRegExp('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))', ''),
/* 43: *//^(?:(\r\n|\n|\r)+)/,
/* 44: *//^(?:([^\S\n\r])+)/,
/* 45: */new XRegExp('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))', ''),
/* 46: */new XRegExp('^(?:([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*))', ''),
/* 47: *//^(?:(\r\n|\n|\r)+)/,
/* 48: *//^(?:([^\s!"$%'-,.\/:-?\[-\^{-}])+)/,
/* 49: *//^(?:(\r\n|\n|\r)+)/,
/* 50: *//^(?:\s+)/,
/* 51: *//^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,
/* 52: *//^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,
/* 53: *//^(?:\[)/,
/* 54: *//^(?:\|)/,
/* 55: *//^(?:\(\?:)/,
/* 56: *//^(?:\(\?=)/,
/* 57: *//^(?:\(\?!)/,
/* 58: *//^(?:\()/,
/* 59: *//^(?:\))/,
/* 60: *//^(?:\+)/,
/* 61: *//^(?:\*)/,
/* 62: *//^(?:\?)/,
/* 63: *//^(?:\^)/,
/* 64: *//^(?:,)/,
/* 65: *//^(?:<<EOF>>)/,
/* 66: *//^(?:<)/,
/* 67: *//^(?:\/!)/,
/* 68: *//^(?:\/)/,
/* 69: *//^(?:\\([0-7]{1,3}|[$(-+.\/?BDSW\[-\^bdfnr-tvw{-}]|c[A-Z]|x[\dA-F]{2}|u[\dA-Fa-f]{4}))/,
/* 70: *//^(?:\\.)/,
/* 71: *//^(?:\$)/,
/* 72: *//^(?:\.)/,
/* 73: *//^(?:%option[s]?)/,
/* 74: *//^(?:%s\b)/,
/* 75: *//^(?:%x\b)/,
/* 76: *//^(?:%code\b)/,
/* 77: *//^(?:%import\b)/,
/* 78: *//^(?:%include\b)/,
/* 79: *//^(?:%include\b)/,
/* 80: */new XRegExp('^(?:%([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}\\-_]*(?:[\\p{Alphabetic}\\p{Number}_]))?)([^\\n\\r]*))', ''),
/* 81: *//^(?:%%)/,
/* 82: *//^(?:\{\d+(,\s*\d+|,)?\})/,
/* 83: */new XRegExp('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})', ''),
/* 84: */new XRegExp('^(?:\\{([\\p{Alphabetic}_](?:[\\p{Alphabetic}\\p{Number}_])*)\\})', ''),
/* 85: *//^(?:\{)/,
/* 86: *//^(?:\})/,
/* 87: *//^(?:(?:\\\\|\\\]|[^\]{])+)/,
/* 88: *//^(?:\{)/,
/* 89: *//^(?:\])/,
/* 90: *//^(?:[^\r\n]*(\r|\n)+)/,
/* 91: *//^(?:[^\r\n]+)/,
/* 92: *//^(?:(\r\n|\n|\r))/,
/* 93: *//^(?:"((?:\\"|\\[^"]|[^\n\r"\\])*)")/,
/* 94: *//^(?:'((?:\\'|\\[^']|[^\n\r'\\])*)')/,
/* 95: *//^(?:([^\S\n\r])+)/,
/* 96: *//^(?:\S+)/,
/* 97: *//^(?:")/,
/* 98: *//^(?:')/,
/* 99: *//^(?:`)/,
/* 100: *//^(?:")/,
/* 101: *//^(?:')/,
/* 102: *//^(?:`)/,
/* 103: *//^(?:")/,
/* 104: *//^(?:')/,
/* 105: *//^(?:`)/,
/* 106: *//^(?:.)/,
/* 107: *//^(?:.)/,
/* 108: *//^(?:$)/],
conditions: {
'rules': {
rules: [0, 26, 27, 28, 29, 30, 31, 32, 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, 80, 81, 82, 83, 85, 86, 103, 104, 105, 106, 107, 108],
inclusive: true
},
'macro': {
rules: [0, 24, 25, 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, 81, 82, 83, 85, 86, 103, 104, 105, 106, 107, 108],
inclusive: true
},
'named_chunk': {
rules: [0, 45, 47, 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, 81, 82, 83, 85, 86, 103, 104, 105, 107, 108],
inclusive: true
},
'code': {
rules: [79, 80, 90, 91, 103, 104, 105, 107, 108],
inclusive: false
},
'start_condition': {
rules: [24, 25, 42, 43, 44, 103, 104, 105, 107, 108],
inclusive: false
},
'options': {
rules: [24, 25, 33, 34, 35, 36, 37, 38, 39, 40, 41, 84, 100, 101, 102, 103, 104, 105, 107, 108],
inclusive: false
},
'conditions': {
rules: [20, 21, 22, 23, 103, 104, 105, 107, 108],
inclusive: false
},
'action': {
rules: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 97, 98, 99, 103, 104, 105, 107, 108],
inclusive: false
},
'path': {
rules: [24, 25, 92, 93, 94, 95, 96, 103, 104, 105, 107, 108],
inclusive: false
},
'set': {
rules: [84, 87, 88, 89, 103, 104, 105, 107, 108],
inclusive: false
},
'INITIAL': {
rules: [0, 24, 25, 46, 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, 80, 81, 82, 83, 85, 86, 103, 104, 105, 107, 108],
inclusive: true
}
}
};
var rmCommonWS = helpers.rmCommonWS;
var dquote = helpers.dquote;
function unescQuote(str) {
str = '' + str;
var a = str.split('\\\\');
a = a.map(function (s) {
return s.replace(/\\'/g, '\'').replace(/\\"/g, '"');
});
str = a.join('\\\\');
return str;
}
lexer.warn = function l_warn() {
if (this.yy && this.yy.parser && typeof this.yy.parser.warn === 'function') {
return this.yy.parser.warn.apply(this, arguments);
} else {
console.warn.apply(console, arguments);
}
};
lexer.log = function l_log() {
if (this.yy && this.yy.parser && typeof this.yy.parser.log === 'function') {
return this.yy.parser.log.apply(this, arguments);
} else {
console.log.apply(console, arguments);
}
};
return lexer;
}();
parser.lexer = lexer;
var rmCommonWS$1 = helpers.rmCommonWS;
var checkActionBlock = helpers.checkActionBlock;
function encodeRE(s) {
return s.replace(/([.*+?^${}()|\[\]\/\\])/g, '\\$1').replace(/\\\\u([a-fA-F0-9]{4})/g, '\\u$1');
}
function prepareString(s) {
// unescape slashes
s = s.replace(/\\\\/g, "\\");
s = encodeRE(s);
return s;
}
// convert string value to number or boolean value, when possible
// (and when this is more or less obviously the intent)
// otherwise produce the string itself as value.
function parseValue(v) {
if (v === 'false') {
return false;
}
if (v === 'true') {
return true;
}
// http://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number
// Note that the `v` check ensures that we do not convert `undefined`, `null` and `''` (empty string!)
if (v && !isNaN(v)) {
var rv = +v;
if (isFinite(rv)) {
return rv;
}
}
return v;
}
parser.warn = function p_warn() {
console.warn.apply(console, arguments);
};
parser.log = function p_log() {
console.log.apply(console, arguments);
};
parser.pre_parse = function p_lex() {
Iif (parser.yydebug) parser.log('pre_parse:', arguments);
};
parser.yy.pre_parse = function p_lex() {
Iif (parser.yydebug) parser.log('pre_parse YY:', arguments);
};
parser.yy.post_lex = function p_lex() {
Iif (parser.yydebug) parser.log('post_lex:', arguments);
};
function Parser() {
this.yy = {};
}
Parser.prototype = parser;
parser.Parser = Parser;
function yyparse() {
return parser.parse.apply(parser, arguments);
}
var lexParser = {
parser: parser,
Parser: Parser,
parse: yyparse
};
//
// Helper library for set definitions
//
// MIT Licensed
//
//
// This code is intended to help parse regex set expressions and mix them
// together, i.e. to answer questions like this:
//
// what is the resulting regex set expression when we mix the regex set
// `[a-z]` with the regex set `[^\s]` where with 'mix' we mean that any
// input which matches either input regex should match the resulting
// regex set. (a.k.a. Full Outer Join, see also http://www.diffen.com/difference/Inner_Join_vs_Outer_Join)
//
var XREGEXP_UNICODE_ESCAPE_RE$1 = /^\{[A-Za-z0-9 \-\._]+\}/; // Matches the XRegExp Unicode escape braced part, e.g. `{Number}`
var CHR_RE$1 = /^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})/;
var SET_PART_RE$1 = /^(?:[^\\\]]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;
var NOTHING_SPECIAL_RE$1 = /^(?:[^\\\[\]\(\)\|^\{\}]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\})+/;
var SET_IS_SINGLE_PCODE_RE = /^\\[dDwWsS]$|^\\p\{[A-Za-z0-9 \-\._]+\}$/;
var UNICODE_BASE_PLANE_MAX_CP$1 = 65535;
// The expanded regex sets which are equivalent to the given `\\{c}` escapes:
//
// `/\s/`:
var WHITESPACE_SETSTR$1 = ' \f\n\r\t\x0B\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF';
// `/\d/`:
var DIGIT_SETSTR$1 = '0-9';
// `/\w/`:
var WORDCHAR_SETSTR$1 = 'A-Za-z0-9_';
// Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex
function i2c(i) {
var c, x;
switch (i) {
case 10:
return '\\n';
case 13:
return '\\r';
case 9:
return '\\t';
case 8:
return '\\b';
case 12:
return '\\f';
case 11:
return '\\v';
case 45:
// ASCII/Unicode for '-' dash
return '\\-';
case 91:
// '['
return '\\[';
case 92:
// '\\'
return '\\\\';
case 93:
// ']'
return '\\]';
case 94:
// ']'
return '\\^';
}
if (i < 32 || i > 0xFFF0 /* Unicode Specials, also in UTF16 */
|| i >= 0xD800 && i <= 0xDFFF /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */
|| String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */
) {
// Detail about a detail:
// U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript
// source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report
// a b0rked generated parser, as the generated code would include this regex right here.
// Hence we MUST escape these buggers everywhere we go...
x = i.toString(16);
Eif (x.length >= 1 && i <= 0xFFFF) {
c = '0000' + x;
return '\\u' + c.substr(c.length - 4);
} else {
return '\\u{' + x + '}';
}
}
return String.fromCharCode(i);
}
// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating
// this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a
// `\\p{NAME}` shorthand to represent [part of] the bitarray:
var Pcodes_bitarray_cache = {};
var Pcodes_bitarray_cache_test_order = [];
// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by
// a single regex 'escape', e.g. `\d` for digits 0-9.
var EscCode_bitarray_output_refs;
// now initialize the EscCodes_... table above:
init_EscCode_lookup_table();
function init_EscCode_lookup_table() {
var s,
bitarr,
set2esc = {},
esc2bitarr = {};
// patch global lookup tables for the time being, while we calculate their *real* content in this function:
EscCode_bitarray_output_refs = {
esc2bitarr: {},
set2esc: {}
};
Pcodes_bitarray_cache_test_order = [];
// `/\S':
bitarr = [];
set2bitarray(bitarr, '^' + WHITESPACE_SETSTR$1);
s = bitarray2set(bitarr);
esc2bitarr['S'] = bitarr;
set2esc[s] = 'S';
// set2esc['^' + s] = 's';
Pcodes_bitarray_cache['\\S'] = bitarr;
// `/\s':
bitarr = [];
set2bitarray(bitarr, WHITESPACE_SETSTR$1);
s = bitarray2set(bitarr);
esc2bitarr['s'] = bitarr;
set2esc[s] = 's';
// set2esc['^' + s] = 'S';
Pcodes_bitarray_cache['\\s'] = bitarr;
// `/\D':
bitarr = [];
set2bitarray(bitarr, '^' + DIGIT_SETSTR$1);
s = bitarray2set(bitarr);
esc2bitarr['D'] = bitarr;
set2esc[s] = 'D';
// set2esc['^' + s] = 'd';
Pcodes_bitarray_cache['\\D'] = bitarr;
// `/\d':
bitarr = [];
set2bitarray(bitarr, DIGIT_SETSTR$1);
s = bitarray2set(bitarr);
esc2bitarr['d'] = bitarr;
set2esc[s] = 'd';
// set2esc['^' + s] = 'D';
Pcodes_bitarray_cache['\\d'] = bitarr;
// `/\W':
bitarr = [];
set2bitarray(bitarr, '^' + WORDCHAR_SETSTR$1);
s = bitarray2set(bitarr);
esc2bitarr['W'] = bitarr;
set2esc[s] = 'W';
// set2esc['^' + s] = 'w';
Pcodes_bitarray_cache['\\W'] = bitarr;
// `/\w':
bitarr = [];
set2bitarray(bitarr, WORDCHAR_SETSTR$1);
s = bitarray2set(bitarr);
esc2bitarr['w'] = bitarr;
set2esc[s] = 'w';
// set2esc['^' + s] = 'W';
Pcodes_bitarray_cache['\\w'] = bitarr;
EscCode_bitarray_output_refs = {
esc2bitarr: esc2bitarr,
set2esc: set2esc
};
updatePcodesBitarrayCacheTestOrder();
}
function updatePcodesBitarrayCacheTestOrder(opts) {
var t = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1);
var l = {};
var user_has_xregexp = opts && opts.options && opts.options.xregexp;
var i, j, k, ba;
// mark every character with which regex pcodes they are part of:
for (k in Pcodes_bitarray_cache) {
ba = Pcodes_bitarray_cache[k];
if (!user_has_xregexp && k.indexOf('\\p{') >= 0) {
continue;
}
var cnt = 0;
for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP$1; i++) {
if (ba[i]) {
cnt++;
if (!t[i]) {
t[i] = [k];
} else {
t[i].push(k);
}
}
}
l[k] = cnt;
}
// now dig out the unique ones: only need one per pcode.
//
// We ASSUME every \\p{NAME} 'pcode' has at least ONE character
// in it that is ONLY matched by that particular pcode.
// If this assumption fails, nothing is lost, but our 'regex set
// optimized representation' will be sub-optimal as than this pcode
// won't be tested during optimization.
//
// Now that would be a pity, so the assumption better holds...
// Turns out the assumption doesn't hold already for /\S/ + /\D/
// as the second one (\D) is a pure subset of \S. So we have to
// look for markers which match multiple escapes/pcodes for those
// ones where a unique item isn't available...
var lut = [];
var done = {};
var keys = Object.keys(Pcodes_bitarray_cache);
for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP$1; i++) {
k = t[i][0];
Iif (t[i].length === 1 && !done[k]) {
assert$1(l[k] > 0);
lut.push([i, k]);
done[k] = true;
}
}
for (j = 0; keys[j]; j++) {
k = keys[j];
if (!user_has_xregexp && k.indexOf('\\p{') >= 0) {
continue;
}
Eif (!done[k]) {
assert$1(l[k] > 0);
// find a minimum span character to mark this one:
var w = Infinity;
var rv;
ba = Pcodes_bitarray_cache[k];
for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP$1; i++) {
if (ba[i]) {
var tl = t[i].length;
if (tl > 1 && tl < w) {
assert$1(l[k] > 0);
rv = [i, k];
w = tl;
}
}
}
Eif (rv) {
done[k] = true;
lut.push(rv);
}
}
}
// order from large set to small set so that small sets don't gobble
// characters also represented by overlapping larger set pcodes.
//
// Again we assume something: that finding the large regex pcode sets
// before the smaller, more specialized ones, will produce a more
// optimal minification of the regex set expression.
//
// This is a guestimate/heuristic only!
lut.sort(function (a, b) {
var k1 = a[1];
var k2 = b[1];
var ld = l[k2] - l[k1];
Eif (ld) {
return ld;
}
// and for same-size sets, order from high to low unique identifier.
return b[0] - a[0];
});
Pcodes_bitarray_cache_test_order = lut;
}
// 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set.
function set2bitarray(bitarr, s, opts) {
var orig = s;
var set_is_inverted = false;
var bitarr_orig;
function mark(d1, d2) {
if (d2 == null) d2 = d1;
for (var i = d1; i <= d2; i++) {
bitarr[i] = true;
}
}
function add2bitarray(dst, src) {
for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP$1; i++) {
if (src[i]) {
dst[i] = true;
}
}
}
function eval_escaped_code(s) {
var c;
// decode escaped code? If none, just take the character as-is
if (s.indexOf('\\') === 0) {
var l = s.substr(0, 2);
switch (l) {
case '\\c':
c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1;
return String.fromCharCode(c);
case '\\x':
s = s.substr(2);
c = parseInt(s, 16);
return String.fromCharCode(c);
case '\\u':
s = s.substr(2);
Iif (s[0] === '{') {
s = s.substr(1, s.length - 2);
}
c = parseInt(s, 16);
Iif (c >= 0x10000) {
return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}');
}
return String.fromCharCode(c);
case '\\0':
case '\\1':
case '\\2':
case '\\3':
case '\\4':
case '\\5':
case '\\6':
case '\\7':
s = s.substr(1);
c = parseInt(s, 8);
return String.fromCharCode(c);
case '\\r':
return '\r';
case '\\n':
return '\n';
case '\\v':
return '\v';
case '\\f':
return '\f';
case '\\t':
return '\t';
case '\\b':
return '\b';
default:
// just the character itself:
return s.substr(1);
}
} else {
return s;
}
}
Eif (s && s.length) {
var c1, c2;
// inverted set?
if (s[0] === '^') {
set_is_inverted = true;
s = s.substr(1);
bitarr_orig = bitarr;
bitarr = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1);
}
// BITARR collects flags for characters set. Inversion means the complement set of character is st instead.
// This results in an OR operations when sets are joined/chained.
while (s.length) {
c1 = s.match(CHR_RE$1);
Iif (!c1) {
// hit an illegal escape sequence? cope anyway!
c1 = s[0];
} else {
c1 = c1[0];
// Quick hack for XRegExp escapes inside a regex `[...]` set definition: we *could* try to keep those
// intact but it's easier to unfold them here; this is not nice for when the grammar specifies explicit
// XRegExp support, but alas, we'll get there when we get there... ;-)
switch (c1) {
case '\\p':
s = s.substr(c1.length);
c2 = s.match(XREGEXP_UNICODE_ESCAPE_RE$1);
Eif (c2) {
c2 = c2[0];
s = s.substr(c2.length);
// do we have this one cached already?
var pex = c1 + c2;
var ba4p = Pcodes_bitarray_cache[pex];
if (!ba4p) {
// expand escape:
var xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar???
// rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`:
var xs = '' + xr;
// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside:
xs = xs.substr(1, xs.length - 2);
ba4p = reduceRegexToSetBitArray(xs, pex, opts);
Pcodes_bitarray_cache[pex] = ba4p;
updatePcodesBitarrayCacheTestOrder(opts);
}
// merge bitarrays:
add2bitarray(bitarr, ba4p);
continue;
}
break;
case '\\S':
case '\\s':
case '\\W':
case '\\w':
case '\\d':
case '\\D':
// these can't participate in a range, but need to be treated special:
s = s.substr(c1.length);
// check for \S, \s, \D, \d, \W, \w and expand them:
var ba4e = EscCode_bitarray_output_refs.esc2bitarr[c1[1]];
assert$1(ba4e);
add2bitarray(bitarr, ba4e);
continue;
case '\\b':
// matches a backspace: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#special-backspace
c1 = '\b';
break;
}
}
var v1 = eval_escaped_code(c1);
// propagate deferred exceptions = error reports.
Iif (v1 instanceof Error) {
return v1;
}
v1 = v1.charCodeAt(0);
s = s.substr(c1.length);
if (s[0] === '-' && s.length >= 2) {
// we can expect a range like 'a-z':
s = s.substr(1);
c2 = s.match(CHR_RE$1);
Iif (!c2) {
// hit an illegal escape sequence? cope anyway!
c2 = s[0];
} else {
c2 = c2[0];
}
var v2 = eval_escaped_code(c2);
// propagate deferred exceptions = error reports.
Iif (v2 instanceof Error) {
return v1;
}
v2 = v2.charCodeAt(0);
s = s.substr(c2.length);
// legal ranges go UP, not /DOWN!
Eif (v1 <= v2) {
mark(v1, v2);
} else {
console.warn('INVALID CHARACTER RANGE found in regex: ', { re: orig, start: c1, start_n: v1, end: c2, end_n: v2 });
mark(v1);
mark('-'.charCodeAt(0));
mark(v2);
}
continue;
}
mark(v1);
}
// When we have marked all slots, '^' NEGATES the set, hence we flip all slots.
//
// Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK
// phase actually marked anything at all: the `^` negation will correctly flip=mark the entire
// range then.
if (set_is_inverted) {
for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP$1; i++) {
if (!bitarr[i]) {
bitarr_orig[i] = true;
}
}
}
}
return false;
}
// convert a simple bitarray back into a regex set `[...]` content:
function bitarray2set(l, output_inverted_variant, output_minimized) {
// construct the inverse(?) set from the mark-set:
//
// Before we do that, we inject a sentinel so that our inner loops
// below can be simple and fast:
l[UNICODE_BASE_PLANE_MAX_CP$1 + 1] = 1;
// now reconstruct the regex set:
var rv = [];
var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2;
var bitarr_is_cloned = false;
var l_orig = l;
if (output_inverted_variant) {
// generate the inverted set, hence all unmarked slots are part of the output range:
cnt = 0;
for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP$1; i++) {
if (!l[i]) {
cnt++;
}
}
if (cnt === UNICODE_BASE_PLANE_MAX_CP$1 + 1) {
// When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`.
// BUT... since we output the INVERTED set, we output the match-all set instead:
return '\\S\\s';
} else if (cnt === 0) {
// When we find the entire Unicode range is in the output match set, we replace this with
// a shorthand regex: `[\S\s]`
// BUT... since we output the INVERTED set, we output the match-nothing set instead:
return '^\\S\\s';
}
// Now see if we can replace several bits by an escape / pcode:
if (output_minimized) {
lut = Pcodes_bitarray_cache_test_order;
for (tn = 0; lut[tn]; tn++) {
tspec = lut[tn];
// check if the uniquely identifying char is in the inverted set:
if (!l[tspec[0]]) {
// check if the pcode is covered by the inverted set:
pcode = tspec[1];
ba4pcode = Pcodes_bitarray_cache[pcode];
match = 0;
for (j = 0; j <= UNICODE_BASE_PLANE_MAX_CP$1; j++) {
if (ba4pcode[j]) {
if (!l[j]) {
// match in current inverted bitset, i.e. there's at
// least one 'new' bit covered by this pcode/escape:
match++;
} else Eif (l_orig[j]) {
// mismatch!
match = false;
break;
}
}
}
// We're only interested in matches which actually cover some
// yet uncovered bits: `match !== 0 && match !== false`.
//
// Apply the heuristic that the pcode/escape is only going to be used
// when it covers *more* characters than its own identifier's length:
if (match && match > pcode.length) {
rv.push(pcode);
// and nuke the bits in the array which match the given pcode:
// make sure these edits are visible outside this function as
// `l` is an INPUT parameter (~ not modified)!
if (!bitarr_is_cloned) {
l2 = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1);
for (j = 0; j <= UNICODE_BASE_PLANE_MAX_CP$1; j++) {
l2[j] = l[j] || ba4pcode[j]; // `!(!l[j] && !ba4pcode[j])`
}
// recreate sentinel
l2[UNICODE_BASE_PLANE_MAX_CP$1 + 1] = 1;
l = l2;
bitarr_is_cloned = true;
} else {
for (j = 0; j <= UNICODE_BASE_PLANE_MAX_CP$1; j++) {
l[j] = l[j] || ba4pcode[j];
}
}
}
}
}
}
i = 0;
while (i <= UNICODE_BASE_PLANE_MAX_CP$1) {
// find first character not in original set:
while (l[i]) {
i++;
}
if (i >= UNICODE_BASE_PLANE_MAX_CP$1 + 1) {
break;
}
// find next character not in original set:
for (j = i + 1; !l[j]; j++) {} /* empty loop */
// generate subset:
rv.push(i2c(i));
if (j - 1 > i) {
rv.push((j - 2 > i ? '-' : '') + i2c(j - 1));
}
i = j;
}
} else {
// generate the non-inverted set, hence all logic checks are inverted here...
cnt = 0;
for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP$1; i++) {
if (l[i]) {
cnt++;
}
}
if (cnt === UNICODE_BASE_PLANE_MAX_CP$1 + 1) {
// When we find the entire Unicode range is in the output match set, we replace this with
// a shorthand regex: `[\S\s]`
return '\\S\\s';
} else if (cnt === 0) {
// When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`.
return '^\\S\\s';
}
// Now see if we can replace several bits by an escape / pcode:
if (output_minimized) {
lut = Pcodes_bitarray_cache_test_order;
for (tn = 0; lut[tn]; tn++) {
tspec = lut[tn];
// check if the uniquely identifying char is in the set:
if (l[tspec[0]]) {
// check if the pcode is covered by the set:
pcode = tspec[1];
ba4pcode = Pcodes_bitarray_cache[pcode];
match = 0;
for (j = 0; j <= UNICODE_BASE_PLANE_MAX_CP$1; j++) {
if (ba4pcode[j]) {
if (l[j]) {
// match in current bitset, i.e. there's at
// least one 'new' bit covered by this pcode/escape:
match++;
} else Eif (!l_orig[j]) {
// mismatch!
match = false;
break;
}
}
}
// We're only interested in matches which actually cover some
// yet uncovered bits: `match !== 0 && match !== false`.
//
// Apply the heuristic that the pcode/escape is only going to be used
// when it covers *more* characters than its own identifier's length:
if (match && match > pcode.length) {
rv.push(pcode);
// and nuke the bits in the array which match the given pcode:
// make sure these edits are visible outside this function as
// `l` is an INPUT parameter (~ not modified)!
if (!bitarr_is_cloned) {
l2 = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1);
for (j = 0; j <= UNICODE_BASE_PLANE_MAX_CP$1; j++) {
l2[j] = l[j] && !ba4pcode[j];
}
// recreate sentinel
l2[UNICODE_BASE_PLANE_MAX_CP$1 + 1] = 1;
l = l2;
bitarr_is_cloned = true;
} else {
for (j = 0; j <= UNICODE_BASE_PLANE_MAX_CP$1; j++) {
l[j] = l[j] && !ba4pcode[j];
}
}
}
}
}
}
i = 0;
while (i <= UNICODE_BASE_PLANE_MAX_CP$1) {
// find first character not in original set:
while (!l[i]) {
i++;
}
if (i >= UNICODE_BASE_PLANE_MAX_CP$1 + 1) {
break;
}
// find next character not in original set:
for (j = i + 1; l[j]; j++) {} /* empty loop */
if (j > UNICODE_BASE_PLANE_MAX_CP$1 + 1) {
j = UNICODE_BASE_PLANE_MAX_CP$1 + 1;
}
// generate subset:
rv.push(i2c(i));
if (j - 1 > i) {
rv.push((j - 2 > i ? '-' : '') + i2c(j - 1));
}
i = j;
}
}
assert$1(rv.length);
var s = rv.join('');
assert$1(s);
// Check if the set is better represented by one of the regex escapes:
var esc4s = EscCode_bitarray_output_refs.set2esc[s];
if (esc4s) {
// When we hit a special case like this, it is always the shortest notation, hence wins on the spot!
return '\\' + esc4s;
}
return s;
}
// Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there;
// ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`.
function reduceRegexToSetBitArray(s, name, opts) {
var orig = s;
// propagate deferred exceptions = error reports.
Iif (s instanceof Error) {
return s;
}
var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1);
var internal_state = 0;
var derr;
while (s.length) {
var c1 = s.match(CHR_RE$1);
Iif (!c1) {
// cope with illegal escape sequences too!
return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"');
} else {
c1 = c1[0];
}
s = s.substr(c1.length);
switch (c1) {
case '[':
// this is starting a set within the regex: scan until end of set!
var set_content = [];
while (s.length) {
var inner = s.match(SET_PART_RE$1);
if (!inner) {
inner = s.match(CHR_RE$1);
Iif (!inner) {
// cope with illegal escape sequences too!
return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"');
} else {
inner = inner[0];
}
Eif (inner === ']') break;
} else {
inner = inner[0];
}
set_content.push(inner);
s = s.substr(inner.length);
}
// ensure that we hit the terminating ']':
var c2 = s.match(CHR_RE$1);
Iif (!c2) {
// cope with illegal escape sequences too!
return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"');
} else {
c2 = c2[0];
}
Iif (c2 !== ']') {
return new Error('regex set expression is broken in regex: ' + orig);
}
s = s.substr(c2.length);
var se = set_content.join('');
if (!internal_state) {
derr = set2bitarray(l, se, opts);
// propagate deferred exceptions = error reports.
Iif (derr instanceof Error) {
return derr;
}
// a set is to use like a single character in a longer literal phrase, hence input `[abc]word[def]` would thus produce output `[abc]`:
internal_state = 1;
}
break;
// Strip unescaped pipes to catch constructs like `\\r|\\n` and turn them into
// something ready for use inside a regex set, e.g. `\\r\\n`.
//
// > Of course, we realize that converting more complex piped constructs this way
// > will produce something you might not expect, e.g. `A|WORD2` which
// > would end up as the set `[AW]` which is something else than the input
// > entirely.
// >
// > However, we can only depend on the user (grammar writer) to realize this and
// > prevent this from happening by not creating such oddities in the input grammar.
case '|':
// a|b --> [ab]
internal_state = 0;
break;
case '(':
// (a) --> a
//
// TODO - right now we treat this as 'too complex':
// Strip off some possible outer wrappers which we know how to remove.
// We don't worry about 'damaging' the regex as any too-complex regex will be caught
// in the validation check at the end; our 'strippers' here would not damage useful
// regexes anyway and them damaging the unacceptable ones is fine.
s = s.replace(/^\((?:\?:)?(.*?)\)$/, '$1'); // (?:...) -> ... and (...) -> ...
s = s.replace(/^\^?(.*?)\$?$/, '$1'); // ^...$ --> ... (catch these both inside and outside the outer grouping, hence do the ungrouping twice: one before, once after this)
s = s.replace(/^\((?:\?:)?(.*?)\)$/, '$1'); // (?:...) -> ... and (...) -> ...
return new Error('[macro [' + name + '] is unsuitable for use inside regex set expressions: "[' + orig + ']"]');
case '.':
case '*':
case '+':
case '?':
// wildcard
//
// TODO - right now we treat this as 'too complex':
return new Error('[macro [' + name + '] is unsuitable for use inside regex set expressions: "[' + orig + ']"]');
case '{':
// range, e.g. `x{1,3}`, or macro?
// TODO - right now we treat this as 'too complex':
return new Error('[macro [' + name + '] is unsuitable for use inside regex set expressions: "[' + orig + ']"]');
default:
// literal character or word: take the first character only and ignore the rest, so that
// the constructed set for `word|noun` would be `[wb]`:
if (!internal_state) {
derr = set2bitarray(l, c1, opts);
// propagate deferred exceptions = error reports.
Iif (derr instanceof Error) {
return derr;
}
internal_state = 2;
}
break;
}
}
s = bitarray2set(l);
// When this result is suitable for use in a set, than we should be able to compile
// it in a regex; that way we can easily validate whether macro X is fit to be used
// inside a regex set:
try {
var re;
assert$1(s);
assert$1(!(s instanceof Error));
re = new XRegExp('[' + s + ']');
re.test(s[0]);
// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]`
// so we check for lingering UNESCAPED brackets in here as those cannot be:
Iif (/[^\\][\[\]]/.exec(s)) {
throw new Error('unescaped brackets in set data');
}
} catch (ex) {
// make sure we produce a set range expression which will fail badly when it is used
// in actual code:
s = new Error('[macro [' + name + '] is unsuitable for use inside regex set expressions: "[' + s + ']"]: ' + ex.message);
}
assert$1(s);
// propagate deferred exceptions = error reports.
Iif (s instanceof Error) {
return s;
}
return l;
}
// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]`
// -- or in this example it can be further optimized to only `\d`!
function produceOptimizedRegex4Set(bitarr) {
// First try to produce a minimum regex from the bitarray directly:
var s1 = bitarray2set(bitarr, false, true);
// and when the regex set turns out to match a single pcode/escape, then
// use that one as-is:
if (s1.match(SET_IS_SINGLE_PCODE_RE)) {
// When we hit a special case like this, it is always the shortest notation, hence wins on the spot!
return s1;
} else {
s1 = '[' + s1 + ']';
}
// Now try to produce a minimum regex from the *inverted* bitarray via negation:
// Because we look at a negated bitset, there's no use looking for matches with
// special cases here.
var s2 = bitarray2set(bitarr, true, true);
if (s2[0] === '^') {
s2 = s2.substr(1);
Iif (s2.match(SET_IS_SINGLE_PCODE_RE)) {
// When we hit a special case like this, it is always the shortest notation, hence wins on the spot!
return s2;
}
} else {
s2 = '^' + s2;
}
s2 = '[' + s2 + ']';
// Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end,
// we also check against the plain, unadulterated regex set expressions:
//
// First try to produce a minimum regex from the bitarray directly:
var s3 = bitarray2set(bitarr, false, false);
// and when the regex set turns out to match a single pcode/escape, then
// use that one as-is:
Iif (s3.match(SET_IS_SINGLE_PCODE_RE)) {
// When we hit a special case like this, it is always the shortest notation, hence wins on the spot!
return s3;
} else {
s3 = '[' + s3 + ']';
}
// Now try to produce a minimum regex from the *inverted* bitarray via negation:
// Because we look at a negated bitset, there's no use looking for matches with
// special cases here.
var s4 = bitarray2set(bitarr, true, false);
if (s4[0] === '^') {
s4 = s4.substr(1);
Iif (s4.match(SET_IS_SINGLE_PCODE_RE)) {
// When we hit a special case like this, it is always the shortest notation, hence wins on the spot!
return s4;
}
} else {
s4 = '^' + s4;
}
s4 = '[' + s4 + ']';
if (s2.length < s1.length) {
s1 = s2;
}
Iif (s3.length < s1.length) {
s1 = s3;
}
if (s4.length < s1.length) {
s1 = s4;
}
return s1;
}
var setmgmt = {
XREGEXP_UNICODE_ESCAPE_RE: XREGEXP_UNICODE_ESCAPE_RE$1,
CHR_RE: CHR_RE$1,
SET_PART_RE: SET_PART_RE$1,
NOTHING_SPECIAL_RE: NOTHING_SPECIAL_RE$1,
SET_IS_SINGLE_PCODE_RE: SET_IS_SINGLE_PCODE_RE,
UNICODE_BASE_PLANE_MAX_CP: UNICODE_BASE_PLANE_MAX_CP$1,
WHITESPACE_SETSTR: WHITESPACE_SETSTR$1,
DIGIT_SETSTR: DIGIT_SETSTR$1,
WORDCHAR_SETSTR: WORDCHAR_SETSTR$1,
set2bitarray: set2bitarray,
bitarray2set: bitarray2set,
produceOptimizedRegex4Set: produceOptimizedRegex4Set,
reduceRegexToSetBitArray: reduceRegexToSetBitArray
};
// Basic Lexer implemented using JavaScript regular expressions
// Zachary Carter <zach@carter.name>
// MIT Licensed
var rmCommonWS = helpers.rmCommonWS;
var mkIdentifier = helpers.mkIdentifier;
var code_exec = helpers.exec;
// import recast from '@gerhobbelt/recast';
// import astUtils from '@gerhobbelt/ast-util';
var version = '0.6.1-215'; // require('./package.json').version;
function chkBugger(src) {
src = '' + src;
if (src.match(/\bcov_\w+/)) {
console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n', src);
}
}
var XREGEXP_UNICODE_ESCAPE_RE = setmgmt.XREGEXP_UNICODE_ESCAPE_RE; // Matches the XRegExp Unicode escape braced part, e.g. `{Number}`
var CHR_RE = setmgmt.CHR_RE;
var SET_PART_RE = setmgmt.SET_PART_RE;
var NOTHING_SPECIAL_RE = setmgmt.NOTHING_SPECIAL_RE;
var UNICODE_BASE_PLANE_MAX_CP = setmgmt.UNICODE_BASE_PLANE_MAX_CP;
// WARNING: this regex MUST match the regex for `ID` in ebnf-parser::bnf.l jison language lexer spec! (`ID = [{ALPHA}]{ALNUM}*`)
//
// This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well!
var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';
// see also ./lib/cli.js
/**
@public
@nocollapse
*/
var defaultJisonLexOptions = {
moduleType: 'commonjs',
debug: false,
enableDebugLogs: false,
json: false,
main: false, // CLI: not:(--main option)
dumpSourceCodeOnFailure: true,
throwErrorOnCompileFailure: true,
moduleName: undefined,
defaultModuleName: 'lexer',
file: undefined,
outfile: undefined,
inputPath: undefined,
inputFilename: undefined,
warn_cb: undefined, // function(msg) | true (= use Jison.Print) | false (= throw Exception)
xregexp: false,
lexerErrorsAreRecoverable: false,
flex: false,
backtrack_lexer: false,
ranges: false, // track position range, i.e. start+end indexes in the input string
trackPosition: true, // track line+column position in the input string
caseInsensitive: false,
showSource: false,
exportSourceCode: false,
exportAST: false,
prettyCfg: true,
pre_lex: undefined,
post_lex: undefined
};
// Merge sets of options.
//
// Convert alternative jison option names to their base option.
//
// The *last* option set which overrides the default wins, where 'override' is
// defined as specifying a not-undefined value which is not equal to the
// default value.
//
// When the FIRST argument is STRING "NODEFAULT", then we MUST NOT mix the
// default values avialable in Jison.defaultJisonOptions.
//
// Return a fresh set of options.
/** @public */
function mkStdOptions() /*...args*/{
var h = Object.prototype.hasOwnProperty;
var opts = {};
var args = [].concat.apply([], arguments);
// clone defaults, so we do not modify those constants?
Eif (args[0] !== "NODEFAULT") {
args.unshift(defaultJisonLexOptions);
} else {
args.shift();
}
for (var i = 0, len = args.length; i < len; i++) {
var o = args[i];
if (!o) continue;
// clone input (while camel-casing the options), so we do not modify those either.
var o2 = {};
for (var p in o) {
if (typeof o[p] !== 'undefined' && h.call(o, p)) {
o2[mkIdentifier(p)] = o[p];
}
}
// now clean them options up:
if (typeof o2.main !== 'undefined') {
o2.noMain = !o2.main;
}
delete o2.main;
// special check for `moduleName` to ensure we detect the 'default' moduleName entering from the CLI
// NOT overriding the moduleName set in the grammar definition file via an `%options` entry:
if (o2.moduleName === o2.defaultModuleName) {
delete o2.moduleName;
}
// now see if we have an overriding option here:
for (var p in o2) {
Eif (h.call(o2, p)) {
Eif (typeof o2[p] !== 'undefined') {
opts[p] = o2[p];
}
}
}
}
return opts;
}
// set up export/output attributes of the `options` object instance
function prepExportStructures(options) {
// set up the 'option' `exportSourceCode` as a hash object for returning
// all generated source code chunks to the caller
var exportSourceCode = options.exportSourceCode;
if (!exportSourceCode || (typeof exportSourceCode === 'undefined' ? 'undefined' : _typeof(exportSourceCode)) !== 'object') {
exportSourceCode = {
enabled: !!exportSourceCode
};
} else Iif (typeof exportSourceCode.enabled !== 'boolean') {
exportSourceCode.enabled = true;
}
options.exportSourceCode = exportSourceCode;
}
// Autodetect if the input lexer spec is in JSON or JISON
// format when the `options.json` flag is `true`.
//
// Produce the JSON lexer spec result when these are JSON formatted already as that
// would save us the trouble of doing this again, anywhere else in the JISON
// compiler/generator.
//
// Otherwise return the *parsed* lexer spec as it has
// been processed through LexParser.
function autodetectAndConvertToJSONformat(lexerSpec, options) {
var chk_l = null;
var ex1, err;
if (typeof lexerSpec === 'string') {
if (options.json) {
try {
chk_l = json5.parse(lexerSpec);
// When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode`
// *OR* there's a JSON/JSON5 format error in the input:
} catch (e) {
ex1 = e;
}
}
Eif (!chk_l) {
// // WARNING: the lexer may receive options specified in the **grammar spec file**,
// // hence we should mix the options to ensure the lexParser always
// // receives the full set!
// //
// // make sure all options are 'standardized' before we go and mix them together:
// options = mkStdOptions(grammar.options, options);
try {
chk_l = lexParser.parse(lexerSpec, options);
} catch (e) {
Iif (options.json) {
err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')');
err.secondary_exception = e;
err.stack = ex1.stack;
} else {
err = new Error('Could not parse lexer spec\nError: ' + e.message);
err.stack = e.stack;
}
throw err;
}
}
} else {
chk_l = lexerSpec;
}
// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary:
return chk_l;
}
// expand macros and convert matchers to RegExp's
function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) {
var m, i, k, rule, action, conditions;
var active_conditions;
assert$1(Array.isArray(dict.rules));
var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here!
var newRules = [];
var macros = {};
var regular_rule_count = 0;
var simple_rule_count = 0;
// Assure all options are camelCased:
assert$1(typeof opts.options['case-insensitive'] === 'undefined');
if (!tokens) {
tokens = {};
}
if (opts.options.flex && rules.length > 0) {
rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']);
}
// Depending on the location within the regex we need different expansions of the macros:
// one expansion for when a macro is *inside* a `[...]` and another expansion when a macro
// is anywhere else in a regex:
if (dict.macros) {
macros = prepareMacros(dict.macros, opts);
}
function tokenNumberReplacement(str, token) {
return 'return ' + (tokens[token] || '\'' + token.replace(/'/g, '\\\'') + '\'');
}
// Make sure a comment does not contain any embedded '*/' end-of-comment marker
// as that would break the generated code
function postprocessComment(str) {
if (Array.isArray(str)) {
str = str.join(' ');
}
str = str.replace(/\*\//g, '*\\/'); // destroy any inner `*/` comment terminator sequence.
return str;
}
var routingCode = ['switch(yyrulenumber) {'];
for (i = 0; i < rules.length; i++) {
rule = rules[i].slice(0); // shallow copy: do not modify input rules
m = rule[0];
active_conditions = [];
if (!Array.isArray(m)) {
// implicit add to all inclusive start conditions
for (k in startConditions) {
if (startConditions[k].inclusive) {
active_conditions.push(k);
startConditions[k].rules.push(i);
}
}
} else if (m[0] === '*') {
// Add to ALL start conditions
active_conditions.push('*');
for (k in startConditions) {
startConditions[k].rules.push(i);
}
rule.shift();
m = rule[0];
} else {
// Add to explicit start conditions
conditions = rule.shift();
m = rule[0];
for (k = 0; k < conditions.length; k++) {
if (!startConditions.hasOwnProperty(conditions[k])) {
startConditions[conditions[k]] = {
rules: [],
inclusive: false
};
console.warn('Lexer Warning:', '"' + conditions[k] + '" start condition should be defined as %s or %x; assuming %x now.');
}
active_conditions.push(conditions[k]);
startConditions[conditions[k]].rules.push(i);
}
}
Eif (typeof m === 'string') {
m = expandMacros(m, macros, opts);
m = new XRegExp('^(?:' + m + ')', opts.options.caseInsensitive ? 'i' : '');
}
newRules.push(m);
action = rule[1];
if (typeof action === 'function') {
// Also cope with Arrow Functions (and inline those as well?).
// See also https://github.com/zaach/jison-lex/issues/23
action = helpers.printFunctionSourceCodeContainer(action).code;
}
action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement);
action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement);
var code = ['\n/*! Conditions::'];
code.push(postprocessComment(active_conditions));
code.push('*/', '\n/*! Rule:: ');
code.push(postprocessComment(rule[0]));
code.push('*/', '\n');
// When the action is *only* a simple `return TOKEN` statement, then add it to the caseHelpers;
// otherwise add the additional `break;` at the end.
//
// Note: we do NOT analyze the action block any more to see if the *last* line is a simple
// `return NNN;` statement as there are too many shoddy idioms, e.g.
//
// ```
// %{ if (cond)
// return TOKEN;
// %}
// ```
//
// which would then cause havoc when our action code analysis (using regexes or otherwise) was 'too simple'
// to catch these culprits; hence we resort and stick with the most fundamental approach here:
// always append `break;` even when it would be obvious to a human that such would be 'unreachable code'.
var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim());
if (match_nr) {
simple_rule_count++;
caseHelper.push([].concat(code, i, ':', match_nr[1]).join(' ').replace(/[\n]/g, '\n '));
} else {
regular_rule_count++;
routingCode.push([].concat('case', i, ':', code, action, '\nbreak;').join(' '));
}
}
if (simple_rule_count) {
routingCode.push('default:');
routingCode.push(' return this.simpleCaseActionClusters[yyrulenumber];');
}
routingCode.push('}');
// only inject the big switch/case chunk when there's any `switch` or `default` branch to switch to:
if (simple_rule_count + regular_rule_count > 0) {
actions.push.apply(actions, routingCode);
} else {
actions.push('/* no rules ==> no rule SWITCH! */');
}
return {
rules: newRules,
macros: macros,
regular_rule_count: regular_rule_count,
simple_rule_count: simple_rule_count
};
}
// expand all macros (with maybe one exception) in the given regex: the macros may exist inside `[...]` regex sets or
// elsewhere, which requires two different treatments to expand these macros.
function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) {
var orig = s;
function errinfo() {
if (name) {
return 'macro [[' + name + ']]';
} else {
return 'regex [[' + orig + ']]';
}
}
// propagate deferred exceptions = error reports.
Iif (s instanceof Error) {
return s;
}
var c1, c2;
var rv = [];
var derr;
var se;
while (s.length) {
c1 = s.match(CHR_RE);
Iif (!c1) {
// cope with illegal escape sequences too!
return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s);
} else {
c1 = c1[0];
}
s = s.substr(c1.length);
switch (c1) {
case '[':
// this is starting a set within the regex: scan until end of set!
var set_content = [];
var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1);
while (s.length) {
var inner = s.match(SET_PART_RE);
if (!inner) {
inner = s.match(CHR_RE);
Iif (!inner) {
// cope with illegal escape sequences too!
return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s);
} else {
inner = inner[0];
}
Eif (inner === ']') break;
} else {
inner = inner[0];
}
set_content.push(inner);
s = s.substr(inner.length);
}
// ensure that we hit the terminating ']':
c2 = s.match(CHR_RE);
Iif (!c2) {
// cope with illegal escape sequences too!
return new Error(errinfo() + ': regex set expression is broken: "' + s + '"');
} else {
c2 = c2[0];
}
Iif (c2 !== ']') {
return new Error(errinfo() + ': regex set expression is broken: apparently unterminated');
}
s = s.substr(c2.length);
se = set_content.join('');
// expand any macros in here:
Eif (expandAllMacrosInSet_cb) {
se = expandAllMacrosInSet_cb(se);
assert$1(se);
Iif (se instanceof Error) {
return new Error(errinfo() + ': ' + se.message);
}
}
derr = setmgmt.set2bitarray(l, se, opts);
Iif (derr instanceof Error) {
return new Error(errinfo() + ': ' + derr.message);
}
// find out which set expression is optimal in size:
var s1 = setmgmt.produceOptimizedRegex4Set(l);
// check if the source regex set potentially has any expansions (guestimate!)
//
// The indexOf('{') picks both XRegExp Unicode escapes and JISON lexer macros, which is perfect for us here.
var has_expansions = se.indexOf('{') >= 0;
se = '[' + se + ']';
if (!has_expansions && se.length < s1.length) {
s1 = se;
}
rv.push(s1);
break;
// XRegExp Unicode escape, e.g. `\\p{Number}`:
case '\\p':
c2 = s.match(XREGEXP_UNICODE_ESCAPE_RE);
Eif (c2) {
c2 = c2[0];
s = s.substr(c2.length);
// nothing to expand.
rv.push(c1 + c2);
} else {
// nothing to stretch this match, hence nothing to expand.
rv.push(c1);
}
break;
// Either a range expression or the start of a macro reference: `.{1,3}` or `{NAME}`.
// Treat it as a macro reference and see if it will expand to anything:
case '{':
c2 = s.match(NOTHING_SPECIAL_RE);
Eif (c2) {
c2 = c2[0];
s = s.substr(c2.length);
var c3 = s[0];
s = s.substr(c3.length);
Eif (c3 === '}') {
// possibly a macro name in there... Expand if possible:
c2 = c1 + c2 + c3;
Eif (expandAllMacrosElsewhere_cb) {
c2 = expandAllMacrosElsewhere_cb(c2);
assert$1(c2);
Iif (c2 instanceof Error) {
return new Error(errinfo() + ': ' + c2.message);
}
}
} else {
// not a well-terminated macro reference or something completely different:
// we do not even attempt to expand this as there's guaranteed nothing to expand
// in this bit.
c2 = c1 + c2 + c3;
}
rv.push(c2);
} else {
// nothing to stretch this match, hence nothing to expand.
rv.push(c1);
}
break;
// Recognize some other regex elements, but there's no need to understand them all.
//
// We are merely interested in any chunks now which do *not* include yet another regex set `[...]`
// nor any `{MACRO}` reference:
default:
// non-set character or word: see how much of this there is for us and then see if there
// are any macros still lurking inside there:
c2 = s.match(NOTHING_SPECIAL_RE);
if (c2) {
c2 = c2[0];
s = s.substr(c2.length);
// nothing to expand.
rv.push(c1 + c2);
} else {
// nothing to stretch this match, hence nothing to expand.
rv.push(c1);
}
break;
}
}
s = rv.join('');
// When this result is suitable for use in a set, than we should be able to compile
// it in a regex; that way we can easily validate whether macro X is fit to be used
// inside a regex set:
try {
var re;
re = new XRegExp(s);
re.test(s[0]);
} catch (ex) {
// make sure we produce a regex expression which will fail badly when it is used
// in actual code:
return new Error(errinfo() + ': expands to an invalid regex: /' + s + '/');
}
assert$1(s);
return s;
}
// expand macros within macros and cache the result
function prepareMacros(dict_macros, opts) {
var macros = {};
// expand a `{NAME}` macro which exists inside a `[...]` set:
function expandMacroInSet(i) {
var k, a, m;
if (!macros[i]) {
m = dict_macros[i];
if (m.indexOf('{') >= 0) {
// set up our own record so we can detect definition loops:
macros[i] = {
in_set: false,
elsewhere: null,
raw: dict_macros[i]
};
for (k in dict_macros) {
if (dict_macros.hasOwnProperty(k) && i !== k) {
// it doesn't matter if the lexer recognized that the inner macro(s)
// were sitting inside a `[...]` set or not: the fact that they are used
// here in macro `i` which itself sits in a set, makes them *all* live in
// a set so all of them get the same treatment: set expansion style.
//
// Note: make sure we don't try to expand any XRegExp `\p{...}` or `\P{...}`
// macros here:
if (XRegExp._getUnicodeProperty(k)) {
// Work-around so that you can use `\p{ascii}` for a XRegExp slug, a.k.a.
// Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories,
// while using `\p{ASCII}` as a *macro expansion* of the `ASCII`
// macro:
Iif (k.toUpperCase() !== k) {
m = new Error('Cannot use name "' + k + '" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "' + k.toUpperCase() + '" to work around this issue or give your offending macro a different name.');
break;
}
}
a = m.split('{' + k + '}');
if (a.length > 1) {
var x = expandMacroInSet(k);
assert$1(x);
Iif (x instanceof Error) {
m = x;
break;
}
m = a.join(x);
}
}
}
}
var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts);
var s1;
// propagate deferred exceptions = error reports.
if (mba instanceof Error) {
s1 = mba;
} else {
s1 = setmgmt.bitarray2set(mba, false);
m = s1;
}
macros[i] = {
in_set: s1,
elsewhere: null,
raw: dict_macros[i]
};
} else {
m = macros[i].in_set;
Iif (m instanceof Error) {
// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away!
return new Error(m.message);
}
// detect definition loop:
Iif (m === false) {
return new Error('Macro name "' + i + '" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');
}
}
return m;
}
function expandMacroElsewhere(i) {
var k, a, m;
if (macros[i].elsewhere == null) {
m = dict_macros[i];
// set up our own record so we can detect definition loops:
macros[i].elsewhere = false;
// the macro MAY contain other macros which MAY be inside a `[...]` set in this
// macro or elsewhere, hence we must parse the regex:
m = reduceRegex(m, i, opts, expandAllMacrosInSet, expandAllMacrosElsewhere);
// propagate deferred exceptions = error reports.
Iif (m instanceof Error) {
return m;
}
macros[i].elsewhere = m;
} else {
m = macros[i].elsewhere;
Iif (m instanceof Error) {
// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away!
return m;
}
// detect definition loop:
Iif (m === false) {
return new Error('Macro name "' + i + '" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');
}
}
return m;
}
function expandAllMacrosInSet(s) {
var i, x;
// process *all* the macros inside [...] set:
if (s.indexOf('{') >= 0) {
for (i in macros) {
Eif (macros.hasOwnProperty(i)) {
var a = s.split('{' + i + '}');
if (a.length > 1) {
x = expandMacroInSet(i);
assert$1(x);
Iif (x instanceof Error) {
return new Error('failure to expand the macro [' + i + '] in set [' + s + ']: ' + x.message);
}
s = a.join(x);
}
// stop the brute-force expansion attempt when we done 'em all:
if (s.indexOf('{') === -1) {
break;
}
}
}
}
return s;
}
function expandAllMacrosElsewhere(s) {
var i, x;
// When we process the remaining macro occurrences in the regex
// every macro used in a lexer rule will become its own capture group.
//
// Meanwhile the cached expansion will expand any submacros into
// *NON*-capturing groups so that the backreference indexes remain as you'ld
// expect and using macros doesn't require you to know exactly what your
// used macro will expand into, i.e. which and how many submacros it has.
//
// This is a BREAKING CHANGE from vanilla jison 0.4.15!
Eif (s.indexOf('{') >= 0) {
for (i in macros) {
Eif (macros.hasOwnProperty(i)) {
// These are all submacro expansions, hence non-capturing grouping is applied:
var a = s.split('{' + i + '}');
if (a.length > 1) {
x = expandMacroElsewhere(i);
assert$1(x);
Iif (x instanceof Error) {
return new Error('failure to expand the macro [' + i + '] in regex /' + s + '/: ' + x.message);
}
s = a.join('(?:' + x + ')');
}
// stop the brute-force expansion attempt when we done 'em all:
if (s.indexOf('{') === -1) {
break;
}
}
}
}
return s;
}
var m, i;
Iif (opts.debug) console.log('\n############## RAW macros: ', dict_macros);
// first we create the part of the dictionary which is targeting the use of macros
// *inside* `[...]` sets; once we have completed that half of the expansions work,
// we then go and expand the macros for when they are used elsewhere in a regex:
// iff we encounter submacros then which are used *inside* a set, we can use that
// first half dictionary to speed things up a bit as we can use those expansions
// straight away!
for (i in dict_macros) {
Eif (dict_macros.hasOwnProperty(i)) {
expandMacroInSet(i);
}
}
for (i in dict_macros) {
Eif (dict_macros.hasOwnProperty(i)) {
expandMacroElsewhere(i);
}
}
Iif (opts.debug) console.log('\n############### expanded macros: ', macros);
return macros;
}
// expand macros in a regex; expands them recursively
function expandMacros(src, macros, opts) {
var expansion_count = 0;
// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already!
// Hence things should be easy in there:
function expandAllMacrosInSet(s) {
var i, m, x;
// process *all* the macros inside [...] set:
if (s.indexOf('{') >= 0) {
for (i in macros) {
Eif (macros.hasOwnProperty(i)) {
m = macros[i];
var a = s.split('{' + i + '}');
if (a.length > 1) {
x = m.in_set;
assert$1(x);
Iif (x instanceof Error) {
// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away!
throw x;
}
// detect definition loop:
Iif (x === false) {
return new Error('Macro name "' + i + '" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');
}
s = a.join(x);
expansion_count++;
}
// stop the brute-force expansion attempt when we done 'em all:
if (s.indexOf('{') === -1) {
break;
}
}
}
}
return s;
}
function expandAllMacrosElsewhere(s) {
var i, m, x;
// When we process the main macro occurrences in the regex
// every macro used in a lexer rule will become its own capture group.
//
// Meanwhile the cached expansion will expand any submacros into
// *NON*-capturing groups so that the backreference indexes remain as you'ld
// expect and using macros doesn't require you to know exactly what your
// used macro will expand into, i.e. which and how many submacros it has.
//
// This is a BREAKING CHANGE from vanilla jison 0.4.15!
Eif (s.indexOf('{') >= 0) {
for (i in macros) {
Eif (macros.hasOwnProperty(i)) {
m = macros[i];
var a = s.split('{' + i + '}');
if (a.length > 1) {
// These are all main macro expansions, hence CAPTURING grouping is applied:
x = m.elsewhere;
assert$1(x);
// detect definition loop:
Iif (x === false) {
return new Error('Macro name "' + i + '" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');
}
s = a.join('(' + x + ')');
expansion_count++;
}
// stop the brute-force expansion attempt when we done 'em all:
if (s.indexOf('{') === -1) {
break;
}
}
}
}
return s;
}
// When we process the macro occurrences in the regex
// every macro used in a lexer rule will become its own capture group.
//
// Meanwhile the cached expansion will have expanded any submacros into
// *NON*-capturing groups so that the backreference indexes remain as you'ld
// expect and using macros doesn't require you to know exactly what your
// used macro will expand into, i.e. which and how many submacros it has.
//
// This is a BREAKING CHANGE from vanilla jison 0.4.15!
var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere);
// propagate deferred exceptions = error reports.
Iif (s2 instanceof Error) {
throw s2;
}
// only when we did expand some actual macros do we take the re-interpreted/optimized/regenerated regex from reduceRegex()
// in order to keep our test cases simple and rules recognizable. This assumes the user can code good regexes on his own,
// as long as no macros are involved...
//
// Also pick the reduced regex when there (potentially) are XRegExp extensions in the original, e.g. `\\p{Number}`,
// unless the `xregexp` output option has been enabled.
if (expansion_count > 0 || src.indexOf('\\p{') >= 0 && !opts.options.xregexp) {
src = s2;
} else {
// Check if the reduced regex is smaller in size; when it is, we still go with the new one!
if (s2.length < src.length) {
src = s2;
}
}
return src;
}
function prepareStartConditions(conditions) {
var sc;
var hash = {};
for (sc in conditions) {
Eif (conditions.hasOwnProperty(sc)) {
hash[sc] = {
rules: [],
inclusive: !conditions[sc]
};
}
}
return hash;
}
function buildActions(dict, tokens, opts) {
var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;'];
var tok;
var toks = {};
var caseHelper = [];
// tokens: map/array of token numbers to token names
for (tok in tokens) {
var idx = parseInt(tok);
Eif (idx && idx > 0) {
toks[tokens[tok]] = idx;
}
}
var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts);
var code = actions.join('\n');
'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) {
code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1');
});
return {
caseHelperInclude: '{\n' + caseHelper.join(',') + '\n}',
actions: 'function lexer__performAction(yy, yyrulenumber, YY_START) {\n var yy_ = this;\n\n ' + code + '\n }',
rules: gen.rules,
macros: gen.macros, // propagate these for debugging/diagnostic purposes
regular_rule_count: gen.regular_rule_count,
simple_rule_count: gen.simple_rule_count
};
}
//
// NOTE: this is *almost* a copy of the JisonParserError producing code in
// jison/lib/jison.js @ line 2304:lrGeneratorMixin.generateErrorClass
//
function generateErrorClass() {
// --- START lexer error class ---
var prelude = '/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a \'classic\' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n Object.defineProperty(this, \'name\', {\n enumerable: false,\n writable: false,\n value: \'JisonLexerError\'\n });\n\n if (msg == null) msg = \'???\';\n\n Object.defineProperty(this, \'message\', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty(\'captureStackTrace\')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, \'stack\', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === \'function\') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = \'JisonLexerError\';';
// --- END lexer error class ---
return prelude;
}
var jisonLexerErrorDefinition = generateErrorClass();
function generateFakeXRegExpClassSrcCode() {
return rmCommonWS(_templateObject36);
}
/** @constructor */
function RegExpLexer(dict, input, tokens, build_options) {
var opts;
var dump = false;
function test_me(tweak_cb, description, src_exception, ex_callback) {
opts = processGrammar(dict, tokens, build_options);
opts.__in_rules_failure_analysis_mode__ = false;
prepExportStructures(opts);
assert$1(opts.options);
Iif (tweak_cb) {
tweak_cb();
}
var source = generateModuleBody(opts);
try {
// The generated code will always have the `lexer` variable declared at local scope
// as `eval()` will use the local scope.
//
// The compiled code will look something like this:
//
// ```
// var lexer;
// bla bla...
// ```
//
// or
//
// ```
// var lexer = { bla... };
// ```
var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', 'return lexer;'].join('\n');
var lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) {
//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n");
chkBugger(sourcecode);
var lexer_f = new Function('', sourcecode);
return lexer_f();
}, opts.options, "lexer");
Iif (!lexer) {
throw new Error('no lexer defined *at all*?!');
}
Iif (_typeof(lexer.options) !== 'object' || lexer.options == null) {
throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');
}
Iif (typeof lexer.setInput !== 'function') {
throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');
}
Iif (lexer.EOF !== 1 && lexer.ERROR !== 2) {
throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');
}
// When we do NOT crash, we found/killed the problem area just before this call!
Iif (src_exception && description) {
var msg = description;
if (typeof description === 'function') {
msg = description();
}
src_exception.message += '\n (' + msg + ')';
}
// patch the pre and post handlers in there, now that we have some live code to work with:
Eif (opts.options) {
var pre = opts.options.pre_lex;
var post = opts.options.post_lex;
// since JSON cannot encode functions, we'll have to do it manually now:
if (typeof pre === 'function') {
lexer.options.pre_lex = pre;
}
if (typeof post === 'function') {
lexer.options.post_lex = post;
}
}
if (opts.options.showSource) {
Eif (typeof opts.options.showSource === 'function') {
opts.options.showSource(lexer, source, opts);
} else {
console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n");
}
}
return lexer;
} catch (ex) {
// if (src_exception) {
// src_exception.message += '\n (' + description + ': ' + ex.message + ')';
// }
if (ex_callback) {
ex_callback(ex);
} else if (dump) {
console.log('source code:\n', source);
}
return false;
}
}
/** @constructor */
var lexer = test_me(null, null, null, function (ex) {
// When we get an exception here, it means some part of the user-specified lexer is botched.
//
// Now we go and try to narrow down the problem area/category:
assert$1(opts.options);
assert$1(opts.options.xregexp !== undefined);
var orig_xregexp_opt = !!opts.options.xregexp;
if (!test_me(function () {
assert$1(opts.options.xregexp !== undefined);
opts.options.xregexp = false;
opts.showSource = false;
}, 'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.', ex, null)) {
if (!test_me(function () {
// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing!
opts.options.xregexp = orig_xregexp_opt;
opts.conditions = [];
opts.showSource = false;
}, function () {
assert$1(Array.isArray(opts.rules));
return opts.rules.length > 0 ? 'One or more of your lexer state names are possibly botched?' : 'Your custom lexer is somehow botched.';
}, ex, null)) {
var rulesSpecSize;
if (!test_me(function () {
// store the parsed rule set size so we can use that info in case
// this attempt also fails:
assert$1(Array.isArray(opts.rules));
rulesSpecSize = opts.rules.length;
// opts.conditions = [];
opts.rules = [];
opts.showSource = false;
opts.__in_rules_failure_analysis_mode__ = true;
}, 'One or more of your lexer rules are possibly botched?', ex, null)) {
// kill each rule action block, one at a time and test again after each 'edit':
var rv = false;
for (var i = 0, len = rulesSpecSize; i < len; i++) {
var lastEditedRuleSpec;
rv = test_me(function () {
assert$1(Array.isArray(opts.rules));
assert$1(opts.rules.length === rulesSpecSize);
// opts.conditions = [];
// opts.rules = [];
// opts.__in_rules_failure_analysis_mode__ = true;
// nuke all rules' actions up to and including rule numero `i`:
for (var j = 0; j <= i; j++) {
// rules, when parsed, have 2 or 3 elements: [conditions, handle, action];
// now we want to edit the *action* part:
var rule = opts.rules[j];
assert$1(Array.isArray(rule));
assert$1(rule.length === 2 || rule.length === 3);
rule.pop();
rule.push('{ /* nada */ }');
lastEditedRuleSpec = rule;
}
}, function () {
return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?';
}, ex, null);
if (rv) {
break;
}
}
if (!rv) {
test_me(function () {
opts.conditions = [];
opts.rules = [];
opts.performAction = 'null';
// opts.options = {};
// opts.caseHelperInclude = '{}';
opts.showSource = false;
opts.__in_rules_failure_analysis_mode__ = true;
dump = false;
}, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null);
}
}
}
}
throw ex;
});
lexer.setInput(input);
/** @public */
lexer.generate = function () {
return generateFromOpts(opts);
};
/** @public */
lexer.generateModule = function () {
return generateModule(opts);
};
/** @public */
lexer.generateCommonJSModule = function () {
return generateCommonJSModule(opts);
};
/** @public */
lexer.generateESModule = function () {
return generateESModule(opts);
};
/** @public */
lexer.generateAMDModule = function () {
return generateAMDModule(opts);
};
// internal APIs to aid testing:
/** @public */
lexer.getExpandedMacros = function () {
return opts.macros;
};
return lexer;
}
// code stripping performance test for very simple grammar:
//
// - removing backtracking parser code branches: 730K -> 750K rounds
// - removing all location info tracking: yylineno, yylloc, etc.: 750K -> 900K rounds
// - no `yyleng`: 900K -> 905K rounds
// - no `this.done` as we cannot have a NULL `_input` anymore: 905K -> 930K rounds
// - `simpleCaseActionClusters` as array instead of hash object: 930K -> 940K rounds
// - lexers which have only return stmts, i.e. only a
// `simpleCaseActionClusters` lookup table to produce
// lexer tokens: *inline* the `performAction` call: 940K -> 950K rounds
// - given all the above, you can *inline* what's left of
// `lexer_next()`: 950K -> 955K rounds (? this stuff becomes hard to measure; inaccuracy abounds!)
//
// Total gain when we forget about very minor (and tough to nail) *inlining* `lexer_next()` gains:
//
// 730 -> 950 ~ 30% performance gain.
//
// As a function can be reproduced in source-code form by any JavaScript engine, we're going to wrap this chunk
// of code in a function so that we can easily get it including it comments, etc.:
/**
@public
@nocollapse
*/
function getRegExpLexerPrototype() {
// --- START lexer kernel ---
return '{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been \'unfolded\' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: \'\', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: \'\', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: \'\', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: \'\', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the \'token value\' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the \'cursor position\' in the input string, i.e. the number of characters matched so far\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: \'line number\' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n * \n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n msg = \'\' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf(\'\\n\') > 0 && msg.indexOf(\'^\') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === \'function\') {\n var pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += \'\\n\';\n }\n msg += \'\\n Erroneous area:\\n\' + this.prettyPrintRange(this.yylloc); \n } else if (typeof this.showPosition === \'function\') {\n var pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== \'\\n\' && pos_str[0] !== \'\\n\') {\n msg += \'\\n\' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n var pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the \'lexer cursor position\'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy,\n lexer: this,\n\n /**\n * and make sure the error info doesn\'t stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n * \n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n * \n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this.hasOwnProperty(key) && typeof key === \'object\') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n * \n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === \'function\') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === \'function\') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } \n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n * \n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n var lineno_msg = \'\';\n if (this.yylloc) {\n lineno_msg = \' on line \' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(\'Lexical error\' + lineno_msg + \': \' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it\'s time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n * \n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n // prevent lingering circular references from causing memory leaks:\n this.setInput(\'\', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === \'function\') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n * \n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n this.yytext = \'\';\n this.yyleng = 0;\n this.match = \'\';\n // - DO NOT reset `this.matched`\n this.matches = false;\n this._more = false;\n this._backtrack = false;\n\n var col = (this.yylloc ? this.yylloc.last_column : 0);\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [this.offset, this.offset]\n };\n },\n\n /**\n * resets the lexer, sets new input\n * \n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n this.yy = yy || this.yy || {};\n\n // also check if we\'ve fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n var rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === \'number\') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n var conditions = this.conditions;\n for (var k in conditions) {\n var spec = conditions[k];\n\n var rule_ids = spec.rules;\n\n var len = rule_ids.length;\n var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n var rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n var idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n this._input = input || \'\';\n this.clear();\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = \'\';\n this.conditionStack = [\'INITIAL\'];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n this.offset = 0;\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse, \n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history. \n * \n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n * \n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface: \n * `function callback(input, cpsArg)`\n * \n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n * \n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API. \n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `"" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html \n * -- that way any returned object\'s `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n * \n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n var rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== \'string\') {\n if (rv) {\n this._input = \'\' + rv; \n }\n // else: keep `this._input` as is. \n } else {\n this._input = rv; \n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n * \n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n if (!this._input) {\n //this.done = true; -- don\'t set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <<EOF>> tokens and perform user action code for a <<EOF>> match, but only does so *once*)\n return null;\n }\n var ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single \'character\' only.\n var slice_len = 1;\n var lines = false;\n if (ch === \'\\n\') {\n lines = true;\n } else if (ch === \'\\r\') {\n lines = true;\n var ch2 = this._input[1];\n if (ch2 === \'\\n\') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n * \n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n var len = ch.length;\n var lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array\'s\n // last index slot; we don\'t mind when other previously \n // matched lines end up in the array too. \n var pre = this.match;\n var pre_lines = pre.split(/(?:\\r\\n?|\\n)/g);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(/(?:\\r\\n?|\\n)/g);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * cache matched text and append it on next action\n * \n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n * \n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an \'error\' token to be produced for the current\n // `.lex()` run.\n var lineno_msg = \'\';\n if (this.yylloc) {\n lineno_msg = \' on line \' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(\'Lexical error\' + lineno_msg + \': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n * \n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n * \n * Limit the returned string length to `maxSize` (default: 20).\n * \n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n * \n * Negative limit values equal *unlimited*.\n * \n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n var past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0)\n maxSize = past.length;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = past.length; // can\'t ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we\'ve transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = past.replace(/\\r\\n|\\r/g, \'\\n\').split(\'\\n\');\n a = a.slice(-maxLines);\n past = a.join(\'\\n\');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = \'...\' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input, i.e. for error messages.\n * \n * Limit the returned string length to `maxSize` (default: 20).\n * \n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n * \n * Negative limit values equal *unlimited*.\n *\n * > ### NOTE ###\n * >\n * > *"upcoming input"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *"currently lexed"* input is the input \n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block. \n * >\n * \n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n var next = this.match;\n if (maxSize < 0)\n maxSize = next.length + this._input.length;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = maxSize; // can\'t ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we\'ve transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += this._input.substring(0, maxSize * 2 + 2); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = next.replace(/\\r\\n|\\r/g, \'\\n\').split(\'\\n\');\n a = a.slice(0, maxLines);\n next = a.join(\'\\n\');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + \'...\';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n * \n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n var pre = this.pastInput(maxPrefix).replace(/\\s/g, \' \');\n var c = new Array(pre.length + 1).join(\'-\');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, \' \') + \'\\n\' + c + \'^\';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be \'constant\' (function has no side-effects).\n * \n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n var loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0; \n loc.range[1] = actual.range[1] | 0;\n } \n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0; \n } \n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0; \n } \n }\n\n // plan C?: see if the \'current\' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0; \n } \n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0; \n } \n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the \'raw\' value of the latter\n // or plan D heuristics to produce a \'sensible\' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced \n * by the given location info range, plus a few lines of context.\n * \n * This function pretty-prints the indicated section of the input, with line numbers \n * and everything!\n * \n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n * \n * - `loc` is the location info object which references the area which should be\n * displayed and \'marked up\': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n * \n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n * \n * When this location info is not provided, a default context of 3 lines is\n * used.\n * \n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n * \n * When this location info is not provided, a default context of 1 line only is\n * used.\n * \n * Special Notes:\n * \n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n * \n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n * \n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n * \n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2); \n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n var input = this.matched + this._input;\n var lines = input.split(\'\\n\');\n var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n var lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n var ws_prefix = new Array(lineno_display_width).join(\' \');\n var nonempty_line_indexes = [];\n var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n var lno = index + l0;\n var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n var rv = lno_pfx + \': \' + line;\n var errpfx = (new Array(lineno_display_width + 1)).join(\'^\');\n var offset = 2 + 1;\n var len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n if (len) {\n var lead = new Array(offset).join(\'.\');\n var mark = new Array(len).join(\'^\');\n rv += \'\\n\' + errpfx + lead + mark;\n\n if (line.trim().length > 0) {\n nonempty_line_indexes.push(index);\n }\n }\n\n rv = rv.replace(/\\t/g, \' \');\n return rv;\n });\n\n // now make sure we don\'t print an overly large amount of error area: limit it \n // to the top and bottom line count:\n if (nonempty_line_indexes.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n var clip_start = nonempty_line_indexes[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n var clip_end = nonempty_line_indexes[nonempty_line_indexes.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n var intermediate_line = (new Array(lineno_display_width + 1)).join(\' \') + \' (...continued...)\';\n intermediate_line += \'\\n\' + (new Array(lineno_display_width + 1)).join(\'-\') + \' (---------------)\';\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n return rv.join(\'\\n\');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n * \n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n * \n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n var l1 = yylloc.first_line;\n var l2 = yylloc.last_line;\n var c1 = yylloc.first_column;\n var c2 = yylloc.last_column;\n var dl = l2 - l1;\n var dc = c2 - c1;\n var rv;\n if (dl === 0) {\n rv = \'line \' + l1 + \', \';\n if (dc <= 1) {\n rv += \'column \' + c1;\n } else {\n rv += \'columns \' + c1 + \' .. \' + c2;\n }\n } else {\n rv = \'lines \' + l1 + \'(column \' + c1 + \') .. \' + l2 + \'(column \' + c2 + \')\';\n }\n if (yylloc.range && display_range_too) {\n var r1 = yylloc.range[0];\n var r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += \' {String Offset: \' + r1 + \'}\';\n } else {\n rv += \' {String Offset range: \' + r1 + \' .. \' + r2 + \'}\';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n * \n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n * \n * Also move the input cursor forward and update the match collectors:\n * \n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n * \n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n var token,\n lines,\n backup,\n match_str,\n match_str_len;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice(0)\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(0),\n done: this.done\n };\n }\n\n match_str = match[0];\n match_str_len = match_str.length;\n // if (match_str.indexOf(\'\\n\') !== -1 || match_str.indexOf(\'\\r\') !== -1) {\n lines = match_str.split(/(?:\\r\\n?|\\n)/g);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n // }\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (var k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one \'error\' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n * \n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n var token,\n match,\n tempMatch,\n index;\n if (!this._more) {\n this.clear();\n }\n var spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n var lineno_msg = \'\';\n if (this.options.trackPosition) {\n lineno_msg = \' on line \' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(\'Internal lexer engine error\' + lineno_msg + \': The lex grammar programmer pushed a non-existing condition name "\' + this.topState() + \'"; this is a fatal error and should be reported to the application programmer team!\', false);\n // produce one \'error\' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n var rule_ids = spec.rules;\n var regexes = spec.__rule_regexes;\n var len = spec.__rule_count;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (var i = 1; i <= len; i++) {\n tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n if (match) {\n token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n } else {\n var lineno_msg = \'\';\n if (this.options.trackPosition) {\n lineno_msg = \' on line \' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(\'Lexical error\' + lineno_msg + \': Unrecognized text.\', this.options.lexerErrorsAreRecoverable);\n\n var pendingInput = this._input;\n var activeCondition = this.topState();\n var conditionStackDepth = this.conditionStack.length;\n\n token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not \'recover\' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches && \n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() && \n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n * \n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n var r;\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === \'function\') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === \'function\') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === \'function\') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === \'function\') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === \'function\') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === \'function\') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the \n * `pre_lex()` nor any of the `post_lex()` callbacks.\n * \n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n var r;\n\n while (!r) {\n r = this.next();\n }\n\n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n * \n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n var rv = {\n fastLex: !(\n typeof this.pre_lex === \'function\' ||\n typeof this.options.pre_lex === \'function\' ||\n (this.yy && typeof this.yy.pre_lex === \'function\') ||\n (this.yy && typeof this.yy.post_lex === \'function\') ||\n typeof this.options.post_lex === \'function\' ||\n typeof this.post_lex === \'function\'\n ) && typeof this.fastLex === \'function\',\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n * \n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n * \n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n * \n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n var n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null; \n return this.conditionStack.pop();\n } else {\n return this.conditionStack[0];\n }\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n * \n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n } else {\n return \'INITIAL\';\n }\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n * \n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n return this.conditions[this.conditionStack[this.conditionStack.length - 1]];\n } else {\n return this.conditions[\'INITIAL\'];\n }\n },\n\n /**\n * return the number of states currently on the stack\n * \n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n return this.conditionStack.length;\n }\n}';
// --- END lexer kernel ---
}
chkBugger(getRegExpLexerPrototype());
RegExpLexer.prototype = new Function(rmCommonWS(_templateObject37, getRegExpLexerPrototype()))();
// The lexer code stripper, driven by optimization analysis settings and
// lexer options, which cannot be changed at run-time.
function stripUnusedLexerCode(src, opt) {
// uses yyleng: ..................... ${opt.lexerActionsUseYYLENG}
// uses yylineno: ................... ${opt.lexerActionsUseYYLINENO}
// uses yytext: ..................... ${opt.lexerActionsUseYYTEXT}
// uses yylloc: ..................... ${opt.lexerActionsUseYYLOC}
// uses ParseError API: ............. ${opt.lexerActionsUseParseError}
// uses location tracking & editing: ${opt.lexerActionsUseLocationTracking}
// uses more() API: ................. ${opt.lexerActionsUseMore}
// uses unput() API: ................ ${opt.lexerActionsUseUnput}
// uses reject() API: ............... ${opt.lexerActionsUseReject}
// uses less() API: ................. ${opt.lexerActionsUseLess}
// uses display APIs pastInput(), upcomingInput(), showPosition():
// ............................. ${opt.lexerActionsUseDisplayAPIs}
// uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC}
var ast = helpers.parseCodeChunkToAST(src, opt);
var new_src = helpers.prettyPrintAST(ast, opt);
new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS(_templateObject38, opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC));
return new_src;
}
// generate lexer source from a grammar
/** @public */
function generate(dict, tokens, build_options) {
var opt = processGrammar(dict, tokens, build_options);
return generateFromOpts(opt);
}
// process the grammar and build final data structures and functions
/** @public */
function processGrammar(dict, tokens, build_options) {
build_options = build_options || {};
var opts = {
// include the knowledge passed through `build_options` about which lexer
// features will actually be *used* by the environment (which in 99.9%
// of cases is a jison *parser*):
//
// (this stuff comes straight from the jison Optimization Analysis.)
//
parseActionsUseYYLENG: build_options.parseActionsUseYYLENG,
parseActionsUseYYLINENO: build_options.parseActionsUseYYLINENO,
parseActionsUseYYTEXT: build_options.parseActionsUseYYTEXT,
parseActionsUseYYLOC: build_options.parseActionsUseYYLOC,
parseActionsUseParseError: build_options.parseActionsUseParseError,
parseActionsUseYYERROR: build_options.parseActionsUseYYERROR,
parseActionsUseYYERROK: build_options.parseActionsUseYYERROK,
parseActionsUseYYRECOVERING: build_options.parseActionsUseYYRECOVERING,
parseActionsUseYYCLEARIN: build_options.parseActionsUseYYCLEARIN,
parseActionsUseValueTracking: build_options.parseActionsUseValueTracking,
parseActionsUseValueAssignment: build_options.parseActionsUseValueAssignment,
parseActionsUseLocationTracking: build_options.parseActionsUseLocationTracking,
parseActionsUseLocationAssignment: build_options.parseActionsUseLocationAssignment,
parseActionsUseYYSTACK: build_options.parseActionsUseYYSTACK,
parseActionsUseYYSSTACK: build_options.parseActionsUseYYSSTACK,
parseActionsUseYYSTACKPOINTER: build_options.parseActionsUseYYSTACKPOINTER,
parseActionsUseYYRULELENGTH: build_options.parseActionsUseYYRULELENGTH,
parseActionsUseYYMERGELOCATIONINFO: build_options.parseActionsUseYYMERGELOCATIONINFO,
parserHasErrorRecovery: build_options.parserHasErrorRecovery,
parserHasErrorReporting: build_options.parserHasErrorReporting,
lexerActionsUseYYLENG: '???',
lexerActionsUseYYLINENO: '???',
lexerActionsUseYYTEXT: '???',
lexerActionsUseYYLOC: '???',
lexerActionsUseParseError: '???',
lexerActionsUseYYERROR: '???',
lexerActionsUseLocationTracking: '???',
lexerActionsUseMore: '???',
lexerActionsUseUnput: '???',
lexerActionsUseReject: '???',
lexerActionsUseLess: '???',
lexerActionsUseDisplayAPIs: '???',
lexerActionsUseDescribeYYLOC: '???'
};
dict = autodetectAndConvertToJSONformat(dict, build_options) || {};
// Feed the possibly reprocessed 'dictionary' above back to the caller
// (for use by our error diagnostic assistance code)
opts.lex_rule_dictionary = dict;
// Always provide the lexer with an options object, even if it's empty!
// Make sure to camelCase all options:
opts.options = mkStdOptions(build_options, dict.options);
opts.moduleType = opts.options.moduleType;
opts.moduleName = opts.options.moduleName;
opts.conditions = prepareStartConditions(dict.startConditions);
opts.conditions.INITIAL = {
rules: [],
inclusive: true
};
// only produce rule action code blocks when there are any rules at all;
// a "custom lexer" has ZERO rules and must be defined entirely in
// other code blocks:
var code = dict.rules ? buildActions(dict, tokens, opts) : {};
opts.performAction = code.actions;
opts.caseHelperInclude = code.caseHelperInclude;
opts.rules = code.rules || [];
opts.macros = code.macros;
opts.regular_rule_count = code.regular_rule_count;
opts.simple_rule_count = code.simple_rule_count;
opts.conditionStack = ['INITIAL'];
opts.actionInclude = dict.actionInclude || '';
opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim();
return opts;
}
// Assemble the final source from the processed grammar
/** @public */
function generateFromOpts(opt) {
var code = '';
switch (opt.moduleType) {
case 'js':
code = generateModule(opt);
break;
case 'amd':
code = generateAMDModule(opt);
break;
case 'es':
code = generateESModule(opt);
break;
case 'commonjs':
default:
code = generateCommonJSModule(opt);
break;
}
return code;
}
function generateRegexesInitTableCode(opt) {
var a = opt.rules;
var print_xregexp = opt.options && opt.options.xregexp;
var id_display_width = 1 + Math.log10(a.length | 1) | 0;
var ws_prefix = new Array(id_display_width).join(' ');
var b = a.map(function generateXRegExpInitCode(re, idx) {
var idx_str = (ws_prefix + idx).substr(-id_display_width);
Eif (re instanceof XRegExp) {
// When we don't need the special XRegExp sauce at run-time, we do with the original
// JavaScript RegExp instance a.k.a. 'native regex':
if (re.xregexp.isNative || !print_xregexp) {
return '/* ' + idx_str + ': */ ' + re;
}
// And make sure to escape the regex to make it suitable for placement inside a *string*
// as it is passed as a string argument to the XRegExp constructor here.
var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&');
return '/* ' + idx_str + ': */ new XRegExp("' + re_src + '", "' + re.xregexp.flags + '")';
} else {
return '/* ' + idx_str + ': */ ' + re;
}
});
return b.join(',\n');
}
function generateModuleBody(opt) {
// make the JSON output look more like JavaScript:
function cleanupJSON(str) {
str = str.replace(/ "rules": \[/g, ' rules: [');
str = str.replace(/ "inclusive": /g, ' inclusive: ');
return str;
}
function produceOptions(opts) {
var obj = {};
var do_not_pass = {
debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway!
enableDebugLogs: 1,
json: 1,
_: 1,
noMain: 1,
dumpSourceCodeOnFailure: 1,
throwErrorOnCompileFailure: 1,
reportStats: 1,
file: 1,
outfile: 1,
inputPath: 1,
inputFilename: 1,
defaultModuleName: 1,
moduleName: 1,
moduleType: 1,
lexerErrorsAreRecoverable: 0,
flex: 0,
backtrack_lexer: 0,
caseInsensitive: 0,
showSource: 1,
exportAST: 1,
exportAllTables: 1,
exportSourceCode: 1,
prettyCfg: 1,
parseActionsUseYYLENG: 1,
parseActionsUseYYLINENO: 1,
parseActionsUseYYTEXT: 1,
parseActionsUseYYLOC: 1,
parseActionsUseParseError: 1,
parseActionsUseYYERROR: 1,
parseActionsUseYYRECOVERING: 1,
parseActionsUseYYERROK: 1,
parseActionsUseYYCLEARIN: 1,
parseActionsUseValueTracking: 1,
parseActionsUseValueAssignment: 1,
parseActionsUseLocationTracking: 1,
parseActionsUseLocationAssignment: 1,
parseActionsUseYYSTACK: 1,
parseActionsUseYYSSTACK: 1,
parseActionsUseYYSTACKPOINTER: 1,
parseActionsUseYYRULELENGTH: 1,
parseActionsUseYYMERGELOCATIONINFO: 1,
parserHasErrorRecovery: 1,
parserHasErrorReporting: 1,
lexerActionsUseYYLENG: 1,
lexerActionsUseYYLINENO: 1,
lexerActionsUseYYTEXT: 1,
lexerActionsUseYYLOC: 1,
lexerActionsUseParseError: 1,
lexerActionsUseYYERROR: 1,
lexerActionsUseLocationTracking: 1,
lexerActionsUseMore: 1,
lexerActionsUseUnput: 1,
lexerActionsUseReject: 1,
lexerActionsUseLess: 1,
lexerActionsUseDisplayAPIs: 1,
lexerActionsUseDescribeYYLOC: 1
};
for (var k in opts) {
if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) {
// make sure numeric values are encoded as numeric, the rest as boolean/string.
Iif (typeof opts[k] === 'string') {
var f = parseFloat(opts[k]);
if (f == opts[k]) {
obj[k] = f;
continue;
}
}
obj[k] = opts[k];
}
}
// And now some options which should receive some special processing:
var pre = obj.pre_lex;
var post = obj.post_lex;
// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on:
if (pre) {
obj.pre_lex = true;
}
if (post) {
obj.post_lex = true;
}
var js = JSON.stringify(obj, null, 2);
js = js.replace(new XRegExp(' "(' + ID_REGEX_BASE + ')": ', 'g'), ' $1: ');
js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) {
return ls + 'pre_lex: ' + String(pre) + (tc || '');
});
js = js.replace(/^( +)post_lex: true(,)?$/gm, function (m, ls, tc) {
return ls + 'post_lex: ' + String(post) + (tc || '');
});
return js;
}
var out;
if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) {
// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined:
// JavaScript is fine with that.
var code = [rmCommonWS(_templateObject39), '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */
];
// get the RegExpLexer.prototype in source code form:
var protosrc = getRegExpLexerPrototype();
// and strip off the surrounding bits we don't want:
protosrc = protosrc.replace(/^[\s\r\n]*\{/, '').replace(/\s*\}[\s\r\n]*$/, '').trim();
code.push(protosrc + ',\n');
assert$1(opt.options);
// Assure all options are camelCased:
assert$1(typeof opt.options['case-insensitive'] === 'undefined');
code.push(' options: ' + produceOptions(opt.options));
/*
function isEmpty(code) {
switch (typeof code) {
case 'undefined':
case 'null':
return true;
case 'string':
}
}
*/
var performActionCode = String(opt.performAction);
var simpleCaseActionClustersCode = String(opt.caseHelperInclude);
var rulesCode = generateRegexesInitTableCode(opt);
var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2));
code.push(rmCommonWS(_templateObject40, performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode));
opt.is_custom_lexer = false;
out = code.join('');
} else {
// We're clearly looking at a custom lexer here as there's no lexer rules at all.
//
// We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise.
//
// Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter
// what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk.
out = 'var lexer;\n';
assert$1(opt.regular_rule_count === 0);
assert$1(opt.simple_rule_count === 0);
opt.is_custom_lexer = true;
Eif (opt.actionInclude) {
out += opt.actionInclude + (!opt.actionInclude.match(/;[\s\r\n]*$/) ? ';' : '') + '\n';
}
}
// The output of this function is guaranteed to read something like this:
//
// ```
// var lexer;
//
// bla bla bla bla ... lotsa bla bla;
// ```
//
// and that should work nicely as an `eval()`-able piece of source code.
return out;
}
function generateGenericHeaderComment() {
var out = rmCommonWS(_templateObject41, version);
return out;
}
function prepareOptions(opt) {
opt = opt || {};
// check for illegal identifier
Eif (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) {
Iif (opt.moduleName) {
var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';
if (typeof opt.warn_cb === 'function') {
opt.warn_cb(msg);
} else {
// do not treat as warning; barf hairball instead so that this oddity gets noticed right away!
throw new Error(msg);
}
}
opt.moduleName = 'lexer';
}
prepExportStructures(opt);
return opt;
}
function generateModule(opt) {
opt = prepareOptions(opt);
var out = [generateGenericHeaderComment(), '', 'var ' + opt.moduleName + ' = (function () {', jisonLexerErrorDefinition, '', generateModuleBody(opt), '', opt.moduleInclude ? opt.moduleInclude + ';' : '', '', 'return lexer;', '})();'];
var src = out.join('\n') + '\n';
src = stripUnusedLexerCode(src, opt);
opt.exportSourceCode.all = src;
return src;
}
function generateAMDModule(opt) {
opt = prepareOptions(opt);
var out = [generateGenericHeaderComment(), '', 'define([], function () {', jisonLexerErrorDefinition, '', generateModuleBody(opt), '', opt.moduleInclude ? opt.moduleInclude + ';' : '', '', 'return lexer;', '});'];
var src = out.join('\n') + '\n';
src = stripUnusedLexerCode(src, opt);
opt.exportSourceCode.all = src;
return src;
}
function generateESModule(opt) {
opt = prepareOptions(opt);
var out = [generateGenericHeaderComment(), '', 'var lexer = (function () {', jisonLexerErrorDefinition, '', generateModuleBody(opt), '', opt.moduleInclude ? opt.moduleInclude + ';' : '', '', 'return lexer;', '})();', '', 'function yylex() {', ' return lexer.lex.apply(lexer, arguments);', '}', rmCommonWS(_templateObject42)];
var src = out.join('\n') + '\n';
src = stripUnusedLexerCode(src, opt);
opt.exportSourceCode.all = src;
return src;
}
function generateCommonJSModule(opt) {
opt = prepareOptions(opt);
var out = [generateGenericHeaderComment(), '', 'var ' + opt.moduleName + ' = (function () {', jisonLexerErrorDefinition, '', generateModuleBody(opt), '', opt.moduleInclude ? opt.moduleInclude + ';' : '', '', 'return lexer;', '})();', '', 'if (typeof require !== \'undefined\' && typeof exports !== \'undefined\') {', ' exports.lexer = ' + opt.moduleName + ';', ' exports.lex = function () {', ' return ' + opt.moduleName + '.lex.apply(lexer, arguments);', ' };', '}'];
var src = out.join('\n') + '\n';
src = stripUnusedLexerCode(src, opt);
opt.exportSourceCode.all = src;
return src;
}
RegExpLexer.generate = generate;
RegExpLexer.version = version;
RegExpLexer.defaultJisonLexOptions = defaultJisonLexOptions;
RegExpLexer.mkStdOptions = mkStdOptions;
RegExpLexer.camelCase = helpers.camelCase;
RegExpLexer.mkIdentifier = mkIdentifier;
RegExpLexer.autodetectAndConvertToJSONformat = autodetectAndConvertToJSONformat;
module.exports = RegExpLexer;
|