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
|
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @brief Parse raw source file string into token list.
*
* Usage:
*
* emsg = some function to output error messages to
* source = string containing entire source file
*
* TokenBegin tokenBegin = TokenBegin.Construct (emsg, source);
*
* tokenBegin = null: tokenizing error
* else: first (dummy) token in file
* the rest are chained by nextToken,prevToken
* final token is always a (dummy) TokenEnd
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
namespace OpenSim.Region.ScriptEngine.Yengine
{
public delegate void TokenErrorMessage(Token token, string message);
/**
* @brief base class for all tokens
*/
public class Token
{
public static readonly int MAX_NAME_LEN = 255;
public static readonly int MAX_STRING_LEN = 4096;
public Token nextToken;
public Token prevToken;
public bool nr2l;
// used for error message printing
public TokenErrorMessage emsg;
public string file = "";
public int line;
public int posn;
public Token copiedFrom;
/**
* @brief construct a token coming directly from a source file
* @param emsg = object that error messages get sent to
* @param file = source file name (or "" if none)
* @param line = source file line number
* @param posn = token's position within that source line
*/
public Token(TokenErrorMessage emsg, string file, int line, int posn)
{
this.emsg = emsg;
this.file = file;
this.line = line;
this.posn = posn;
}
/**
* @brief construct a token with same error message parameters
* @param original = original token to create from
*/
public Token(Token original)
{
if(original != null)
{
this.emsg = original.emsg;
this.file = original.file;
this.line = original.line;
this.posn = original.posn;
this.nr2l = original.nr2l;
}
}
/**
* @brief output an error message associated with this token
* sends the message to the token's error object
* @param message = error message string
*/
public void ErrorMsg(string message)
{
if(emsg != null)
{
emsg(this, message);
}
}
/*
* Generate a unique string (for use in CIL label names, etc)
*/
public string Unique
{
get
{
return file + "_" + line + "_" + posn;
}
}
/*
* Generate source location string (for use in error messages)
*/
public string SrcLoc
{
get
{
string loc = file + "(" + line + "," + posn + ")";
if(copiedFrom == null)
return loc;
string fromLoc = copiedFrom.SrcLoc;
if(fromLoc.StartsWith(loc))
return fromLoc;
return loc + ":" + fromLoc;
}
}
/*
* Used in generic instantiation to copy token.
* Only valid for parsing tokens, not reduction tokens
* because it is a shallow copy.
*/
public Token CopyToken(Token src)
{
Token t = (Token)this.MemberwiseClone();
t.file = src.file;
t.line = src.line;
t.posn = src.posn;
t.copiedFrom = this;
return t;
}
/*
* Generate debugging string - should look like source code.
*/
public virtual void DebString(StringBuilder sb)
{
sb.Append(this.ToString());
}
}
/**
* @brief token that begins a source file
* Along with TokenEnd, it keeps insertion/removal of intermediate tokens
* simple as the intermediate tokens always have non-null nextToken,prevToken.
*/
public class TokenBegin: Token
{
private class Options
{
public bool arrays; // has seen 'XMROption arrays;'
public bool advFlowCtl; // has seen 'XMROption advFlowCtl;'
public bool tryCatch; // has seen 'XMROption tryCatch;'
public bool objects; // has seen 'XMROption objects;'
public bool chars; // has seen 'XMROption chars;'
public bool noRightToLeft; // has seen 'XMROption noRightToLeft;'
public bool dollarsigns; // has seen 'XMROption dollarsigns;'
}
private bool youveAnError; // there was some error tokenizing
private int bolIdx; // index in 'source' at begining of current line
private int lineNo; // current line in source file, starting at 0
private string filNam; // current source file name
private string source; // the whole script source code
private Token lastToken; // last token created so far
private string cameFrom; // where the source came from
private TextWriter saveSource; // save copy of source here (or null)
private Options options = new Options();
/**
* @brief convert a source file in the form of a string
* to a list of raw tokens
* @param cameFrom = where the source came from
* @param emsg = where to output messages to
* @param source = whole source file contents
* @returns null: conversion error, message already output
* else: list of tokens, starting with TokenBegin, ending with TokenEnd.
*/
public static TokenBegin Construct(string cameFrom, TextWriter saveSource, TokenErrorMessage emsg, string source, out string sourceHash)
{
sourceHash = null;
// Now do the tokenization.
TokenBegin tokenBegin = new TokenBegin(emsg, "", 0, 0);
tokenBegin.cameFrom = cameFrom;
tokenBegin.saveSource = saveSource;
tokenBegin.lastToken = tokenBegin;
tokenBegin.source = source;
tokenBegin.filNam = cameFrom;
if(saveSource != null)
saveSource.WriteLine(source);
tokenBegin.Tokenize();
if(tokenBegin.youveAnError)
return null;
tokenBegin.AppendToken(new TokenEnd(emsg, tokenBegin.filNam, ++tokenBegin.lineNo, 0));
/*
* Return source hash so caller can know if source changes.
*/
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] hashBytes = md5.ComputeHash(new TokenStream(tokenBegin));
int hashBytesLen = hashBytes.Length;
StringBuilder sb = new StringBuilder(hashBytesLen * 2);
for(int i = 0; i < hashBytesLen; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
}
sourceHash = sb.ToString();
if(saveSource != null)
{
saveSource.WriteLine("");
saveSource.WriteLine("********************************************************************************");
saveSource.WriteLine("**** source hash: " + sourceHash);
saveSource.WriteLine("********************************************************************************");
}
return tokenBegin;
}
private TokenBegin(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
/*
* Stream consisting of all the tokens.
* Null delimeters between the tokens.
* Used for creating the source hash.
*/
private class TokenStream: Stream
{
private Token curTok;
private bool delim;
private byte[] curBuf;
private int curOfs;
private int curLen;
public TokenStream(Token t)
{
curTok = t;
}
public override bool CanRead
{
get
{
return true;
}
}
public override bool CanSeek
{
get
{
return false;
}
}
public override bool CanWrite
{
get
{
return false;
}
}
public override long Length
{
get
{
return 0;
}
}
public override long Position
{
get
{
return 0;
}
set
{
}
}
public override void Write(byte[] buffer, int offset, int count)
{
}
public override void Flush()
{
}
public override long Seek(long offset, SeekOrigin origin)
{
return 0;
}
public override void SetLength(long value)
{
}
public override int Read(byte[] buffer, int offset, int count)
{
int len, total;
for(total = 0; total < count; total += len)
{
while((len = curLen - curOfs) <= 0)
{
if(curTok is TokenEnd)
goto done;
curTok = curTok.nextToken;
if(curTok is TokenEnd)
goto done;
curBuf = System.Text.Encoding.UTF8.GetBytes(curTok.ToString());
curOfs = 0;
curLen = curBuf.Length;
delim = true;
}
if(delim)
{
buffer[offset + total] = 0;
delim = false;
len = 1;
}
else
{
if(len > count - total)
len = count - total;
Array.Copy(curBuf, curOfs, buffer, offset + total, len);
curOfs += len;
}
}
done:
return total;
}
}
/*
* Produces raw token stream: names, numbers, strings, keywords/delimeters.
* @param this.source = whole source file in one string
* @returns this.nextToken = filled in with tokens
* this.youveAnError = true: some tokenizing error
* false: successful
*/
private void Tokenize()
{
bolIdx = 0;
lineNo = 0;
for(int i = 0; i < source.Length; i++)
{
char c = source[i];
if(c == '\n')
{
// Increment source line number and set char index of beg of next line.
lineNo++;
bolIdx = i + 1;
// Check for '#' lineno filename newline
// lineno is line number of next line in file
// If found, save values and remove tokens from stream
if((lastToken is TokenStr) &&
(lastToken.prevToken is TokenInt) &&
(lastToken.prevToken.prevToken is TokenKwHash))
{
filNam = ((TokenStr)lastToken).val;
lineNo = ((TokenInt)lastToken.prevToken).val;
lastToken = lastToken.prevToken.prevToken.prevToken;
lastToken.nextToken = null;
}
continue;
}
// Skip over whitespace.
if(c <= ' ')
continue;
// Skip over comments.
if((i + 2 <= source.Length) && source.Substring(i, 2).Equals("//"))
{
while((i < source.Length) && (source[i] != '\n'))
i++;
lineNo++;
bolIdx = i + 1;
continue;
}
if((i + 2 <= source.Length) && (source.Substring(i, 2).Equals("/*")))
{
i += 2;
while((i + 1 < source.Length) && (((c = source[i]) != '*') || (source[i + 1] != '/')))
{
if(c == '\n')
{
lineNo++;
bolIdx = i + 1;
}
i++;
}
i++;
continue;
}
// Check for numbers.
if((c >= '0') && (c <= '9'))
{
int j = TryParseFloat(i);
if(j == 0)
j = TryParseInt(i);
i = --j;
continue;
}
if((c == '.') && (i + 1 < source.Length) && (source[i + 1] >= '0') && (source[i + 1] <= '9'))
{
int j = TryParseFloat(i);
if(j > 0)
i = --j;
continue;
}
// Check for quoted strings.
if(c == '"')
{
StringBuilder sb = new StringBuilder();
bool backslash;
int j;
backslash = false;
for(j = i; ++j < source.Length;)
{
c = source[j];
if(c == '\\' && !backslash)
{
backslash = true;
continue;
}
if(c == '\n')
{
lineNo++;
bolIdx = j + 1;
}
else
{
if(!backslash && (c == '"'))
break;
if(backslash && (c == 'n'))
c = '\n';
if(backslash && (c == 't'))
{
sb.Append(" ");
c = ' ';
}
}
backslash = false;
sb.Append(c);
}
if(j - i > MAX_STRING_LEN)
{
TokenError(i, "string too long, max " + MAX_STRING_LEN);
}
else
{
AppendToken(new TokenStr(emsg, filNam, lineNo, i - bolIdx, sb.ToString()));
}
i = j;
continue;
}
// Check for quoted characters.
if(c == '\'')
{
char cb = (char)0;
bool backslash, overflow, underflow;
int j;
backslash = false;
overflow = false;
underflow = true;
for(j = i; ++j < source.Length;)
{
c = source[j];
if(c == '\\' && !backslash)
{
backslash = true;
continue;
}
if(c == '\n')
{
lineNo++;
bolIdx = j + 1;
}
else
{
if(!backslash && (c == '\''))
break;
if(backslash && (c == 'n'))
c = '\n';
if(backslash && (c == 't'))
c = '\t';
}
backslash = false;
overflow = !underflow;
underflow = false;
cb = c;
}
if(underflow || overflow)
{
TokenError(i, "character must be exactly one character");
}
else
{
AppendToken(new TokenChar(emsg, filNam, lineNo, i - bolIdx, cb));
}
i = j;
continue;
}
// Check for keywords/names.
if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_') || (c == '$' && options.dollarsigns))
{
int j;
for(j = i; ++j < source.Length;)
{
c = source[j];
if(c >= 'a' && c <= 'z')
continue;
if(c >= 'A' && c <= 'Z')
continue;
if(c >= '0' && c <= '9')
continue;
if(c == '$' && options.dollarsigns)
continue;
if(c != '_')
break;
}
if(j - i > MAX_NAME_LEN)
{
TokenError(i, "name too long, max " + MAX_NAME_LEN);
}
else
{
string name = source.Substring(i, j - i);
if(name == "quaternion")
name = "rotation"; // see lslangtest1.lsl
if(keywords.ContainsKey(name))
{
Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx };
AppendToken((Token)keywords[name].Invoke(args));
}
else if(options.arrays && arrayKeywords.ContainsKey(name))
{
Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx };
AppendToken((Token)arrayKeywords[name].Invoke(args));
}
else if(options.advFlowCtl && advFlowCtlKeywords.ContainsKey(name))
{
Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx };
AppendToken((Token)advFlowCtlKeywords[name].Invoke(args));
}
else if(options.tryCatch && tryCatchKeywords.ContainsKey(name))
{
Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx };
AppendToken((Token)tryCatchKeywords[name].Invoke(args));
}
else if(options.objects && objectsKeywords.ContainsKey(name))
{
Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx };
AppendToken((Token)objectsKeywords[name].Invoke(args));
}
else if(options.chars && charsKeywords.ContainsKey(name))
{
Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx };
AppendToken((Token)charsKeywords[name].Invoke(args));
}
else
{
AppendToken(new TokenName(emsg, filNam, lineNo, i - bolIdx, name));
}
}
i = --j;
continue;
}
// Check for option enables.
if((c == ';') && (lastToken is TokenName) &&
(lastToken.prevToken is TokenName) &&
(strcasecmp(((TokenName)lastToken.prevToken).val, "yoption") == 0))
{
string opt = ((TokenName)lastToken).val;
if(strcasecmp(opt, "allowall") == 0)
{
options.arrays = true;
options.advFlowCtl = true;
options.tryCatch = true;
options.objects = true;
options.chars = true;
// options.noRightToLeft = true;
options.dollarsigns = true;
}
else if(strcasecmp(opt, "arrays") == 0)
options.arrays = true;
else if(strcasecmp(opt, "advflowctl") == 0)
options.advFlowCtl = true;
else if(strcasecmp(opt, "trycatch") == 0)
options.tryCatch = true;
else if(strcasecmp(opt, "objects") == 0)
options.objects = true;
else if(strcasecmp(opt, "chars") == 0)
options.chars = true;
else if(strcasecmp(opt, "norighttoleft") == 0)
options.noRightToLeft = true;
else if(strcasecmp(opt, "dollarsigns") == 0)
options.dollarsigns = true;
else
lastToken.ErrorMsg("unknown YOption");
lastToken = lastToken.prevToken.prevToken;
lastToken.nextToken = null;
continue;
}
// Lastly, check for delimeters.
{
int j;
int len = 0;
for(j = 0; j < delims.Length; j++)
{
len = delims[j].str.Length;
if((i + len <= source.Length) && (source.Substring(i, len).Equals(delims[j].str)))
break;
}
if(j < delims.Length)
{
Object[] args = { emsg, filNam, lineNo, i - bolIdx };
Token kwToken = (Token)delims[j].ctorInfo.Invoke(args);
AppendToken(kwToken);
i += --len;
continue;
}
}
// Don't know what it is!
TokenError(i, "unknown character '" + c + "'");
}
}
private static int strcasecmp(String s, String t)
{
return String.Compare(s, t, StringComparison.OrdinalIgnoreCase);
}
/**
* @brief try to parse a floating-point number from the source
* @param i = starting position within this.source of number
* @returns 0: not a floating point number, try something else
* else: position in this.source of terminating character, ie, past number
* TokenFloat appended to token list
* or error message has been output
*/
private int TryParseFloat(int i)
{
bool decimals, error, negexp, nulexp;
char c;
double f, f10;
int exponent, j, x, y;
ulong m, mantissa;
decimals = false;
error = false;
exponent = 0;
mantissa = 0;
for(j = i; j < source.Length; j++)
{
c = source[j];
if((c >= '0') && (c <= '9'))
{
m = mantissa * 10 + (ulong)(c - '0');
if(m / 10 != mantissa)
{
if(!decimals)
exponent++;
}
else
{
mantissa = m;
if(decimals)
exponent--;
}
continue;
}
if(c == '.')
{
if(decimals)
{
TokenError(i, "more than one decimal point");
return j;
}
decimals = true;
continue;
}
if((c == 'E') || (c == 'e'))
{
if(++j >= source.Length)
{
TokenError(i, "floating exponent off end of source");
return j;
}
c = source[j];
negexp = (c == '-');
if(negexp || (c == '+'))
j++;
y = 0;
nulexp = true;
for(; j < source.Length; j++)
{
c = source[j];
if((c < '0') || (c > '9'))
break;
x = y * 10 + (c - '0');
if(x / 10 != y)
{
if(!error)
TokenError(i, "floating exponent overflow");
error = true;
}
y = x;
nulexp = false;
}
if(nulexp)
{
TokenError(i, "bad or missing floating exponent");
return j;
}
if(negexp)
{
x = exponent - y;
if(x > exponent)
{
if(!error)
TokenError(i, "floating exponent overflow");
error = true;
}
}
else
{
x = exponent + y;
if(x < exponent)
{
if(!error)
TokenError(i, "floating exponent overflow");
error = true;
}
}
exponent = x;
}
if ((c == 'F') || (c == 'f'))
{
if (++j >= source.Length)
{
TokenError(i, "f at end of source");
return j;
}
c = source[j];
if (((c >= '0') && (c <= '9')) || c == '.' || ((c == 'E') || (c == 'e')) || ((c == 'F') || (c == 'f')))
{
TokenError(j-1, "Syntax error");
return j;
}
break;
}
break;
}
if(!decimals)
{
return 0;
}
f = mantissa;
if((exponent != 0) && (mantissa != 0) && !error)
{
f10 = 10.0;
if(exponent < 0)
{
exponent = -exponent;
while(exponent > 0)
{
if((exponent & 1) != 0)
{
f /= f10;
}
exponent /= 2;
f10 *= f10;
}
}
else
{
while(exponent > 0)
{
if((exponent & 1) != 0)
{
f *= f10;
}
exponent /= 2;
f10 *= f10;
}
}
}
if(!error)
{
AppendToken(new TokenFloat(emsg, filNam, lineNo, i - bolIdx, f));
}
return j;
}
/**
* @brief try to parse an integer number from the source
* @param i = starting position within this.source of number
* @returns 0: not an integer number, try something else
* else: position in this.source of terminating character, ie, past number
* TokenInt appended to token list
* or error message has been output
*/
private int TryParseInt(int i)
{
bool error;
char c;
int j;
uint basse, m, mantissa;
basse = 10;
error = false;
mantissa = 0;
for(j = i; j < source.Length; j++)
{
c = source[j];
if((c >= '0') && (c <= '9'))
{
m = mantissa * basse + (uint)(c - '0');
if(m / basse != mantissa)
{
if(!error)
TokenError(i, "integer overflow");
error = true;
}
mantissa = m;
continue;
}
if((basse == 16) && ((c >= 'A') && (c <= 'F')))
{
m = mantissa * basse + (uint)(c - 'A') + 10U;
if(m / basse != mantissa)
{
if(!error)
TokenError(i, "integer overflow");
error = true;
}
mantissa = m;
continue;
}
if((basse == 16) && ((c >= 'a') && (c <= 'f')))
{
m = mantissa * basse + (uint)(c - 'a') + 10U;
if(m / basse != mantissa)
{
if(!error)
TokenError(i, "integer overflow");
error = true;
}
mantissa = m;
continue;
}
if(((c == 'x') || (c == 'X')) && (mantissa == 0) && (basse == 10))
{
basse = 16;
continue;
}
break;
}
if(!error)
{
AppendToken(new TokenInt(emsg, filNam, lineNo, i - bolIdx, (int)mantissa));
}
return j;
}
/**
* @brief append token on to end of list
* @param newToken = token to append
* @returns with token appended onto this.lastToken
*/
private void AppendToken(Token newToken)
{
newToken.nextToken = null;
newToken.prevToken = lastToken;
newToken.nr2l = this.options.noRightToLeft;
lastToken.nextToken = newToken;
lastToken = newToken;
}
/**
* @brief print tokenizing error message
* and remember that we've an error
* @param i = position within source file of the error
* @param message = error message text
* @returns with this.youveAnError set
*/
private void TokenError(int i, string message)
{
Token temp = new Token(this.emsg, this.filNam, this.lineNo, i - this.bolIdx);
temp.ErrorMsg(message);
youveAnError = true;
}
/**
* @brief get a token's constructor
* @param tokenType = token's type
* @returns token's constructor
*/
private static Type[] constrTypes = new Type[] {
typeof (TokenErrorMessage), typeof (string), typeof (int), typeof (int)
};
private static System.Reflection.ConstructorInfo GetTokenCtor(Type tokenType)
{
return tokenType.GetConstructor(constrTypes);
}
/**
* @brief delimeter table
*/
private class Delim
{
public string str;
public System.Reflection.ConstructorInfo ctorInfo;
public Delim(string str, Type type)
{
this.str = str;
ctorInfo = GetTokenCtor(type);
}
}
private static Delim[] delims = new Delim[] {
new Delim ("...", typeof (TokenKwDotDotDot)),
new Delim ("&&&", typeof (TokenKwAndAndAnd)),
new Delim ("|||", typeof (TokenKwOrOrOr)),
new Delim ("<<=", typeof (TokenKwAsnLSh)),
new Delim (">>=", typeof (TokenKwAsnRSh)),
new Delim ("<=", typeof (TokenKwCmpLE)),
new Delim (">=", typeof (TokenKwCmpGE)),
new Delim ("==", typeof (TokenKwCmpEQ)),
new Delim ("!=", typeof (TokenKwCmpNE)),
new Delim ("++", typeof (TokenKwIncr)),
new Delim ("--", typeof (TokenKwDecr)),
new Delim ("&&", typeof (TokenKwAndAnd)),
new Delim ("||", typeof (TokenKwOrOr)),
new Delim ("+=", typeof (TokenKwAsnAdd)),
new Delim ("&=", typeof (TokenKwAsnAnd)),
new Delim ("-=", typeof (TokenKwAsnSub)),
new Delim ("*=", typeof (TokenKwAsnMul)),
new Delim ("/=", typeof (TokenKwAsnDiv)),
new Delim ("%=", typeof (TokenKwAsnMod)),
new Delim ("|=", typeof (TokenKwAsnOr)),
new Delim ("^=", typeof (TokenKwAsnXor)),
new Delim ("<<", typeof (TokenKwLSh)),
new Delim (">>", typeof (TokenKwRSh)),
new Delim ("~", typeof (TokenKwTilde)),
new Delim ("!", typeof (TokenKwExclam)),
new Delim ("@", typeof (TokenKwAt)),
new Delim ("%", typeof (TokenKwMod)),
new Delim ("^", typeof (TokenKwXor)),
new Delim ("&", typeof (TokenKwAnd)),
new Delim ("*", typeof (TokenKwMul)),
new Delim ("(", typeof (TokenKwParOpen)),
new Delim (")", typeof (TokenKwParClose)),
new Delim ("-", typeof (TokenKwSub)),
new Delim ("+", typeof (TokenKwAdd)),
new Delim ("=", typeof (TokenKwAssign)),
new Delim ("{", typeof (TokenKwBrcOpen)),
new Delim ("}", typeof (TokenKwBrcClose)),
new Delim ("[", typeof (TokenKwBrkOpen)),
new Delim ("]", typeof (TokenKwBrkClose)),
new Delim (";", typeof (TokenKwSemi)),
new Delim (":", typeof (TokenKwColon)),
new Delim ("<", typeof (TokenKwCmpLT)),
new Delim (">", typeof (TokenKwCmpGT)),
new Delim (",", typeof (TokenKwComma)),
new Delim (".", typeof (TokenKwDot)),
new Delim ("?", typeof (TokenKwQMark)),
new Delim ("/", typeof (TokenKwDiv)),
new Delim ("|", typeof (TokenKwOr)),
new Delim ("#", typeof (TokenKwHash))
};
/**
* @brief keyword tables
* The keyword tables translate a keyword string
* to the corresponding token constructor.
*/
private static Dictionary<string, System.Reflection.ConstructorInfo> keywords = BuildKeywords();
private static Dictionary<string, System.Reflection.ConstructorInfo> arrayKeywords = BuildArrayKeywords();
private static Dictionary<string, System.Reflection.ConstructorInfo> advFlowCtlKeywords = BuildAdvFlowCtlKeywords();
private static Dictionary<string, System.Reflection.ConstructorInfo> tryCatchKeywords = BuildTryCatchKeywords();
private static Dictionary<string, System.Reflection.ConstructorInfo> objectsKeywords = BuildObjectsKeywords();
private static Dictionary<string, System.Reflection.ConstructorInfo> charsKeywords = BuildCharsKeywords();
private static Dictionary<string, System.Reflection.ConstructorInfo> BuildKeywords()
{
Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>();
kws.Add("default", GetTokenCtor(typeof(TokenKwDefault)));
kws.Add("do", GetTokenCtor(typeof(TokenKwDo)));
kws.Add("else", GetTokenCtor(typeof(TokenKwElse)));
kws.Add("float", GetTokenCtor(typeof(TokenTypeFloat)));
kws.Add("for", GetTokenCtor(typeof(TokenKwFor)));
kws.Add("if", GetTokenCtor(typeof(TokenKwIf)));
kws.Add("integer", GetTokenCtor(typeof(TokenTypeInt)));
kws.Add("list", GetTokenCtor(typeof(TokenTypeList)));
kws.Add("jump", GetTokenCtor(typeof(TokenKwJump)));
kws.Add("key", GetTokenCtor(typeof(TokenTypeKey)));
kws.Add("return", GetTokenCtor(typeof(TokenKwRet)));
kws.Add("rotation", GetTokenCtor(typeof(TokenTypeRot)));
kws.Add("state", GetTokenCtor(typeof(TokenKwState)));
kws.Add("string", GetTokenCtor(typeof(TokenTypeStr)));
kws.Add("vector", GetTokenCtor(typeof(TokenTypeVec)));
kws.Add("while", GetTokenCtor(typeof(TokenKwWhile)));
return kws;
}
private static Dictionary<string, System.Reflection.ConstructorInfo> BuildArrayKeywords()
{
Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>();
kws.Add("array", GetTokenCtor(typeof(TokenTypeArray)));
kws.Add("foreach", GetTokenCtor(typeof(TokenKwForEach)));
kws.Add("in", GetTokenCtor(typeof(TokenKwIn)));
kws.Add("is", GetTokenCtor(typeof(TokenKwIs)));
kws.Add("object", GetTokenCtor(typeof(TokenTypeObject)));
kws.Add("undef", GetTokenCtor(typeof(TokenKwUndef)));
return kws;
}
private static Dictionary<string, System.Reflection.ConstructorInfo> BuildAdvFlowCtlKeywords()
{
Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>();
kws.Add("break", GetTokenCtor(typeof(TokenKwBreak)));
kws.Add("case", GetTokenCtor(typeof(TokenKwCase)));
kws.Add("constant", GetTokenCtor(typeof(TokenKwConst)));
kws.Add("continue", GetTokenCtor(typeof(TokenKwCont)));
kws.Add("switch", GetTokenCtor(typeof(TokenKwSwitch)));
return kws;
}
private static Dictionary<string, System.Reflection.ConstructorInfo> BuildTryCatchKeywords()
{
Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>();
kws.Add("catch", GetTokenCtor(typeof(TokenKwCatch)));
kws.Add("exception", GetTokenCtor(typeof(TokenTypeExc)));
kws.Add("finally", GetTokenCtor(typeof(TokenKwFinally)));
kws.Add("throw", GetTokenCtor(typeof(TokenKwThrow)));
kws.Add("try", GetTokenCtor(typeof(TokenKwTry)));
return kws;
}
private static Dictionary<string, System.Reflection.ConstructorInfo> BuildObjectsKeywords()
{
Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>();
kws.Add("abstract", GetTokenCtor(typeof(TokenKwAbstract)));
kws.Add("base", GetTokenCtor(typeof(TokenKwBase)));
kws.Add("class", GetTokenCtor(typeof(TokenKwClass)));
kws.Add("constructor", GetTokenCtor(typeof(TokenKwConstructor)));
kws.Add("delegate", GetTokenCtor(typeof(TokenKwDelegate)));
kws.Add("destructor", GetTokenCtor(typeof(TokenKwDestructor)));
kws.Add("final", GetTokenCtor(typeof(TokenKwFinal)));
kws.Add("get", GetTokenCtor(typeof(TokenKwGet)));
kws.Add("interface", GetTokenCtor(typeof(TokenKwInterface)));
kws.Add("new", GetTokenCtor(typeof(TokenKwNew)));
kws.Add("override", GetTokenCtor(typeof(TokenKwOverride)));
kws.Add("partial", GetTokenCtor(typeof(TokenKwPartial)));
kws.Add("private", GetTokenCtor(typeof(TokenKwPrivate)));
kws.Add("protected", GetTokenCtor(typeof(TokenKwProtected)));
kws.Add("public", GetTokenCtor(typeof(TokenKwPublic)));
kws.Add("set", GetTokenCtor(typeof(TokenKwSet)));
kws.Add("static", GetTokenCtor(typeof(TokenKwStatic)));
kws.Add("this", GetTokenCtor(typeof(TokenKwThis)));
kws.Add("typedef", GetTokenCtor(typeof(TokenKwTypedef)));
kws.Add("virtual", GetTokenCtor(typeof(TokenKwVirtual)));
return kws;
}
private static Dictionary<string, System.Reflection.ConstructorInfo> BuildCharsKeywords()
{
Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>();
kws.Add("char", GetTokenCtor(typeof(TokenTypeChar)));
return kws;
}
}
/**
* @brief All output token types in addition to TokenBegin.
* They are all sub-types of Token.
*/
public class TokenChar: Token
{
public char val;
public TokenChar(TokenErrorMessage emsg, string file, int line, int posn, char val) : base(emsg, file, line, posn)
{
this.val = val;
}
public TokenChar(Token original, char val) : base(original)
{
this.val = val;
}
public override string ToString()
{
switch(val)
{
case '\'':
return "'\\''";
case '\\':
return "'\\\\'";
case '\n':
return "'\\n'";
case '\t':
return "'\\t'";
default:
return "'" + val + "'";
}
}
}
public class TokenFloat: Token
{
public double val;
public TokenFloat(TokenErrorMessage emsg, string file, int line, int posn, double val) : base(emsg, file, line, posn)
{
this.val = val;
}
public override string ToString()
{
return val.ToString();
}
}
public class TokenInt: Token
{
public int val;
public TokenInt(TokenErrorMessage emsg, string file, int line, int posn, int val) : base(emsg, file, line, posn)
{
this.val = val;
}
public TokenInt(Token original, int val) : base(original)
{
this.val = val;
}
public override string ToString()
{
return val.ToString();
}
}
public class TokenName: Token
{
public string val;
public TokenName(TokenErrorMessage emsg, string file, int line, int posn, string val) : base(emsg, file, line, posn)
{
this.val = val;
}
public TokenName(Token original, string val) : base(original)
{
this.val = val;
}
public override string ToString()
{
return this.val;
}
}
public class TokenStr: Token
{
public string val;
public TokenStr(TokenErrorMessage emsg, string file, int line, int posn, string val) : base(emsg, file, line, posn)
{
this.val = val;
}
public override string ToString()
{
if((val.IndexOf('"') < 0) &&
(val.IndexOf('\\') < 0) &&
(val.IndexOf('\n') < 0) &&
(val.IndexOf('\t') < 0))
return "\"" + val + "\"";
int len = val.Length;
StringBuilder sb = new StringBuilder(len * 2 + 2);
sb.Append('"');
for(int i = 0; i < len; i++)
{
char c = val[i];
switch(c)
{
case '"':
{
sb.Append('\\');
sb.Append('"');
break;
}
case '\\':
{
sb.Append('\\');
sb.Append('\\');
break;
}
case '\n':
{
sb.Append('\\');
sb.Append('n');
break;
}
case '\t':
{
sb.Append('\\');
sb.Append('t');
break;
}
default:
{
sb.Append(c);
break;
}
}
}
return sb.ToString();
}
}
/*
* This one marks the end-of-file.
*/
public class TokenEnd: Token
{
public TokenEnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
}
/*
* Various keywords and delimeters.
*/
public delegate object TokenRValConstBinOpDelegate(object left, object right);
public delegate object TokenRValConstUnOpDelegate(object right);
public class TokenKw: Token
{
public TokenRValConstBinOpDelegate binOpConst;
public TokenRValConstUnOpDelegate unOpConst;
public bool sdtClassOp;
public TokenKw(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn)
{
}
public TokenKw(Token original) : base(original)
{
}
}
public class TokenKwDotDotDot: TokenKw
{
public TokenKwDotDotDot(TokenErrorMessage emsg, string file,
int line, int posn) : base(emsg, file, line, posn)
{
binOpConst = TokenRValConstOps.Null;
unOpConst = TokenRValConstOps.Null;
sdtClassOp = false;
}
public TokenKwDotDotDot(Token original) : base(original)
{
binOpConst = TokenRValConstOps.Null;
unOpConst = TokenRValConstOps.Null;
sdtClassOp = false;
}
public override string ToString()
{
return "...";
}
}
public class TokenKwAndAndAnd: TokenKw
{
public TokenKwAndAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn)
{
binOpConst = TokenRValConstOps.Null;
unOpConst = TokenRValConstOps.Null;
sdtClassOp = false;
}
public TokenKwAndAndAnd(Token original) : base(original)
{
binOpConst = TokenRValConstOps.Null;
unOpConst = TokenRValConstOps.Null;
sdtClassOp = false;
}
public override string ToString()
{
return "&&&";
}
}
public class TokenKwOrOrOr: TokenKw
{
public TokenKwOrOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn)
{
binOpConst = TokenRValConstOps.Null;
unOpConst = TokenRValConstOps.Null;
sdtClassOp = false;
}
public TokenKwOrOrOr(Token original) : base(original)
{
binOpConst = TokenRValConstOps.Null;
unOpConst = TokenRValConstOps.Null;
sdtClassOp = false;
}
public override string ToString()
{
return "|||";
}
}
public class TokenKwAsnLSh: TokenKw
{
public TokenKwAsnLSh(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn)
{
binOpConst = TokenRValConstOps.Null;
unOpConst = TokenRValConstOps.Null;
sdtClassOp = true;
}
public TokenKwAsnLSh(Token original) : base(original)
{
binOpConst = TokenRValConstOps.Null;
unOpConst = TokenRValConstOps.Null;
sdtClassOp = true;
}
public override string ToString()
{
return "<<=";
}
}
public class TokenKwAsnRSh: TokenKw
{
public TokenKwAsnRSh(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnRSh(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return ">>=";
}
}
public class TokenKwCmpLE: TokenKw
{
public TokenKwCmpLE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwCmpLE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "<=";
}
}
public class TokenKwCmpGE: TokenKw
{
public TokenKwCmpGE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwCmpGE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return ">=";
}
}
public class TokenKwCmpEQ: TokenKw
{
public TokenKwCmpEQ(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwCmpEQ(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "==";
}
}
public class TokenKwCmpNE: TokenKw
{
public TokenKwCmpNE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwCmpNE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "!=";
}
}
public class TokenKwIncr: TokenKw
{
public TokenKwIncr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwIncr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "++";
}
}
public class TokenKwDecr: TokenKw
{
public TokenKwDecr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwDecr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "--";
}
}
public class TokenKwAndAnd: TokenKw
{
public TokenKwAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAndAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "&&";
}
}
public class TokenKwOrOr: TokenKw
{
public TokenKwOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwOrOr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "||";
}
}
public class TokenKwAsnAdd: TokenKw
{
public TokenKwAsnAdd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnAdd(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "+=";
}
}
public class TokenKwAsnAnd: TokenKw
{
public TokenKwAsnAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "&=";
}
}
public class TokenKwAsnSub: TokenKw
{
public TokenKwAsnSub(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnSub(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "-=";
}
}
public class TokenKwAsnMul: TokenKw
{
public TokenKwAsnMul(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnMul(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "*=";
}
}
public class TokenKwAsnDiv: TokenKw
{
public TokenKwAsnDiv(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnDiv(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "/=";
}
}
public class TokenKwAsnMod: TokenKw
{
public TokenKwAsnMod(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnMod(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "%=";
}
}
public class TokenKwAsnOr: TokenKw
{
public TokenKwAsnOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnOr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "|=";
}
}
public class TokenKwAsnXor: TokenKw
{
public TokenKwAsnXor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAsnXor(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "^=";
}
}
public class TokenKwLSh: TokenKw
{
public TokenKwLSh(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.LSh; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwLSh(Token original) : base(original) { binOpConst = TokenRValConstOps.LSh; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "<<";
}
}
public class TokenKwRSh: TokenKw
{
public TokenKwRSh(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.RSh; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwRSh(Token original) : base(original) { binOpConst = TokenRValConstOps.RSh; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return ">>";
}
}
public class TokenKwTilde: TokenKw
{
public TokenKwTilde(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Not; sdtClassOp = true; }
public TokenKwTilde(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Not; sdtClassOp = true; }
public override string ToString()
{
return "~";
}
}
public class TokenKwExclam: TokenKw
{
public TokenKwExclam(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwExclam(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "!";
}
}
public class TokenKwAt: TokenKw
{
public TokenKwAt(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwAt(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "@";
}
}
public class TokenKwMod: TokenKw
{
public TokenKwMod(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Mod; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwMod(Token original) : base(original) { binOpConst = TokenRValConstOps.Mod; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "%";
}
}
public class TokenKwXor: TokenKw
{
public TokenKwXor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Xor; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwXor(Token original) : base(original) { binOpConst = TokenRValConstOps.Xor; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "^";
}
}
public class TokenKwAnd: TokenKw
{
public TokenKwAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.And; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.And; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "&";
}
}
public class TokenKwMul: TokenKw
{
public TokenKwMul(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Mul; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwMul(Token original) : base(original) { binOpConst = TokenRValConstOps.Mul; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "*";
}
}
public class TokenKwParOpen: TokenKw
{
public TokenKwParOpen(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwParOpen(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "(";
}
}
public class TokenKwParClose: TokenKw
{
public TokenKwParClose(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwParClose(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return ")";
}
}
public class TokenKwSub: TokenKw
{
public TokenKwSub(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Sub; unOpConst = TokenRValConstOps.Neg; sdtClassOp = true; }
public TokenKwSub(Token original) : base(original) { binOpConst = TokenRValConstOps.Sub; unOpConst = TokenRValConstOps.Neg; sdtClassOp = true; }
public override string ToString()
{
return "-";
}
}
public class TokenKwAdd: TokenKw
{
public TokenKwAdd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Add; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwAdd(Token original) : base(original) { binOpConst = TokenRValConstOps.Add; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "+";
}
}
public class TokenKwAssign: TokenKw
{
public TokenKwAssign(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwAssign(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "=";
}
}
public class TokenKwBrcOpen: TokenKw
{
public TokenKwBrcOpen(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwBrcOpen(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "{";
}
}
public class TokenKwBrcClose: TokenKw
{
public TokenKwBrcClose(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwBrcClose(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "}";
}
}
public class TokenKwBrkOpen: TokenKw
{
public TokenKwBrkOpen(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwBrkOpen(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "[";
}
}
public class TokenKwBrkClose: TokenKw
{
public TokenKwBrkClose(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwBrkClose(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "]";
}
}
public class TokenKwSemi: TokenKw
{
public TokenKwSemi(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwSemi(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return ";";
}
}
public class TokenKwColon: TokenKw
{
public TokenKwColon(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwColon(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return ":";
}
}
public class TokenKwCmpLT: TokenKw
{
public TokenKwCmpLT(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwCmpLT(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "<";
}
}
public class TokenKwCmpGT: TokenKw
{
public TokenKwCmpGT(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwCmpGT(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return ">";
}
}
public class TokenKwComma: TokenKw
{
public TokenKwComma(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwComma(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return ",";
}
}
public class TokenKwDot: TokenKw
{
public TokenKwDot(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwDot(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return ".";
}
}
public class TokenKwQMark: TokenKw
{
public TokenKwQMark(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwQMark(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "?";
}
}
public class TokenKwDiv: TokenKw
{
public TokenKwDiv(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Div; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwDiv(Token original) : base(original) { binOpConst = TokenRValConstOps.Div; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "/";
}
}
public class TokenKwOr: TokenKw
{
public TokenKwOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Or; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public TokenKwOr(Token original) : base(original) { binOpConst = TokenRValConstOps.Or; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
public override string ToString()
{
return "|";
}
}
public class TokenKwHash: TokenKw
{
public TokenKwHash(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwHash(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "#";
}
}
public class TokenKwAbstract: TokenKw
{
public TokenKwAbstract(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwAbstract(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "abstract";
}
}
public class TokenKwBase: TokenKw
{
public TokenKwBase(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwBase(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "base";
}
}
public class TokenKwBreak: TokenKw
{
public TokenKwBreak(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwBreak(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "break";
}
}
public class TokenKwCase: TokenKw
{
public TokenKwCase(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwCase(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "case";
}
}
public class TokenKwCatch: TokenKw
{
public TokenKwCatch(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwCatch(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "catch";
}
}
public class TokenKwClass: TokenKw
{
public TokenKwClass(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwClass(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "class";
}
}
public class TokenKwConst: TokenKw
{
public TokenKwConst(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwConst(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "constant";
}
}
public class TokenKwConstructor: TokenKw
{
public TokenKwConstructor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwConstructor(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "constructor";
}
}
public class TokenKwCont: TokenKw
{
public TokenKwCont(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwCont(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "continue";
}
}
public class TokenKwDelegate: TokenKw
{
public TokenKwDelegate(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwDelegate(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "delegate";
}
}
public class TokenKwDefault: TokenKw
{
public TokenKwDefault(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwDefault(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "default";
}
}
public class TokenKwDestructor: TokenKw
{
public TokenKwDestructor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwDestructor(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "destructor";
}
}
public class TokenKwDo: TokenKw
{
public TokenKwDo(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwDo(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "do";
}
}
public class TokenKwElse: TokenKw
{
public TokenKwElse(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwElse(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "else";
}
}
public class TokenKwFinal: TokenKw
{
public TokenKwFinal(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwFinal(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "final";
}
}
public class TokenKwFinally: TokenKw
{
public TokenKwFinally(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwFinally(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "finally";
}
}
public class TokenKwFor: TokenKw
{
public TokenKwFor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwFor(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "for";
}
}
public class TokenKwForEach: TokenKw
{
public TokenKwForEach(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwForEach(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "foreach";
}
}
public class TokenKwGet: TokenKw
{
public TokenKwGet(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwGet(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "get";
}
}
public class TokenKwIf: TokenKw
{
public TokenKwIf(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwIf(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "if";
}
}
public class TokenKwIn: TokenKw
{
public TokenKwIn(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwIn(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "in";
}
}
public class TokenKwInterface: TokenKw
{
public TokenKwInterface(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwInterface(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "interface";
}
}
public class TokenKwIs: TokenKw
{
public TokenKwIs(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwIs(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "is";
}
}
public class TokenKwJump: TokenKw
{
public TokenKwJump(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwJump(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "jump";
}
}
public class TokenKwNew: TokenKw
{
public TokenKwNew(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwNew(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "new";
}
}
public class TokenKwOverride: TokenKw
{
public TokenKwOverride(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwOverride(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "override";
}
}
public class TokenKwPartial: TokenKw
{
public TokenKwPartial(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwPartial(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "partial";
}
}
public class TokenKwPrivate: TokenKw
{
public TokenKwPrivate(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwPrivate(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "private";
}
}
public class TokenKwProtected: TokenKw
{
public TokenKwProtected(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwProtected(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "protected";
}
}
public class TokenKwPublic: TokenKw
{
public TokenKwPublic(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwPublic(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "public";
}
}
public class TokenKwRet: TokenKw
{
public TokenKwRet(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwRet(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "return";
}
}
public class TokenKwSet: TokenKw
{
public TokenKwSet(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwSet(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "set";
}
}
public class TokenKwState: TokenKw
{
public TokenKwState(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwState(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "state";
}
}
public class TokenKwStatic: TokenKw
{
public TokenKwStatic(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwStatic(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "static";
}
}
public class TokenKwSwitch: TokenKw
{
public TokenKwSwitch(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwSwitch(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "switch";
}
}
public class TokenKwThis: TokenKw
{
public TokenKwThis(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwThis(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "this";
}
}
public class TokenKwThrow: TokenKw
{
public TokenKwThrow(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwThrow(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "throw";
}
}
public class TokenKwTry: TokenKw
{
public TokenKwTry(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwTry(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "try";
}
}
public class TokenKwTypedef: TokenKw
{
public TokenKwTypedef(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwTypedef(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "typedef";
}
}
public class TokenKwUndef: TokenKw
{
public TokenKwUndef(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwUndef(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "undef";
}
}
public class TokenKwVirtual: TokenKw
{
public TokenKwVirtual(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwVirtual(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "virtual";
}
}
public class TokenKwWhile: TokenKw
{
public TokenKwWhile(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public TokenKwWhile(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; }
public override string ToString()
{
return "while";
}
}
/**
* @brief These static functions attempt to perform arithmetic on two constant
* operands to generate the resultant constant.
* Likewise for unary operators.
*
* @param left = left-hand value
* @param right = right-hand value
* @returns null: not able to perform computation
* else: resultant value object
*
* Note: it is ok for these to throw any exception (such as overflow or div-by-zero),
* and it will be treated as the 'not able to perform computation' case.
*/
public class TokenRValConstOps
{
public static object Null(object left, object right)
{
return null;
}
public static object Div(object left, object right)
{
if((left is int) && (right is int))
{
return (int)left / (int)right;
}
if((left is int) && (right is double))
{
return (int)left / (double)right;
}
if((left is double) && (right is int))
{
return (double)left / (int)right;
}
if((left is double) && (right is double))
{
return (double)left / (double)right;
}
return null;
}
public static object Mod(object left, object right)
{
if((left is int) && (right is int))
{
return (int)left % (int)right;
}
if((left is int) && (right is double))
{
return (int)left % (double)right;
}
if((left is double) && (right is int))
{
return (double)left % (int)right;
}
if((left is double) && (right is double))
{
return (double)left % (double)right;
}
return null;
}
public static object Mul(object left, object right)
{
if((left is int) && (right is int))
{
return (int)left * (int)right;
}
if((left is int) && (right is double))
{
return (int)left * (double)right;
}
if((left is double) && (right is int))
{
return (double)left * (int)right;
}
if((left is double) && (right is double))
{
return (double)left * (double)right;
}
return null;
}
public static object And(object left, object right)
{
if((left is int) && (right is int))
{
return (int)left & (int)right;
}
if((left is int) && (right is double))
{
return (int)left & (int)(double)right;
}
if((left is double) && (right is int))
{
return (int)(double)left & (int)right;
}
if((left is double) && (right is double))
{
return (int)(double)left & (int)(double)right;
}
return null;
}
public static object LSh(object left, object right)
{
if((left is int) && (right is int))
{
return (int)left << (int)right;
}
if((left is int) && (right is double))
{
return (int)left << (int)(double)right;
}
if((left is double) && (right is int))
{
return (int)(double)left << (int)right;
}
if((left is double) && (right is double))
{
return (int)(double)left << (int)(double)right;
}
return null;
}
public static object Or(object left, object right)
{
if((left is int) && (right is int))
{
return (int)left | (int)right;
}
if((left is int) && (right is double))
{
return (int)left | (int)(double)right;
}
if((left is double) && (right is int))
{
return (int)(double)left | (int)right;
}
if((left is double) && (right is double))
{
return (int)(double)left | (int)(double)right;
}
return null;
}
public static object RSh(object left, object right)
{
if((left is int) && (right is int))
{
return (int)left >> (int)right;
}
if((left is int) && (right is double))
{
return (int)left >> (int)(double)right;
}
if((left is double) && (right is int))
{
return (int)(double)left >> (int)right;
}
if((left is double) && (right is double))
{
return (int)(double)left >> (int)(double)right;
}
return null;
}
public static object Xor(object left, object right)
{
if((left is int) && (right is int))
{
return (int)left ^ (int)right;
}
if((left is int) && (right is double))
{
return (int)left ^ (int)(double)right;
}
if((left is double) && (right is int))
{
return (int)(double)left ^ (int)right;
}
if((left is double) && (right is double))
{
return (int)(double)left ^ (int)(double)right;
}
return null;
}
public static object Add(object left, object right)
{
if((left is char) && (right is int))
{
return (char)((char)left + (int)right);
}
if((left is double) && (right is double))
{
return (double)left + (double)right;
}
if((left is double) && (right is int))
{
return (double)left + (int)right;
}
if((left is double) && (right is string))
{
return TypeCast.FloatToString((double)left) + (string)right;
}
if((left is int) && (right is double))
{
return (int)left + (double)right;
}
if((left is int) && (right is int))
{
return (int)left + (int)right;
}
if((left is int) && (right is string))
{
return TypeCast.IntegerToString((int)left) + (string)right;
}
if((left is string) && (right is char))
{
return (string)left + (char)right;
}
if((left is string) && (right is double))
{
return (string)left + TypeCast.FloatToString((double)right);
}
if((left is string) && (right is int))
{
return (string)left + TypeCast.IntegerToString((int)right);
}
if((left is string) && (right is string))
{
return (string)left + (string)right;
}
return null;
}
public static object Sub(object left, object right)
{
if((left is char) && (right is int))
{
return (char)((char)left - (int)right);
}
if((left is int) && (right is int))
{
return (int)left - (int)right;
}
if((left is int) && (right is double))
{
return (int)left - (double)right;
}
if((left is double) && (right is int))
{
return (double)left - (int)right;
}
if((left is double) && (right is double))
{
return (double)left - (double)right;
}
return null;
}
public static object Null(object right)
{
return null;
}
public static object Neg(object right)
{
if(right is int)
{
return -(int)right;
}
if(right is double)
{
return -(double)right;
}
return null;
}
public static object Not(object right)
{
if(right is int)
{
return ~(int)right;
}
return null;
}
}
/*
* Various datatypes.
*/
public abstract class TokenType: Token
{
public TokenType(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenType(Token original) : base(original) { }
public static TokenType FromSysType(Token original, System.Type typ)
{
if(typ == typeof(LSL_List))
return new TokenTypeList(original);
if(typ == typeof(LSL_Rotation))
return new TokenTypeRot(original);
if(typ == typeof(void))
return new TokenTypeVoid(original);
if(typ == typeof(LSL_Vector))
return new TokenTypeVec(original);
if(typ == typeof(float))
return new TokenTypeFloat(original);
if(typ == typeof(int))
return new TokenTypeInt(original);
if(typ == typeof(string))
return new TokenTypeStr(original);
if(typ == typeof(double))
return new TokenTypeFloat(original);
if(typ == typeof(bool))
return new TokenTypeBool(original);
if(typ == typeof(object))
return new TokenTypeObject(original);
if(typ == typeof(XMR_Array))
return new TokenTypeArray(original);
if(typ == typeof(LSL_Integer))
return new TokenTypeLSLInt(original);
if(typ == typeof(LSL_Float))
return new TokenTypeLSLFloat(original);
if(typ == typeof(LSL_String))
return new TokenTypeLSLString(original);
if(typ == typeof(char))
return new TokenTypeChar(original);
if(typ == typeof(Exception))
return new TokenTypeExc(original);
throw new Exception("unknown script type " + typ.ToString());
}
public static TokenType FromLSLType(Token original, string typ)
{
if(typ == "list")
return new TokenTypeList(original);
if(typ == "rotation")
return new TokenTypeRot(original);
if(typ == "vector")
return new TokenTypeVec(original);
if(typ == "float")
return new TokenTypeFloat(original);
if(typ == "integer")
return new TokenTypeInt(original);
if(typ == "key")
return new TokenTypeKey(original);
if(typ == "string")
return new TokenTypeStr(original);
if(typ == "object")
return new TokenTypeObject(original);
if(typ == "array")
return new TokenTypeArray(original);
if(typ == "bool")
return new TokenTypeBool(original);
if(typ == "void")
return new TokenTypeVoid(original);
if(typ == "char")
return new TokenTypeChar(original);
if(typ == "exception")
return new TokenTypeExc(original);
throw new Exception("unknown type " + typ);
}
/**
* @brief Estimate the number of bytes of memory taken by one of these
* objects. For objects with widely varying size, return the
* smallest it can be.
*/
public static int StaticSize(System.Type typ)
{
if(typ == typeof(LSL_List))
return 96;
if(typ == typeof(LSL_Rotation))
return 80;
if(typ == typeof(void))
return 0;
if(typ == typeof(LSL_Vector))
return 72;
if(typ == typeof(float))
return 8;
if(typ == typeof(int))
return 8;
if(typ == typeof(string))
return 40;
if(typ == typeof(double))
return 8;
if(typ == typeof(bool))
return 8;
if(typ == typeof(XMR_Array))
return 96;
if(typ == typeof(object))
return 32;
if(typ == typeof(char))
return 2;
if(typ == typeof(LSL_Integer))
return 32;
if(typ == typeof(LSL_Float))
return 32;
if(typ == typeof(LSL_String))
return 40;
throw new Exception("unknown type " + typ.ToString());
}
/**
* @brief Return the corresponding system type.
*/
public abstract Type ToSysType();
/**
* @brief Return the equivalent LSL wrapping type.
*
* null: normal
* else: LSL-style wrapping, ie, LSL_Integer, LSL_Float, LSL_String
* ToSysType()=System.Int32; lslWrapping=LSL_Integer
* ToSysType()=System.Float; lslWrapping=LSL_Float
* ToSysType()=System.String; lslWrapping=LSL_String
*/
public virtual Type ToLSLWrapType()
{
return null;
}
/**
* @brief Assign slots in either the global variable arrays or the script-defined type instance arrays.
* These only need to be implemented for script-visible types, ie, those that a script writer
* can actually define a variable as.
*/
public virtual void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
throw new Exception("not implemented for " + ToString() + " (" + GetType() + ")");
}
/**
* @brief Get heap tracking type.
* null indicates there is no heap tracker for the type.
*/
public virtual Type ToHeapTrackerType()
{
return null;
}
public virtual ConstructorInfo GetHeapTrackerCtor()
{
throw new ApplicationException("no GetHeapTrackerCtor for " + this.GetType());
}
public virtual void CallHeapTrackerPopMeth(Token errorAt, ScriptMyILGen ilGen)
{
throw new ApplicationException("no CallHeapTrackerPopMeth for " + this.GetType());
}
public virtual void CallHeapTrackerPushMeth(Token errorAt, ScriptMyILGen ilGen)
{
throw new ApplicationException("no CallHeapTrackerPushMeth for " + this.GetType());
}
}
public class TokenTypeArray: TokenType
{
private static readonly FieldInfo iarArraysFieldInfo = typeof(XMRInstArrays).GetField("iarArrays");
public TokenTypeArray(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeArray(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(XMR_Array);
}
public override string ToString()
{
return "array";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarArraysFieldInfo;
declVar.vTableIndex = arSizes.iasArrays++;
}
}
public class TokenTypeBool: TokenType
{
public TokenTypeBool(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeBool(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(bool);
}
public override string ToString()
{
return "bool";
}
}
public class TokenTypeChar: TokenType
{
private static readonly FieldInfo iarCharsFieldInfo = typeof(XMRInstArrays).GetField("iarChars");
public TokenTypeChar(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeChar(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(char);
}
public override string ToString()
{
return "char";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarCharsFieldInfo;
declVar.vTableIndex = arSizes.iasChars++;
}
}
public class TokenTypeExc: TokenType
{
private static readonly FieldInfo iarObjectsFieldInfo = typeof(XMRInstArrays).GetField("iarObjects");
public TokenTypeExc(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeExc(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(Exception);
}
public override string ToString()
{
return "exception";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarObjectsFieldInfo;
declVar.vTableIndex = arSizes.iasObjects++;
}
}
public class TokenTypeFloat: TokenType
{
private static readonly FieldInfo iarFloatsFieldInfo = typeof(XMRInstArrays).GetField("iarFloats");
public TokenTypeFloat(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeFloat(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(double);
}
public override string ToString()
{
return "float";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarFloatsFieldInfo;
declVar.vTableIndex = arSizes.iasFloats++;
}
}
public class TokenTypeInt: TokenType
{
private static readonly FieldInfo iarIntegersFieldInfo = typeof(XMRInstArrays).GetField("iarIntegers");
public TokenTypeInt(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeInt(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(int);
}
public override string ToString()
{
return "integer";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarIntegersFieldInfo;
declVar.vTableIndex = arSizes.iasIntegers++;
}
}
public class TokenTypeKey: TokenType
{
private static readonly FieldInfo iarStringsFieldInfo = typeof(XMRInstArrays).GetField("iarStrings");
public TokenTypeKey(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeKey(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(string);
}
public override string ToString()
{
return "key";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarStringsFieldInfo;
declVar.vTableIndex = arSizes.iasStrings++;
}
}
public class TokenTypeList: TokenType
{
private static readonly FieldInfo iarListsFieldInfo = typeof(XMRInstArrays).GetField("iarLists");
private static readonly ConstructorInfo htListCtor = typeof(HeapTrackerList).GetConstructor(new Type[] { typeof(XMRInstAbstract) });
public TokenTypeList(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeList(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(LSL_List);
}
public override string ToString()
{
return "list";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarListsFieldInfo;
declVar.vTableIndex = arSizes.iasLists++;
}
public override Type ToHeapTrackerType()
{
return typeof(HeapTrackerList);
}
public override ConstructorInfo GetHeapTrackerCtor()
{
return htListCtor;
}
public override void CallHeapTrackerPopMeth(Token errorAt, ScriptMyILGen ilGen)
{
HeapTrackerList.GenPop(errorAt, ilGen);
}
public override void CallHeapTrackerPushMeth(Token errorAt, ScriptMyILGen ilGen)
{
HeapTrackerList.GenPush(errorAt, ilGen);
}
}
public class TokenTypeObject: TokenType
{
private static readonly FieldInfo iarObjectsFieldInfo = typeof(XMRInstArrays).GetField("iarObjects");
private static readonly ConstructorInfo htObjectCtor = typeof(HeapTrackerObject).GetConstructor(new Type[] { typeof(XMRInstAbstract) });
public TokenTypeObject(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeObject(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(object);
}
public override string ToString()
{
return "object";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarObjectsFieldInfo;
declVar.vTableIndex = arSizes.iasObjects++;
}
public override Type ToHeapTrackerType()
{
return typeof(HeapTrackerObject);
}
public override ConstructorInfo GetHeapTrackerCtor()
{
return htObjectCtor;
}
public override void CallHeapTrackerPopMeth(Token errorAt, ScriptMyILGen ilGen)
{
HeapTrackerObject.GenPop(errorAt, ilGen);
}
public override void CallHeapTrackerPushMeth(Token errorAt, ScriptMyILGen ilGen)
{
HeapTrackerObject.GenPush(errorAt, ilGen);
}
}
public class TokenTypeRot: TokenType
{
private static readonly FieldInfo iarRotationsFieldInfo = typeof(XMRInstArrays).GetField("iarRotations");
public TokenTypeRot(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeRot(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(LSL_Rotation);
}
public override string ToString()
{
return "rotation";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarRotationsFieldInfo;
declVar.vTableIndex = arSizes.iasRotations++;
}
}
public class TokenTypeStr: TokenType
{
private static readonly FieldInfo iarStringsFieldInfo = typeof(XMRInstArrays).GetField("iarStrings");
private static readonly ConstructorInfo htStringCtor = typeof(HeapTrackerString).GetConstructor(new Type[] { typeof(XMRInstAbstract) });
public TokenTypeStr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeStr(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(string);
}
public override string ToString()
{
return "string";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarStringsFieldInfo;
declVar.vTableIndex = arSizes.iasStrings++;
}
public override Type ToHeapTrackerType()
{
return typeof(HeapTrackerString);
}
public override ConstructorInfo GetHeapTrackerCtor()
{
return htStringCtor;
}
public override void CallHeapTrackerPopMeth(Token errorAt, ScriptMyILGen ilGen)
{
HeapTrackerString.GenPop(errorAt, ilGen);
}
public override void CallHeapTrackerPushMeth(Token errorAt, ScriptMyILGen ilGen)
{
HeapTrackerString.GenPush(errorAt, ilGen);
}
}
public class TokenTypeUndef: TokenType
{ // for the 'undef' constant, ie, null object pointer
public TokenTypeUndef(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeUndef(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(object);
}
public override string ToString()
{
return "undef";
}
}
public class TokenTypeVec: TokenType
{
private static readonly FieldInfo iarVectorsFieldInfo = typeof(XMRInstArrays).GetField("iarVectors");
public TokenTypeVec(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeVec(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(LSL_Vector);
}
public override string ToString()
{
return "vector";
}
public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes)
{
declVar.vTableArray = iarVectorsFieldInfo;
declVar.vTableIndex = arSizes.iasVectors++;
}
}
public class TokenTypeVoid: TokenType
{ // used only for function/method return types
public TokenTypeVoid(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeVoid(Token original) : base(original) { }
public override Type ToSysType()
{
return typeof(void);
}
public override string ToString()
{
return "void";
}
}
public class TokenTypeLSLFloat: TokenTypeFloat
{
public TokenTypeLSLFloat(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeLSLFloat(Token original) : base(original) { }
public override Type ToLSLWrapType()
{
return typeof(LSL_Float);
}
}
public class TokenTypeLSLInt: TokenTypeInt
{
public TokenTypeLSLInt(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeLSLInt(Token original) : base(original) { }
public override Type ToLSLWrapType()
{
return typeof(LSL_Integer);
}
}
public class TokenTypeLSLKey: TokenTypeKey
{
public TokenTypeLSLKey(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeLSLKey(Token original) : base(original) { }
public override Type ToLSLWrapType()
{
return typeof(LSL_Key);
}
}
public class TokenTypeLSLString: TokenTypeStr
{
public TokenTypeLSLString(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
public TokenTypeLSLString(Token original) : base(original) { }
public override Type ToLSLWrapType()
{
return typeof(LSL_String);
}
}
}
|