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
|
#if(0)
FTANGLE v1.53.1.13, created with UNIX on "Thursday, January 2, 1997 at 0:57." \
COMMAND LINE: "Web/ftangle Web/ratfor -A -# --F -= 1.60/Web/ratfor.c"\
RUN TIME: "Wednesday, January 1, 1997 at 20:33."\
WEB FILE: "Web/ratfor.web"\
CHANGE FILE: (none)
#endif
#define _RATFOR_h
#define _ratfor_ /* Used in \.{r\_type.web}. */ \
#define stringg (eight_bits)02 /* Extended ASCII alpha should not appear. (The funny \
spelling is to avoid conflict with the VAX' \.{stdlib}.) */
#define constant (eight_bits)03 /* Numerical constant. */
#define begin_Xmeta or_or
#define end_Xmeta star_star
#define cdir (eight_bits)06 /* Brackets compiler directive.. */
#define colon_colon (eight_bits)011 /* \Cpp\ and \Fortran--90: `$\WCF$'. */ \
#define join (eight_bits)0177 /* |ASCII| delete will not appear. */ \
#define ID0 0200 /* $128 =$ end of the 7-bit ASCII codes. */
#define TOKEN1(a)((a)<ID0)/* Is |a|~a single-byte token? */ \
#define MACRO_ARGUMENT 0377 /* See the related definition and discussion of \
|MOD0|. */
#define BASE2 0400 /* |0xFF + 1 = 0x100 = 256| */ \
#define MODULE_NAME 10240 /* |024000= 10240 = (0250-0200)*0400| */
#define MODULE_NUM 20480 /* |050000 = 20480 = (0320-0200)*0400| */
#define LINE_NUM 53248L /* |0150000==0320*0400| */ \
#define IDENTIFIER(left,right) \
((sixteen_bits)(((left)-ID0)*BASE2+(sixteen_bits)(right))) \
/* Construct two-byte token out of its constituents. */ \
#define LEFT(a,id)((eight_bits)(((a)/BASE2+(id))))/* Make left-hand byte out of \
|sixteen_bits|. */
#define RIGHT(a)((eight_bits)(((a)%BASE2)))/* Make right-hand byte. */ \
#define ignore 0 /* Control code of no interest to \.{TANGLE}. */ \
#define begin_comment0 (eight_bits)0376 /* Sent from |input_ln|; marker for long comment. */
#define begin_comment1 (eight_bits)0375 /* As above; marker for short comment. */ \
#define module_number (eight_bits)0201 /* Code returned by |get_output| for mod.\ numbers. */
#define identifier (eight_bits)0202 /* Code returned by |get_output| for identifiers. */
#define id_keyword (eight_bits)0203 /* As above, but for expandable keyword. */ \
#define L_switch (eight_bits)0257 /* Control code for `\.{@L}'. */
#define begin_FORTRAN (eight_bits)0260
#define begin_RATFOR (eight_bits)0261
#define begin_C (eight_bits)0262
#define begin_LITERAL (eight_bits)0263 \
#define verbatim (eight_bits)0264 /* Can't be~|02| as for \.{fweave}, because \
|stringg| is defined to be that. */ \
#define invisible_cmnt (eight_bits)0265 /* Control code for `\.{@\%}'. */
#define compiler_directive (eight_bits)0266 /* No longer used. */
#define Compiler_Directive (eight_bits)0267 /* Control code for `\.{@?}'. */
#define no_index (eight_bits)0300 /* Control code for `\.{@-}'. */
#define yes_index (eight_bits)0301 /* Control code for `\.{@+}'. */ \
#define ascii_constant (eight_bits)0302 /* Control code for `\.{@'}'. */
#define begin_vcmnt (eight_bits)0303 /* Control code for `\.{@\slashstar}'. */
#define big_line_break (eight_bits)0304 /* Control code for `\.{@\#}'. */ \
#define begin_bp (eight_bits)0305
#define insert_bp (eight_bits)0306 \
#define begin_meta (eight_bits)017 /* Control code for |"@("|. */
#define end_meta (eight_bits)027 \
#define TeX_string (eight_bits)0307
#define xref_roman (eight_bits)0310
#define xref_typewriter (eight_bits)0311
#define xref_wildcard (eight_bits)0312 \
#define control_text (eight_bits)0313 /* Control code for `\.{@t}', `\.{@\^}', etc. */ \
#define begin_nuweb (eight_bits)0314
#define no_mac_expand (eight_bits)0315 /* Control code for `\.{@\~}' */
#define set_line_info (eight_bits)0316 /* Expt'l control code for `\.{@Q}'. */ \
#define formatt (eight_bits)0320 /* Control code for `\.{@f}'. */ \
#define limbo_text (eight_bits)0323 /* Control code for `\.{@l}'. */
#define op_def (eight_bits)0324 /* Control code for `\.{@v}'. */
#define macro_def (eight_bits)0325 /* Control code for `\.{@W}'. */ \
#define ignore_defn (eight_bits)0327 /* Stuff to here should be ignored when scanning defn. */ \
#define new_output_file (eight_bits)0331 /* Control code for `\.{@o}'. */ \
#define definition (eight_bits)0332 /* Control code for `\.{@d}'. */
#define undefinition (eight_bits)0333 /* Control code for `\.{@u}'. */
#define WEB_definition (eight_bits)0334 /* Control code for `\.{@m}'. */ \
#define m_ifdef (eight_bits)0335
#define m_ifndef (eight_bits)0336
#define m_if (eight_bits)0337
#define m_else (eight_bits)0340
#define m_elif (eight_bits)0341
#define m_endif (eight_bits)0342
#define m_for (eight_bits)0343
#define m_endfor (eight_bits)0344
#define m_line (eight_bits)0345
#define m_undef (eight_bits)0346 \
#define end_of_buffer (eight_bits)0347 \
#define begin_code (eight_bits)0350 /* Control code for `\.{@a}'. */
#define module_name (eight_bits)0351 /* Control code for `\.{@<}'. */ \
#define new_module (eight_bits)0352 /* Control code for `\.{@\ }' and `\.{@*}'. */ \
#define cur_end cur_state.end_field /* Current ending location in |tok_mem|. */
#define cur_byte cur_state.byte_field /* Location of next output byte in |tok_mem|. */
#define cur_name cur_state.name_field /* Pointer to current name being expanded. */
#define cur_repl cur_state.repl_field /* Pointer to current replacement text. */
#define cur_mod cur_state.mod_field /* Current module number being expanded. */ \
#define cur_language cur_state.language /* Current language. */
#define cur_global_language cur_state.global_params.Language \
/* Global language for this level. */ \
\
/* Current flags. */
#define cur_params cur_state.params /* Local flags. */
#define cur_global_params cur_state.global_params /* Global flags. */ \
\
/* Current macro buffer params. */
#define macrobuf cur_state.macro_buf
#define cur_mp cur_state.mp
#define macrobuf_end cur_state.macro_buf_end \
#define semi 01 /* Kludge! */ \
#define SILENT (boolean)NO
#define COMPLAIN (boolean)YES \
#define OUTER_MACRO 0xFF
#define OUTER_UNMACRO 0xFE
#define UNDEFINED_MACRO 0xFD \
#define MAX_XLEVELS 200 \
#define equiv equiv_or_xref /* Info corresponding to names. */
#define EQUIV ASCII HUGE*/* For casting into the above field. */ \
\
/* Note that the following function retrieves not only regular \WEB\ \
macros, but also built-in functions. */
#define MAC_LOOKUP(cur_val)(cur_val<MODULE_NAME? \
(text_pointer)(name_dir+(cur_val))->equiv:NULL) \
#define macro 0 /* For appending a macro; distinguishes from a module. */ \
\
\
/* The following are the values of the |macro_type| field of \
|name_pointer|s. */
#define NOT_DEFINED 0
#define DEFERRED_MACRO 1 /* Numbers chosen so that |DEFERRED_MACRO + \
scanning_defn| gives the two choices. */
#define IMMEDIATE_MACRO 2
#define FILE_NAME 3 /* Used to prevent truncations from affecting file names. */ \
#define MAKE_RECURSIVE 052 /* To allow a WEB macro to be recursive, preface its \
definition by this symbol, as in `\.{@m *R R}'. (Recursive macros \
are not presently implemented.) */ \
#define AUTO_INSERT 0133
#define END_AUTO_INSERT 0135 \
\
/* Guard against overflow of the macro buffer. */
#define MCHECK(n,reason)if(mp+(n)>macrobuf_end) \
mbuf_full((unsigned long)(n),(outer_char*)reason) \
#define BP_MARKER 1 \
#define PROPER_END(end) \
end= (np+1)->byte_start; \
if(*end==BP_MARKER&&np!=npmax)end= ((BP*)end)->byte_start \
#define MAX_ID_LENGTH 32 /* Truncated identifiers can't be longer than this. */ \
#define UNNAMED_MODULE 0
#define N_IDBUF 100 \
#define fatal_RAT_ERROR(s1,s2,s3){ \
RAT_error(ERROR,OC(s1),0); \
fatal(ERR_R,OC(s2),OC(s3));} \
#define COPY_COMMENTS NO
#define SAVE_COMMENTS YES \
#define current_cmd lbl[wlevel].cmd
#define do_or_while (current_cmd==do_CMD||current_cmd==while_CMD) \
#define s_top lbl[wlevel].Top
#define s_next lbl[wlevel].Next
#define was_next lbl[wlevel].was_Next
#define s_break lbl[wlevel].Break
#define was_break lbl[wlevel].was_Break
#define s_case lbl[wlevel].Case
#define s_default lbl[wlevel].Default
#define icase lbl[wlevel].Icase \
#define DONT_PRINT_IF_0 YES
#define PRINT_IF_0 NO \
#define TO_OUTPUT NO /* First argument of |copyd|. */
#define TO_MEMORY YES \
#define SAVE_IN_MEM(a){if(cur_case->txt.next>=cur_case->txt.end) \
resize(&cur_case->txt.start,BIG_SAVE8, \
&cur_case->txt.next, \
&cur_case->txt.end); \
*(cur_case->txt.next++)= (eight_bits)(a);} \
#define SAVE_16 {SAVE_IN_MEM(a0)SAVE_IN_MEM(a1)}/* Store a 16-bit token. */ \
#define XPN_CASES YES
#define DONT_XPN_CASES NO \
#define BLEVELS 100 \
#define copy_to(r_after)copy_2to(NOT_BEFORE,r_after) \
#define BRACE_ONLY 1 /* In some situations such as after |switch|, only a brace \
is expected. */ \
#define unmatched(l,r) \
RAT_error(WARNING,OC("Ignored '%c' not matched with %s"),2,XCHR(r),qdelim(l)) \
#define inserted(n,l0,r0,l,level) \
RAT_error(WARNING,OC("Inserted %d '%c' to balance '%c' at %s level %d"),5,n,XCHR(r0),XCHR(l0),qdelim(l),level) \
\
/* Copy, then immediately output. */
#define COPY_TO(r)psave_buffer= SAVE_AFTER(&save_buffer,BIG_SAVE8,r); \
copy_out(save_buffer,psave_buffer,!macro) \
#define COPY_2TO(r_before,r_after) \
psave_buffer= save_out(&save_buffer,BIG_SAVE8,r_before,r_after); \
copy_out(save_buffer,psave_buffer,!macro) \
#define INDENT indent_level++;blank_out(1)
#define OUTDENT indent_level--;out_pos-= indnt_size \
#define LABEL(lbl)out_label(DONT_PRINT_IF_0,(STMT_LBL)(lbl))/* Statement label. */
#define NUMBER(lbl)out_label(PRINT_IF_0,(STMT_LBL)(lbl))/* Ordinary integer, \
including~0. */ \
#define PARENS copyd(TO_OUTPUT,XPN_CASES,050,051,NO)/* Copies text between \
(and including) parens. */ \
#define NL out_char(012)
#define LP out_char(050)
#define RP out_char(051)
#define COMMA out_char(054)
#define NOT out_char(041)
#define EQUALS out_char(075)
#define MINUS out_char(055)
#define EQ_EQ out_char(eq_eq)
#define OR out_char(or_or)
#define LT out_char(074)
#define GT out_char(076) \
#define IF(stmt_num)LABEL(stmt_num);id0(id__IF)
#define THEN id0(id__THEN);NL
#define ELSE id0(id__ELSE)
#define ENDIF id0(id__ENDIF);if(symbolic_label)id0(symbolic_label);NL
#define ENDWHERE id0(id__ENDWHERE);NL
#define GOTO(stmt)id0(id__GOTO);LABEL(stmt);NL
#define CONTINUE(stmt)LABEL(stmt);id0(id__CONTINUE);NL
#define RETURN id0(id__RETURN);NL
#define END id0(id__END);NL \
#define END_DO id0(id__END);id0(id__DO);NL
#define END_SELECT id0(id__END);id0(id__SELECT);NL \
#define NOT_LOOP(id,msg)not_loop(OC(id),OC(msg)) \
#define SAVE8 200 /* Default length of buffer for parenthesized stuff like \
|if(...). */
#define BIG_SAVE8 10000 /* Default length for |case| text. */ \
#define id__ignore ignore \
#define UNEXPECTED(id)unexpected(OC(id)) \
#define NSWITCHES 20 /* Nesting level for |switch| statements. */
#define NCASES 257 /* Number of |case| labels in a |switch|. */
#define cur_switch switches[switch_level] \
#ifndef part
#define part 0 /* Standard value, when the files aren't split. */
#else
#if(part != 1 && part != 2 && part != 3)
#define part 1 /* Should issue error message here. */
#endif
#endif /* |part| */
#if(part == 0 || part == 1)
#define part1_or_extern
#define SET1(stuff) = stuff
#define TSET1(stuff) = stuff
#else
#define part1_or_extern extern
#define SET1(stuff)
#define TSET1(stuff)
#endif
#include "typedefs.h"
#include "map.h"
typedef struct
{
eight_bits HUGE*tok_start;/* Pointer into |tok_mem| (for a module or \
regular macro). For an internal macro, points to the internal function. */
sixteen_bits text_link;/* Relates replacement texts (0 for a macro). */
boolean Language;/* Which language referenced this name. */
eight_bits nargs;/* Number of macro arguments. */
unsigned
moffset:8,/* Offset to macro replacement text from start. */
recursive:1,/* Is this macro allowed to be recursive? */
var_args:1,/* Can it have variable number of arguments? */
module_text:1,/* Distinguishes from preprocessor fragment. */
built_in:1,/* Is it a built-in function (internal macro)? */
nbytes:20;/* Length of macro or text. $2^{20} \approx 10^6$. */
}text;
typedef text HUGE*text_pointer;
typedef struct{
eight_bits HUGE*end_field;/* Ending location of replacement text. */
eight_bits HUGE*byte_field;/* Present location within replacement text. */
name_pointer name_field;/* |byte_start| index for text being output. */
text_pointer repl_field;/* |tok_start| index for text being output. */
sixteen_bits mod_field;/* Module number, or zero if not a module. */
PARAMS global_params,params;/* Various flags. */
eight_bits HUGE*macro_buf,HUGE*mp,HUGE*macro_buf_end;
/* Current macro buffer. */
}output_state;
typedef output_state HUGE*stack_pointer;
/* Precedence of the various operators. */
typedef enum{BAD_TOKEN,OR_OR,AND_AND,BIT_OR,BIT_XOR,BIT_AND,LOG_EQ,LOG_LT,
BIT_SHIFT,PLUS_MINUS,TIMES,EXP,UNARY,HIGHEST_UNARY}PRECEDENCE;
/* An operator, together with its precedence. */
typedef struct
{
eight_bits token;
PRECEDENCE precedence;
}OP;
/* The actual data value. */
typedef union
{
long i;/* All integers are long, to humor the pc people. */
double d;/* We handle just one floating-point type. */
sixteen_bits id;/* An identifier token. */
OP op;
}VALUE;
/* Type of the data value. The relative order must be preserved here, \
because it is used in the type promotion routine |promote|. */
typedef enum{Int,Double,Id,Op}TYPE;
/* Complete data structure for the token; includes links to the next and \
last |VAL| structures. */
typedef struct val
{
VALUE value;/* The actual data value or operator token. */
TYPE type;/* The type of value stored in |value|. */
struct val HUGE*last,HUGE*next;/* Link to the last and next values. */
}VAL;
typedef struct
{
sixteen_bits token[MAX_XLEVELS];
int level;
}XIDS;
#if(0)
IN_COMMON boolean truncate_ids;/* Truncate identifers? */
IN_COMMON unsigned short tr_max[];/* Truncate to this length. */
IN_COMMON name_pointer npmax;/* |name_ptr - 1|. */
#endif
/* Back-pointer structure points back to the original name in |name_dir|. */
typedef struct Bp
{
ASCII c;/* Dummy byte that always remains~|BP_MARKER|. */
LANGUAGE Language;
CONST ASCII HUGE*byte_start,HUGE*byte_end;/* Points to original, \
untruncated name. */
struct Bp HUGE*next;/* Links to next back-pointer structure, in \
case a truncated name came from more than one original name. */
struct Trunc HUGE*Root;
}BP;
/* Info about a truncated identifier. */
typedef struct Trunc
{
boolean Language;/* All languages associated with this name. */
size_t num[NUM_LANGUAGES];
/* \# of instances of the truncated name. */
ASCII HUGE*id,HUGE*id_end;/* Truncated variable name. */
BP HUGE*first,HUGE*last;/* First and last back-pointer structures. */
struct Trunc HUGE*next;/* Next structure in truncated chain. */
}TRUNC;
IN_RATFOR int switch_level RSET(0);
/* The starting and ending positions of a token string. */
typedef struct
{
eight_bits HUGE*start,HUGE*next,HUGE*end;
}TEXT;
/* The info for one |case| or |default|. */
typedef struct
{
STMT_LBL label;/* Statement label assigned to this |case|. */
TEXT case_txt;/* The token string for the |case| value. */
CASE_TYPE value;/* The numerical value of the above string. */
TEXT txt;/* The body of the |case| or |default|. */
boolean is_default;/* Distinguishes between |default| and |case|. */
}CASE;
IN_RATFOR CASE HUGE*cur_case;/* A pointer to the current case being processed. */
/* A whole |switch|. */
typedef struct
{
CASE HUGE*cases;/* The array of cases. */
unsigned short ncases;/* How many cases? */
boolean has_default;/* At most one |default| is allowed. */
}SWITCH;
IN_RATFOR SWITCH HUGE*switches;/* Switches may be nested, so we need an array. */
#include "t_type.h" /* Function prototypes for everything. */
/* The shorter length here is primarily to keep the stack under control. \
Now that |N_MSGBUF| is used dynamically, maybe this statement isn't \
necessary. */
#ifdef SMALL_MEMORY
#define N_MSGBUF 2000
#else
#define N_MSGBUF 10000
#endif
EXTERN long max_texts;/* Number of replacement texts, must be $< 10240$. */
EXTERN text HUGE*text_info;/* Dynamic array. */
EXTERN text_pointer text_end;/* End of above. */
EXTERN long dtexts_max;/* Number of deferred replacement texts. */
EXTERN text HUGE*txt_dinfo;/* Dynamic array. */
EXTERN text_pointer textd_end;
EXTERN text_pointer text_ptr,txt_dptr;/* First unused position in |text_info| \
and in |txt_dinfo|. */
EXTERN long max_toks;/* Number of bytes in compressed code. */
EXTERN eight_bits HUGE*tok_mem;/* Dynamic array. */
EXTERN eight_bits HUGE*tok_m_end;
EXTERN long max_dtoks;/* Number of bytes in deferred macros. */
EXTERN eight_bits HUGE*tok_dmem;/* Dynamic array. */
EXTERN eight_bits HUGE*tokd_end;
EXTERN eight_bits HUGE*tok_ptr,HUGE*tok_dptr;/* First unused position in \
|tok_mem| and in |tok_dmem|. */
EXTERN eight_bits HUGE*mx_tok_ptr,HUGE*mx_dtok_ptr;/* Largest value \
assumed by |tok_ptr| and |tok_ptrd|; for statistics. */
EXTERN text_pointer macro_text;
EXTERN output_state cur_state;/* |cur_end|, |cur_byte|, |cur_name|, \
|cur_repl|, |cur_mod|, |cur_global_language|, and |cur_language|. */
EXTERN long stck_size;/* Number of simultaneous levels of macro expansion. */
EXTERN output_state HUGE*stack;/* Dynamic array: Info for non-current levels. */
EXTERN stack_pointer stck_end;/* End of |stack|. */
EXTERN stack_pointer stck_ptr;/* First unused loc.\ in the output state stack. */
IN_COMMON STMT_LBL max_stmt;/* See \.{common.web}. */
EXTERN sixteen_bits outp_line[NUM_LANGUAGES]
#ifdef _FTANGLE_h
#if(part == 0 || part == 1)
= {1,1,1,1,1,1,1,1}
#endif /* |part == 1| */
#endif /* |_FTANGLE_h| */
;
EXTERN boolean mac_protected,in_string;
EXTERN text_pointer macro_text;
EXTERN long cur_val;
EXTERN OUTPUT_STATE out_state;
EXTERN int indent_level,out_pos,rst_pos,indnt_size;
EXTERN eight_bits sent;
IN_COMMON STMT_LBL max_stmt;
IN_COMMON sixteen_bits outp_line[];
/* Expandable input tokens. */
IN_RATFOR sixteen_bits
id_block,id_blockdata,id_break,
id_case,
#if(0)
id_continue,
#endif
id_default,id_do,
id_else,id_elseif,id_end,
id_endif,
id_for,
#if(0)
id_goto,
#endif
id_if,
id_next,id_procedure,id_repeat,
id_return,id_switch,id_then,id_until,
id_while;
IN_RATFOR sixteen_bits id_function,id_program,id_subroutine;
IN_RATFOR sixteen_bits
id_contains,id_elsewhere,id_endinterface,id_endtype,id_endmodule,
id_endselect,id_endwhere,id_interface,id_module,id_type,id_where;
/* Non-expandable input tokens. */
IN_RATFOR sixteen_bits id_data;
/* Output tokens. */
IN_RATFOR sixteen_bits
id__CASE,id__CONTINUE,id__DEFAULT,
id__DO,id__ELSE,id__ELSEIF,id__END,
id__ENDIF,id__EXIT,id__GOTO,id__IF,
id__RETURN,id__THEN,
id__WHILE;
/* More output tokens for \Fortran--90. */
IN_RATFOR sixteen_bits
id__CONTAINS,id__CYCLE,id__ENDWHERE,id__INTERFACE,id__MODULE,
id__SELECT,id__TYPE,id__WHERE;
/* The following tokens are printed as the result of \Ratfor\ translation. \
(The lengths are filled in by |ini_out_tokens|.) */
IN_RATFOR SPEC out_tokens[]
#if(part == 0 || part == 1)
= {
{"CASE",0,NULL,&id__CASE},
{"CONTINUE",0,NULL,&id__CONTINUE},
{"DEFAULT",0,NULL,&id__DEFAULT},
{"DO",0,NULL,&id__DO},
{"ELSE",0,NULL,&id__ELSE},
{"ELSEIF",0,NULL,&id__ELSEIF},
{"END",0,NULL,&id__END},
{"ENDIF",0,NULL,&id__ENDIF},
{"EXIT",0,NULL,&id__EXIT},
{"GOTO",0,NULL,&id__GOTO},
{"IF",0,NULL,&id__IF},
{"RETURN",0,NULL,&id__RETURN},
{"THEN",0,NULL,&id__THEN},
{"WHILE",0,NULL,&id__WHILE},
{"",0,NULL,NULL}
}
#endif
;
IN_RATFOR SPEC out90_tokens[]
#if(part == 0 || part == 1)
= {
{"CONTAINS",0,NULL,&id__CONTAINS},
{"CYCLE",0,NULL,&id__CYCLE},
{"ENDWHERE",0,NULL,&id__ENDWHERE},
{"INTERFACE",0,NULL,&id__INTERFACE},
{"MODULE",0,NULL,&id__MODULE},
{"SELECT",0,NULL,&id__SELECT},
{"TYPE",0,NULL,&id__TYPE},
{"WHERE",0,NULL,&id__WHERE},
{"",0,NULL,NULL}
}
#endif
;
/* The following is used during \FORTRAN-88\ |case| expansion to see \
whether the last |case| ended with |break|. */
eight_bits break_tokens[3];
/* These are the special \Ratfor\ tokens that are expanded. */
IN_RATFOR SPEC spec_tokens[]
#if(part == 0 || part == 1)
= {
{"block",0,x_block,&id_block},
{"blockdata",0,x_blockdata,&id_blockdata},
{"break",0,x_break,&id_break},
{"case",0,(X_FCN(*)(VOID))x_case,&id_case},
{"default",0,(X_FCN(*)(VOID))x_default,&id_default},
{"do",0,x_do,&id_do},
{"else",0,x_else,&id_else},
{"elseif",0,x_els_if,&id_elseif},
{"end",0,x_end,&id_end},
{"endif",0,x_en_if,&id_endif},
{"for",0,x_for,&id_for},
{"function",0,x_function,&id_function},
{"if",0,x_if,&id_if},
{"next",0,x_next,&id_next},
{"procedure",0,x_procedure,&id_procedure},
{"program",0,x_program,&id_program},
{"repeat",0,x_repeat,&id_repeat},
{"return",0,x_return,&id_return},
{"switch",0,x_switch,&id_switch},
{"subroutine",0,x_subroutine,&id_subroutine},
{"then",0,x_then,&id_then},
{"until",0,x_until,&id_until},
{"while",0,x_while,&id_while},
{"",0,NULL,NULL}
}
#endif
;
/* \Fortran--90. */
IN_RATFOR SPEC spec90_tokens[]
#if(part == 0 || part == 1)
= {
{"contains",0,x_contains,&id_contains},
{"endinterface",0,x_en_interface,&id_endinterface},
{"endmodule",0,x_en_module,&id_endmodule},
{"endselect",0,x_en_select,&id_endselect},
{"endtype",0,x_en_type,&id_endtype},
{"endwhere",0,x_en_where,&id_endwhere},
{"interface",0,x_interface,&id_interface},
{"module",0,x_module,&id_module},
{"type",0,x_type,&id_type},
{"where",0,x_where,&id_where},
{"",0,NULL,NULL}
}
#endif
;
IN_RATFOR sixteen_bits sym_label RSET(0);
IN_RATFOR boolean saved_token RSET(NO);/* Is there another byte waiting? */
IN_RATFOR eight_bits last_a;/* The byte that was saved. */
IN_RATFOR int last_bytes;
/* Length (either~1 or~2) of the token just read. Used to \
back up properly. */
IN_RATFOR eight_bits HUGE*cmnt_buf RSET(NULL),
HUGE*cmnt_buf_end RSET(NULL),
HUGE*cmnt_pos RSET(NULL);
typedef struct
{
CMD cmd;/* The command that initiated this block. */
STMT_LBL Top,Next,Break;/* Statement labels for loops. */
STMT_LBL Case,Default;/* Labels for next |case| or |default|. */
sixteen_bits Icase;/* Identifier token for current comparand. */
unsigned was_Break:1,/* Did a |break| occur? */
was_Next:1;/* Did a |@r next| occur? */
}LBL;
IN_RATFOR LBL HUGE*lbl,HUGE*lbl_end;/* Dynamic array. */
IN_RATFOR BUF_SIZE max_lbls;/* Dynamic allocation length. */
IN_RATFOR int wlevel RSET(0);
/* Current level of expansion that can be broken out of \
with a |break| or |next|. This is incremented for \
such things as |do|, but not for such things as \
|if|. */
IN_RATFOR boolean balanced RSET(YES);
IN_RATFOR ASCII cur_delim RSET('\0');
IN_RATFOR eight_bits HUGE*save_buffer RSET(NULL),HUGE*psave_buffer;
IN_RATFOR outer_char HUGE*cmd_fmt;
IN_RATFOR ASCII HUGE*cmd_msg,HUGE*cmd_end;
IN_RATFOR BUF_SIZE cmd_fsize,cmd_size;
IN_COMMON double g_ratio;
IN_COMMON CASE_TYPE max_spread;
IN_COMMON unsigned short marginal_cases;
IN_EVAL VAL HUGE*val_ptr,HUGE*val_heap;
/* For pc's, the file is split into two compilable parts using the \
compiler-line macro |part|, which must equal either~1 or~2. */
#if(part != 2)
SRTN
is_Rat_present(VOID)
{
Rat_is_loaded= YES;
}
boolean
Rat_OK FCN((msg))
outer_char*msg C1("")
{
return YES;
}
SRTN
ini_RAT_tokens FCN((language0))
LANGUAGE language0 C1("")
{
switch(language0)
{
case RATFOR_90:
ini_special_tokens(language0,spec90_tokens);
ini_out_tokens(out90_tokens);
/* The previous case falls through to here! */
case RATFOR:
ini_special_tokens(language0,spec_tokens);/* Initialize special tokens. */
ini_out_tokens(out_tokens);/* Printed during Ratfor expansion. */
break;
default:
confusion(OC("ini_RAT_tokens"),OC("Language should be RATFOR-like here"));
}
ini_univ_tokens(language0);
{
ASCII HUGE*pd;
/* Store the phrase ``|break;|''. */
break_tokens[0]= LEFT(id_break,ID0);
break_tokens[1]= RIGHT(id_break);
break_tokens[2]= 073;
pd= x_to_ASCII(OC("data"));
id_data= ID_NUM(pd,pd+4);
}
}
int
chk_lbl(VOID)
{
sixteen_bits a;
if(next_byte()==072)
{
sym_label= (sixteen_bits)cur_val;/* Remember symbolic label. */
if(TOKEN1(a= next_byte()))BACK_UP
else
{/* Labelled identifier. */
a= IDENTIFIER(a,next_byte());/* Labelled token. */
if(name_dir[a].expandable)
{/* It's a labelled \Ratfor\ token. */
cur_val= a;
return YES;
}
else
{/* Nothing special about this label; spit it out. */
BACK_UP
cur_val= sym_label;
sym_label= ignore;
checking_label= YES;
out_char(identifier);
checking_label= NO;
return-1;
}
}
}
/* The identifier isn't followed by a colon, so it isn't a label. */
sym_label= ignore;
BACK_UP
return NO;
}
SRTN
RAT_error FCN(VA_ALIST((err_type,msg,n VA_ARGS)))
VA_DCL(
ERR_TYPE err_type C0("Is it warning or error?")
CONST outer_char msg[]C0("Error message.")
int n C2("Number of arguments to follow."))
{
VA_LIST(arg_ptr)
outer_char HUGE*temp,HUGE*temp1;
int last_level;
#if(NUM_VA_ARGS == 1)
ERR_TYPE err_type;
CONST outer_char*msg;
int n;
#endif
temp= GET_MEM("RAT_error:temp",N_MSGBUF,outer_char);
temp1= GET_MEM("RAT_error:temp1",N_MSGBUF,outer_char);
VA_START(arg_ptr,n);
#if(NUM_VA_ARGS == 1)
err_type= va_arg(arg_ptr,ERR_TYPE);
msg= va_arg(arg_ptr,char*);
va_arg(arg_ptr,int);
#endif
vsprintf((char*)temp1,(CONST char*)msg,arg_ptr);
va_end(arg_ptr);
if(
nsprintf(temp,OC("RATFOR %s (Output l. %u in %s): %s."),4,err_type==ERROR?"ERROR":"WARNING",OUTPUT_LINE,params.OUTPUT_FILE_NAME,temp1)>=(int)(N_MSGBUF))OVERFLW("temp","");
last_level= MAX(rlevel-1,0);
if(
nsprintf(temp1,OC("%s Expanding \"%s\" (loop level %d) beginning at output line %u. \
In \"%s %s\" beginning at line %u."),7,(char*)temp,(char*)cmd_name(begun[last_level].cmd),begun[last_level].level,begun[last_level].line,(char*)cmd_name(begun[0].cmd),(char*)name_of(begun[0].name),begun[0].line)>=(int)(N_MSGBUF))OVERFLW("temp1","");
printf("\n%s\n",(char*)temp1);/* Error msg to the terminal. */
OUT_MSG(to_ASCII(temp1),NULL);/* Error msg to the file. */
mark_error;
FREE_MEM(temp,"RAT_error:temp",N_MSGBUF,char);
FREE_MEM(temp1,"RAT_error:temp1",N_MSGBUF,char);
}
SRTN
output_ended FCN(VA_ALIST((msg,n VA_ARGS)))
VA_DCL(
CONST outer_char msg[]C0("Error message.")
int n C2("Number of arguments to follow."))
{
VA_LIST(arg_ptr)
char HUGE*temp;
temp= GET_MEM("output_ended:temp",N_MSGBUF,char);
VA_START(arg_ptr,n);
#if(NUM_VA_ARGS==1)
{
char*fmt0= va_arg(arg_ptr,char*);
va_arg(arg_ptr,int);
vsprintf((char*)temp,fmt0,arg_ptr);
}
#else
vsprintf(temp,(CONST char*)msg,arg_ptr);
#endif
va_end(arg_ptr);
RAT_error(ERROR,OC("Output ended %s"),1,temp);
fatal(ERR_R,OC("ABORTING!"),OC(""));
}
outer_char HUGE*
cmd_name FCN((cmd))
CMD cmd C1("Type of command.")
{
switch(cmd)
{
case _DO_CMD:
return OC("$DO");
case blockdata_CMD:return OC("blockdata");
case break_CMD:return OC("break");
case case_CMD:return OC("case");
case contains_CMD:return OC("contains");
case default_CMD:return OC("default");
case do_CMD:return OC("do");
case for_CMD:return OC("for");
case function_CMD:return OC("function");
case if_CMD:return OC("if");
case interface_CMD:return OC("interface");
case module_CMD:return OC("module");
case next_CMD:return OC("next");
case program_CMD:return OC("program");
case repeat_CMD:return OC("repeat");
case return_CMD:return OC("return");
case subroutine_CMD:return OC("subroutine");
case switch_CMD:return OC("switch");
case type_CMD:return OC("type");
case until_CMD:return OC("until");
case where_CMD:return OC("where");
case while_CMD:return OC("while");
default:return OC("UNKNOWN CMD");
}
}
SRTN
not_switch FCN((s))
CONST outer_char s[]C1("Error message.")
{
RAT_error(ERROR,OC("Misplaced keyword: \
\"%s\" must be used only inside \"switch\""),1,s);
}
SRTN didnt_expand FCN((c0,c,op))
eight_bits c0 C0("")
eight_bits c C0("")
CONST char*op C1("")
{
RAT_error(ERROR,OC("Was expecting '%c', not '%c', after \"%s\"; \
expansion aborted"),3,XCHR(c0),XCHR(c),op);
}
boolean
char_after FCN((c))
outer_char c C1("Character expected next.")
{
if((ASCII)(next_byte())!=XORD(c))
{
RAT_error(WARNING,OC("Inserted '%c' after \"%s\""),1,c,cmd_name(begun[rlevel-1].cmd));
BACK_UP
return NO;
}
return YES;
}
eight_bits
next_byte(VOID)
{
eight_bits a0;/* The next byte. */
sixteen_bits a;/* Next two-byte token. */
static boolean ended_module= NO;
long cur_val0;/* Incoming value of |cur_val|. */
/* Check if there's a byte already waiting. */
if(saved_token)
{
saved_token= NO;
return last_a;
}
cur_val0= cur_val;/* Trouble if we don't restore the state of |cur_val|. */
WHILE()
{
if(DONE_LEVEL)
{
if(!ended_module)
{
cur_val= -(long)cur_mod;
if(cur_val!=ignore)OUT_CHAR(module_number);
ended_module= YES;
}
if(!pop_level())
{
a0= ignore;
break;
}
ended_module= NO;
}
if(TOKEN1(a0= *cur_byte++))
{
if(a0==ignore&&!in_string)
continue;/* Forget about null bytes. */
if(rlevel>0&&a0==begin_language)
{/* Skip the |begin_language|--|NUWEB_OFF| pair. */
cur_byte++;
continue;
}
last_bytes= 1;
break;
}
{
a= IDENTIFIER(a0,last_a= *cur_byte++);
last_bytes= 2;
/* Expand the two-byte token. */
switch(a/MODULE_NAME)
{
case 0:/* An identifier. */
if(is_deferred(a))continue;/* Execute deferred macro def'n. */
/* If it's a macro, expand it. */
if(!mac_protected&&
(macro_text= (text_pointer)mac_lookup(a))!=NULL)
{
eight_bits HUGE*p;
long cur_val0= cur_val;
cur_val= a;/* In case it's a built-in function. */
p= xmacro(macro_text,&cur_byte,&cur_end,YES,
macrobuf);
cur_val= cur_val0;
push_level(NULL,p,mp);
break;
}
else if(!balanced&&language==RATFOR&&
(a==id_function||a==id_program||a==id_subroutine))
{
RAT_error(ERROR,OC("Inserted missing '%c' at beginning of function"),1,XCHR(cur_delim));
cur_byte-= 2;
saved_token= NO;
a0= cur_delim;
goto return_next_byte;
}
else
{
saved_token= YES;
goto return_next_byte;
}
case 1:/* Module name. */
x_mod_a(a);
break;
default:
cur_val= a-MODULE_NUM;
if(cur_val>UNNAMED_MODULE)cur_mod= (sixteen_bits)cur_val;
OUT_CHAR(module_number);
}
}
}
return_next_byte:
cur_val= cur_val0;
return a0;
}
SRTN
skip_newlines FCN((save_comments))
boolean save_comments C1("")
{
eight_bits a;
if(save_comments)
{/* Allocate a buffer to hold the comments. */
cmnt_pos= cmnt_buf= GET_MEM("cmnt_buf",SAVE8,eight_bits);
cmnt_buf_end= cmnt_buf+SAVE8;
}
while((a= copy_comment(save_comments))==012);
if(a==ignore)
output_ended(OC("while skipping newlines"),0);
BACK_UP
}
eight_bits
copy_comment FCN((save_comments))
boolean save_comments C1("")
{
eight_bits a;
WHILE()
if((a= next_byte())!=stringg)return a;
/* Beginning of string. */
else if(save_comments)
{/* Save in preallocated buffer, for later use with \
|flush_comments|. */
*cmnt_pos++= a;
in_string= YES;
while((a= next_byte())!=stringg)
{
if(cmnt_pos==cmnt_buf_end)
resize(&cmnt_buf,SAVE8,&cmnt_pos,&cmnt_buf_end);
*cmnt_pos++= a;
}
*cmnt_pos++= a;
in_string= NO;
}
else
{/* Copy directly to output. */
OUT_CHAR(stringg);
while((a= get_output())!=stringg);
}
DUMMY_RETURN(ignore);
}
SRTN
flush_comments(VOID)
{
eight_bits*p;
if(!cmnt_buf)return;/* Nothing left in buffer. */
for(p= cmnt_buf;p<cmnt_pos;p++)out_char(*p);/* Print out saved stuff. */
if(cmnt_pos>cmnt_buf)NL;/* If there was a comment, issue a newline. */
FREE_MEM(cmnt_buf,"cmnt_buf",SAVE8,eight_bits);
cmnt_buf= cmnt_buf_end= cmnt_pos= NULL;
}
SRTN
id0 FCN((cur_val))
sixteen_bits cur_val C1("Token to print out.")
{
if(cur_val==ignore)return;
if(out_state==NUM_OR_ID)C_putc(' ');/* Space properly between identifiers. */
out_ptrunc(cur_val);/* Output a possibly truncated identifier; see \
\.{ftangle.web}. */
out_state= NUM_OR_ID;
}
int
save_lbls FCN((cmd,top0,next0,break0,n_used))
CMD cmd C0("The current command.")
STMT_LBL top0 C0("Label number for top of block.")
STMT_LBL next0 C0("Go here on |next|.")
STMT_LBL break0 C0("Go here on |break|.")
int n_used C1("Number of labels used in this expansion.")
{
/* Advance the level counter; check for overflow. */
if(++wlevel>=(int)max_lbls)OVERFLW("stmt labels","");
current_cmd= cmd;/* Save type of block. */
s_top= top0;/* Top of block. */
s_next= next0;/* Jump here on |@r next|. */
s_break= break0;/* Jump here on |@r break|. */
was_break= was_next= NO;/* Did one occur during loop? */
max_stmt+= n_used;/* Advance the statement counter to ensure unique \
labels. */
s_case= s_default= 0;
icase= ignore;
return wlevel;
}
SRTN
out_label FCN((suppress_0,stmt_num))
boolean suppress_0 C0("Suppress if zero?")
STMT_LBL stmt_num C1("Statement number to print.")
{
outer_char temp[N_IDBUF];
outer_char*p;
if(stmt_num==(STMT_LBL)0&&suppress_0)return;
/* In \Fortran, the statement number must be $\le 99999$. */
if(stmt_num>(STMT_LBL)99999)
{
stmt_num= (STMT_LBL)99999;
RAT_error(WARNING,OC("Automatic statement number out of bounds; %ld assumed"),1,stmt_num);
}
if(
nsprintf(temp,OC("%ld"),1,stmt_num)>=(int)(N_IDBUF))OVERFLW("temp","");
OUT_CHAR(constant);
for(p= temp;*p;p++)
OUT_CHAR(XORD(*p));
OUT_CHAR(constant);
}
SRTN
copyd FCN((to_memory,xpn_cases,l,r,semi_allowed))
boolean to_memory C0("To memory?")
boolean xpn_cases C0("Expand |case| statements?")
ASCII l C0("Left-hand delimiter.")
ASCII r C0("Right-hand delimiter.")
boolean semi_allowed C1("Is a semicolon allowed in the text to be \
copied?")
{
int bal,bal0[BLEVELS];
LINE_NUMBER starting_line;
eight_bits(*output_rtn)(VOID);
sixteen_bits a,last_token;
sixteen_bits l0= ignore,r0= ignore;
boolean found_semi;
boolean balanced0= balanced;/* Save since possible recursion. */
ASCII cur_delim0= cur_delim;
switch(l)
{
case 0173:
l0= 050;r0= 051;
break;
case 050:
l0= 0173;r0= 0175;
break;
default:
confusion(OC("copyd"),OC("Invalid left delimiter 0x%x"),l);
}
if(l==0173&&xpn_cases)/* We should be positioned after the brace. */
{
if(DONE_LEVEL&&!pop_level())
output_ended(OC("after '{'"),0);
bal0[bal= 1]= 0;/* Don't copy the opening brace. */
}
else
{
if((ASCII)(next_byte())!=l)
{
RAT_error(ERROR,OC("Missing opening delimiter '%c'; \
text not copied"),1,XCHR(l));
return;
}
/* Include the opening delimiter in the copy. */
BACK_UP
bal0[bal= 0]= 0;
}
starting_line= OUTPUT_LINE;
/* Normally we copy the stuff directly to the output. However, if we're \
processing a |switch|, we store it. */
output_rtn= to_memory?next_byte:get_output;
/* We use |last_token| to help check for a semicolon just before the closing \
delimiter. */
last_token= ignore;
found_semi= NO;
/* For use with check in |get_output|. */
balanced= NO;
cur_delim= r;
WHILE()
{
a= (sixteen_bits)(*output_rtn)();/* Copy a token to the output, \
and remember it. */
if(to_memory&&a==(sixteen_bits)stringg)
in_string= BOOLEAN(!in_string);
if(!in_string)
{
if(a==ignore)
output_ended(OC("while scanning for '%c'. Scan began \
with delimiter '%c' at line %u"),3,XCHR(r),XCHR(l),starting_line);
if(a==(sixteen_bits)l)bal0[++bal]= 0;
else if(a==(sixteen_bits)r)
{
if(bal<=0)
{
if(!to_memory)out_pos--;/* Kill off what was already output. */
unmatched(l,r);
continue;
}
else
{
if(bal0[bal]!=0)
{
inserted(bal0[bal],l0,r0,l,bal);
while(bal0[bal]--)
if(to_memory)SAVE_IN_MEM(r0)
else OUT_CHAR(r0);
}
if(--bal==0)
{
if(semi_allowed&&last_token&&last_token!=073)
{
RAT_error(WARNING,OC("Supplied missing ';' before \
delimiter '%c'"),1,r);
if(to_memory)SAVE_IN_MEM(073)
else OUT_CHAR(073);
}
if(to_memory)SAVE_IN_MEM(r)
/* We've successfully found the end of the scan. */
balanced= YES;
cur_delim= '\0';
break;
}
}
}
else if(a==l0)bal0[bal]++;
else if(a==r0)
{
if(bal0[bal]<=0)
{
if(!to_memory)out_pos--;
unmatched((ASCII)l0,(ASCII)r0);
continue;
}
else bal0[bal]--;
}
else if(a!=stringg)
{
if(a==073)
if(semi_allowed)found_semi= YES;
else
RAT_error(ERROR,OC("Spurious semicolon"),0);
if(chk_stmts)
if(!to_memory&&a==id_keyword)last_token= ignore;
else last_token= a;/* Remember last character so we can check \
for semicolon. */
}
}
if(to_memory)
{
if(TOKEN1(a))
{
SAVE_IN_MEM(a)/* Store it if necessary. */
switch(a)
{
case dot_const:
case begin_language:
SAVE_IN_MEM(*cur_byte++);
break;
case new_output_file:
RAT_error(ERROR,OC("@o command not allowed inside switch"),0);
}
}
else
{
if(xpn_cases)
{
eight_bits a0,a1;
a= IDENTIFIER(a0= (eight_bits)a,a1= next_byte());
if(a==id_switch)
{
SAVE_16;/* |switch|. */
copyd(TO_MEMORY,DONT_XPN_CASES,050,051,NO);/* $(\dots)$ */
skip_newlines(COPY_COMMENTS);
copyd(TO_MEMORY,DONT_XPN_CASES,0173,0175,YES);/* |{body;}| */
}
else if(a==id_case)x_case();
else if(a==id_default)x_default();
else SAVE_16;
}
else
{/* For inner |switches|, just copy tokens. */
SAVE_IN_MEM(a)
SAVE_IN_MEM(next_byte())
}
}
}
}
balanced= balanced0;
cur_delim= cur_delim0;
}
SRTN
cp_fcn_body(VOID)
{
brace_level++;
copyd(TO_OUTPUT,XPN_CASES,0173,0175,YES);
if(--brace_level==0)
{
END;/* Automatically insert an |@r end| statement. */
cur_fcn= NO_FCN;/* No longer inside a function. */
rlevel--;
}
}
SRTN
stmt FCN((to_memory,brace_only))
boolean to_memory C0("")
boolean brace_only C1("Is only a left brace allowed next?")
{
sixteen_bits a;
EAT_AUTO_SEMI;
skip_newlines(COPY_COMMENTS);
if((a= next_byte())!=0173)
{
if(a==ignore)
output_ended(OC("at beginning of statement"),0);
/* Issue error message if was expecting brace. */
if(brace_only)
{
RAT_error(WARNING,OC("Inserted '{'"),0);
BACK_UP
copyd(to_memory,XPN_CASES,0173,0175,YES);
return;
}
if(TOKEN1(a))
{/* Definitely not a compound statement. */
BACK_UP
x_stmt();
}
else
{/* Check if it's a Ratfor token that needs to be \
expanded. */
SPEC HUGE*s;
a= IDENTIFIER(a,next_byte());
for(s= spec_tokens;s->len!=0;s++)
if(a==*s->pid&&s->expand!=NULL)
{
(*s->expand)();
return;/* Successfully expanded special token. */
}
BACK_UP
x_stmt();
}
}
else copyd(to_memory,XPN_CASES,0173,0175,YES);/* Scan compound \
statement. */
}
SRTN
x_stmt(VOID)
{
eight_bits a;
WHILE()
{
if((a= get_output())==ignore)
output_ended(OC("during scan of simple \
statement "),0);
if(a==073&&!in_string)break;
}
/* Does a verbatim comment follow? If so, it's bracketed by |stringg|. */
if((a= next_byte())!=stringg){BACK_UP return;}
if(*cur_byte!=012){BACK_UP return;}
/* Copy verbatim comment. */
OUT_CHAR(a);
while((a= get_output())!=stringg);
}
eight_bits HUGE*
save_out FCN((pp,nmax,r_before,r_after))
eight_bits HUGE**pp C0("Address of pointer to buffer where result is \
saved.")
int nmax C0("Length of above buffer.")
eight_bits r_before C0("Stop before here.")
eight_bits r_after C1("Stop after here.")
{
eight_bits a,l;
eight_bits HUGE*p,HUGE*p_end;
LINE_NUMBER starting_line;
int bal,bal0[BLEVELS];
/* If a save buffer hasn't already been allocated, do that. */
if(!(*pp))
*pp= GET_MEM("*pp",nmax,eight_bits);/* Send back the buffer \
address, so we can free later. */
p= *pp;
p_end= p+nmax-1;/* End of buffer. When we get this far, we must \
reallocate. The $-1$~is because we might \
increment~|p| by~2. */
switch(r_after)
{
case 051:
l= (eight_bits)050;
bal= 1;
break;
case 0175:
l= (eight_bits)0173;
bal= 1;
break;
default:
l= '\0';
bal= 0;
break;
}
bal0[bal]= 0;
starting_line= OUTPUT_LINE;/* Remember where the scan started, in case \
there is an error. */
if(in_string)
confusion(OC("save_out"),OC("Shouldn't be inside string here"));
WHILE()
{
if(p>=p_end)resize(pp,nmax,&p,&p_end);/* Reallocate the save \
buffer. */
if(TOKEN1(a= next_byte()))
{
if(!in_string)
{
if(a==ignore)
output_ended(OC("while scanning from line %u \
for delimiter (r_before = '%c', r_after = '%c')"),3,starting_line,XCHR(r_before),XCHR(r_after));
if(a==l)bal0[++bal]= 0;
else if(a==r_after&&r_after!=NOT_AFTER)
{
if(l&&bal<=0)
{
p--;
unmatched(l,r_after);
continue;
}
else
{
if(bal0[bal]!=0)
{
inserted(bal0[bal],0173,0175,l,bal);
while(bal0[bal]--)
{
*p++= 0175;
if(p>=p_end)resize(pp,nmax,&p,&p_end);
}
}
if(l)bal--;
if(bal==0)
{/* Found right-hand delimiter. */
*p= '\0';/* Mark end of tokens. */
return p;
}
}
}
else if(a==r_before&&r_before!=NOT_BEFORE)
{
BACK_UP;
*p= '\0';
return p;
}
else if(a==0173)bal0[bal]++;
else if(a==0175)
{
if(bal0[bal]<=0)
{
p--;
unmatched(0173,0175);
continue;
}
else bal0[bal]--;
}
}
{
*p++= a;
switch(a)
{
case stringg:
in_string= BOOLEAN(!in_string);
break;
case dot_const:
case begin_language:
*p++= *cur_byte++;
break;
}
}
}
else
{
*p++= a;
*p++= next_byte();
}
}
DUMMY_RETURN(NULL);
}
outer_char*
qdelim FCN((delim))
ASCII delim C1("")
{
static outer_char q0[4];
sprintf((char*)q0,delim?"'%c'":"?",XCHR(delim));
return q0;
}
SRTN
resize FCN((pp,nmax,pq,pp_end))
eight_bits HUGE**pp C0("Addr of ptr to beginning of buffer")
int nmax C0("Resizing increment")
eight_bits HUGE**pq C0("Address of current pointer")
eight_bits HUGE**pp_end C1("Addr of ptr to end of buffer")
{
int old_len= PTR_DIFF(int,*pq,*pp);/* Old length. Should this be |size_t|? */
int new_len= old_len+nmax;/* New length. */
*pp= (eight_bits HUGE*)REALLOC(*pp,
new_len*sizeof(eight_bits),
old_len*sizeof(eight_bits));
*pq= *pp+old_len;/* New next position to which to accrete. */
*pp_end= *pp+new_len-1;/* New end. */
}
#endif /* Part 1 */
#if(part != 1)
SRTN
alloc_Rat(VOID)
{
ALLOC(LBL,lbl,"lb",max_lbls,0);
lbl_end= lbl+max_lbls;
ALLOC(outer_char,cmd_fmt,"cf",cmd_fsize,0);
ALLOC(ASCII,cmd_msg,"cg",cmd_size,0);
cmd_end= cmd_msg+cmd_size;
begun= GET_MEM("begun",max_lbls,BEGUN);
}
SRTN
out_cmd FCN(VA_ALIST((emit_continue,abbrev,beginning,fmt0,n VA_ARGS)))
VA_DCL(
boolean emit_continue C0("Put a |continue| in case of label.")
outer_char abbrev C0("Abbreviation of command.")
CONST outer_char beginning[]C0("Beginning part of message.")
CONST outer_char*fmt0 C0("Format of the message.")
int n C2("Number of arguments to message."))
{
VA_LIST(arg_ptr)
#if(NUM_VA_ARGS == 1)
boolean emit_continue;
char abbrev;
CONST outer_char*beginning;
CONST outer_char*fmt0;
int n;
#endif
VA_START(arg_ptr,n);
#if(NUM_VA_ARGS == 1)
emit_continue= va_arg(arg_ptr,boolean);
abbrev= va_arg(arg_ptr,char);
beginning= va_arg(arg_ptr,char*);
fmt0= va_arg(arg_ptr,char*);
va_arg(arg_ptr,int);
#endif
{
static outer_char brkset[3]= "*?";/* Prototype list of possible characters to \
be searched for in the command-line list. */
char*strpbrk();
boolean found_abbrev;
brkset[1]= abbrev;
found_abbrev= BOOLEAN(STRPBRK(abbrev_cmds,brkset)!=NULL);
if(suppress_cmds){if(found_abbrev)return;}
else{if(!found_abbrev)return;}
}
if(emit_continue)
{
CONTINUE(ignore);/* In case there's a statement label. */
}
/* Make prettier format. */
if(
nsprintf(cmd_fmt,OC("--- %s \"%s%s\" ---"),3,beginning,cmd_name(begun[rlevel-1].cmd),fmt0)>=(int)(cmd_fsize))OVERFLW("cmd_fmt","");
{
outer_char HUGE*p;
ASCII HUGE*q;
eight_bits HUGE*s,HUGE*s1;
p= cmd_fmt;
q= cmd_msg;
while(*p)
{
if(q>=cmd_end)
OVERFLW("cmd_msg","cg");
if(*p=='%'&&*(p+1)=='s')
{
p+= 2;
/* For compilers that don't implement variable arguments, the following \
calls return a string beginning with \.{"KLUDGE"}. (See \
\.{proto.hweb}.) This doesn't work right on the MAC, since it seems to \
put copies of identical strings into different locations. Thus, the \
\Ratfor\ comments look strange. To kill off those comments, use the \.{-k} \
option. */
s= va_arg(arg_ptr,eight_bits*);
s1= va_arg(arg_ptr,eight_bits*);
while(s<s1)
*q++= *s++;
}
else
*q++= XORD(*p++);
}
va_end(arg_ptr);
/* Translate it to the output. */
OUT_MSG(cmd_msg,q);
}
;
if(Fortran88&&symbolic_label)
{
id0(symbolic_label);OUT_CHAR(072);
}
}
SRTN
expanding FCN((cmd))
CMD cmd C1("Type of identifier being expanded.")
{
if(rlevel>=(int)max_lbls)OVERFLW("Nesting","");
begun[rlevel].cmd= cmd;
begun[rlevel].name= rlevel?cur_fcn:NO_FCN;
begun[rlevel].symbolic= sym_label;/* For |do| or |switch|. */
begun[rlevel].function= BOOLEAN(CHOICE(rlevel,is_function,NO));
begun[rlevel].line= OUTPUT_LINE;
begun[rlevel].level= wlevel;
rlevel++;
}
X_FCN
x_while(VOID)
{
eight_bits HUGE*a= NULL,HUGE*pa;
expanding(while_CMD);
save_lbls(while_CMD,max_stmt,max_stmt,max_stmt+1,2);
/* Is parenthesized condition present? */
{
eight_bits c;
if((c= next_byte())!='(')
{
didnt_expand('(',c,"while");
return;
}
};
pa= SAVE_AFTER(&a,SAVE8,051);/* Save the condition. */
out_cmd(YES,'w',OC(""),OC("(%s)"),2,a,pa);/* Comment to output. */
if(Fortran88)
{
id0(id__DO);id0(id__WHILE);LP;copy_out(a,pa,!macro);RP;
NL;/* |@n DO WHILE|$(\dots)$ */
}
else
{
IF(s_top);LP;copy_out(a,pa,!macro);RP;THEN;
}
INDENT;
stmt(TO_OUTPUT,0);/* Body. */
if(!Fortran88){GOTO(s_top);}
OUTDENT;
if(Fortran88){END_DO;}
else
{
ENDIF;
if(was_break){CONTINUE(s_break);}
}
wlevel--;
rlevel--;
FREE_MEM(a,"while:a",SAVE8,eight_bits);
}
X_FCN
x_break(VOID)
{
sixteen_bits a;
/* Check that we're in a loop or |switch|. */
if(wlevel==0&&switch_level==0)
{
NOT_LOOP("break"," or \"switch\"");
COPY_TO(073);
return;
}
expanding(break_CMD);
was_break= YES;/* Remember that at least one \
|break| statement happened during this loop. */
out_cmd(YES,'b',OC(""),OC(""),0);/* Comment to output. */
if(Fortran88&&do_or_while)
{
id0(id__EXIT);
if(TOKEN1(a= next_byte()))BACK_UP
else id0(IDENTIFIER(a,next_byte()));
NL;/* The |do_or_while| is used since |EXIT| can only \
be used inside of |do|'s or |while|'s. */
}
else{GOTO(s_break);}
char_after(';');/* |break| must be immediately followed by semicolon. */
rlevel--;
}
SRTN
not_loop FCN((id,msg))
CONST outer_char id[]C0("Errant identifier name.")
CONST outer_char msg[]C1("Error message.")
{
RAT_error(WARNING,OC("Misplaced keyword: \
\"%s\" must appear inside loop%s; command ignored"),2,id,msg);
}
X_FCN
x_next(VOID)
{
sixteen_bits a;
/* Check that |next| occurs inside loop. */
if(wlevel==0)
{
NOT_LOOP("next","");
COPY_TO(073);
return;
}
expanding(next_CMD);
was_next= YES;/* At least one |next| occurred during this loop. */
out_cmd(YES,'n',OC(""),OC(""),0);
if(Fortran88&&do_or_while)
{
id0(id__CYCLE);
if(TOKEN1(a= next_byte()))BACK_UP
else id0(IDENTIFIER(a,next_byte()));
NL;
}
else{GOTO(s_next);}
char_after(';');
rlevel--;
}
X_FCN
x_repeat(VOID)
{
sixteen_bits a;
eight_bits HUGE*u= NULL,HUGE*pu;
expanding(repeat_CMD);
save_lbls(repeat_CMD,max_stmt,max_stmt+1,max_stmt+2,3);
out_cmd(YES,'p',OC(""),OC(""),0);/* Comment to output. */
CONTINUE(s_top);
INDENT;
stmt(TO_OUTPUT,0);
OUTDENT;
if(was_next)LABEL(s_next);
skip_newlines(SAVE_COMMENTS);
/* Check for optional |@r until|. */
if(TOKEN1(a= next_byte()))BACK_UP
else
{
a= IDENTIFIER(a,next_byte());
if(a==id_until)
{
flush_comments();
rlevel--;
expanding(until_CMD);
{
eight_bits c;
if((c= next_byte())!='(')
{
didnt_expand('(',c,"until");
return;
}
};
pu= SAVE_AFTER(&u,SAVE8,051);/* The |until| condition. */
out_cmd(NO,'p',OC(""),OC("(%s)"),2,u,pu);
IF(ignore);LP;NOT;
LP;copy_out(u,pu,!macro);RP;
RP;
FREE_MEM(u,"repeat:u",SAVE8,eight_bits);
}
else BACK_UP
}
GOTO(s_top);
flush_comments();
if(was_break){CONTINUE(s_break);}
wlevel--;
rlevel--;
}
X_FCN
x_do(VOID)
{
eight_bits b;
sixteen_bits a;
/* Is the next a statement number? */
b= next_byte();BACK_UP
/* Don't expand the ordinary Fortran numbered |do|. */
if(b==constant)
{
id0(id_do);/* Numbered |do|. */
return;
}
/* Expand the Ratfor |do|. */
expanding(do_CMD);
save_lbls(do_CMD,0L,max_stmt,max_stmt+1,2);
out_cmd(YES,'d',OC(""),OC(""),0);/* Comment to output. */
/* The following |if| accounts for the possibility of a semicolon or left \
brace immediately following the |do|. */
if(!TOKEN1(a= next_byte()))
a= IDENTIFIER(a,next_byte());
BACK_UP
if(!(a==id_while))
{
id0(id__DO);if(!Fortran88)LABEL(s_next);COPY_2TO(0173,073);NL;
INDENT;
stmt(TO_OUTPUT,0);
OUTDENT;
if(Fortran88)
{
id0(id__END);id0(id__DO);
if(symbolic_label)id0(symbolic_label);
NL;
}
else
{
CONTINUE(s_next);
if(was_break){CONTINUE(s_break);}
}
}
wlevel--;
rlevel--;
}
X_FCN
x_for(VOID)
{
eight_bits HUGE*a= NULL,HUGE*b= NULL,HUGE*c= NULL,
HUGE*pa,HUGE*pb,HUGE*pc;
expanding(for_CMD);
save_lbls(for_CMD,max_stmt,max_stmt+1,max_stmt+2,3);
/* Check for parenthesized list. */
{
eight_bits c;
if((c= next_byte())!='(')
{
didnt_expand('(',c,"for");
return;
}
};
pa= SAVE_AFTER(&a,SAVE8,073);/* Initialization. */
pb= SAVE_AFTER(&b,SAVE8,073);/* Test. */
pc= SAVE_AFTER(&c,SAVE8,051);/* Reinitialization. */
out_cmd(YES,'f',OC(""),OC("(%s;%s;%s)"),6,a,pa,b,pb,c,pc);/* Comment to output. */
/* Initialization. */
if(pa>a){copy_out(a,pa,!macro);NL;}
/* Conditional. */
if(pb>b)
{IF(s_top);LP;copy_out(b,pb,!macro);RP;THEN;}
else{CONTINUE(s_top);}
/* Body. */
INDENT;
stmt(TO_OUTPUT,0);
/* Reinitialization. */
if(was_next){CONTINUE(s_next);}
if(pc>c)
{
out_cmd(NO,'f',OC("Reinitialization of"),OC("(%s;%s;%s)"),6,a,pa,b,pb,c,pc);
copy_out(c,pc,!macro);NL;
}
GOTO(s_top);
OUTDENT;
if(pb>b){ENDIF;}
if(was_break){CONTINUE(s_break);}
wlevel--;
rlevel--;
FREE_MEM(a,"for:a",SAVE8,eight_bits);
FREE_MEM(b,"for:b",SAVE8,eight_bits);
FREE_MEM(c,"for:c",SAVE8,eight_bits);
}
X_FCN
x_if(VOID)
{
expanding(if_CMD);
out_cmd(YES,'i',OC(""),OC(""),0);
xpn_body(id__IF,YES,id__THEN);
/* Hunt for |else| or |elseif|. */
WHILE()
if(!
xpn_else(id_if,id_elseif,id__IF,YES,id__THEN))break;
ENDIF;
flush_comments();
rlevel--;
}
SRTN
xpn_body FCN((token1,scan_parens,token2))
sixteen_bits token1 C0("")
boolean scan_parens C0("")
sixteen_bits token2 C1("")
{
LABEL(ignore);id0(token1);
if(scan_parens)PARENS;
if(token2)id0(token2);
NL;
INDENT;
stmt(TO_OUTPUT,0);
OUTDENT;
}
boolean
xpn_else FCN((id_x,id_else_x,token1,scan_parens,token2))
sixteen_bits id_x C0("")
sixteen_bits id_else_x C0("")
sixteen_bits token1 C0("")
boolean scan_parens C0("")
sixteen_bits token2 C1("")
{
sixteen_bits a;
skip_newlines(SAVE_COMMENTS);
if(TOKEN1(a= next_byte()))
{/* Not a keyword. */
BACK_UP
return NO;
}
else
{
a= IDENTIFIER(a,next_byte());
if(a==id_else_x)
{/* |@r elseif| */
flush_comments();
ELSE;
xpn_body(token1,scan_parens,token2);
return YES;
}
if(a!=id_else)
{/* Neither |else if| nor |else|. */
BACK_UP
return NO;
}
else
{/* |@r else| */
flush_comments();
ELSE;
if(TOKEN1(a= next_byte()))BACK_UP
else
{/* Possible |@r if| or |@r where|. */
a= IDENTIFIER(a,next_byte());
if(a==id_x)/* |else if| or |else where */
{
xpn_body(token1,scan_parens,token2);
return YES;
}
else BACK_UP
}
if(out_pos>rst_pos)NL;/* Terminate the |else|. */
INDENT;
stmt(TO_OUTPUT,0);/* Expand body of |else|. */
OUTDENT;
return NO;
}
}
}
X_FCN
x_else(VOID)
{
UNEXPECTED("else");
}
X_FCN
x_els_if(VOID)
{
UNEXPECTED("elseif");
}
X_FCN
x_end(VOID)
{
UNEXPECTED("end");
}
X_FCN
x_en_if(VOID)
{
UNEXPECTED("endif");
}
X_FCN
x_en_interface(VOID)
{
UNEXPECTED("endinterface");
}
X_FCN
x_en_module(VOID)
{
UNEXPECTED("endmodule");
}
X_FCN
x_en_select(VOID)
{
UNEXPECTED("endselect");
}
X_FCN
x_en_type(VOID)
{
UNEXPECTED("endtype");
}
X_FCN
x_en_where(VOID)
{
UNEXPECTED("endwhere");
}
X_FCN
x_procedure(VOID)
{
UNEXPECTED("procedure");
}
X_FCN
x_then(VOID)
{
UNEXPECTED("then");
}
X_FCN
x_until(VOID)
{
UNEXPECTED("until");
}
X_FCN
x_where(VOID)
{
expanding(where_CMD);
out_cmd(YES,'h',OC(""),OC(""),0);
xpn_body(id__WHERE,YES,id__ignore);
xpn_else(id_where,id_elsewhere,id__WHERE,NO,id__ignore);
ENDWHERE;
rlevel--;
}
SRTN
unexpected FCN((id))
CONST outer_char id[]C1("Error message.")
{
RAT_error(WARNING,OC("Unexpected keyword \"%s\" ignored"),1,id);
}
X_FCN
x_switch(VOID)
{
eight_bits HUGE*a= NULL,HUGE*pa;
outer_char temp[N_IDBUF];
unsigned short k;
boolean computed_goto= NO;
CASE_TYPE cmin= 0,cmax;/* Minimum and maximum |case| values. */
CASE_TYPE mcases= 0;/* Spread in the case value. */
unsigned short num_cases;/* Number of cases. */
expanding(switch_CMD);
if(switches==NULL)switches= GET_MEM("switches",NSWITCHES,SWITCH);
++switch_level;
if(cur_switch.cases==NULL)
cur_switch.cases= GET_MEM("cur_switch.cases",NCASES,CASE);
cur_switch.ncases= 0;
cur_switch.has_default= NO;
/* Allocate the zeroth case. This won't be used, except if there's text \
before the first |case|. */
cur_case= &cur_switch.cases[0];
cur_case->txt.next= cur_case->txt.start=
GET_MEM("cur_case->txt.start",BIG_SAVE8,eight_bits);
cur_case->txt.end= cur_case->txt.start+BIG_SAVE8;
save_lbls(switch_CMD,0L,s_next,max_stmt,1);
/* Look for the parenthesized expression. */
{
eight_bits c;
if((c= next_byte())!='(')
{
didnt_expand('(',c,"switch");
return;
}
};
pa= SAVE_AFTER(&a,SAVE8,051);/* Save the expression. */
out_cmd(YES,'s',OC(""),OC("(%s)"),2,a,pa);/* Comment to output. */
if(Fortran88)
{
id0(id__SELECT);id0(id__CASE);LP;copy_out(a,pa,!macro);RP;NL;
}
INDENT;
stmt(TO_MEMORY,BRACE_ONLY);/* Read the |switch| into memory. */
if(Fortran88)
{
computed_goto= NO;
}
else
{
unsigned short k;
VAL val;
/* We need to find the minimum and maximum |case| value. */
cmin= LONG_MAX;/* See |limits.h|. */
cmax= LONG_MIN+1;/* The |+1| takes care of an \.{scc} bug. */
for(k= 1;k<=cur_switch.ncases;k++)
{
cur_case= &cur_switch.cases[k];
if(cur_case->is_default)continue;
/* Call up the expression evaluator to reduce the |case| text to an \
integer. */
{
extern boolean eval_msgs;
eval_msgs= NO;
EVALUATE(val,cur_case->case_txt.start,cur_case->case_txt.next);
eval_msgs= YES;
}
switch(val.type)
{
case Int:
cur_case->value= (CASE_TYPE)(val.value.i);
break;
case Double:
RAT_error(WARNING,OC("Case value %#g of type double truncated to int"),1,val.value.d);
cur_case->value= (CASE_TYPE)(val.value.d);
break;
default:
/* The case didn't evaluate to an integer. */
computed_goto= NO;
goto not_integer;
}
/* Running determination of the minimum and maximum |case| value. */
if(cur_case->value<cmin)cmin= cur_case->value;
if(cur_case->value>cmax)cmax= cur_case->value;
}
if(cur_switch.ncases==1&&s_default!=0)
{
mcases= 0;
computed_goto= YES;
goto not_integer;
}
else mcases= (cmax-cmin+1);/* Spread in the cases. */
if((num_cases= cur_switch.ncases-(unsigned short)(s_default!=0))==0)
{
computed_goto= NO;
goto not_integer;
}
computed_goto= BOOLEAN((num_cases>marginal_cases&&
mcases<max_spread)?YES:
((double)mcases)/num_cases<=g_ratio);
not_integer:;
}
;
if(computed_goto)
{
CASE_TYPE m;/* Indexes case values. */
unsigned short k;/* Indexes the cases. */
/* Generate computed |goto| to handle the cases; fill in any gaps. */
OUTDENT;
if(mcases>0){id0(id__GOTO);LP;}
for(m= 0;m<mcases;m++,m<mcases?COMMA:RP)
LABEL(label_case(cmin,m));
if(mcases>0)
{
COMMA;LP;copy_out(a,pa,!macro);RP;
MINUS;LP;NUMBER(cmin-1);RP;NL;
}
/* Handle the out-of-bound statements. (If the previous |goto| was out of \
range, control passes to here.) */
GOTO(s_default?s_default:(was_break= YES,s_break));
INDENT;
/* Output the various cases. */
for(k= 1;k<=cur_switch.ncases;k++)
{
cur_case= &cur_switch.cases[k];
show_cmd(cur_case);
OUTDENT;
CONTINUE(cur_case->label);
INDENT;
copy_out(cur_case->txt.start,cur_case->txt.next,!macro);
rlevel--;
}
}
else
{
boolean case_ended_with_break= NO;
boolean made_temp= YES;/* Did we construct a temporary integer for the \
|switch|? */
/* |made_temp == NO| means the expression is a single identifier. */
if(!Fortran88&&(made_temp= BOOLEAN(!((pa-a)==2&&!TOKEN1(*a)))))
{
/* Make a temporary integer identifier to effect the comparisons. */
if(
nsprintf(temp,OC("I%d"),1,s_break)>=(int)(N_IDBUF))OVERFLW("temp","");
to_ASCII(temp);
icase= ID_NUM((ASCII HUGE*)temp,(ASCII HUGE*)(temp+STRLEN(temp)));
id0(icase);EQUALS;copy_out(a,pa,!macro);NL;
}
for(k= 1;k<=cur_switch.ncases;k++)
{
cur_case= &cur_switch.cases[k];
if(Fortran88)
if(k==1)s_case= max_stmt++;
else
{
{
CASE HUGE*last_case= &cur_switch.cases[k-1];
if(PTR_DIFF(long,last_case->txt.next,last_case->txt.start)>=3)
case_ended_with_break=
BOOLEAN(MEMCMP(last_case->txt.next-3,break_tokens,3)==0);
else case_ended_with_break= NO;
}
if(!case_ended_with_break){GOTO(s_case);}
}
show_cmd(cur_case);
OUTDENT;
if(Fortran88)
{
id0(id__CASE);
if(cur_case->is_default)id0(id__DEFAULT);
else
{
if(*cur_case->case_txt.start!=050)LP;
copy_out(cur_case->case_txt.start,cur_case->case_txt.next,
!macro);
if(*(cur_case->case_txt.next-1)!=051)RP;
}
NL;
INDENT;
if(k>1&&!case_ended_with_break)
{
CONTINUE(s_case);
s_case= max_stmt++;
}
}
else
{
if(cur_case->is_default){CONTINUE(s_default);}
else
{
IF(s_case);LP;NOT;LP;
/* The |made_temp?: form of the next command crashed the Apollo \
compiler. */
if(made_temp)id0(icase);else copy_out(a,pa,!macro);
EQ_EQ;
copy_out(cur_case->case_txt.start,
cur_case->case_txt.next,!macro);
RP;RP;
GOTO(s_case= max_stmt++);
}
INDENT;
}
/* Recall the text stored previously. */
copy_out(cur_case->txt.start,cur_case->txt.next,!macro);
rlevel--;
}
if(!Fortran88)
{
CONTINUE(s_case);/* Finish off the last |case|. */
if(s_default)
{
GOTO(s_default);/* Jump to the |default|, if present. */
}
}
}
OUTDENT;
if(Fortran88)
{
if(was_break)LABEL(s_break);
id0(id__END);id0(id__SELECT);
if(symbolic_label)id0(symbolic_label);
NL;
}
else if(was_break){CONTINUE(s_break);}
wlevel--;
rlevel--;
switch_level--;
FREE_MEM(a,"switch:a",SAVE8,eight_bits);
}
SRTN
show_cmd FCN((cur_case))
CONST CASE HUGE*cur_case C1("")
{
if(cur_case->is_default)
{
expanding(default_CMD);
out_cmd(NO,'t',OC(""),OC(":"),0);
}
else
{
expanding(case_CMD);
out_cmd(NO,'c',OC(""),OC(" %s:"),2,cur_case->case_txt.start,cur_case->case_txt.next);
}
}
STMT_LBL
label_case FCN((cmin,m))
CASE_TYPE cmin C0("")
CASE_TYPE m C1("")
{
CASE_TYPE num= cmin+m;
unsigned short k;
/* Check for ordinary cases. */
for(k= 1;k<=cur_switch.ncases;k++)
{
cur_case= &cur_switch.cases[k];
if(!cur_case->is_default&&cur_case->value==num)
return cur_case->label= s_case= max_stmt++;
}
/* Look for |default|. */
for(k= 1;k<=cur_switch.ncases;k++)
if(cur_case->is_default)return s_default;
return s_break;/* A gap. */
}
X_FCN x_case(VOID)
{
if(switch_level==0)
{
not_switch(OC("case"));
return;
}
expanding(case_CMD);
*cur_case->txt.next= '\0';/* Terminate previous text. */
/* Get address of next available |CASE| structure. */
cur_case= &cur_switch.cases[++cur_switch.ncases];
/* If that hasn't been allocated yet, do so. */
if(cur_case->case_txt.start==NULL)
{
cur_case->case_txt.start=
GET_MEM("cur_case->case_txt.start",SAVE8,eight_bits);
cur_case->case_txt.end= cur_case->case_txt.start+SAVE8;
cur_case->txt.start=
GET_MEM("cur_case->txt.start",BIG_SAVE8,eight_bits);
cur_case->txt.end= cur_case->txt.start+BIG_SAVE8;
}
/* Initialize the pointer to beginning of buffer. */
cur_case->txt.next= cur_case->txt.start;
;
cur_case->case_txt.next= SAVE_AFTER(&cur_case->case_txt.start,SAVE8,072);
cur_case->is_default= NO;
{
unsigned short k;
CONST CASE HUGE*old_case;
for(k= 1;k<cur_switch.ncases;k++)
{
old_case= &cur_switch.cases[k];
if(web_strcmp((CONST ASCII HUGE*)cur_case->case_txt.start,
(CONST ASCII HUGE*)cur_case->case_txt.next,
(CONST ASCII HUGE*)old_case->case_txt.start,
(CONST ASCII HUGE*)old_case->case_txt.next)==EQUAL)
{
RAT_error(ERROR,OC("Duplicate case value in switch"),0);
break;
}
}
}
rlevel--;
}
X_FCN
x_default(VOID)
{
if(switch_level==0)
{
not_switch(OC("default"));
return;
}
expanding(default_CMD);
if(cur_switch.has_default)
RAT_error(ERROR,OC("Only one default allowed per switch"),0);
else cur_switch.has_default= YES;
*cur_case->txt.next= '\0';/* Terminate previous text. */
/* Get address of next available |CASE| structure. */
cur_case= &cur_switch.cases[++cur_switch.ncases];
/* If that hasn't been allocated yet, do so. */
if(cur_case->case_txt.start==NULL)
{
cur_case->case_txt.start=
GET_MEM("cur_case->case_txt.start",SAVE8,eight_bits);
cur_case->case_txt.end= cur_case->case_txt.start+SAVE8;
cur_case->txt.start=
GET_MEM("cur_case->txt.start",BIG_SAVE8,eight_bits);
cur_case->txt.end= cur_case->txt.start+BIG_SAVE8;
}
/* Initialize the pointer to beginning of buffer. */
cur_case->txt.next= cur_case->txt.start;
;
cur_case->case_txt.next= cur_case->case_txt.start;
cur_case->is_default= YES;
cur_case->label= s_default= max_stmt++;
char_after(':');/* |default| must be followed immediately by colon. */
rlevel--;
}
X_FCN x_program(VOID)
{
sixteen_bits a;
eight_bits b;
expanding(program_CMD);
WHILE()
{
a= next_byte();
if(!(a==040||a==tab_mark))
break;
}
if(TOKEN1(a))
{
#if(YES)
RAT_error(ERROR,OC("Expected identifier after \"%s\""),1,"program");
#endif
BACK_UP
cur_fcn= NO_FCN;
is_function= NO;
}
else
{
cur_fcn= IDENTIFIER(a,next_byte());
is_function= NO;
}
id0(id_program);id0(cur_fcn);
if(cur_fcn==id_procedure)
{
COPY_TO(073);NL;
}
else
{
b= next_byte();BACK_UP
if(b==050)PARENS;
NL;
EAT_AUTO_SEMI;
skip_newlines(COPY_COMMENTS);
INDENT;
copy_out(insert.program.start,insert.program.end,!macro);
out_char(073);
COPY_2TO(0173,NOT_AFTER);
if(psave_buffer>save_buffer)NL;
brace_level++;
stmt(TO_OUTPUT,BRACE_ONLY);
brace_level--;
OUTDENT;
id0(id__END);
if(Fortran88){id0(id_program);id0(cur_fcn);}
NL;
}
cur_fcn= NO_FCN;
rlevel--;
}
X_FCN x_module(VOID)
{
sixteen_bits a;
eight_bits b;
expanding(module_CMD);
WHILE()
{
a= next_byte();
if(!(a==040||a==tab_mark))
break;
}
if(TOKEN1(a))
{
#if(YES)
RAT_error(ERROR,OC("Expected identifier after \"%s\""),1,"module");
#endif
BACK_UP
cur_fcn= NO_FCN;
is_function= NO;
}
else
{
cur_fcn= IDENTIFIER(a,next_byte());
is_function= NO;
}
id0(id_module);id0(cur_fcn);
if(cur_fcn==id_procedure)
{
COPY_TO(073);NL;
}
else
{
b= next_byte();BACK_UP
if(b==050)PARENS;
NL;
EAT_AUTO_SEMI;
skip_newlines(COPY_COMMENTS);
INDENT;
copy_out(insert.module.start,insert.module.end,!macro);
out_char(073);
COPY_2TO(0173,NOT_AFTER);
if(psave_buffer>save_buffer)NL;
brace_level++;
stmt(TO_OUTPUT,BRACE_ONLY);
brace_level--;
OUTDENT;
id0(id__END);
if(Fortran88){id0(id_module);id0(cur_fcn);}
NL;
}
cur_fcn= NO_FCN;
rlevel--;
}
X_FCN x_subroutine(VOID)
{
sixteen_bits a;
eight_bits b;
expanding(subroutine_CMD);
WHILE()
{
a= next_byte();
if(!(a==040||a==tab_mark))
break;
}
if(TOKEN1(a))
{
#if(YES)
RAT_error(ERROR,OC("Expected identifier after \"%s\""),1,"subroutine");
#endif
BACK_UP
cur_fcn= NO_FCN;
is_function= NO;
}
else
{
cur_fcn= IDENTIFIER(a,next_byte());
is_function= NO;
}
id0(id_subroutine);id0(cur_fcn);
if(cur_fcn==id_procedure)
{
COPY_TO(073);NL;
}
else
{
b= next_byte();BACK_UP
if(b==050)PARENS;
NL;
EAT_AUTO_SEMI;
skip_newlines(COPY_COMMENTS);
INDENT;
copy_out(insert.subroutine.start,insert.subroutine.end,!macro);
out_char(073);
COPY_2TO(0173,NOT_AFTER);
if(psave_buffer>save_buffer)NL;
brace_level++;
stmt(TO_OUTPUT,BRACE_ONLY);
brace_level--;
OUTDENT;
id0(id__END);
if(Fortran88){id0(id_subroutine);id0(cur_fcn);}
NL;
}
cur_fcn= NO_FCN;
rlevel--;
}
X_FCN x_function(VOID)
{
sixteen_bits a;
eight_bits b;
expanding(function_CMD);
WHILE()
{
a= next_byte();
if(!(a==040||a==tab_mark))
break;
}
if(TOKEN1(a))
{
#if(YES)
RAT_error(ERROR,OC("Expected identifier after \"%s\""),1,"function");
#endif
BACK_UP
cur_fcn= NO_FCN;
is_function= NO;
}
else
{
cur_fcn= IDENTIFIER(a,next_byte());
is_function= YES;
}
id0(id_function);id0(cur_fcn);
if(cur_fcn==id_procedure)
{
COPY_TO(073);NL;
}
else
{
b= next_byte();BACK_UP
if(b==050)PARENS;
NL;
EAT_AUTO_SEMI;
skip_newlines(COPY_COMMENTS);
INDENT;
copy_out(insert.function.start,insert.function.end,!macro);
out_char(073);
COPY_2TO(0173,NOT_AFTER);
if(psave_buffer>save_buffer)NL;
brace_level++;
stmt(TO_OUTPUT,BRACE_ONLY);
brace_level--;
OUTDENT;
id0(id__END);
if(Fortran88){id0(id_function);id0(cur_fcn);}
NL;
}
cur_fcn= NO_FCN;
rlevel--;
}
X_FCN x_blockdata(VOID)
{
sixteen_bits a;
eight_bits b;
expanding(blockdata_CMD);
WHILE()
{
a= next_byte();
if(!(a==040||a==tab_mark))
break;
}
if(TOKEN1(a))
{
#if(NO)
RAT_error(ERROR,OC("Expected identifier after \"%s\""),1,"blockdata");
#endif
BACK_UP
cur_fcn= NO_FCN;
is_function= NO;
}
else
{
cur_fcn= IDENTIFIER(a,next_byte());
is_function= NO;
}
id0(id_blockdata);id0(cur_fcn);
if(cur_fcn==id_procedure)
{
COPY_TO(073);NL;
}
else
{
b= next_byte();BACK_UP
if(b==050)PARENS;
NL;
EAT_AUTO_SEMI;
skip_newlines(COPY_COMMENTS);
INDENT;
copy_out(insert.blockdata.start,insert.blockdata.end,!macro);
out_char(073);
COPY_2TO(0173,NOT_AFTER);
if(psave_buffer>save_buffer)NL;
brace_level++;
stmt(TO_OUTPUT,BRACE_ONLY);
brace_level--;
OUTDENT;
id0(id__END);
if(Fortran88){id0(id_blockdata);id0(cur_fcn);}
NL;
}
cur_fcn= NO_FCN;
rlevel--;
}
X_FCN x_interface(VOID)
{
sixteen_bits a;
eight_bits b;
expanding(interface_CMD);
WHILE()
{
a= next_byte();
if(!(a==040||a==tab_mark))
break;
}
if(TOKEN1(a))
{
#if(NO)
RAT_error(ERROR,OC("Expected identifier after \"%s\""),1,"interface");
#endif
BACK_UP
cur_fcn= NO_FCN;
is_function= NO;
}
else
{
cur_fcn= IDENTIFIER(a,next_byte());
is_function= NO;
}
id0(id_interface);id0(cur_fcn);
if(cur_fcn==id_procedure)
{
COPY_TO(073);NL;
}
else
{
b= next_byte();BACK_UP
if(b==050)PARENS;
NL;
EAT_AUTO_SEMI;
skip_newlines(COPY_COMMENTS);
INDENT;
copy_out(insert.interface.start,insert.interface.end,!macro);
out_char(073);
COPY_2TO(0173,NOT_AFTER);
if(psave_buffer>save_buffer)NL;
brace_level++;
stmt(TO_OUTPUT,BRACE_ONLY);
brace_level--;
OUTDENT;
id0(id__END);
if(Fortran88){id0(id_interface);id0(cur_fcn);}
NL;
}
cur_fcn= NO_FCN;
rlevel--;
}
X_FCN
x_block(VOID)
{
sixteen_bits a;
if(TOKEN1(a= next_byte()))
{
BACK_UP
id0(id_block);
}
else
{
a= IDENTIFIER(a,next_byte());
if(a==id_data)x_blockdata();
else
{
BACK_UP
id0(a);
}
}
}
X_FCN
x_contains(VOID)
{
OUTDENT;
id0(id__CONTAINS);
char_after(':');
NL;
INDENT;
}
X_FCN x_type(VOID)
{
sixteen_bits a;
eight_bits b;
b= next_byte();BACK_UP
if(b==054){}
else if(b==050)
{
id0(id_type);
return;
}
expanding(type_CMD);
if(TOKEN1(a= next_byte()))
{
RAT_error(ERROR,OC("Expected identifier after \"%s\""),1,"type");
BACK_UP
cur_struct= NO_FCN;
}
else
{
cur_struct= IDENTIFIER(a,next_byte());
}
id0(id_type);id0(cur_struct);
NL;
INDENT;
brace_level++;
stmt(TO_OUTPUT,BRACE_ONLY);
brace_level--;
OUTDENT;
id0(id__END);id0(id_type);id0(cur_struct);
char_after(';');OUT_CHAR(';');
wlevel--;
rlevel--;
}
X_FCN
x_return(VOID)
{
eight_bits HUGE*return_expr= NULL,HUGE*pr;
expanding(return_CMD);
/* Save the return expression, if it's there. */
if((pr= SAVE_AFTER(&return_expr,SAVE8,073))>return_expr)
{
if(!is_function)
RAT_error(ERROR,OC("Can't return value from program or subroutine"),0);
else
{
out_cmd(YES,'r',OC(""),OC(" %s"),2,return_expr,pr);
id0(cur_fcn);EQUALS;
copy_out(return_expr,pr,!macro);NL;
}
}
RETURN;
rlevel--;
FREE_MEM(return_expr,"return_expr",SAVE8,eight_bits);
}
X_FCN
x_unroll(VOID)
{
eight_bits HUGE*I= NULL,HUGE*pI;
eight_bits HUGE*Imin= NULL,HUGE*pImin;
eight_bits HUGE*Imax= NULL,HUGE*pImax;
eight_bits HUGE*Di= NULL,HUGE*pDi;
eight_bits HUGE*txt= NULL,HUGE*ptxt;
int i,imin,imax,di;
name_pointer n;
text_pointer t;
eight_bits temp[20];
extern int last_bytes;
extern boolean saved_token;
eight_bits c;
expanding(_DO_CMD);
{
eight_bits c;
if((c= next_byte())!='(')
{
didnt_expand('(',c,"$DO");
return;
}
};
pI= SAVE_AFTER(&I,SAVE8,054);
if(TOKEN1(*I))
{
RAT_error(ERROR,OC("Expected identifier for first argument of $DO; \
expansion aborted"),0);
return;
}
pImin= SAVE_AFTER(&Imin,SAVE8,054);
imin= neval(Imin,pImin);
pImax= SAVE_AFTER(&Imax,SAVE8,054);
imax= neval(Imax,pImax);
pDi= SAVE_AFTER(&Di,SAVE8,051);
di= neval(Di,pDi);
EAT_AUTO_SEMI;
skip_newlines(NO);
c= next_byte();
if(!(c==0173||c==050))
{
RAT_error(ERROR,OC("Was expecting '{' or '(', not '%c', after $DO(); \
expansion aborted"),1,XCHR(c));
return;
}
/* Absorb the body of the |$DO|. Tell |next_byte| to not expand macros, so \
the loop counter can be used as an argument to a macro such as |$IFCASE|. */
mac_protected= YES;
ptxt= SAVE_AFTER(&txt,BIG_SAVE8,c==0173?0175:051);
mac_protected= NO;
n= name_dir+IDENTIFIER(*I,*(I+1));
n->info.Macro_type= IMMEDIATE_MACRO;
t= GET_MEM("equiv",2,text);
n->equiv_or_xref= (EQUIV)t;
t->tok_start= temp;
t->moffset= 2;
if(!((di>=0&&imax<imin)||(di<0&&imax>imin)))
for(i= imin;di>=0?i<=imax:i>=imax;i+= di)
{
STRNCPY(temp,I,2);
sprintf((char*)(temp+2),"%c%d%c",XCHR(constant),i,XCHR(constant));
to_ASCII(temp+2);
#if 0
(t+1)->tok_start= temp+STRLEN(temp);
#endif
t->nbytes= STRLEN(temp);
copy_out(txt,ptxt,!macro);
if(i==imax)
break;
}
rlevel--;
FREE_MEM(t,"t",2,text);
n->equiv_or_xref= NULL;
n->info.Macro_type= NOT_DEFINED;
FREE_MEM(I,"unroll:I",SAVE8,eight_bits);
FREE_MEM(Imin,"unroll:Imin",SAVE8,eight_bits);
FREE_MEM(Imax,"unroll:Imax",SAVE8,eight_bits);
FREE_MEM(txt,"unroll:txt",SAVE8,eight_bits);
}
SRTN
ini_Ratfor(VOID)
{
insert.program.start= insert.program.end=
GET_MEM("program",2,eight_bits);
insert.module.start= insert.module.end=
GET_MEM("module",2,eight_bits);
insert.subroutine.start= insert.subroutine.end=
GET_MEM("subroutine",2,eight_bits);
insert.function.start= insert.function.end=
GET_MEM("function",2,eight_bits);
insert.blockdata.start= insert.blockdata.end=
GET_MEM("blockdata",2,eight_bits);
insert.interface.start= insert.interface.end=
GET_MEM("interface",2,eight_bits);
}
#endif /* Part 2 */
|