1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959
|
-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries
--
-- SmartEiffel is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License, as published by the
-- Free Software Foundation; either version 2, or (at your option) any later
-- version.
-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-- more details. You should have received a copy of the GNU General Public
-- License along with SmartEiffel; see the file COPYING. If not, write to
-- the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-- MA 02111-1307, USA.
--
-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.
-- - University of Nancy 1 - FRANCE
-- Copyright(C) 2003: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne
-- - University of Nancy 2 - FRANCE
--
-- Dominique COLNET, Suzanne COLLIN, Olivier ZENDRA,
-- Philippe RIBET, Cyril ADRIAN
--
-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
--
class EIFFEL_PARSER
--
-- Singleton object in charge of Eiffel parsing.
-- This singleton is shared via the GLOBALS.`eiffel_parser' once function.
--
inherit
PARSER
feature
case_insensitive: BOOLEAN
-- When flag "-case_insensitive" is on.
no_style_warning: BOOLEAN
-- When flag "-no_style_warning" is on.
is_running: BOOLEAN
-- True when the parser is running (i.e. parsing of the current
-- class is not finished).
feature {SMART_EIFFEL}
analyse_class(class_name: CLASS_NAME): BASE_CLASS is
require
not is_running
not smart_eiffel.is_ready
class_name.to_string /= Void
parser_buffer.is_ready
local
old_nbe, old_nbw: INTEGER; path: STRING
do
current_id := id_provider.item(class_name.to_string)
path := parser_buffer.path
if nb_errors > 0 then
error_handler.append("Correct previous error(s) first.")
error_handler.print_as_fatal_error
end
debug
if smart_eiffel.is_ready then
error_handler.append(once "Tried to load class ")
error_handler.append(path)
error_handler.append(once " while smart_eiffel `is_ready'.")
error_handler.print_as_warning
end
end
echo.put_integer(smart_eiffel.base_class_count + 1)
echo.put_character('%T')
echo.put_string(path)
echo.put_character('%N')
old_nbe := nb_errors
old_nbw := nb_warnings
is_running := True
inside_function := False
in_ensure := False
last_comment := Void
line := 1
column := 1
current_line := parser_buffer.item(line)
if current_line.count = 0 then
cc := '%N'
else
cc := current_line.first
end
!!last_base_class.make(path, class_name.to_string,
parser_buffer.cluster, current_id)
skip_comments
a_class_declaration
is_running := False
parser_buffer.release
Result := last_base_class
if nb_errors - old_nbe > 0 then
show_nb_errors
echo.w_put_string("Load class %"")
echo.w_put_string(path)
echo.w_put_string("%" aborted.%N")
Result := Void
elseif nb_warnings - old_nbw > 0 then
show_nb_warnings
check
Result /= Void
end
end
if Result /= Void then
Result.get_started
end
ensure
not parser_buffer.is_ready
end
analyse_buffer: BASE_CLASS is
-- Scan the header of the `parser_buffer' in order to find the name
-- of the class in order to launch `analyse_class' with the
-- appropriate argument. (This is used for to handle the "include"
-- option of ACE files.)
require
not is_running
not smart_eiffel.is_ready
parser_buffer.is_ready
local
stop: BOOLEAN; n: STRING; cn: CLASS_NAME
do
last_comment := Void
line := 1
column := 1
current_line := parser_buffer.item(line)
if current_line.count = 0 then
cc := '%N'
else
cc := current_line.first
end
from
skip_comments
until
stop
loop
if cc = end_of_text then
stop := True
elseif a_keyword(fz_class) then
stop := True
from
!!n.make(32)
until
(once " %T[%/0/%N").has(cc)
loop
n.extend(cc)
next_char
end
!!cn.unknown_position(string_aliaser.item(n))
else
from until (once " %T%/0/%N").has(cc)
loop
next_char
end
skip_comments
end
end
if cn = Void then
error_handler.append("Unable to find a class definition in %"")
error_handler.append(parser_buffer.path)
error_handler.append("%".")
error_handler.print_as_fatal_error
end
Result := analyse_class(cn)
end
feature {ACE, COMMAND_LINE_TOOLS}
set_case_insensitive is
do
case_insensitive := True
string_aliaser.case_insensitive_notify
end
set_no_style_warning is
do
no_style_warning := True
end
feature {CECIL_FILE}
connect_to_cecil(a_path: STRING): STRING is
-- Return the cecil file user's include path (first information).
require
not is_running
nb_errors = 0
a_path /= Void
local
path: STRING
do
echo.put_string(once "Parsing Cecil File: %"")
echo.put_string(a_path)
echo.put_string(fz_18)
parser_buffer.load_file(a_path)
if not parser_buffer.is_ready then
error_handler.append(
"Cannot open Cecil file (use -verbose flag for details).")
error_handler.print_as_fatal_error
end
path := parser_buffer.path
current_id := id_provider.item(path)
is_running := True
formal_generic_list := Void
inside_function := False
in_ensure := False
last_comment := Void
line := 1
column := 1
current_line := parser_buffer.item(line)
last_base_class := Void
if current_line.count = 0 then
cc := '%N'
else
cc := current_line.first
end
skip_comments
from
!!Result.make(32)
until
cc = '%N' or else cc = end_of_text
loop
Result.extend(cc)
next_char
end
skip_comments
if cc = end_of_text then
error_handler.append(
"Empty Cecil file (use -verbose flag for details).")
error_handler.print_as_fatal_error
end
end
end_of_input: BOOLEAN is
do
Result := cc = end_of_text
end
parse_c_name: STRING is
do
from
!!Result.make(32)
until
cc.is_separator
loop
Result.extend(cc)
next_char
end
skip_comments
end
parse_run_type: E_TYPE is
do
if a_class_type then
Result := last_class_type
else
fcp(em16)
end
ensure
nb_errors = 0
end
parse_feature_name: FEATURE_NAME is
do
if a_feature_name then
Result := last_feature_name
else
fcp(em2)
end
ensure
nb_errors = 0
end
disconnect is
do
is_running := False
parser_buffer.release
end
feature {SMART_EIFFEL}
show_nb_warnings is
local
do_it: BOOLEAN
do
if echo.verbose then
do_it := True
elseif error_handler.no_warning then
else
do_it := True
end
if do_it then
show_nb(nb_warnings, once " warning(s).%N")
end
end
show_nb_errors is
do
show_nb(nb_errors, once " error(s).%N")
end
feature {COMPILE_TO_C, COMPILE_TO_JVM}
set_drop_comments is
do
drop_comments := True
end
feature {TMP_FEATURE}
ecp(msg: STRING) is
-- Error at current position.
do
error(current_position, msg)
end
feature {EIFFEL_PARSER_VISITOR}
accept(visitor: EIFFEL_PARSER_VISITOR) is
do
visitor.visit_eiffel_parser(Current)
end
feature {NONE}
current_id: INTEGER_16
-- This is the `id' of the `last_base_class' or the `id' of the ACE file
-- or of some cecil file path.
last_base_class: BASE_CLASS
-- The one beeing parsed.
inside_function: BOOLEAN
-- True when a function (once or non-once) is parsed.
formal_generic_list: FORMAL_GENERIC_LIST
-- Void or not empty list of formal generic arguments.
in_ensure: BOOLEAN
-- True during the parsing of a ensure clause.
in_rescue: BOOLEAN
-- True during the parsing of a rescue clause.
arguments: FORMAL_ARG_LIST
-- Void or actual formal arguments list.
local_vars: LOCAL_VAR_LIST
-- Void or actual local variables list.
ok: BOOLEAN
-- Dummy variable to call functions.
last_base_type: E_TYPE
last_bit_constant: BIT_CONSTANT
last_boolean_constant: BOOLEAN_CONSTANT
last_character_or_integer: BASE_TYPE_CONSTANT
last_character_constant: CHARACTER_CONSTANT
last_class_name: CLASS_NAME
last_class_type: E_TYPE
last_expression: EXPRESSION
last_feature_declaration: E_FEATURE
last_feature_name: FEATURE_NAME
last_feature_name_list: FEATURE_NAME_LIST
last_type_formal_generic: TYPE_FORMAL_GENERIC
last_integer_constant: INTEGER_CONSTANT
last_instruction: INSTRUCTION
last_index_value: EXPRESSION
last_manifest_constant: EXPRESSION
last_manifest_string: MANIFEST_STRING
last_parent: PARENT
last_real_constant: REAL_CONSTANT
last_type: E_TYPE
last_tag_mark: TAG_NAME
a_argument: BOOLEAN is
local
rank: INTEGER
do
if arguments /= Void then
rank := arguments.rank_of(tmp_name.aliased_string)
if rank > 0 then
last_expression := tmp_name.to_argument_name2(arguments, rank)
Result := True
end
end
end
a_current: BOOLEAN is
do
if tmp_name.is_current then
!WRITTEN_CURRENT!last_expression.make(tmp_name.start_position)
Result := True
end
end
a_formal_arg_list is
--++ formal_arg_list -> ["(" {declaration_group ";" ...} ")"]
--++ declaration_group -> {identifier "," ...}+ ":" type
local
name: ARGUMENT_NAME1; name_list: ARRAY[ARGUMENT_NAME1]
declaration: DECLARATION; list: ARRAY[DECLARATION]
state: INTEGER
do
arguments := Void
if skip1('(') then
from
until
state > 4
loop
inspect
state
when 0 then -- Waiting for the first name of a group.
if a_identifier then
name := tmp_name.to_argument_name1
state := 1
elseif skip1(')') then
state := 5
else
state := 6
end
when 1 then -- Waiting "," or ":".
if skip1(':') then
if name_list /= Void then
name_list.add_last(name)
name := Void
end
state := 3
else
ok := skip1(',')
if name_list = Void then
!!name_list.with_capacity(2, 1)
end
name_list.add_last(name)
name := Void
state := 2
end
when 2 then -- Waiting for a name (not the first).
if a_identifier then
name := tmp_name.to_argument_name1
state := 1
elseif cc = ',' or else cc = ';' then
wcp(em13)
ok := skip1(',') or else skip1(';')
else
state := 6
end
when 3 then -- Waiting for type mark.
if a_type then
if name_list /= Void then
!DECLARATION_GROUP!declaration.make(name_list, last_type)
name_list := Void
else
!DECLARATION_1!declaration.make(name, last_type)
name := Void
end
if list = Void then
!!list.with_capacity(2, 1)
end
list.add_last(declaration)
declaration := Void
state := 4
else
state := 6
end
when 4 then -- Waiting ";" or ")".
if skip1(')') then
state := 5
elseif cc = ',' then
wcp(once "Substitute with %";%".")
ok := skip1(',')
state := 0
else
ok := skip1(';')
state := 0
end
end
end
if state = 6 then
fcp("Bad formal arguments list.")
elseif list = Void then
wcp(once "Empty formal argument list (deleted).")
else
!!arguments.make(list)
tmp_feature.set_arguments(arguments)
end
end
end
a_local_var_list is
--++ local_var_list -> [{declaration_group ";" ...}]
--++ declaration_group -> {identifier "," ...}+ ":" type
local
name: LOCAL_NAME1; name_list: ARRAY[LOCAL_NAME1]
declaration: DECLARATION; list: ARRAY[DECLARATION]
rank, state: INTEGER
do
from
until
state > 4
loop
inspect
state
when 0 then -- Waiting for the first name of a group.
if a_identifier then
name := tmp_name.to_local_name1
state := 1
if arguments /= Void then
rank := arguments.rank_of(name.to_string)
if rank > 0 then
error_handler.add_position(name.start_position)
error(arguments.name(rank).start_position, em26)
end
end
elseif cc = ',' or else cc = ';' then
wcp(em13)
ok := skip1(',') or else skip1(';')
else
state := 5
end
when 1 then -- Waiting "," or ":".
if skip1(':') then
if name_list /= Void then
name_list.add_last(name)
name := Void
end
state := 3
else
if cc = ';' then
wcp(once "Substitute with %",%".")
ok := skip1(';')
else
ok := skip1(',')
end
if name_list = Void then
!!name_list.with_capacity(2, 1)
end
name_list.add_last(name)
name := Void
state := 2
end
when 2 then -- Waiting for a name (not the first).
if a_identifier then
name := tmp_name.to_local_name1
state := 1
if arguments /= Void then
rank := arguments.rank_of(name.to_string)
if rank > 0 then
error_handler.add_position(name.start_position)
error_handler.add_position(arguments.name(rank).start_position)
error_handler.append(em26)
error_handler.print_as_error
end
end
elseif cc = ',' or else cc = ';' then
wcp(em13)
ok := skip1(',') or else skip1(';')
else
state := 6
end
when 3 then -- Waiting for type mark.
if a_type then
if name_list /= Void then
!DECLARATION_GROUP!declaration.make(name_list, last_type)
name_list := Void
else
!DECLARATION_1!declaration.make(name, last_type)
name := Void
end
if list = Void then
!!list.with_capacity(2, 1)
end
list.add_last(declaration)
state := 4
else
state := 6
end
when 4 then -- Waiting ";".
if cc = ',' then
wcp(once "Substitute with %";%".")
ok := skip1(',')
state := 0
else
ok := skip1(';')
state := 0
end
end
end
if state = 6 then
fcp("Bad local variable list.")
elseif list /= Void then
!!local_vars.make(list)
tmp_feature.set_local_vars(local_vars)
end
end
a_local_variable: BOOLEAN is
local
rank: INTEGER
do
if local_vars /= Void then
rank := local_vars.rank_of(tmp_name.aliased_string)
if rank > 0 then
last_expression := tmp_name.to_local_name2(local_vars, rank)
Result := True
end
end
end
a_result: BOOLEAN is
do
if tmp_name.is_result then
last_expression := last_result
Result := True
end
end
a_void: BOOLEAN is
do
if tmp_name.is_void then
last_expression := tmp_name.to_e_void
Result := True
end
end
get_comment: COMMENT is
do
Result := last_comment
last_comment := Void
end
go_back_at(l, c: INTEGER) is
-- Go back to some existing line `l', and column `c'.
require
l >= 1; c >= 1
local
sp: POSITION
do
line := l
column := c
current_line := parser_buffer.item(l)
cc := current_line.item(c)
if last_comment /= Void then
sp := last_comment.start_position
if l < sp.line then
last_comment := Void
elseif l = sp.line then
if c < sp.column then
last_comment := Void
end
end
end
end
skip2(c1, c2: CHARACTER): BOOLEAN is
do
if c1 = cc then
start_line := line
start_column := column
next_char
if c2 = cc then
Result := True
next_char
skip_comments
else
cc := c1
column := start_column
end
end
end
skip1unless2(c1, c2: CHARACTER): BOOLEAN is
do
start_line := line
start_column := column
if cc = c1 then
next_char
if cc = c2 then
cc := c1
column := start_column
else
Result := True
skip_comments
end
end
end
a_bit_constant: BOOLEAN is
local
l, c: INTEGER; stop: BOOLEAN
do
if cc = '0' or else cc = '1' then
from
l := line; c := column
buffer.clear
buffer.extend(cc)
until
stop
loop
next_char
inspect
cc
when '0', '1' then
buffer.extend(cc)
when 'b', 'B' then
!!last_bit_constant.make(pos(l, c), buffer.twin)
next_char
skip_comments
stop := True
Result := True
else
go_back_at(l, c)
stop := True
end
end
end
end
a_character_constant: BOOLEAN is
local
sp: POSITION; value: CHARACTER state, printing_mode,
ascii_code, digit_count: INTEGER
do
if cc = '%'' then
from
sp := pos(line, column)
Result := True
until
state > 4
loop
next_char
inspect
state
when 0 then -- First '%'' read.
inspect
cc
when '%%' then
state := 1
when '%'' then
fcp(em10)
state := 2
else
value := cc
printing_mode := 0
state := 2
end
when 1 then -- First '%%' read.
printing_mode := 1
state := 2
inspect
cc
when 'A' then value := '%A'
when 'B' then value := '%B'
when 'C' then value := '%C'
when 'D' then value := '%D'
when 'F' then value := '%F'
when 'H' then value := '%H'
when 'L' then value := '%L'
when 'N' then value := '%N'
when 'Q' then value := '%Q'
when 'R' then value := '%R'
when 'S' then value := '%S'
when 'T' then value := '%T'
when 'U' then value := '%U'
when 'V' then value := '%V'
when '%%' then value := '%%'
when '%'' then value := '%''
when '%"' then value := '%"'
when '(' then value := '%('
when ')' then value := '%)'
when '<' then value := '%<'
when '>' then value := '%>'
when '/' then
state := 3
printing_mode := 2
else
fcp(em37)
end
when 2 then -- Wait for second '%''.
inspect
cc
when '%'' then
state := 5
else
fcp(em10)
end
next_char
skip_comments
when 3 then -- Inside ascii decimal code. After opening '/'.
inspect
cc
when '0' .. '9' then
digit_count := digit_count + 1
ascii_code := ascii_code * 10 + cc.decimal_value
when '/' then
state := 2
if digit_count = 0 then
ecp(em39)
elseif ascii_code > Maximum_character_code then
ascii_code := 0
ecp(em40)
end
value := ascii_code.to_character
when 'x' then
if digit_count = 1 and then ascii_code = 0 then
digit_count := 0
state := 4
else
fcp(em38)
end
else
fcp(em38)
end
when 4 then -- Inside ascii hexade code. After '/0x
if cc.is_hexadecimal_digit then
ascii_code := ascii_code * 16 + cc.hexadecimal_value
digit_count := digit_count + 1
elseif cc = '/' then
state := 2
if digit_count /= 2 then
ecp("You must use exactely 2 hexadecimal %
%digits to denote a CHARACTER.")
end
value := ascii_code.to_character
else
fcp(em38)
end
end
end
create last_character_constant.make(sp, value, printing_mode)
end
end
a_constant: BOOLEAN is
-- Only True for constant allowed in "when of inspect".
local
implicit_current: IMPLICIT_CURRENT; sfn: FEATURE_NAME
do
if a_identifier then
Result := True
sfn := tmp_name.to_simple_feature_name
!!implicit_current.make(sfn.start_position)
!CALL_0_C!last_expression.make(implicit_current, sfn)
elseif a_character_constant then
Result := True
last_expression := last_character_constant
elseif a_integer_constant then
Result := True
last_expression := last_integer_constant
elseif a_manifest_string then
Result := True
last_expression := last_manifest_string
else
fcp(fz_iinaiv)
end
end
a_base_class_name: BOOLEAN is
local
c: INTEGER; stop, do_warning: BOOLEAN
do
if cc.is_letter then
from
if cc >= 'a' then
do_warning := True
cc := cc.to_upper
end
c := column
tmp_name.reset(pos(line, c))
tmp_name.extend(cc)
until
stop
loop
next_char
inspect
cc
when 'A' .. 'Z', '0' .. '9', '_' then
tmp_name.extend(cc)
when 'a' .. 'z' then
do_warning := True
tmp_name.extend(cc.to_upper)
else
stop := True
end
end
if tmp_name.isa_keyword then
cc := tmp_name.buffer.first
column := c
else
Result := True
skip_comments
if do_warning then
warning(tmp_name.start_position, em14)
end
last_class_name := tmp_name.to_class_name
end
end
debug
if Result then
check
tmp_name.buffer.is_equal(tmp_name.buffer.as_upper)
end
end
end
end
a_base_class_name1 is
-- Read the current base class name.
local
cn: CLASS_NAME; bc: BASE_CLASS
do
bc := last_base_class
cn := bc.name
cn.set_accurate_position(pos(line, column))
if a_base_class_name then
if last_class_name.to_string /= cn.to_string then
error_handler.add_position(last_class_name.start_position)
error_handler.append(fz_01)
error_handler.append(bc.path)
error_handler.append("%" does not contain class %"")
error_handler.append(cn.to_string)
error_handler.append(fz_03)
error_handler.print_as_fatal_error
end
else
fcp(em15)
end
if as_none = cn.to_string then
error_handler.add_position(cn.start_position)
error_handler.append("Cannot write such a class.")
error_handler.print_as_fatal_error
end
end
a_type_formal_generic: BOOLEAN is
local
fga: FORMAL_GENERIC_ARG; cn: CLASS_NAME; rank: INTEGER
do
if formal_generic_list /= Void then
from
rank := 1
until
Result or else rank > formal_generic_list.count
loop
fga := formal_generic_list.item(rank)
if a_keyword(fga.name.to_string) then
!!cn.make(fga.name.to_string, pos(start_line, start_column))
!!last_type_formal_generic.make(cn, fga, rank)
Result := True
end
rank := rank + 1
end
end
end
a_free_operator_definition(prefix_flag: BOOLEAN): BOOLEAN is
-- A free operator name definition (the one which comes after the
-- "infix" keyword or the "prefix" keyword at the definition
-- place). A free operator must start and finish with one of the
-- following character: +-*/\=<>@#|&~
local
stop: BOOLEAN; l, c: INTEGER
do
inspect
cc
when '+','-','*','/','\','=','<','>','@','#','|','&','~' then
l := line; c := column; buffer.clear
Result := True
from
buffer.extend(cc)
next_char
until
stop
loop
inspect
cc
when '.', '?', '{', '}' then
Result := False
buffer.extend(cc)
next_char
when '+','-','*','/','\','=','<','>','@','#','|','&','~','^' then
Result := True
buffer.extend(cc)
next_char
else
stop := True
end
end
if not Result then
error_handler.add_position(pos(line, column))
error_handler.append(em43)
error_handler.print_as_fatal_error
end
if buffer.count = 1 and then buffer.first = '=' then
error_handler.add_position(pos(l, c))
error_handler.append(
"The basic = operator cannot be redefined. (This is a %
%hard-coded builtin that we must trust.)")
error_handler.print_as_fatal_error
end
create_infix_prefix(prefix_flag, l, c)
else
end
end
a_free_operator_usage(prefix_flag: BOOLEAN): BOOLEAN is
-- Syntactically, a free operator must start and finish with one
-- of the following set of characters: +-*/\=<>@#|&~
-- Because of priority, traditional operators are not handled here.
local
stop: BOOLEAN; l, c: INTEGER
do
inspect
cc
when '+','-','*','/','\','=','<','>','@','#','|','&','~' then
l := line; c := column; buffer.clear
from
Result := True
buffer.extend(cc)
next_char
until
stop
loop
inspect
cc
when '.', '?', '{', '}' then
Result := False
buffer.extend(cc)
next_char
when '+','-','*','/','\','=','<','>','@','#','|','&','~','^' then
Result := True
buffer.extend(cc)
next_char
else
stop := True
end
end
-- Elimination of traditional operators which are handled
-- by specific class as well as some other usage in order
-- to provide backward compatibility:
if Result then
inspect
buffer.count
when 1 then
inspect
buffer.first
when '+', '-', '*', '/', '=', '<', '>' then
Result := False
else
end
when 2 then
inspect
buffer.first
when '>' then
inspect
buffer.last
when '=', '>' then
Result := False
else
end
when '/', '\', '<' then
inspect
buffer.last
when '=', '\', '/' then
Result := False
else
end
else
end
else
Result := buffer.occurrences('>') /= buffer.count
end
end
if Result then
skip_comments
create_infix_prefix(prefix_flag, l, c)
else
go_back_at(l, c)
end
else
end
end
a_identifier: BOOLEAN is
do
if case_insensitive then
Result := a_identifier_case_sensitive
else
Result := a_identifier_regular
end
end
a_integer(negative: BOOLEAN): BOOLEAN is
local
state, l, c: INTEGER; value: INTEGER_64
underscore_flag, hexadecimal_flag: BOOLEAN
do
-- Note: we should also detect that overflow for constant like
-- 92233720368547758085 as an example.
if cc.is_digit then
from
l := line; c := column
value := - cc.value
until
state > 7
loop
next_char
inspect
state
when 0 then -- 1st digit read (no '_' encountered).
inspect
cc
when '0'..'9' then
value := value * 10 - cc.value
state := 1
when '_' then
state := 4
when 'x' then
if value = 0 then
hexadecimal_flag := True
end
state := 8
else
state := 8
end
when 1 then -- 2nd digit read (no '_' encountered).
inspect
cc
when '0'..'9' then
value := value * 10 - cc.value
state := 2
when '_' then
state := 4
else
state := 8
end
when 2 then -- 3rd digit read (no '_' encountered).
inspect
cc
when '0'..'9' then
value := value * 10 - cc.value
state := 3
when '_' then
state := 4
else
state := 8
end
when 3 then -- More than 3 digit read (no '_' encountered).
inspect
cc
when '0'..'9' then
value := value * 10 - cc.value
when '_' then
fcp(em9)
else
state := 8
end
when 4 then -- After first '_'.
underscore_flag := True
inspect
cc
when '0'..'9' then
value := value * 10 - cc.value
state := 5
else
fcp(em9)
end
when 5 then -- After '_' and 1 digit read.
inspect
cc
when '0'..'9' then
value := value * 10 - cc.value
state := 6
else
fcp(em9)
end
when 6 then -- After '_' and 2 digit read.
inspect
cc
when '0'..'9' then
value := value * 10 - cc.value
state := 7
else
fcp(em9)
end
when 7 then -- After '_' and 3 digit read.
inspect
cc
when '0'..'9' then
fcp(em9)
when '_' then
state := 4
else
state := 8
end
end
end -- loop
if hexadecimal_flag then
Result := True
a_hexadecimal(l, c)
elseif cc.is_letter then
go_back_at(l, c)
else
Result := True
skip_comments
create last_integer_constant.with(underscore_flag,
negative, value, pos(l, c))
end
end
end
a_hexadecimal(l, c: INTEGER) is
local
digit_count: INTEGER_8; value: INTEGER_64; stop, negative: BOOLEAN
do
next_char
inspect
cc
when '0' .. '7' then
value := cc.decimal_value
when '8' .. '9', 'A' .. 'F', 'a' .. 'f' then
negative := True
value := cc.hexadecimal_value - 8
else
fcp("Hexadecimal digit expected.")
end
digit_count := 1
from until
stop
loop
next_char
if cc.is_hexadecimal_digit then
value := value * 16 + cc.hexadecimal_value
digit_count := digit_count + 1
else
stop := True
end
end
inspect
digit_count
when 2, 4, 8, 16 then
else
error_handler.append("Incorrect hexadecimal notation. %
%Wrong number of hexadecimal digits (")
error_handler.append_integer(digit_count)
fcp(" digits). You must use exactely 2, 4, 8 or 16 digits only. %
%A 2 digits value denote an INTEGER_8, a 4 digits value %
%denote an INTEGER_16, a 8 digits value denote an %
%INTEGER_32, and, finally, a 16 digits value denote an %
%INTEGER_64. (See examples in file%
% %"SmartEiffel/tutorial/hexadecimal.e%".)")
end
if cc.is_letter then
fcp("Separator expected to end hexadecimal notation.")
end
create last_integer_constant.hexadecimal(negative, digit_count,
value, pos(l, c))
skip_comments
end
a_manifest_string: BOOLEAN is
local
state, l, c: INTEGER; once_flag, unicode_flag, stop: BOOLEAN
ascii_code, unicode, digit_count: INTEGER
source_view: FIXED_ARRAY[STRING]; line_view: STRING
multi_line_end: STRING; left_alignment, current_alignment: INTEGER
do
l := line; c := column
if a_keyword(fz_once) then once_flag := True end
if cc = 'U' then
unicode_flag := True; next_char
end
if cc = '%"' then
Result := True
if smart_eiffel.short_flag or else smart_eiffel.pretty_flag then
create source_view.with_capacity(4)
create line_view.make(32)
source_view.add_last(line_view)
end
from buffer.clear until
state > 9
loop
if source_view /= Void then
line_view.extend(cc)
if cc = '%N' then
create line_view.make(32)
source_view.add_last(line_view)
end
end
next_char
inspect
state
when 0 then -- Somewhere inside the manifest string.
inspect
cc
when '%N' then
from until multi_line_end /= Void
loop
if buffer.is_empty then
fcp(em8)
else
inspect
buffer.last
when ' ', '%T' then
buffer.remove_last(1)
wcp(em42)
when '{', '[' then
multi_line_end := once "]foo%""
multi_line_end.clear
if buffer.last = '{' then
multi_line_end.extend('}')
left_alignment := 1
state := 8
else
multi_line_end.extend(']')
state := 7
end
multi_line_end.append(buffer)
current_alignment := 1
multi_line_end.remove_last(1)
multi_line_end.extend('%"')
buffer.clear
else
fcp(em8)
end
end
end
when '%"' then
state := 11
when '%%' then
state := 1
else
buffer.extend(cc)
end
when 1 then -- Just after a '%%'.
state := 0
inspect
cc
when '%N' then
state := 3
when 'A' then buffer.extend('%A')
when 'B' then buffer.extend('%B')
when 'C' then buffer.extend('%C')
when 'D' then buffer.extend('%D')
when 'F' then buffer.extend('%F')
when 'H' then buffer.extend('%H')
when 'L' then buffer.extend('%L')
when 'N' then buffer.extend('%N')
when 'Q' then buffer.extend('%Q')
when 'R' then buffer.extend('%R')
when 'S' then buffer.extend('%S')
when 'T' then buffer.extend('%T')
when 'U' then buffer.extend('%U')
when 'V' then buffer.extend('%V')
when '%%' then buffer.extend('%%')
when '%'' then buffer.extend('%'')
when '%"' then buffer.extend('%"')
when '(' then buffer.extend('%(')
when ')' then buffer.extend('%)')
when '<' then buffer.extend('%<')
when '>' then buffer.extend('%>')
when '/' then
ascii_code := 0
digit_count := 0
state := 4
when ' ','%T' then
state := 2
else
fcp(em37)
state := 0
end
when 2 then -- Extended form. At end of line.
inspect
cc
when '%N' then
state := 3
when ' ', '%T' then
wcp(em42)
else
fcp("In extended form of manifest string.%
%Bad character after '%%'.")
end
when 3 then -- Extended form. At beginning of line.
inspect
cc
when ' ', '%T' then
when '%%' then
state := 0
when '%N' then
fcp(em8)
else
fcp("In extended form of manifest string.%
% Bad character before '%%'.")
end
when 4 then -- Inside ascii code. After opening '/'.
inspect
cc
when '0' .. '9' then
digit_count := digit_count + 1
ascii_code := ascii_code * 10 + cc.decimal_value
when 'x' then
if digit_count = 1 and ascii_code = 0 then
digit_count := 0
state := 5
else
fcp(em38)
end
when 'U' then
if digit_count = 0 then
next_char
if cc = 'x' then
state := 6
unicode := 0
digit_count := 0
else fcp(em38) end
else
fcp(em38)
end
when '/' then
buffer.extend(ascii_code.to_character)
state := 0
if digit_count = 0 then
ecp(em39)
elseif ascii_code > Maximum_character_code then
ascii_code := 0
ecp(em40)
end
else
fcp(em38)
end
when 5 then -- Inside ascii code. After /0x
if cc.is_hexadecimal_digit then
ascii_code := ascii_code * 16 + cc.hexadecimal_value
digit_count := digit_count + 1
if digit_count.even then
buffer.extend(ascii_code.to_character)
ascii_code := 0
end
elseif cc = '/' then
state := 0
if digit_count = 0 then
ecp(em45)
elseif digit_count.odd then
ecp("You must use an even number of hexadecimal %
%digits to denote a sequence of CHARACTERs.")
end
else
fcp(em45)
end
when 6 then -- Inside unicode code. After /Ux
if cc.is_hexadecimal_digit then
unicode := unicode * 16 + cc.hexadecimal_value
digit_count := digit_count + 1
elseif cc = '/' then
state := 0
if digit_count = 0 then
ecp(em46)
elseif digit_count > 8 then
ecp("Too long hexadecimal sequence %
%for a single unicode value.")
else
unicode_string_buffer.clear
if unicode_string_buffer.valid_unicode(unicode) then
unicode_string_buffer.add_last(unicode)
unicode_string_buffer.utf8_encode_in(buffer)
else
ecp("Invalid unicode notation (see also http://%
%www.unicode.org as well as feature %
%{UNICODE_STRING}.valid_unicode).")
end
end
else
fcp(em46)
end
when 7 then -- Just after the multi-line opener, in left
-- alignment mode.
check left_alignment = 0 end
inspect
cc
when ' ', '%T' then
current_alignment := current_alignment + 1
when '%N' then
buffer.extend('%N'); current_alignment := 1
when end_of_text then
error_handler.add_position(pos(l, c))
fcp(em41)
else
buffer.extend(cc)
if left_alignment = 0 then
left_alignment := current_alignment
end
state := 8
end
when 8 then -- Inside multi-line manifest string.
current_alignment := current_alignment + 1
inspect
cc
when ' ', '%T' then
if current_alignment >= left_alignment then
buffer.extend(cc)
end
when '%N' then
buffer.extend(cc); current_alignment := 0
when end_of_text then
error_handler.add_position(pos(l, c))
fcp(em41)
when '%"' then
buffer.extend(cc)
if buffer.has_suffix(multi_line_end) then
state := 10
end
else
if current_alignment < left_alignment then
if cc = multi_line_end.first then
buffer.extend(cc)
state := 9
else
error_handler.add_position(pos(l, c))
fcp(em41)
end
else
buffer.extend(cc)
end
end
when 9 then -- Inside multi-line closer.
inspect
cc
when end_of_text then
error_handler.add_position(pos(l, c))
fcp(em41)
when '%"' then
buffer.extend(cc)
if buffer.has_suffix(multi_line_end) then
state := 10
end
else
buffer.extend(cc)
end
end
end
if state = 10 then -- Good verbatim string.
buffer.remove_suffix(multi_line_end)
from
until stop
loop
if buffer.is_empty then
stop := True
else
stop := buffer.last = '%N'
buffer.remove_last(1)
end
end
end
if source_view /= Void then line_view.extend('%"') end
create last_manifest_string.make(pos(l, c),
once_flag, unicode_flag, buffer)
last_manifest_string.set_source_view(source_view)
next_char
skip_comments
elseif once_flag or else unicode_flag then
go_back_at(l, c)
end
end
a_real(sign: INTEGER_8): BOOLEAN is
require
sign = -1 or sign = 0
local
state, l, c: INTEGER
do
if cc.is_digit or else cc = '.' then
from
l := line; c := column
buffer.clear
if sign < 0 then
buffer.extend('-')
end
if cc = '.' then
buffer.append(fz_59)
state := 5
else
buffer.extend(cc)
end
until
state > 11
loop
next_char
inspect
state
when 0 then -- Reading integral part.
inspect
cc
when '0' .. '9' then
buffer.extend(cc)
when '.' then
buffer.extend('.')
state := 4
else
state := 13
end
when 1 then -- Reading integral part after '_'.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
state := 2
else
fcp(em9)
end
when 2 then -- Reading integral part after '_' and 1 digit.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
state := 3
else
fcp(em9)
end
when 3 then -- Reading integral part after '_' and 2 digits.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
state := 0
else
fcp(em9)
end
when 4 then -- The '.' is read and non empty integral_part.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
state := 6
when 'E', 'e' then
buffer.extend('E')
state := 10
else
state := 12
end
when 5 then -- The '.' is read and empty integral_part.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
state := 6
else
state := 13
end
when 6 then -- Reading frac_part.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
when 'E', 'e' then
buffer.extend('E')
state := 10
when '_' then
state := 7
else
state := 12
end
when 7 then -- Reading frac_part after '_'.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
state := 8
else
fcp(em1)
end
when 8 then -- Reading frac_part after '_' and 1 digit.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
state := 9
else
fcp(em1)
end
when 9 then -- Reading frac_part after '_' and 2 digits.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
state := 6
else
fcp(em1)
end
when 10 then -- 'E' or 'e' read.
inspect
cc
when '+' then
state := 11
when '-' then
buffer.extend('-')
state := 11
when '0'..'9' then
buffer.extend(cc)
state := 11
else
fcp("Exponent of a real value expected.")
state := 13
end
else -- Reading exponent.
inspect
cc
when '0'..'9' then
buffer.extend(cc)
else
state := 12
end
end
end
if state = 12 then
create last_real_constant.make(pos(l, c), buffer.twin)
Result := True
skip_comments
else
go_back_at(l, c)
end
end
end
a_retry: BOOLEAN is
do
if a_keyword(fz_retry) then
if not in_rescue then
error(pos(start_line, start_column),
"%"retry%" cannot be outside of a rescue clause.")
end
!E_RETRY!last_instruction.make(pos(start_line, start_column))
Result := True
end
end
a_actual: BOOLEAN is
--++ actual -> expression | "$" identifier | "?"
--++
local
l, c: INTEGER; type: E_TYPE; sfn: FEATURE_NAME
do
if skip1('%D') then
if a_identifier then
if a_result or else a_void or else a_current then
error_handler.add_position(last_expression.start_position)
error_handler.append(fz_vuar4)
error_handler.print_as_fatal_error
else
sfn := tmp_name.to_simple_feature_name
!ADDRESS_OF!last_expression.make(sfn)
Result:= True
end
else
fcp(fz_vuar4)
end
elseif skip1('?') then
Result := True
l := start_line; c := start_column
create {OPEN_OPERAND} last_expression.make(pos(l, c))
elseif skip1('{') then
l := start_line; c := start_column
if not a_type then fcp(em32) end
type := last_type
if not skip1('}') then fcp(em36) end
if a_keyword(as_precursor) then
go_back_at(l, c)
else
Result := True
create {OPEN_OPERAND} last_expression.with(pos(l, c), type)
end
elseif a_expression then
Result := True
end
end
a_actuals: EFFECTIVE_ARG_LIST is
--++ actuals -> "(" {actual "," ...} ")"
--++
local
first_one: EXPRESSION; remainder: FIXED_ARRAY[EXPRESSION]
do
if skip1('(') then
from
until
not a_actual
loop
if first_one = Void then
first_one := last_expression
else
if remainder = Void then
!!remainder.with_capacity(4)
end
remainder.add_last(last_expression)
end
if not skip1(',') and then cc /= ')' then
wcp(em5)
end
end
if first_one = Void then
wcp(once "Empty argument list (deleted).")
else
!!Result.make_n(first_one, remainder)
end
if not skip1(')') then
fcp("')' expected to end arguments list.")
end
end
end
a_after_a_dot(do_instruction: BOOLEAN; target: EXPRESSION) is
--++ after_a_dot -> identifier [actuals] ["." after_a_dot]
--++
require
target /= Void
local
sfn: FEATURE_NAME; eal: EFFECTIVE_ARG_LIST
do
if a_identifier then
if a_result or else a_void or else a_current then
error(last_expression.start_position,
"This name must not appear after a dot.")
end
sfn := tmp_name.to_simple_feature_name
eal := a_actuals
a_r10(do_instruction, target, sfn, eal, False)
else
fcp("Identifier expected after a dot.")
end
end
a_assignment_or_call: BOOLEAN is
--++ assignment_or_call -> "(" expression ")" r10 |
--++ precursor_call |
--++ "Current" r10 |
--++ "Result" r10 |
--++ local_variable r10 |
--++ formal_argument r10 |
--++ writable ":=" expression |
--++ writable "?=" expression |
--++ identifier procedure_call
--++
do
if skip1('(') and then a_expression then
Result := True
if skip1(')') then
a_r10(True, last_expression, Void, Void, False)
else
fcp("')' expected.")
end
elseif a_precursor(True) then
Result := True
elseif a_identifier then
Result := True
if skip2(':', '=') then
a_assignment_aux(True)
elseif skip2('?', '=') then
a_assignment_aux(False)
elseif a_argument then
a_r10(True, last_expression, Void, Void, True)
elseif a_current or else a_result or else a_local_variable then
a_r10(True, last_expression, Void, Void, False)
else
a_procedure_call
end
end
end
a_assignment_aux(regular: BOOLEAN) is
local
writable, rhs: EXPRESSION
do
if a_current then
error_handler.add_position(last_expression.start_position)
error_handler.append("Must not affect `Current'.")
error_handler.print_as_fatal_error
elseif a_void then
error_handler.add_position(tmp_name.start_position)
error_handler.append("Must not affect `Void'.")
error_handler.print_as_fatal_error
elseif a_argument then
error_handler.add_position(last_expression.start_position)
error_handler.append("Must not affect a formal argument.")
error_handler.print_as_fatal_error
else
if tmp_name.is_result then
writable := last_result
elseif a_local_variable then
writable := last_expression
else
writable := tmp_name.to_simple_feature_name
end
if a_expression then
rhs := last_expression
if regular then
!ASSIGNMENT!last_instruction.make(writable, rhs)
else
!ASSIGNMENT_ATTEMPT!last_instruction.make(writable, rhs)
end
else
fcp("Right hand side expression expected for assignment.")
end
end
end
a_assertion_buffer: FIXED_ARRAY[ASSERTION] is
-- Used only inside `a_assertion'.
once
create Result.with_capacity(32)
end
a_assertion: FIXED_ARRAY[ASSERTION] is
--++ assertion -> {assertion_clause ";" ...}
--++ assertion_clause -> [identifier ":"] [expression] [comment]
--++
local
tag: like last_tag_mark; expression: like last_expression
assertion: ASSERTION; state: INTEGER
do
from
a_assertion_buffer.clear
until
state > 3
loop
inspect
state
when 0 then -- Nothing read.
if cc = ';' then
wcp(em24)
ok := skip1(';')
elseif last_comment /= Void then
!!assertion.make(Void, Void, get_comment)
a_assertion_buffer.add_last(assertion)
elseif a_tag_mark then
tag := last_tag_mark
state := 1
elseif a_expression then
expression := last_expression
state := 2
else
state := 4
end
when 1 then -- Read a `tag'.
if skip1(';') then
!!assertion.make(tag, Void, get_comment)
a_assertion_buffer.add_last(assertion)
state := 0
elseif a_tag_mark then
!!assertion.make(tag, Void, get_comment)
a_assertion_buffer.add_last(assertion)
tag := last_tag_mark
elseif a_expression then
expression := last_expression
state := 3
else
!!assertion.make(tag, Void, get_comment)
a_assertion_buffer.add_last(assertion)
state := 4
end
when 2 then -- Read an `expression'.
if skip1(';') then
!!assertion.make(Void, expression, get_comment)
a_assertion_buffer.add_last(assertion)
state := 0
elseif a_tag_mark then
!!assertion.make(Void, expression, get_comment)
a_assertion_buffer.add_last(assertion)
tag := last_tag_mark
state := 1
elseif a_expression then
!!assertion.make(Void, expression, get_comment)
a_assertion_buffer.add_last(assertion)
expression := last_expression
state := 2
else
!!assertion.make(Void, expression, get_comment)
a_assertion_buffer.add_last(assertion)
state := 4
end
else -- Read a `tag' and an `expression'.
if skip1(';') then
!!assertion.make(tag, expression, get_comment)
a_assertion_buffer.add_last(assertion)
state := 0
elseif a_tag_mark then
!!assertion.make(tag, expression, get_comment)
a_assertion_buffer.add_last(assertion)
tag := last_tag_mark
state := 1
elseif a_expression then
!!assertion.make(tag, expression, get_comment)
a_assertion_buffer.add_last(assertion)
expression := last_expression
state := 2
else
!!assertion.make(tag, expression, get_comment)
a_assertion_buffer.add_last(assertion)
state := 4
end
end
end
if not a_assertion_buffer.is_empty then
Result := a_assertion_buffer.twin
end
end
a_base_type: BOOLEAN is
--++ base_type -> "ANY" | ARRAY "[" type "]" | "BOOLEAN" |
--++ "CHARACTER" | "DOUBLE" | "INTEGER" | "NONE" |
--++ "POINTER" | "REAL" | "STRING" | "TUPLE" |
--++ "ROUTINE" | "PROCEDURE" | "FUNCTION" | "PREDICATE"
--++
local
sp: POSITION; types: ARRAY[E_TYPE]; type1, type2, type3: E_TYPE
do
Result := True
if a_keyword(as_any) then
create {TYPE_ANY}
last_base_type.make(pos(start_line, start_column))
elseif a_keyword(as_array) then
sp := pos(start_line, start_column)
if skip1('[') and then a_type and then skip1(']') then
check
last_type /= Void
end
create {TYPE_ARRAY}
last_base_type.make(sp, last_type)
else
fcp("Bad use of predefined type ARRAY.")
end
elseif a_keyword(as_native_array) then
sp := pos(start_line, start_column)
if skip1('[') and then a_type and then skip1(']') then
check
last_type /= Void
end
create {TYPE_NATIVE_ARRAY}
last_base_type.make(sp, last_type)
else
fcp("Bad use of predefined type NATIVE_ARRAY.")
end
elseif a_keyword(as_boolean) then
create {TYPE_BOOLEAN}
last_base_type.make(pos(start_line, start_column))
elseif a_keyword(as_character) then
create {TYPE_CHARACTER}
last_base_type.make(pos(start_line, start_column))
elseif a_keyword(as_double) then
create {TYPE_DOUBLE}
last_base_type.make(pos(start_line, start_column))
elseif a_keyword(as_pointer_ref) then
old_ref_style_compatibility(
create {TYPE_POINTER}.make(pos(start_line, start_column)))
elseif a_keyword(as_boolean_ref) then
old_ref_style_compatibility(
create {TYPE_BOOLEAN}.make(pos(start_line, start_column)))
elseif a_keyword(as_character_ref) then
old_ref_style_compatibility(
create {TYPE_CHARACTER}.make(pos(start_line, start_column)))
elseif a_keyword(as_integer_ref) then
old_ref_style_compatibility(
create {TYPE_INTEGER}.integer(pos(start_line, start_column)))
elseif a_keyword(as_real_ref) then
old_ref_style_compatibility(
create {TYPE_REAL}.make(pos(start_line, start_column)))
elseif a_keyword(as_double_ref) then
old_ref_style_compatibility(
create {TYPE_DOUBLE}.make(pos(start_line, start_column)))
elseif a_keyword(as_integer) then
create {TYPE_INTEGER}
last_base_type.integer(pos(start_line, start_column))
elseif a_keyword(as_integer_8) then
create {TYPE_INTEGER}
last_base_type.integer_8(pos(start_line, start_column))
elseif a_keyword(as_integer_16) then
create {TYPE_INTEGER}
last_base_type.integer_16(pos(start_line, start_column))
elseif a_keyword(as_integer_32) then
create {TYPE_INTEGER}
last_base_type.integer_32(pos(start_line, start_column))
elseif a_keyword(as_integer_64) then
create {TYPE_INTEGER}
last_base_type.integer_64(pos(start_line, start_column))
elseif a_keyword(as_integer_general) then
create {TYPE_INTEGER}
last_base_type.integer_general(pos(start_line, start_column))
elseif a_keyword(as_none) then
create {TYPE_NONE}
last_base_type.make(pos(start_line, start_column))
elseif a_keyword(as_pointer) then
create {TYPE_POINTER}
last_base_type.make(pos(start_line, start_column))
elseif a_keyword(as_real) then
create {TYPE_REAL}
last_base_type.make(pos(start_line, start_column))
elseif a_keyword(as_string) then
create {TYPE_STRING}
last_base_type.make(pos(start_line, start_column))
elseif a_keyword(as_tuple) then
sp := pos(start_line, start_column)
if skip1('[') then
if cc = ']' then
wcp(em35)
if skip1(']') then end
else
from
create types.with_capacity(4, 1)
until
skip1(']')
loop
if a_type then
types.add_last(last_type)
if not skip1(',') then
if cc /= ']' then
wcp(em5)
end
end
else
error_handler.add_position(current_position)
error_handler.append("Incorrect TUPLE (type expected).")
error_handler.print_as_fatal_error
end
end
end
end
create {TYPE_TUPLE} last_base_type.make(sp, types)
elseif a_keyword(as_routine) then
sp := pos(start_line, start_column)
if not skip1('[') then fcp(em30); end
if not a_type then fcp(em32) end
type1 := last_type
if not skip1(',') then wcp(em5); end
if not a_type then fcp(em32) end
type2 := last_type
if not skip1(']') then fcp(em31); end
create {TYPE_PROCEDURE} last_base_type.routine(sp, type1, type2)
elseif a_keyword(as_procedure) then
sp := pos(start_line, start_column)
if not skip1('[') then fcp(em30); end
if not a_type then fcp(em32) end
type1 := last_type
if not skip1(',') then wcp(em5); end
if not a_type then fcp(em32) end
type2 := last_type
if not skip1(']') then fcp(em31); end
create {TYPE_PROCEDURE} last_base_type.procedure(sp, type1, type2)
elseif a_keyword(as_predicate) then
sp := pos(start_line, start_column)
if not skip1('[') then fcp(em30); end
if not a_type then fcp(em32) end
type1 := last_type
if not skip1(',') then wcp(em5); end
if not a_type then fcp(em32) end
type2 := last_type
if not skip1(']') then fcp(em31); end
create {TYPE_FUNCTION} last_base_type.make(sp, type1, type2, Void)
elseif a_keyword(as_function) then
sp := pos(start_line, start_column)
if not skip1('[') then fcp(em30); end
if not a_type then fcp(em32) end
type1 := last_type
if not skip1(',') then wcp(em5); end
if not a_type then fcp(em32) end
type2 := last_type
if not skip1(',') then wcp(em5); end
if not a_type then fcp(em32) end
type3 := last_type
if not skip1(']') then fcp(em31); end
create {TYPE_FUNCTION} last_base_type.make(sp, type1, type2, type3)
else
Result := False
end
end
a_binary(sp: POSITION): BOOLEAN is
--++ binary -> "<=" | ">=" | "//" | "\\" |
--++ "+" | "-" | "*" | "/" | "<" | ">" | "^" |
--++ xor" | "implies" | "and then" | "and" |
--++ "or else" | "or" | "#+" | "#-" | "#*"
--++
do
Result := True
if skip2('<', '=') then
create last_feature_name.infix_name(as_le, sp)
elseif skip2('>', '=') then
create last_feature_name.infix_name(as_ge, sp)
elseif skip2('/', '/') then
create last_feature_name.infix_name(as_slash_slash, sp)
elseif skip2('\', '\') then
create last_feature_name.infix_name(as_backslash_backslash, sp)
elseif skip1('+') then
create last_feature_name.infix_name(as_plus, sp)
elseif skip1('-') then
create last_feature_name.infix_name(as_minus, sp)
elseif skip1('*') then
create last_feature_name.infix_name(as_muls, sp)
elseif skip1('/') then
create last_feature_name.infix_name(as_slash, sp)
elseif skip1('>') then
create last_feature_name.infix_name(as_gt, sp)
elseif skip1('<') then
create last_feature_name.infix_name(as_lt, sp)
elseif skip1('^') then
create last_feature_name.infix_name(as_pow, sp)
elseif a_keyword(as_xor) then
create last_feature_name.infix_name(as_xor, sp)
elseif a_keyword(as_implies) then
create last_feature_name.infix_name(as_implies, sp)
elseif a_keyword(as_and) then
if a_keyword(fz_then) then
create last_feature_name.infix_name(as_and_then, sp)
else
create last_feature_name.infix_name(as_and, sp)
end
elseif a_keyword(as_or) then
if a_keyword(fz_else) then
create last_feature_name.infix_name(as_or_else, sp)
else
create last_feature_name.infix_name(as_or, sp)
end
elseif skip2('#', '+') then
create last_feature_name.infix_name(as_plus_native, sp)
elseif skip2('#', '-') then
create last_feature_name.infix_name(as_minus_native, sp)
elseif skip2('#', '*') then
create last_feature_name.infix_name(as_muls_native, sp)
else
last_feature_name := Void
Result := False
end
end
a_boolean_constant: BOOLEAN is
--++ boolean_constant -> "True" | "False"
--++
do
if a_keyword(fz_true) then
!E_TRUE!last_boolean_constant.make(pos(start_line, start_column))
Result := True
elseif a_keyword(fz_false) then
!E_FALSE!last_boolean_constant.make(pos(start_line, start_column))
Result := True
end
end
a_character_or_integer: BOOLEAN is
--++ character_or_integer -> character_constant |
--++ integer_constant
--++
do
if a_character_constant then
last_character_or_integer := last_character_constant
Result := True
elseif a_integer_constant then
last_character_or_integer := last_integer_constant
Result := True
else
fcp(fz_iinaiv)
end
end
a_check: BOOLEAN is
--++ check -> "check" assertion "end"
--++
local
sp: POSITION; hc: COMMENT; al: FIXED_ARRAY[ASSERTION]
do
if a_keyword(fz_check) then
sp := pos(start_line, start_column)
hc := get_comment
al := a_assertion
if not a_keyword(fz_end) then
error_handler.add_position(sp)
fcp("Keyword %"end%" expected at the end of check clause.")
end
if hc /= Void or else al /= Void then
create {E_CHECK} last_instruction.make(sp, hc, al)
Result := True
elseif skip1(';') then
end
end
end
a_class_declaration is
--++ class_declaration -> [indexing]
--++ ["expanded" | "deferred" | "separate"]
--++ "class" base_class_name
--++ ["[" formal_generic_list "]"]
--++ [comment]
--++ ["obsolete" manifest_string]
--++ ["inherit" parent_list]
--++ {"creation" creation_clause ...}
--++ {"create" creation_clause ...}
--++ {"feature" feature_clause ...}
--++ ["invariant" assertion]
--++ "end"
--++
local
sp: POSITION; hc: COMMENT; al: FIXED_ARRAY[ASSERTION]
drop_comments_save, end_of_class_flag: BOOLEAN
prefixword: BOOLEAN
do
a_indexing
from
prefixword := True
until
not prefixword
loop
if a_keyword(fz_deferred) then
last_base_class.set_is_deferred
elseif a_keyword(fz_expanded) then
last_base_class.set_is_expanded
elseif a_keyword(fz_separate) then
error_handler.add_position(pos(start_line, start_column))
error_handler.append("Compiler limitation: separate classes are not %
%yet supported. Use separate entities instead.")
error_handler.print_as_fatal_error
last_base_class.set_is_separate
else
prefixword := False
end
end
last_base_class.set_heading_comment1(get_comment)
if not a_keyword(fz_class) then
fcp("Keyword %"class%" expected.")
end
a_base_class_name1
a_formal_generic_list
if a_keyword(fz_obsolete) then
if a_manifest_string then
last_manifest_string.set_once_flag(True)
last_base_class.set_obsolete_type_string(last_manifest_string)
else
fcp("Manifest string expected for %"obsolete%" clause.")
end
end
last_base_class.set_heading_comment2(get_comment)
if a_keyword(fz_inherit) then
end_of_class_flag := True
a_parent_list(pos(start_line, start_column), get_comment)
end
from
until
not (a_keyword(fz_creation) or else a_keyword(fz_create))
loop
a_creation_clause(pos(start_line, start_column))
end_of_class_flag := False
end
from
until
not a_keyword(fz_feature)
loop
a_feature_clause
end_of_class_flag := False
end
drop_comments_save := drop_comments
drop_comments := False
if a_keyword(fz_invariant) then
end_of_class_flag := False
sp := pos(start_line, start_column)
hc := get_comment
al := a_assertion
last_base_class.set_invariant(sp, hc, al)
end
if a_keyword(fz_end) or else end_of_class_flag then
ok := skip1(';')
last_base_class.set_end_comment(get_comment)
if cc /= end_of_text then
fcp("End of text expected.")
end
else
fcp("Keyword %"end%" expected at the end of a class.")
end
drop_comments := drop_comments_save
end
a_class_type: BOOLEAN is
--++ class_type -> base_type |
--++ base_class_name ["[" {type "," ...} "]"]
--++
local
state: INTEGER; base_class_name: CLASS_NAME
generic_list: ARRAY[E_TYPE]
do
if a_base_type then
last_class_type := last_base_type
Result := True
elseif a_base_class_name then
from
Result := True
base_class_name := last_class_name
until
state > 2
loop
inspect
state
when 0 then -- `base_class_name' read.
if skip1('[') then
state := 1
else
!TYPE_CLASS!last_class_type.make(base_class_name)
state := 3
end
when 1 then -- Waiting next generic argument.
if a_type then
if generic_list = Void then
!!generic_list.with_capacity(2, 1)
end
generic_list.add_last(last_type)
state := 2
elseif cc = ',' then
wcp(em12)
ok := skip1(',')
elseif cc = ']' then
state := 2
else
fcp(em16)
state := 2
end
when 2 then -- Waiting ',' or ']'.
if skip1(',') then
state := 1
elseif cc = ']' then
if generic_list = Void then
wcp(em35)
!TYPE_CLASS!last_class_type.make(base_class_name)
else
!TYPE_GENERIC!last_class_type.make(base_class_name, generic_list)
end
ok := skip1(']')
state := 3
elseif a_type then
if generic_list = Void then
!!generic_list.with_capacity(2, 1)
end
generic_list.add_last(last_type)
warning(last_type.start_position, em5)
else
fcp("Bad generic list.")
state := 3
end
end
end
end
end
a_clients: CLIENT_LIST is
--++ clients -> "{" { base_class_name "," ... } "}"
--++
local
sp: POSITION; list: CLASS_NAME_LIST; state: INTEGER
do
if skip1('{') then
from
sp := pos(start_line, start_column)
until
state > 3
loop
inspect
state
when 0 then -- Waiting a base_class_name or "}" if empty list.
if a_base_class_name then
!!list.make_1(last_class_name)
state := 2
elseif skip1('}') then
state := 4
elseif cc = ',' then
wcp(em7)
ok := skip1(',')
else
state := 3
end
when 1 then -- Waiting a base_class_name after a ",".
if a_base_class_name then
list.add_last(last_class_name)
state := 2
elseif cc = ',' then
wcp(em7)
ok := skip1(',')
elseif cc = '}' then
wcp(once "Unexpected bracket.")
ok := skip1('}')
state := 4
else
state := 3
end
when 2 then -- Waiting "," or "}" to end list.
if skip1(',') then
state := 1
elseif skip1('}') then
state := 4
elseif a_base_class_name then
warning(last_class_name.start_position, em5)
list.add_last(last_class_name)
else
state := 3
end
when 3 then -- Error.
fcp(em11)
state := 4
end
end
!!Result.make(sp, list)
else
Result := omitted_client_list
end
ensure
Result /= Void
end
a_compound1: COMPOUND is
--++ compound -> {instruction ";" ...}
--++
local
hc: COMMENT; instruction: INSTRUCTION
do
from
hc := get_comment
ok := skip1(';')
until
not a_instruction
loop
instruction := last_instruction
check
instruction /= Void
end
if cc = '(' then
wcp(em6)
end
from
ok := skip1(';')
until
cc /= ';'
loop
wcp(em24)
ok := skip1(';')
end
if nb_errors = 0 then
instruction := instruction_with_comment(instruction)
if Result = Void then
!!Result.make_1(hc, instruction)
else
Result.add_last(instruction)
end
end
end
if hc /= Void and then Result = Void then
!!Result.make_0(hc)
end
end
a_compound2(compound_of, terminator: STRING): COMPOUND is
-- Similar to `a_compound1' but stop when `terminator' is encountered.
local
hc: COMMENT; instruction: INSTRUCTION
do
from
hc := get_comment
ok := skip1(';')
until
not a_instruction
loop
instruction := last_instruction
check
instruction /= Void
end
if cc = '(' then
wcp(em6)
end
from
ok := skip1(';')
until
cc /= ';'
loop
wcp(em24)
ok := skip1(';')
end
if nb_errors = 0 then
instruction := instruction_with_comment(instruction)
if Result = Void then
!!Result.make_1(hc, instruction)
else
Result.add_last(instruction)
end
end
end
if not a_keyword(terminator) then
error_handler.append("In compound (")
error_handler.append(compound_of)
error_handler.append("). Instruction or keyword %"")
error_handler.append(terminator)
fcp("%" expected.")
end
if hc /= Void and then Result = Void then
!!Result.make_0(hc)
end
end
a_conditional: BOOLEAN is
--++ conditional -> "if" then_part_list ["else" compound] "end"
--++
local
ifthenelse: IFTHENELSE
do
if a_keyword(fz_if) then
Result := True
!!ifthenelse.make(pos(start_line, start_column))
a_then_part_list(ifthenelse)
if a_keyword(fz_else) then
ifthenelse.set_else_compound(a_compound2(once "else part",
fz_end))
else
if not a_keyword(fz_end) then
wcp("Keyword %"end%" added.")
end
end
last_instruction := ifthenelse
end
end
a_old_creation: BOOLEAN is
--++ old_creation -> "!"[type]"!" writable
--++ ["." procedure_name [actuals]]
--++
local
sp: POSITION; type: E_TYPE; writable: EXPRESSION
procedure_name: FEATURE_NAME; call: PROC_CALL
do
if skip1('!') then
Result := True
sp := pos(start_line, start_column)
if a_type then
type := last_type
anchored_creation_check(type)
if not skip1('!') then
fcp("Bad creation instruction ('!' expected).")
end
elseif skip1('!') then
else
fcp("Bad creation instruction (type or '!' expected).")
end
writable := mandatory_writable
if skip1('.') then
if a_identifier then
procedure_name := tmp_name.to_simple_feature_name
if cc = '(' then
call := to_proc_call(writable, procedure_name, a_actuals)
else
!PROC_CALL_0!call.make(writable, procedure_name)
end
else
fcp(em23)
end
end
!OLD_CREATION!last_instruction.make(sp, type, writable, call)
end
end
a_create_instruction: BOOLEAN is
--++ create_instruction -> "create" ["{" type "}"] writable
--++ ["." procedure_name [actuals]]
--++
local
sp: POSITION; type: E_TYPE; writable: EXPRESSION
procedure_name: FEATURE_NAME; call: PROC_CALL
do
if a_keyword(fz_create) then
Result := True
sp := pos(start_line, start_column)
if skip1('{') then
if a_type then
type := last_type
anchored_creation_check(type)
if not skip1('}') then
fcp(em36)
end
else
fcp("Bad create instruction (type expected).")
end
end
writable := mandatory_writable
if skip1('.') then
if a_identifier then
procedure_name := tmp_name.to_simple_feature_name
if cc = '(' then
call := to_proc_call(writable, procedure_name, a_actuals)
else
!PROC_CALL_0!call.make(writable, procedure_name)
end
end
end
!CREATE_INSTRUCTION!last_instruction.make(sp, type, writable, call)
end
end
a_create_expression: BOOLEAN is
--++ create_expression -> "create" "{" type "}" ["." procedure_name [actuals]]
--++
local
sp: POSITION; type: E_TYPE; procedure_name: FEATURE_NAME
call: PROC_CALL; fake_target: FAKE_TARGET
do
if a_keyword(fz_create) then
Result := True
sp := pos(start_line, start_column)
if not skip1('{') then
fcp("Bad create expression ('{' expected).")
end
if not a_type then
fcp("Bad create instruction (type expected).")
end
type := last_type
anchored_creation_check(type)
if not skip1('}') then
fcp("Bad create expression ('}' expected).")
end
if skip1('.') then
if a_identifier then
procedure_name := tmp_name.to_simple_feature_name
!!fake_target.make(type)
if cc = '(' then
call := to_proc_call(fake_target, procedure_name, a_actuals)
else
!PROC_CALL_0!call.make(fake_target, procedure_name)
end
end
end
!CREATE_EXPRESSION!last_expression.make(sp, type, call)
end
end
a_agent: BOOLEAN is
--++ agent -> "agent" ...
--++
local
sp: POSITION; base: E_TYPE; e: EXPRESSION; call: CALL
sfn: FEATURE_NAME
do
if a_keyword(as_agent) then
sp := pos(start_line, start_column)
Result := True
if skip1('{') then
if not a_type then fcp("Bad agent (BASE type expected).") end
base := last_type
if not skip1('}') then fcp("Bad agent (%"}%" expected).") end
if not skip1('.') then fcp("Bad agent (%".%" expected).") end
elseif skip1('(') then
if a_expression then
e := last_expression
end
if not skip1(')') then fcp("Bad agent (%")%" expected).") end
if not skip1('.') then fcp("Bad agent (%".%" expected).") end
end
if not a_identifier then
fcp(em34)
end
if e /= Void then
sfn := tmp_name.to_simple_feature_name
a_r10(False, e, sfn, a_actuals, True)
elseif a_argument then
a_r10(False, last_expression, Void, Void, True)
elseif a_result or else a_current or else a_void or else
a_local_variable then
a_r10(False, last_expression, Void, Void, False)
else
-- Implicit `Current' target:
a_function_call
end
e := last_expression
call ?= e
if call = Void then
if e /= Void then
error_handler.add_position(e.start_position)
end
error_handler.append(em34)
error_handler.print_as_fatal_error
end
create {E_AGENT} last_expression.make(sp, base, call)
end
end
a_creation_clause(sp: POSITION) is
--++ creation_clause -> [clients] [comment] feature_list
--++
local
clients: CLIENT_LIST; comments: COMMENT;
creation_clause: CREATION_CLAUSE
do
clients := a_clients
comments := get_comment
if a_feature_name_list then end
!!creation_clause.make(sp, clients, comments, last_feature_name_list)
last_base_class.add_creation_clause(creation_clause)
end
a_debug: BOOLEAN is
--++ debug -> "debug" "(" {manifest_string "," ...} ")"
--++ compound "end"
--++
local
sp: POSITION; list: FIXED_ARRAY[MANIFEST_STRING]; e_debug: E_DEBUG
do
if a_keyword(fz_debug) then
sp := pos(start_line, start_column)
if skip1('(') then
from
!!list.with_capacity(4)
until
not a_manifest_string
loop
last_manifest_string.set_once_flag(True)
list.add_last(last_manifest_string)
ok := skip1(',')
end
if list.is_empty then
wcp("Empty debug key list (deleted).")
list := Void
end
if not skip1(')') then
fcp("%")%" expected to end debug string list.")
end
end
Result := True
!!e_debug.make(sp, list, a_compound2(once "debug", fz_end))
last_instruction := e_debug
end
end
a_expression: BOOLEAN is
--++ expression -> "<<" {Expression "," ...} ">>" |
--++ "[" {Expression "," ...} "]" |
--++ Void |
--++ e0
--++
local
sp: POSITION; list: FIXED_ARRAY[EXPRESSION]
do
if skip2('<', '<') then
from
Result := True
sp := pos(start_line, start_column)
until
not a_expression
loop
if list = Void then
!!list.with_capacity(4)
end
list.add_last(last_expression)
ok := skip1(',')
end
if not skip2('>', '>') then
fcp("End of manifest array expected.")
end
!MANIFEST_ARRAY!last_expression.make(sp, list)
elseif skip1('[') then
from
Result := True
sp := pos(start_line, start_column)
until
not a_expression
loop
if list = Void then
!!list.with_capacity(4)
end
list.add_last(last_expression)
ok := skip1(',')
end
if not skip1(']') then
fcp("End of TUPLE expression expected.")
end
!TUPLE_EXPRESSION!last_expression.make(sp, list)
else
Result := a_e0
end
end
a_e0: BOOLEAN is
--++ e0 -> e1 r1
--++
do
Result := a_e1
if Result then
a_r1(last_expression)
end
end
a_e1: BOOLEAN is
--++ e1 -> e2 r2
--++
do
Result := a_e2
if Result then
a_r2(last_expression)
end
end
a_e2: BOOLEAN is
--++ e2 -> e3 r3
--++
do
Result := a_e3
if Result then
a_r3(last_expression)
end
end
a_e3: BOOLEAN is
--++ e3 -> e4 r4
--++
do
Result := a_e4
if Result then
a_r4(last_expression)
end
end
a_e4: BOOLEAN is
--++ e4 -> e5 r5
--++
do
Result := a_e5
if Result then
a_r5(last_expression)
end
end
a_e5: BOOLEAN is
--++ e5 -> e6 r6
--++
do
Result := a_e6
if Result then
a_r6(last_expression)
end
end
a_e6: BOOLEAN is
--++ e6 -> e7 r7
--++
do
Result := a_e7
if Result then
a_r7(last_expression)
end
end
a_e7: BOOLEAN is
--++ e7 -> e8 r8
--++
do
Result := a_e8
if Result then
a_r8(last_expression)
end
end
a_e8: BOOLEAN is
--++ e8 -> "not" e8 |
--++ "+" e8 |
--++ "-" e8 |
--++ free_operator e8 !
--++ e9
--++
local
op: FEATURE_NAME; prefix_freeop: CALL_PREFIX_FREEOP; sp: POSITION
l, c: INTEGER
do
if a_keyword(as_not) then
sp := pos(start_line, start_column)
if a_e8 then
create {CALL_PREFIX_NOT}
last_expression.make(sp, last_expression)
Result := True
else
err_exp(sp, True, as_not)
end
elseif skip1('+') then
l := start_line; c := start_column
if a_real(0) then
last_expression := last_real_constant
Result := True
elseif a_integer(False) then
last_expression := last_integer_constant
Result := True
else
sp := pos(l, c)
if a_e8 then
create {CALL_PREFIX_PLUS}
last_expression.make(sp, last_expression)
Result := True
else
err_exp(sp, True, as_plus)
end
end
elseif skip1('-') then
l := start_line; c := start_column
if a_real(-1) then
last_expression := last_real_constant
Result := True
elseif a_integer(True) then
last_expression := last_integer_constant
Result := True
else
sp := pos(l, c)
if a_e8 then
create {CALL_PREFIX_MINUS}
last_expression.make(sp, last_expression)
Result := True
else
err_exp(sp, True, as_minus)
end
end
elseif a_free_operator_usage(True) then
op := last_feature_name
if a_e8 then
create prefix_freeop.make(last_expression, op)
last_expression := prefix_freeop
Result := True
else
err_exp(op.start_position, True, op.to_string)
end
else
Result := a_e9
end
end
a_e9: BOOLEAN is
--++ e9 -> e10 |
--++ "old" e10
--++
do
if a_keyword(fz_old) then
if not in_ensure then
error(pos(start_line, start_column),
"Expression %"old%" can be used in ensure clause %
%only (VAOL.1).")
end
if a_e10 then
!E_OLD!last_expression.make(last_expression)
Result := True
else
fcp("Expression expected after %"old%".")
end
else
Result := a_e10
end
end
a_e10: BOOLEAN is
--++ e10 -> strip |
--++ "(" expression ")" r10 |
--++ manifest_constant |
--++ precursor_call |
--++ "Result" r10 |
--++ "Current" r10 |
--++ "Void" r10 |
--++ local_variable r10 |
--++ argument r10 |
--++ function_call r10 |
--++
do
if a_strip then
Result := True
elseif skip1('(') then
Result := True
if a_expression then
if skip1(')') then
a_r10(False, last_expression, Void, Void, False)
else
fcp("')' expected in expression.")
end
else
fcp("Expression expected.")
end
elseif a_manifest_constant then
last_expression := last_manifest_constant
Result := True
if skip1('.') then
wcp(once "Added brackets for manifest constant before dot.")
a_after_a_dot(False, last_expression)
end
elseif a_precursor(False) then
Result := True
elseif a_create_expression then
Result := True
elseif a_agent then
Result := True
elseif a_identifier then
Result := True
if a_argument then
a_r10(False, last_expression, Void, Void, True)
elseif a_current or else a_result or else a_void or else a_local_variable then
a_r10(False, last_expression, Void, Void, False)
else
a_function_call
end
end
end
a_external: E_ROUTINE is
--++ external -> "<external-specification>" external_name
--++ external_name -> ["alias" manifest_string]
--++
local
alias_tag: STRING; l: NATIVE; external_tag: MANIFEST_STRING
do
if not a_manifest_string then
fcp("Bad external clause (manifest string expected).")
end
unused_once_warning_check
external_tag := last_manifest_string
external_tag.set_once_flag(False)
mini_buffer.start_with(external_tag)
if mini_buffer.is_off then
unknown_external_language(external_tag)
elseif mini_buffer.a_word(fz_smarteiffel) then
create {NATIVE_SMART_EIFFEL} l.make(external_tag)
elseif mini_buffer.a_word(once "SmallEiffel") then
error_handler.add_position(external_tag.start_position)
error_handler.append(
"Obsolete %"SmallEiffel%" keyword replaced %
%with %"SmartEiffel%" (update your code).")
error_handler.print_as_warning
create {NATIVE_SMART_EIFFEL} l.make(external_tag)
elseif mini_buffer.a_keyword(once "C++") then
create {NATIVE_C_PLUS_PLUS} l.make(external_tag)
elseif mini_buffer.a_keyword(once "C") then
create {NATIVE_C} l.make(external_tag)
elseif mini_buffer.a_keyword(once "Java") then
create {NATIVE_JAVA} l.make(external_tag)
else
unknown_external_language(external_tag)
end
if a_keyword(fz_alias) then
if not a_manifest_string then
fcp("Bad external alias clause.")
end
unused_once_warning_check
alias_tag := last_manifest_string.to_string
end
Result := tmp_feature.to_external_routine(l, alias_tag)
end
a_feature_name_list: BOOLEAN is
--++ feature_name_list -> {feature_name "," ...}
--++
--
-- Gives True when list is not empty.
local
state: INTEGER
do
from
last_feature_name_list := Void
until
state >= 3
loop
inspect
state
when 0 then -- Nothing read.
if a_feature_name then
!!last_feature_name_list.make_1(last_feature_name)
Result := True
state := 1
elseif cc = ',' then
wcp(em7)
ok := skip1(',')
else
state := 3
end
when 1 then -- Feature name read.
if cc = ',' then
ok := skip1(',')
state := 2
elseif a_feature_name then
warning(last_feature_name.start_position, em5)
last_feature_name_list.add_last(last_feature_name)
else
state := 3
end
when 2 then -- Separator read.
if a_feature_name then
last_feature_name_list.add_last(last_feature_name)
state := 1
elseif cc = ',' then
wcp(em12)
ok := skip1(',')
else
ecp(em2)
state := 3
end
end
end
end
a_feature_name: BOOLEAN is
--++ feature_name -> prefix |
--++ infix |
--++ simple_feature_name
--++
do
if a_prefix then
Result := True
elseif a_infix then
Result := True
elseif a_identifier then
last_feature_name := tmp_name.to_simple_feature_name
Result := True
end
end
a_feature_clause is
--++ feature_clause -> [clients] [comment] feature_declaration_list
--++
local
feature_clause: FEATURE_CLAUSE; clients: CLIENT_LIST
comment: COMMENT
do
from
clients := a_clients
comment := get_comment
faof.clear
until
not a_feature_declaration
loop
ok := skip1(';')
if last_feature_declaration /= Void then
faof.add_last(last_feature_declaration)
last_feature_declaration.set_header_comment(get_comment)
end
end
if not faof.is_empty then
!!feature_clause.make(clients, comment, faof.twin)
last_base_class.add_feature_clause(feature_clause)
elseif comment /= Void then
!!feature_clause.make(clients, comment, Void)
last_base_class.add_feature_clause(feature_clause)
end
end
a_feature_declaration: BOOLEAN is
--++ feature_declaration -> {["frozen"] feature_name "," ...}+
--++ formal_arg_list
--++ [":" type]
--++ ["is" "unique" |
--++ "is" manifest_constant |
--++ "is" routine]
--++
do
from
tmp_feature.initialize
if a_keyword(fz_frozen) then
if a_feature_name then
Result := True
to_frozen_feature_name
tmp_feature.add_synonym(last_feature_name)
else
fcp(em2)
end
elseif a_feature_name then
Result := True
tmp_feature.add_synonym(last_feature_name)
end
until
not skip1(',')
loop
if a_keyword(fz_frozen) then
if a_feature_name then
to_frozen_feature_name
tmp_feature.add_synonym(last_feature_name)
else
fcp("Frozen feature name synonym expected.")
end
elseif a_feature_name then
tmp_feature.add_synonym(last_feature_name)
else
ecp("Synonym feature name expected.")
end
end
if Result then
a_formal_arg_list
if skip1(':') then
if a_type then
inside_function := True
tmp_feature.set_type(last_type)
else
fcp(em16)
end
else
inside_function := False
end
if a_keyword(fz_is) then
if a_keyword(fz_unique) then
last_feature_declaration := tmp_feature.to_cst_att_unique
elseif a_boolean_constant then
last_feature_declaration :=
tmp_feature.to_cst_att_boolean(last_boolean_constant)
elseif a_character_constant then
last_feature_declaration :=
tmp_feature.to_cst_att_character(last_character_constant)
elseif a_manifest_string then
unused_once_warning_check
last_manifest_string.set_once_flag(True)
last_feature_declaration :=
tmp_feature.to_cst_att_string(last_manifest_string)
elseif a_bit_constant then
last_feature_declaration :=
tmp_feature.to_cst_att_bit(last_bit_constant)
elseif a_real_constant then
last_feature_declaration :=
tmp_feature.to_cst_att_real(last_real_constant)
elseif a_integer_constant then
last_feature_declaration :=
tmp_feature.to_cst_att_integer(last_integer_constant)
else
last_feature_declaration := a_routine
end
else
last_feature_declaration := tmp_feature.to_writable_attribute
end
inside_function := False
arguments := Void
end
end
a_formal_generic_list is
--++ formal_generic_list -> ["[" {formal_generic "," ...} "]"]
--++ formal_generic -> base_class_name ["->" class_type]
--++
local
fga: FORMAL_GENERIC_ARG; formal_generic_name: CLASS_NAME
constraint: E_TYPE; state: INTEGER
do
formal_generic_list := Void
if skip1('[') then
from
!!formal_generic_list.make(pos(start_line, start_column))
last_base_class.set_formal_generic_list(formal_generic_list)
until
state > 3
loop
inspect
state
when 0 then -- Waiting for a `formal_generic_name'.
if a_base_class_name then
formal_generic_name := last_class_name
state := 1
else
state := 5
end
when 1 then -- Waiting for "->" or "," or "]".
if skip2('-','>') then
state := 3
elseif cc = ',' or else cc = ']' then
!!fga.make(formal_generic_name, constraint)
constraint := Void
formal_generic_list.add_last(fga)
inspect
cc
when ',' then state := 0
when ']' then state := 4
end
ok := skip1(cc)
else
state := 5
end
when 2 then -- Waiting for "," or "]".
if cc = ',' or else cc = ']' then
!!fga.make(formal_generic_name, constraint)
constraint := Void
formal_generic_list.add_last(fga)
inspect
cc
when ',' then state := 0
when ']' then state := 4
end
ok := skip1(cc)
else
state := 5
end
when 3 then -- Waiting for a `constraint' type.
if a_type_formal_generic then
constraint := last_type_formal_generic
state := 2
elseif a_class_type then
constraint := last_class_type
state := 2
else
fcp("Constraint Class name expected.")
state := 5
end
end
end
inspect
state
when 4 then
if formal_generic_list.count = 0 then
error_handler.add_position(formal_generic_list.start_position)
error_handler.append("Empty formal generic list (deleted).")
error_handler.print_as_warning
formal_generic_list := Void
last_base_class.set_formal_generic_list(Void)
end
when 5 then
check nb_errors > 0 end
end
end
end
a_function_call is
--++ function_call -> [actuals] r10 |
--++ ^
--++
local
sfn: FEATURE_NAME; implicit_current: IMPLICIT_CURRENT
do
sfn := tmp_name.to_simple_feature_name
!!implicit_current.make(sfn.start_position)
a_r10(False, implicit_current, sfn, a_actuals, True)
end
a_index_clause: BOOLEAN is
--++ index_clause -> [identifier ":"] {index_value "," ...}+
--++
local
index_clause: INDEX_CLAUSE
do
if a_identifier then
Result := True
if skip1(':') then
!!index_clause.with_tag(tmp_name.aliased_string)
if a_index_value then
index_clause.add_last(last_index_value)
else
fcp(em3)
end
else
!!index_clause.without_tag(tmp_name.to_simple_feature_name)
end
elseif a_manifest_constant then
Result := True
!!index_clause.without_tag(last_manifest_constant)
end
if Result then
from
until
not skip1(',')
loop
if a_index_value then
index_clause.add_last(last_index_value)
else
fcp(em3)
end
end
last_base_class.add_index_clause(index_clause)
end
end
a_index_value: BOOLEAN is
--++ index_value -> identifier | manifest_constant
--++
do
if a_identifier then
last_index_value := tmp_name.to_simple_feature_name
Result := True
elseif a_manifest_constant then
last_index_value := last_manifest_constant
Result := True
end
end
a_indexing is
--++ indexing -> "indexing" {index_clause ";" ...}
--++
do
if a_keyword(fz_indexing) then
from
until
not a_index_clause
loop
ok := skip1(';')
end
end
end
a_infix: BOOLEAN is
--++ infix -> "infix" "%"" binary "%""
--++ "infix" "%"" free_operator "%""
--++
local
sp: POSITION
do
if a_keyword(fz_infix) then
Result := True
sp := pos(start_line, start_column)
if cc = '%"' then
next_char
else
wcp("Character '%%%"' inserted after %"infix%".")
end
if a_binary(sp) then
elseif a_free_operator_definition(False) then
else
fcp("Infix operator name expected.")
end
if not skip1('%"') then
wcp("Character '%%%"' inserted.")
end
end
end
a_inspect: BOOLEAN is
--++ inspect -> "inspect" expression
--++ {when_part ...}
--++ ["else" compound]
--++ "end"
--++
local
sp, spec: POSITION; i: E_INSPECT; ec: COMPOUND
do
if a_keyword(fz_inspect) then
Result := True
sp := pos(start_line, start_column)
if a_expression then
last_expression := expression_with_comment(last_expression)
else
fcp("Expression expected (%"inspect ... %").")
end
from
!!i.make(sp, last_expression)
until
not a_when_part(i)
loop
end
if a_keyword(fz_else) then
spec := pos(start_line, start_column)
ec := a_compound2(once "else of inspect", fz_end)
i.set_else_compound(spec, ec)
elseif not a_keyword(fz_end) then
wcp("Added %"end%" for inspect instruction.")
end
last_instruction := i
end
end
a_instruction: BOOLEAN is
--++ instruction -> check | debug | conditionnal | retry |
--++ inspect | loop | old_creation |
--++ create_instruction | assignment_or_call
--++
do
Result := True
if a_check then
elseif a_debug then
elseif a_conditional then
elseif a_retry then
elseif a_inspect then
elseif a_loop then
elseif a_create_instruction then
elseif a_assignment_or_call then
elseif a_old_creation then
else
Result := False
end
end
a_integer_constant: BOOLEAN is
--++ integer_constant -> ["+" | "-"] integer
--++
local
l, c: INTEGER
do
l := line; c := column
if skip1('+') then
if a_integer(False) then
Result := True
else
go_back_at(l, c)
end
elseif skip1('-') then
if a_integer(True) then
Result := True
else
go_back_at(l, c)
end
elseif a_integer(False) then
Result := True
end
end
a_loop: BOOLEAN is
--++ loop -> "from" compound
--++ ["invariant"] assertion
--++ ["variant" [identifier ":"] expression]
--++ "until" expression
--++ "loop" compound
--++ "end"
--++
local
l1, c1, l2, c2: INTEGER; e_loop: E_LOOP; i: COMPOUND
ic: LOOP_INVARIANT; vc: LOOP_VARIANT; ue: EXPRESSION
lb: COMPOUND; hc, vc1, vc2: COMMENT; al: FIXED_ARRAY[ASSERTION]
tag_name: TAG_NAME
do
if a_keyword(fz_from) then
Result := True
l1 := start_line
c1 := start_column
i := a_compound1
if a_keyword(fz_invariant) then
l2 := start_line
c2 := start_column
hc := get_comment
al := a_assertion
if hc /= Void or else al /= Void then
create ic.make(pos(l2, c2), hc, al)
end
end
if a_keyword(fz_variant) then
vc1 := get_comment
if a_tag_mark then
tag_name := last_tag_mark
end
vc2 := get_comment
if a_expression then
!!vc.make(vc1, tag_name, vc2,
expression_with_comment(last_expression))
else
wcp("Variant (INTEGER) Expression Expected.")
end
end
if a_keyword(fz_until) then
if a_expression then
ue := expression_with_comment(last_expression)
else
fcp("Boolean expression expected (until).")
ue := last_expression
end
else
fcp("Keyword %"until%" expected (in a loop).")
ue := last_expression
end
if cc = ';' then
wcp(em24)
ok := skip1(';')
end
if not a_keyword(fz_loop) then
wcp("Keyword %"loop%" expected (in a loop).")
end
lb := a_compound2(once "loop body", fz_end)
!!e_loop.make(pos(l1, c1), i, ic, vc, ue, lb)
last_instruction := e_loop
end
end
a_manifest_constant: BOOLEAN is
--++ manifest_constant -> boolean_constant | character_constant |
--++ real_constant | integer_constant |
--++ manifest_string | bit_constant
--++
do
if a_boolean_constant then
last_manifest_constant := last_boolean_constant
Result := True
elseif a_character_constant then
last_manifest_constant := last_character_constant
Result := True
elseif a_manifest_string then
last_manifest_constant := last_manifest_string
Result := True
elseif a_bit_constant then
last_manifest_constant := last_bit_constant
Result := True
elseif a_real_constant then
last_manifest_constant := last_real_constant
Result := True
elseif a_integer_constant then
last_manifest_constant := last_integer_constant
Result := True
end
end
a_new_export_list is
--++ new_export_list -> ["export" {new_export_item ";" ...}]
--++ new_export_item -> clients "all" |
--++ clients feature_list
--++
local
export_list: EXPORT_LIST; sp: POSITION; clients: CLIENT_LIST
items: ARRAY[EXPORT_ITEM]; new_export_item: EXPORT_ITEM
state: INTEGER
do
if a_keyword(fz_export) then
from
sp := pos(start_line, start_column)
until
state > 3
loop
inspect
state
when 0 then -- Waiting for a `clients'.
if cc = '{' then
clients := a_clients
state := 1
elseif cc = ';' then
wcp(em24)
ok := skip1(';')
else
if items /= Void then
!!export_list.make(sp, items)
last_parent.set_export(export_list)
end
state := 4
end
when 1 then -- `clients' read.
if a_keyword(fz_all) then
!!new_export_item.make_all(clients)
if items = Void then
!!items.with_capacity(2, 1)
end
items.add_last(new_export_item)
state := 2
else
if a_feature_name_list then
!!new_export_item.make(clients, last_feature_name_list)
if items = Void then
!!items.with_capacity(2, 1)
end
items.add_last(new_export_item)
state := 2
else
state := 3
end
end
when 2 then -- Waiting ";" before next one.
if skip1(';') then
state := 0
elseif cc = '{' then
wcp(em6)
state := 0
else
if items /= Void then
!!export_list.make(sp, items)
last_parent.set_export(export_list)
end
state := 4
end
when 3 then -- Error.
fcp(em11)
state := 4
end
end
end
end
a_parent_list(sp: POSITION; hc: COMMENT) is
--++ parent_list -> {parent ";" ...}
--++
local
list: FIXED_ARRAY[PARENT]
do
from until
not a_parent
loop
if list = Void then
create list.with_capacity(4)
end
list.add_last(last_parent)
ok := skip1(';')
last_parent.set_comment(get_comment)
end
if hc /= Void or else list /= Void then
if list = Void then
if last_base_class.heading_comment2 = Void then
last_base_class.set_heading_comment2(hc)
else
last_base_class.heading_comment2.append(hc)
end
else
last_base_class.set_parent_list(sp, hc, list)
end
end
end
a_parent: BOOLEAN is
--++ parent -> class_type
--++ ["rename" rename_list]
--++ new_export_list
--++ ["undefine" feature_name_list]
--++ ["redefine" feature_name_list]
--++ ["select" feature_name_list]
--++ ["end"]
--++
local
needs_end: BOOLEAN
do
if a_keyword(fz_expanded) then
error_handler.add_position(pos(start_line, start_column))
error_handler.append(
"This form of inheritance (expanded inheritance) is %
%not yet implemented.")
error_handler.print_as_error
elseif a_keyword(fz_reference) then
error_handler.add_position(pos(start_line, start_column))
error_handler.append("Unexpected %"reference%" keyword.")
error_handler.print_as_error
end
if a_class_type then
Result := True
create last_parent.make(last_class_type)
if a_keyword(fz_rename) then
a_rename_list
if cc = ';' then
wcp("Unexpected %";%" to end rename list.")
ok := skip1(';')
end
needs_end := True
end
a_new_export_list
if a_keyword(fz_undefine) then
if a_feature_name_list then
last_parent.set_undefine(last_feature_name_list)
end
needs_end := True
end
if a_keyword(fz_redefine) then
if a_feature_name_list then
last_parent.set_redefine(last_feature_name_list)
end
needs_end := True
end
if a_keyword(fz_select) then
if a_feature_name_list then
last_parent.set_select(last_feature_name_list)
end
needs_end := True
end
if a_keyword(fz_rename) or else
a_keyword(fz_export) or else
a_keyword(fz_undefine) or else
a_keyword(fz_redefine) or else
a_keyword(fz_select) then
error_handler.add_position(pos(start_line, start_column))
error_handler.append(
"Inheritance option not at a correct place. %
%The correct order is: %"rename... export... %
%undefine... redefine... select...%".")
error_handler.print_as_fatal_error
end
ok := a_keyword(fz_end)
if not ok and then needs_end then
wcp("Keyword %"end%" added.")
end
end
end
a_prefix: BOOLEAN is
--++ prefix -> "prefix" "%"" unary "%""
--++ "prefix" "%"" free_operator "%""
--++
do
if a_keyword(fz_prefix) then
Result := True
if cc = '%"' then
next_char
else
wcp("Character '%%%"' inserted after %"prefix%".")
end
if a_unary then
elseif a_free_operator_definition(True) then
else
fcp("Prefix operator name expected.")
end
if not skip1('%"') then
wcp("Character '%%%"' inserted.")
end
end
end
a_precursor(do_instruction: BOOLEAN): BOOLEAN is
--++ precursor -> ["{" class_name "}"] "Precursor" [actuals] -- obsolete
--++ "Precursor" ["{" class_name "}"] [actuals] -- ETL3
--++
local
l, c: INTEGER; parent: CLASS_NAME; args: EFFECTIVE_ARG_LIST
p: POSITION; old_syntax: BOOLEAN
do
if skip1('{') then
Result := True
l := start_line; c := start_column
if skip1('{') then
warning(pos(start_line, start_column),
"One single opening '{' is correct too here.")
end
if a_base_class_name then
parent := last_class_name
end
if not skip1('}') then
fcp("Closing '}' expected to end Precursor's parent %
%qualification.")
end
if skip1('}') then
warning(pos(start_line, start_column),
"One single closing '}' is correct too here.")
end
old_syntax := True
end
if a_keyword(as_precursor) then
Result := True
if l = 0 then
l := start_line
c := start_column
end
elseif l > 0 then
fcp("Precursor keyword expected here.")
end
if Result then
p := pos(l, c)
if old_syntax then
warning(pos(start_line, start_column),
"Obsolete syntax: the parent should now be written %
%after the `precursor' keyword.")
else
-- new ETL3 syntax
if skip1('{') then
if skip1('{') then
warning(pos(start_line, start_column),
"One single opening '{' is correct too here.")
end
if a_base_class_name then
parent := last_class_name
end
if not skip1('}') then
fcp("Closing '}' expected to end Precursor's parent %
%qualification.")
end
if skip1('}') then
warning(pos(start_line, start_column),
"One single closing '}' is correct too here.")
end
end
end
args := a_actuals
if skip1('.') then
!PRECURSOR_EXPRESSION!last_expression.make(p, parent, args)
a_after_a_dot(do_instruction, last_expression)
elseif do_instruction then
!PRECURSOR_INSTRUCTION!last_instruction.make(p, parent, args)
else
!PRECURSOR_EXPRESSION!last_expression.make(p, parent, args)
end
end
end
a_procedure_call is
--++ procedure_call -> [actuals] r10 |
--++ ^
--++
local
sfn: FEATURE_NAME; implicit_current: IMPLICIT_CURRENT
do
sfn := tmp_name.to_simple_feature_name
!!implicit_current.make(sfn.start_position)
a_r10(True, implicit_current, sfn, a_actuals, True)
end
a_real_constant: BOOLEAN is
--++ real_constant -> ["+" | "-"] real
--++
local
l, c: INTEGER
do
l := line; c := column
if skip1('+') then
if a_real(0) then
Result := True
else
go_back_at(l, c)
end
elseif skip1('-') then
if a_real(-1) then
Result := True
else
go_back_at(l, c)
end
else
Result := a_real(0)
end
end
a_rename_list is
--++ rename_list -> {rename_pair "," ...}
--++
do
from until
not a_rename_pair
loop
ok := skip1(',')
end
end
a_rename_pair: BOOLEAN is
--++ rename_pair -> identifier "as" identifier
--++
local
name1: FEATURE_NAME; rename_pair: RENAME_PAIR; l, c: INTEGER
do
l := line; c := column
if a_feature_name then
name1 := last_feature_name
if a_keyword(fz_as) then
if a_feature_name then
Result := True
!!rename_pair.make(name1, last_feature_name)
last_parent.add_rename(rename_pair)
else
fcp("Second identifier of a %"rename%" pair expected.")
end
else
go_back_at(l, c)
end
end
end
a_routine: E_ROUTINE is
--++ routine -> ["obsolete" manifest_string]
--++ ["require" ["else"] assertion]
--++ ["local" entity_declaration_list]
--++ routine_body
--++ ["ensure" ["then"] assertion]
--++ ["rescue" compound]
--++ "end"
--++
local
sp: POSITION; hc: COMMENT; al: FIXED_ARRAY[ASSERTION]; ea: E_ENSURE
else_flag, then_flag: BOOLEAN
do
if a_keyword(fz_obsolete) then
if a_manifest_string then
last_manifest_string.set_once_flag(True)
tmp_feature.set_obsolete_mark(last_manifest_string)
else
fcp("Obsolete manifest string expected.")
end
end
tmp_feature.set_header_comment(get_comment)
if a_keyword(fz_require) then
sp := pos(start_line, start_column)
else_flag := a_keyword(fz_else)
hc := get_comment
tmp_feature.set_require(sp, else_flag, hc, a_assertion)
end
if a_keyword(fz_local) then
a_local_var_list
end
Result := a_routine_body
if a_keyword(fz_ensure) then
sp := pos(start_line, start_column)
in_ensure := True
then_flag := a_keyword(fz_then)
hc := get_comment
al := a_assertion
if hc /= Void or else al /= Void then
create ea.with(sp, then_flag, hc, al)
end
Result.set_ensure_assertion(ea)
in_ensure := False
end
if a_keyword(fz_rescue) then
in_rescue := True
Result.set_rescue_compound(a_compound2(fz_rescue, fz_end))
in_rescue := False
elseif a_keyword(fz_end) then
if ace.sedb then
sp := pos(start_line, start_column)
Result.set_sedb_trace_before_exit(sp)
end
else
wcp("A routine must be ended with %"end%".")
end
local_vars := Void
end
a_routine_body: E_ROUTINE is
--++ routine_body -> "deferred" |
--++ "external" external |
--++ "do" compound |
--++ "once" compound
--++
do
if a_keyword(fz_deferred) then
last_base_class.set_is_deferred
Result := tmp_feature.to_deferred_routine
elseif a_keyword(fz_external) then
Result := a_external
elseif a_keyword(fz_do) then
tmp_feature.set_routine_body(a_compound1)
Result := tmp_feature.to_procedure_or_function
elseif a_keyword(fz_once) then
tmp_feature.set_routine_body(a_compound1)
Result := tmp_feature.to_once_routine
else
fcp("Routine body expected.")
end
end
a_r1(left_part: like last_expression) is
--++ r1 -> "implies" e1 r1 |
--++ ^
--++
local
infix_implies: CALL_INFIX_IMPLIES; sp: POSITION
do
if a_keyword(as_implies) then
sp := pos(start_line, start_column)
if a_e1 then
!!infix_implies.make(left_part, sp, last_expression)
a_r1(infix_implies)
else
error(sp, "Expression expected after 'implies'.")
end
else
last_expression := left_part
end
end
a_r2(left_part: like last_expression) is
--++ r2 -> "or else" e2 r2 |
--++ "or" e2 r2 |
--++ "xor" e2 r2 |
--++ ^
--++
local
infix_or_else: CALL_INFIX_OR_ELSE; infix_or: CALL_INFIX_OR
infix_xor: CALL_INFIX_XOR; sp: POSITION
do
if a_keyword(as_or) then
sp := pos(start_line, start_column)
if a_keyword(fz_else) then
if a_e2 then
!!infix_or_else.make(left_part, sp, last_expression)
a_r2(infix_or_else)
else
err_exp(sp, False, as_or_else)
end
else
if a_e2 then
!!infix_or.make(left_part, sp, last_expression)
a_r2(infix_or)
else
err_exp(sp, False, as_or)
end
end
elseif a_keyword(as_xor) then
sp := pos(start_line, start_column)
if a_e2 then
!!infix_xor.make(left_part, sp, last_expression)
a_r2(infix_xor)
else
err_exp(sp, False, as_xor)
end
else
last_expression := left_part
end
end
a_r3(left_part: like last_expression) is
--++ r3 -> "and then" e3 r3 |
--++ "and" e3 r3 |
--++ ^
--++
local
infix_and_then: CALL_INFIX_AND_THEN; infix_and: CALL_INFIX_AND
sp: POSITION
do
if a_keyword(as_and) then
sp := pos(start_line, start_column)
if a_keyword(fz_then) then
if a_e3 then
!!infix_and_then.make(left_part, sp, last_expression)
a_r3(infix_and_then)
else
err_exp(sp, False, as_and_then)
end
else
if a_e3 then
!!infix_and.make(left_part, sp, last_expression)
a_r3(infix_and)
else
err_exp(sp, False, as_and)
end
end
else
last_expression := left_part
end
end
a_r4(left_part: like last_expression) is
--++ r4 -> "=" e4 r4 |
--++ "/=" e4 r4 |
--++ "<=" e4 r4 |
--++ "<" e4 r4 |
--++ ">=" e4 r4 |
--++ ">" e4 r4 |
--++ ^
--++
local
call_infix: CALL_INFIX; sp: POSITION
do
if skip1('=') then
sp := pos(start_line, start_column)
if a_e4 then
!CALL_INFIX_EQ!call_infix.make(left_part, sp, last_expression)
a_r4(call_infix)
else
err_exp(sp, False, as_eq)
end
elseif skip2('/', '=') then
sp := pos(start_line, start_column)
if a_e4 then
!CALL_INFIX_NEQ!call_infix.make(left_part, sp, last_expression)
a_r4(call_infix)
else
err_exp(sp, False, as_neq)
end
elseif skip2('<', '=') then
sp := pos(start_line, start_column)
if a_e4 then
!CALL_INFIX_LE!call_infix.make(left_part, sp, last_expression)
a_r4(call_infix)
else
err_exp(sp, False, as_le)
end
elseif skip2('>', '=') then
sp := pos(start_line, start_column)
if a_e4 then
!CALL_INFIX_GE!call_infix.make(left_part, sp, last_expression)
a_r4(call_infix)
else
err_exp(sp, False, as_ge)
end
elseif skip1('<') then
sp := pos(start_line, start_column)
if a_e4 then
!CALL_INFIX_LT!call_infix.make(left_part, sp, last_expression)
a_r4(call_infix)
else
err_exp(sp, False, as_lt)
end
elseif skip1unless2('>', '>') then
sp := pos(start_line, start_column)
if a_e4 then
!CALL_INFIX_GT!call_infix.make(left_part, sp, last_expression)
a_r4(call_infix)
else
err_exp(sp, False, as_gt)
end
else
last_expression := left_part
end
end
a_r5(left_part: like last_expression) is
--++ r5 -> "+" e5 r5 |
--++ "-" e5 r5 |
--++ ^
--++
local
infix_plus: CALL_INFIX_PLUS; infix_minus: CALL_INFIX_MINUS
sp: POSITION
do
if skip1('+') then
sp := pos(start_line, start_column)
if a_e5 then
!!infix_plus.make(left_part, sp, last_expression)
a_r5(infix_plus)
else
err_exp(sp, False, as_plus)
end
elseif skip1('-') then
sp := pos(start_line, start_column)
if a_e5 then
!!infix_minus.make(left_part, sp, last_expression)
a_r5(infix_minus)
else
err_exp(sp, False, as_minus)
end
else
last_expression := left_part
end
end
a_r6(left_part: like last_expression) is
--++ r6 -> "*" e6 r6 |
--++ "//" e6 r6 |
--++ "\\" e6 r6 |
--++ "/" e6 r6 |
--++ ^
--++
local
infix_times: CALL_INFIX_TIMES; infix_int_div: CALL_INFIX_INT_DIV
infix_int_rem: CALL_INFIX_INT_REM; infix_div: CALL_INFIX_DIV
sp: POSITION
do
if skip1('*') then
sp := pos(start_line, start_column)
if a_e6 then
!!infix_times.make(left_part, sp, last_expression)
a_r6(infix_times)
else
err_exp(sp, False, as_muls)
end
elseif skip2('/', '/') then
sp := pos(start_line, start_column)
if a_e6 then
!!infix_int_div.make(left_part, sp, last_expression)
a_r6(infix_int_div)
else
err_exp(sp, False, as_slash_slash)
end
elseif skip2('\', '\') then
sp := pos(start_line, start_column)
if a_e6 then
!!infix_int_rem.make(left_part, sp, last_expression)
a_r6(infix_int_rem)
else
err_exp(sp, False, as_backslash_backslash)
end
elseif skip1unless2('/', '=') then
sp := pos(start_line, start_column)
if a_e6 then
!!infix_div.make(left_part, sp, last_expression)
a_r6(infix_div)
else
err_exp(sp, False, as_slash)
end
else
last_expression := left_part
end
end
a_r7(left_part: like last_expression) is
--++ r7 -> "^" e7 r7 |
--++ ^
--++
local
sp: POSITION
do
if skip1('^') then
sp := pos(start_line, start_column)
if a_e7 then
a_r7(last_expression)
!CALL_INFIX_POWER!last_expression.make(left_part, sp,
last_expression)
else
err_exp(sp, False, as_pow)
end
else
last_expression := left_part
end
end
a_r8(left_part: like last_expression) is
--++ r8 -> free_operator e8 r8 |
--++ ^
--++
local
infix_name: FEATURE_NAME; infix_freeop: CALL_INFIX_FREEOP
do
if a_free_operator_usage(False) then
infix_name := last_feature_name
if a_e8 then
!!infix_freeop.make(left_part, infix_name, last_expression)
a_r8(infix_freeop)
else
err_exp(infix_name.start_position, False,
infix_name.to_string)
end
else
last_expression := left_part
end
end
a_r10(do_instruction: BOOLEAN; t: EXPRESSION; fn: FEATURE_NAME
eal: EFFECTIVE_ARG_LIST
separate_allowed: BOOLEAN) is
--++ r10 -> "." after_a_dot |
--++ ^
--++
do
if skip1('.') then
if t /= Void and then t.is_void then
error_handler.add_position(t.start_position)
error_handler.append("Void is not a valid target.")
error_handler.print_as_fatal_error
end
a_after_a_dot(do_instruction, to_call(t, fn, eal))
else
if do_instruction then
last_instruction := to_proc_call(t, fn, eal)
last_expression := Void
else
last_expression := to_call(t, fn, eal)
last_instruction := Void
end
end
end
a_strip: BOOLEAN is
--++ a_strip -> "strip" "(" {identifier "," ...} ")"
local
sp: POSITION
do
if a_keyword(fz_strip) then
sp := pos(start_line, start_column)
if skip1('(') then
ok := a_feature_name_list
!E_STRIP!last_expression.make(sp, last_feature_name_list)
if not skip1(')') then
fcp("')' expected to end a strip expression.")
end
Result := True
else
fcp("'(' expected to begin a strip list.")
end
end
end
a_tag_mark: BOOLEAN is
--++ tag_mark -> identifier ":"
--++
local
l, c: INTEGER
do
l := line; c := column
if a_identifier then
if skip1(':') then
Result := True
last_tag_mark := tmp_name.to_tag_name
else
go_back_at(l, c)
end
end
end
a_then_part_list(ifthenelse: IFTHENELSE) is
--++ then_part_list -> {then_part "elseif"}+
--++
do
from
if not a_then_part(ifthenelse) then
fcp("In %"if ... then ...%".")
end
until
not a_keyword(fz_elseif)
loop
if not a_then_part(ifthenelse) then
fcp("In %"elseif ... then ...%".")
end
end
end
a_then_part(ifthenelse: IFTHENELSE): BOOLEAN is
--++ then_part -> expression "then"
--++
local
expression: EXPRESSION
do
if a_expression then
Result := True
expression := expression_with_comment(last_expression)
if not a_keyword(fz_then) then
wcp("Added %"then%".")
end
ifthenelse.add_if_then(expression, a_compound1)
end
end
a_type: BOOLEAN is
--++ type -> "like" <anchor> | "expanded" class_type | BIT <constant>
--++ "separate" class_type
--++ type_formal_generic | class_type
--++
local
sp: POSITION; argument_name2: ARGUMENT_NAME2
do
Result := True
if a_keyword(fz_like) then
sp := pos(start_line, start_column)
if a_infix then
!TYPE_LIKE_FEATURE!last_type.make(sp, last_feature_name)
elseif a_prefix then
!TYPE_LIKE_FEATURE!last_type.make(sp, last_feature_name)
elseif a_identifier then
if a_current then
!TYPE_LIKE_CURRENT!last_type.make(sp)
elseif a_argument then
argument_name2 ?= last_expression
!TYPE_LIKE_ARGUMENT!last_type.make(sp, argument_name2)
else
!TYPE_LIKE_FEATURE!last_type.make(sp,
tmp_name.to_simple_feature_name)
end
else
fcp("Anchor expected. An anchor could be `Current', %
%a feature name or an argument name.")
end
elseif a_keyword(fz_expanded) then
sp := pos(start_line, start_column)
if a_class_type then
!TYPE_EXPANDED!last_type.make(sp, last_class_type)
else
fcp("Must find a class type after %"expanded%".")
end
elseif a_keyword(fz_reference) then
sp := pos(start_line, start_column)
if a_class_type then
create {TYPE_REFERENCE} last_type.make(sp, last_class_type)
else
fcp("Must find a class type after %"reference%".")
end
elseif a_keyword(fz_separate) then
sp := pos(start_line, start_column)
if a_class_type then
last_type := separate_tools.create_type_separate(sp,
last_class_type)
else
fcp("Must find a class type after %"separate%".")
end
elseif a_keyword(as_bit) then
sp := pos(start_line, start_column)
if a_integer(False) then
!TYPE_BIT_1!last_type.make(sp, last_integer_constant)
elseif a_identifier then
!TYPE_BIT_2!last_type.make(sp, tmp_name.to_simple_feature_name)
else
fcp("Expected constant for BIT_N type declaration.")
end
elseif a_type_formal_generic then
last_type := last_type_formal_generic
elseif a_class_type then
last_type := last_class_type
else
Result := False
end
end
a_unary: BOOLEAN is
--++ unary -> "not" | "+" | "-"
--++
do
if a_keyword(as_not) then
create
last_feature_name.prefix_name(as_not,
pos(start_line, start_column))
Result := True
elseif skip1('+') then
create
last_feature_name.prefix_name(as_plus,
pos(start_line, start_column))
Result := True
elseif skip1('-') then
create
last_feature_name.prefix_name(as_minus,
pos(start_line, start_column))
Result := True
end
end
a_when_part(i: E_INSPECT): BOOLEAN is
--++ when_part -> "when" {when_part_item "," ...} then compound
--++
--++ when_part_item -> constant ".." constant |
--++ constant
--++
--++ constant -> character_constant | integer_constant | identifier
--++
local
state: INTEGER; e_when: E_WHEN; constant: EXPRESSION
do
if a_keyword(fz_when) then
from
Result := True
!!e_when.make(pos(start_line, start_column), get_comment)
until
state > 3
loop
inspect
state
when 0 then -- Separator read, waiting a constant or "then".
if a_constant then
constant := last_expression
state := 1
elseif a_keyword(fz_then) then
if constant /= Void then
e_when.add_value(constant)
end
e_when.set_compound(a_compound1)
i.add_when(e_when)
state := 4
elseif cc = ',' then
wcp(em7)
ok := skip1(',')
else
fcp(em4)
state := 4
end
when 1 then -- First constant read.
if a_keyword(fz_then) then
if constant /= Void then
e_when.add_value(constant)
end
e_when.set_compound(a_compound1)
i.add_when(e_when)
state := 4
elseif skip2('.', '.') then
state := 2
elseif skip1(',') then
e_when.add_value(constant)
constant := Void
state := 0
else
fcp(em4)
state := 4
end
when 2 then -- ".." read.
if a_constant then
e_when.add_slice(constant, last_expression)
constant := Void
state := 3
else
fcp(em4)
state := 4
end
when 3 then -- Slice read.
if skip1(',') then
state := 0
elseif a_keyword(fz_then) then
e_when.set_compound(a_compound1)
i.add_when(e_when)
state := 4
elseif a_constant then
constant := last_expression
warning(tmp_name.start_position, em5)
state := 1
else
fcp(em4)
state := 4
end
end
end
end
end
mandatory_writable: EXPRESSION is
-- Skip and return the writable which is mandatory here.
do
if a_identifier then
if a_current then
error_handler.add_position(last_expression.start_position)
error_handler.append("Current is not a writable variable.")
error_handler.print_as_fatal_error
elseif a_argument then
error_handler.add_position(last_expression.start_position)
error_handler.append(em21)
error_handler.print_as_fatal_error
elseif a_result or else a_local_variable then
Result := last_expression
else
Result := tmp_name.to_simple_feature_name
end
else
fcp(em22)
end
ensure
Result /= Void
end
to_call(t: EXPRESSION; fn: FEATURE_NAME
eal: EFFECTIVE_ARG_LIST): EXPRESSION is
require
t /= Void
do
if fn = Void then
check
eal = Void
end
Result := t
elseif eal = Void then
!CALL_0_C!Result.make(t, fn)
elseif eal.count = 1 then
!CALL_1_C!Result.make(t, fn, eal)
else
!CALL_N!Result.make(t, fn, eal)
end
end
to_proc_call(t: EXPRESSION; fn: FEATURE_NAME
eal: EFFECTIVE_ARG_LIST): PROC_CALL is
do
if fn = Void then
fcp("An expression has a result value. %
%This is not an instruction.")
elseif eal = Void then
!PROC_CALL_0!Result.make(t, fn)
elseif eal.count = 1 then
!PROC_CALL_1!Result.make(t, fn, eal)
else
!PROC_CALL_N!Result.make(t, fn, eal)
end
end
buffer: STRING is
once
create Result.make(80)
end
a_identifier_case_sensitive: BOOLEAN is
-- Case Insensitive (option -case_insensitive).
require
case_insensitive
local
backward_column: INTEGER; stop: BOOLEAN
do
if cc.is_letter then
from
backward_column := column
tmp_name.reset(pos(line, backward_column))
tmp_name.extend(cc.to_lower)
until
stop
loop
next_char
inspect
cc
when 'a'..'z' then
tmp_name.extend(cc)
when '0'..'9', '_' then
tmp_name.extend(cc)
when 'A'..'Z' then
tmp_name.extend(cc.to_lower)
else
stop := True
end
end
if tmp_name.isa_keyword then
cc := tmp_name.buffer.first
column := backward_column
else
Result := True
skip_comments
end
end
end
a_identifier_regular: BOOLEAN is
-- Case Sensitivity for identifiers (default).
require
not case_insensitive
local
backward_column: INTEGER
stop, may_be_a_keyword, style_warning: BOOLEAN
do
if cc.is_letter then
from
backward_column := column
may_be_a_keyword := True
tmp_name.reset(pos(line, backward_column))
tmp_name.extend(cc)
until
stop
loop
next_char
inspect
cc
when 'a'..'z' then
tmp_name.extend(cc)
when 'A'..'Z' then
style_warning := True
tmp_name.extend(cc)
when '0'..'9', '_' then
may_be_a_keyword := False
tmp_name.extend(cc)
else
stop := True
end
end
if may_be_a_keyword and then tmp_name.isa_keyword then
cc := tmp_name.buffer.first
column := backward_column
else
Result := True
skip_comments
if style_warning then
if not no_style_warning then
warning(tmp_name.start_position, em25)
end
end
end
end
end
show_nb(nb: INTEGER; tail: STRING) is
do
if nb > 0 then
echo.w_put_string(fz_error_stars)
echo.w_put_integer(nb)
echo.w_put_string(tail)
end
end
tmp_feature: TMP_FEATURE
to_frozen_feature_name is
do
create last_feature_name.frozen_name(last_feature_name)
end
last_result: E_RESULT is
local
sp: POSITION
do
sp := tmp_name.start_position
if inside_function then
create {E_RESULT} Result.make(sp)
else
error_handler.add_position(sp)
error_handler.append("`Result' must only be used inside a function.")
error_handler.print_as_fatal_error
end
ensure
Result /= Void
end
faof: FIXED_ARRAY[E_FEATURE] is
once
!!Result.with_capacity(256)
end
err_exp(sp: POSITION; prefix_flag: BOOLEAN; operator: STRING) is
-- When an error occurs in the right hand side of some `operator'.
local
msg: STRING
do
msg := "Right hand side expression of "
if prefix_flag then
msg.append(fz_prefix)
else
msg.append(fz_infix)
end
msg.append(" %"")
msg.append(operator)
msg.append("%" expected.")
error_handler.add_position(sp)
error_handler.append(msg)
error_handler.print_as_fatal_error
end
pos(l, c: INTEGER): POSITION is
do
Result.eiffel_file(l, c, current_id, last_base_class)
end
instruction_with_comment(i: INSTRUCTION): INSTRUCTION is
-- If there is some following comment, `i' is wrapped inside an
-- INSTRUCTION_WITH_COMMENT object.
local
c: COMMENT
do
c := get_comment
if c = Void or else c.count = 0 then
Result := i
else
Result := i.add_comment(c)
end
end
expression_with_comment(e: EXPRESSION): EXPRESSION is
-- There is some following comment, `e' may be wrapped
-- inside some EXPRESSION_WITH_COMMENT object.
local
c: COMMENT
do
c := get_comment
if c = Void or else c.count = 0 then
Result := e
else
!EXPRESSION_WITH_COMMENT!Result.make(e, c)
end
end
unknown_external_language(external_tag: MANIFEST_STRING) is
do
error_handler.add_position(external_tag.start_position)
error_handler.append("Unknown external language specification.")
error_handler.print_as_fatal_error
end
unused_once_warning_check is
do
if last_manifest_string.once_flag then
error_handler.add_position(last_manifest_string.start_position)
error_handler.append(em18)
error_handler.print_as_warning
end
end
create_infix_prefix(prefix_flag: BOOLEAN; l, c: INTEGER) is
local
operator: STRING
do
operator := string_aliaser.item(buffer)
if prefix_flag then
create last_feature_name.prefix_name(operator, pos(l, c))
else
create last_feature_name.infix_name(operator, pos(l, c))
end
end
old_ref_style_compatibility(bt: E_TYPE) is
-- To obsolete all *_REF type, just ad the warning here.
require
bt.is_basic_eiffel_expanded
do
create {TYPE_REFERENCE}
last_base_type.make(bt.start_position, bt)
end
anchored_creation_check(type: E_TYPE) is
do
if type.is_anchored then
if type.is_like_current then
-- SmartEiffel relaxed rule because there is no risk at all
-- to allow create {like Current}.
else
warning(type.start_position,
"Explicit creation/create type mark should not be anchored.")
end
end
end
unicode_string_buffer: UNICODE_STRING is
once
create Result.make_empty
end
singleton_memory: EIFFEL_PARSER is
once
Result := Current
end
invariant
is_real_singleton: Current = singleton_memory
end -- EIFFEL_PARSER
|