tokenizer v 1.0.2, contribution by David Paktor <dlpaktor@netscape.net> git-svn-id: svn://coreboot.org/openbios/fcode-utils@100 f158a5a8-5612-0410-a976-696ce0be7e32
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
diff --git a/toke/Makefile b/toke/Makefile
index d151df6..14ae095 100644
--- a/toke/Makefile
+++ b/toke/Makefile
@@ -29,7 +29,7 @@ STRIP = strip
INCLUDES = -I../shared
# Normal flags
-CFLAGS = -O2 -Wall -Wno-pointer-sign -fno-strict-aliasing -DSYS_IS_GNU_Linux
+CFLAGS = -O2 -Wall -Wno-pointer-sign -fno-strict-aliasing
LDFLAGS =
# Coverage:
diff --git a/toke/clflags.c b/toke/clflags.c
index 19cea65..1a67a3b 100644
--- a/toke/clflags.c
+++ b/toke/clflags.c
@@ -104,6 +104,7 @@ bool verbose_dup_warning = TRUE ;
bool obso_fcode_warning = TRUE ;
bool trace_conditionals = FALSE ;
bool big_end_pci_image_rev = FALSE ;
+bool allow_ret_stk_interp = TRUE ;
/* And one to trigger a "help" message */
bool clflag_help = FALSE;
@@ -242,6 +243,11 @@ static const cl_flag_t cl_flags_list[] = {
"Save the Vendor's Rev Level field of the PCI Header"
" in Big-Endian format" } ,
+ { "Ret-Stk-Interp",
+ &allow_ret_stk_interp,
+ "\t\t",
+ "Allow Return-Stack Operations during Interpretation" } ,
+
/* Keep the "help" pseudo-flag last in the list */
{ "help",
diff --git a/toke/clflags.h b/toke/clflags.h
index 26f923d..25818ab 100644
--- a/toke/clflags.h
+++ b/toke/clflags.h
@@ -124,6 +124,7 @@ extern bool big_end_pci_image_rev;
extern bool force_tokens_case;
extern bool force_lower_case_tokens;
+extern bool allow_ret_stk_interp;
extern bool clflag_help;
diff --git a/toke/devnode.c b/toke/devnode.c
index 54ec03f..9a06bed 100644
--- a/toke/devnode.c
+++ b/toke/devnode.c
@@ -580,7 +580,7 @@ bool exists_in_ancestor( char *m_name)
}
if ( grandpa != NULL )
{
- char as_what_buf[32] = "";
+ char as_what_buf[AS_WHAT_BUF_SIZE] = "";
if ( as_a_what( found->fword_defr, as_what_buf) )
{
strcat( as_what_buf, " ");
diff --git a/toke/dictionary.c b/toke/dictionary.c
index dcc7bde..d22c218 100644
--- a/toke/dictionary.c
+++ b/toke/dictionary.c
@@ -50,6 +50,7 @@
#include "errhandler.h"
#include "tokzesc.h"
#include "conditl.h"
+#include "tracesyms.h"
/* **************************************************************************
*
@@ -87,9 +88,47 @@
* Begin development of implementation of a way to define both (all?)
* types of definitions in a single tic_hdr_t type vocabulary.
*
+ * Wed, 04 Oct 2006 by David L. Paktor
+ * Issue a message when a name on the trace list is invoked (as well
+ * as when it is created), but keep a limit on the speed penalty.
+ * (I.e., don't scan the trace-list for every symbol invoked.)
+ * We will scan the trace-list for every pre-defined symbol during
+ * initialization of the built-in vocabularies' lists, but that
+ * occurs only once...
+ *
**************************************************************************** */
+/* **************************************************************************
+ *
+ * Global Variables Exported
+ *
+ * scope_is_global Indication that "global" scope is in effect
+ *
+ * define_token Normally TRUE, but if the definition in progress
+ * occurs inside a control-structure, (which is an Error), we
+ * make this FALSE. We will allow the definition to proceed
+ * (in order to avoid "cascade" errors and so that other errors
+ * can be recognized normally) but we will use this to suppress
+ * adding the new definition's token to the vocab. We also use
+ * this to suppress the actions of "hide_..." and "reveal..."
+ * because if the token wasn't added to the vocabulary, there's
+ * nothing to find that needed to be "hidden"...
+ *
+ **************************************************************************** */
+
+bool scope_is_global = FALSE;
+bool define_token = TRUE; /* TRUE = Normal definition process;
+ * FALSE when definition is an Error.
+ * We enter definition state anyway,
+ * but must still suppress:
+ * (1) adding an entry for the token
+ * to the vocab,
+ * (2) "hiding" it at first, and
+ * (3) "revealing" it later.
+ *
+ * Makes for more "normal" error- detection...
+ */
/* **************************************************************************
*
@@ -170,6 +209,8 @@
/* **************************************************************************
*
+ * Internal Static Variables
+ *
* We'll be initializing the lists later, but will be referencing
* the pointers sooner, so we need to declare the pointers here.
*
@@ -278,20 +319,20 @@ static void emit_fc_token( tic_param_t pfield)
#define FC_TOKEN_FUNC emit_fc_token
#define BUILTIN_FCODE( tok, nam) \
- VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , UNSPECIFIED )
+ VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , UNSPECIFIED, TRUE )
/* Built-in FCodes with known definers: */
#define BI_FCODE_VALUE( tok, nam) \
- VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , VALUE )
+ VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , VALUE, TRUE )
#define BI_FCODE_VRBLE( tok, nam) \
- VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , VARIABLE )
+ VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , VARIABLE, TRUE )
#define BI_FCODE_DEFER( tok, nam) \
- VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , DEFER )
+ VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , DEFER, TRUE )
#define BI_FCODE_CONST( tok, nam) \
- VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , CONST )
+ VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , CONST, TRUE )
/* **************************************************************************
*
@@ -322,10 +363,10 @@ static void obsolete_fc_token( tic_param_t pfield)
#define OBSO_FC_FUNC obsolete_fc_token
#define OBSOLETE_FCODE( tok, nam) \
- VALPARAM_TIC(nam, OBSO_FC_FUNC, tok , UNSPECIFIED )
+ VALPARAM_TIC(nam, OBSO_FC_FUNC, tok , UNSPECIFIED, TRUE )
#define OBSOLETE_VALUE( tok, nam) \
- VALPARAM_TIC(nam, OBSO_FC_FUNC, tok , VALUE )
+ VALPARAM_TIC(nam, OBSO_FC_FUNC, tok , VALUE, TRUE )
/* **************************************************************************
@@ -457,9 +498,6 @@ void skip_string( tic_param_t pfield);
**************************************************************************** */
static tic_hdr_t **save_device_definitions;
-/* Export the indication that "global" scope is in effect */
-bool scope_is_global = FALSE;
-
void enter_global_scope( void )
{
@@ -626,20 +664,24 @@ static tic_hdr_t *save_current = NULL;
* name The name of the new entry
* fc_token The new entry's assigned FCode-number
* fw_definer The new entry's definer
- * define_token If FALSE, suppress adding the entry,
- * but preserve the side-effect of
- * setting save_current
* Global Variables:
* current_definitions Pointer to pointer to "tail" of the
* Vocabulary currently in effect;
* either Device-node or Global.
+ * define_token TRUE = Normal definition process;
+ * FALSE if def'n is an Error.
+ * Suppress adding entry to vocab;
+ * Display "failure" Trace-note
+ * and Duplicate-Name Warning.
*
* Outputs:
* Returned Value: NONE
* Global Variables:
* *current_definitions Updated with the new entry
* Local Static Variables:
- * save_current Pointer to previous entry
+ * save_current Saved state of current_definitions
+ * before the new entry is added,
+ * to permit "hide" and "reveal".
* Memory Allocated
* For the new entry's copy of the name.
* When Freed?
@@ -653,34 +695,38 @@ static tic_hdr_t *save_current = NULL;
* All user-defined words have the same action, i.e., emitting
* the assigned FCode-number. The new entry's "parameter
* field" size is, of course, zero; the "ignore-function"
- * is NULL.
+ * is NULL, and the entry has a single-token FCode number.
*
* Extraneous Remarks:
- * The define_token parameter is a late addition, necessitated
- * by the decision to continue processing after an erroneous
+ * The define_token input is a late addition, necessitated by
+ * the decision to continue processing after an erroneous
* attempt to create a definition inside a control-structure,
* in order to catch other errors.
*
- *
**************************************************************************** */
void add_to_current( char *name,
TIC_P_DEFLT_TYPE fc_token,
- fwtoken definer,
- bool define_token)
+ fwtoken definer)
{
- save_current = *current_definitions;
if ( define_token )
{
char *nu_name = strdup( name);
+
+ save_current = *current_definitions;
add_tic_entry( nu_name, FC_TOKEN_FUNC, fc_token,
- definer, 0 , NULL, current_definitions );
+ definer, 0 , TRUE , NULL, current_definitions );
+ }else{
+ trace_create_failure( name, NULL, fc_token);
+ warn_if_duplicate( name);
}
}
void hide_last_colon ( void )
{
+ if ( define_token )
+ {
tic_hdr_t *temp_vocab;
/* The add_to_current() function will have been called before this
@@ -692,16 +738,20 @@ void hide_last_colon ( void )
temp_vocab = save_current ;
save_current = *current_definitions;
*current_definitions = temp_vocab;
+ }
}
void reveal_last_colon ( void )
{
+ if ( define_token )
+ {
/* We call this function either when the colon-definition is
* completed, or when "recursive"-ness is intentional.
*/
*current_definitions = save_current ;
}
+}
/* **************************************************************************
@@ -724,6 +774,15 @@ void reveal_last_colon ( void )
* current_definitions Device-node vocabulary currently
* in effect.
* scope_is_global TRUE if "global" scope is in effect
+ * split_alias_message Message-type for announcement that
+ * the "new" name was created in
+ * a different vocabulary than where
+ * the "old" name was found, if so
+ * be. (See "Rule 3", below). An
+ * Advisory, normally, but if either
+ * of the names is being Traced, the
+ * create_split_alias() routine will
+ * change it to a Trace-Note.
* Local Static Variables:
* global_voc_dict_ptr "Tail" of Global Vocabulary
*
@@ -766,35 +825,52 @@ void reveal_last_colon ( void )
*
* And one other thing:
* We will always make the alias's pfld_size zero. See the
- * prolog for create_tic_alias() in ticvocab.c for details...
+ * prolog for create_split_alias() in ticvocab.c for details...
*
* Extraneous Remarks:
- * I will stretch the rules of well-structured code here, too.
+ * I tried stretching the rules of well-structured code, but
+ * I'm finding that there is a _good_reason_ for them...
*
**************************************************************************** */
bool create_current_alias( char *new_name, char *old_name )
{
bool retval = FALSE;
+ bool split_alias = FALSE;
+ /* Rules 1 & 2 are implemented in the same code. */
if ( create_tic_alias( new_name, old_name, current_definitions) )
{
- return ( TRUE );
- }
-
+ retval = TRUE;
+ }else{
if ( INVERSE(scope_is_global) )
{
- tic_hdr_t *found = lookup_core_word( old_name );
- if ( found != NULL )
- {
- add_tic_entry( new_name, found->funct,
- found->pfield.deflt_elem,
- found->fword_defr,
- 0, found->ign_func,
+ /* Rule 3.
+ * Because the vocab into which the new definition will go is
+ * not the same as the one in which the old name was found,
+ * we cannot call create_tic_alias but must replicate it.
+ */
+ /* Hmmmmmm.....
+ * We could get around that by refactoring: add a parameter,
+ * make the vocab to search separate from the one in which to
+ * create. Also, by making it a separate routine, we won't
+ * have to disturb the other callers of create_tic_alias()
+ * Yes! Excellent! Make it so!
+ */
+ split_alias = TRUE;
+ split_alias_message = INFO;
+ retval = create_split_alias(
+ new_name, old_name,
+ &global_voc_dict_ptr,
current_definitions );
- retval = TRUE;
+ }
+ }
+
+ if ( retval )
{
- tokenization_error( INFO,
+ if ( split_alias )
+ {
+ tokenization_error( split_alias_message,
"%s is a Global definition, but its alias, %s, "
"will only be defined %s",
strupr( old_name), new_name,
@@ -802,7 +878,6 @@ bool create_current_alias( char *new_name, char *old_name )
show_node_start();
}
}
- }
return ( retval );
}
@@ -1347,18 +1422,29 @@ tic_hdr_t *lookup_token( char *tname)
*
* Process Explanation:
* We cannot rely on the "definer" field to indicate whether
- * it is a single-token entry; instead, we will look at
- * the associated function.
- * Keep this routine here to avoid needing to export the names
- * of the permitted functions or their synonymous macros.
- * If we ever need to change it, we can do so at a single
- * point of maintenance.
- * Because the entry might have been found in the initial list
- * of entries to the "FCode-Tokens" list, we need to check
- * whether the associated function is either the general
- * single-token emitting function, FC_TOKEN_FUNC , or the
- * function OBSO_FC_FUNC , which presents a message before
- * emitting, but is still a valid single-token function.
+ * it is a single-token entry, and there too many possible
+ * associated functions to be practical; instead we will
+ * look at the is_token flag of the data structure.
+ *
+ * Revision History:
+ * Updated Mon, 25 Sep 2006 by David L. Paktor
+ * Previously operated by examining the function associated
+ * with the entry, accepting the general single-token
+ * emitting function, FC_TOKEN_FUNC , and later adding
+ * the function OBSO_FC_FUNC , which presents a message
+ * before emitting. Now the functions that present a
+ * message before emitting might be about to proliferate,
+ * rendering this implementation strategy impractical (i.e.,
+ * ugly to code and too attention-demanding to maintain)
+ * Instead, I will introduce a flag into the TIC-entry
+ * data-structure and rely on it.
+ * Updated Wed, 11 Oct 2006 by David L. Paktor
+ * Discarded plan to have functions that present a "Trace-Note"
+ * message prior to performing their other duties (just too
+ * unwieldly all around) in favor of adding a "tracing" flag
+ * to the TIC_HDR data-structure. Could have gone back to
+ * doing this the other way, but this is so much neater a
+ * solution that I'm keeping it.
*
**************************************************************************** */
@@ -1367,11 +1453,7 @@ bool entry_is_token( tic_hdr_t *test_entry )
bool retval = FALSE;
if ( test_entry != NULL )
{
- if ( ( test_entry->funct == FC_TOKEN_FUNC ) ||
- ( test_entry->funct == OBSO_FC_FUNC ) )
- {
- retval = TRUE;
- }
+ retval = test_entry->is_token;
}
return ( retval );
}
@@ -1836,9 +1918,10 @@ void init_dictionary( void )
* Inputs:
* Parameters: NONE
* Global Variables:
+ * current_device_node Vocab struct of current dev-node
+ * Local Static Variables:
* global_voc_reset_ptr Position to which to reset
* the "Global" Vocabulary
- * current_device_node Vocab struct of current dev-node
*
* Outputs:
* Returned Value: NONE
diff --git a/toke/emit.c b/toke/emit.c
index 7ca55ef..bbc59b6 100644
--- a/toke/emit.c
+++ b/toke/emit.c
@@ -30,6 +30,19 @@
* Modifications Author: David L. Paktor dlpaktor@us.ibm.com
**************************************************************************** */
+/* **************************************************************************
+ *
+ * Still to be done:
+ * Re-arrange routine and variable locations to clarify the
+ * functions of this file and its companion, stream.c
+ * This file should be concerned primarily with management
+ * of the Outputs; stream.c should be primarily concerned
+ * with management of the Inputs.
+ * Hard to justify, pragmatically, but will make for easier
+ * maintainability down the proverbial road...
+ *
+ **************************************************************************** */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -58,6 +71,20 @@
/* **************************************************************************
*
+ * Global Variables Exported:
+ * opc Output Buffer Position Counter
+ * pci_hdr_end_ob_off Offsets into Output Buffer of end
+ * of last PCI Header Block structure
+ * (To help match up the offset printed in Tokenization_error()
+ * with the offsets shown by the DeTokenizer)
+ *
+ **************************************************************************** */
+
+unsigned int opc = 0;
+unsigned int pci_hdr_end_ob_off = 0; /* 0 means "Not initialized" */
+
+/* **************************************************************************
+ *
* Macro to zero-fill a field of the size of the given structure
* into the Output Buffer using the emit_byte() routine.
*
@@ -113,8 +140,8 @@ extern void increase_output_buffer( void);
/* **************************************************************************
*
* Function name: init_emit
- * Synopsis: Initialize Local Static Variables before starting
- * Output.
+ * Synopsis: Initialize Output-related Local Static and Global
+ * Variables before starting Output.
* Exposure as Limited as possible.
*
**************************************************************************** */
@@ -126,6 +153,8 @@ void init_emit( void)
fcode_body_ob_off = -1;
pci_hdr_ob_off = -1;
pci_data_blk_ob_off = -1;
+ opc = 0;
+ pci_hdr_end_ob_off = 0;
fcode_written = FALSE;
haveend = FALSE; /* Get this one too... */
}
@@ -462,13 +491,19 @@ static void emit_pci_data_block(void)
* Inputs:
* Parameters: NONE
* Global Variables:
+ * opc Output Buffer Position Counter
* fcode_start_ob_off Initted if FCode output has begun
* noerrors The "Ignore Errors" flag
*
* Outputs:
* Returned Value: NONE
* Global Variables:
- * FCode Output buffer:
+ * pci_hdr_end_ob_off Set to the Output Buffer Position
+ * Counter after the PCI Header
+ * FCode Output buffer
+ * :The beginning of the PCI Header will be entered, waiting for
+ * the fields that could not be determined until the end
+ * to be filled in.
*
* Error Detection:
* An attempt to write a PCI Header after FCode output -- either an
@@ -496,6 +531,8 @@ void emit_pcihdr(void)
emit_pci_rom_hdr();
emit_pci_data_block();
+
+ pci_hdr_end_ob_off = opc;
}
/* **************************************************************************
@@ -561,8 +598,18 @@ void finish_pcihdr(void)
pci_hdr_ob_off = -1;
pci_data_blk_ob_off = -1;
+ pci_hdr_end_ob_off = 0;
}
+
+/* **************************************************************************
+ *
+ * Function name: finish_headers
+ * Synopsis: Fill-in the fields of the FCode- and PCI- Headers
+ * that could not be determined until the end.
+ *
+ *************************************************************************** */
+
void finish_headers(void)
{
if (fcode_hdr_ob_off != -1) finish_fcodehdr();
diff --git a/toke/emit.h b/toke/emit.h
index 987d210..85d1ef2 100644
--- a/toke/emit.h
+++ b/toke/emit.h
@@ -96,6 +96,15 @@ typedef struct {
/* ************************************************************************** *
*
+ * Global Variables Exported
+ *
+ **************************************************************************** */
+
+extern unsigned int opc;
+extern unsigned int pci_hdr_end_ob_off;
+
+/* ************************************************************************** *
+ *
* Function Prototypes / Functions Exported:
*
**************************************************************************** */
diff --git a/toke/errhandler.c b/toke/errhandler.c
index a07a6a9..81d8a22 100644
--- a/toke/errhandler.c
+++ b/toke/errhandler.c
@@ -59,6 +59,14 @@
*
**************************************************************************** */
+/* **************************************************************************
+ *
+ * Revision History:
+ * Updated Fri, 13 Oct 2006 by David L. Paktor
+ * Added "(Output Position ..." to standard message format.
+ *
+ **************************************************************************** */
+
/* **************************************************************************
*
@@ -89,13 +97,18 @@
* It's a deprecated feature, or one
* that might be incompatible with
* other standard tokenizers.
+ *
+ * Other types of Messages fall into these broad categories:
* INFO Nothing is changed in processing, but
- * an advisory is still in order.
+ * an advisory is still in order. Omitted
+ * if "verbose" is not specified.
* MESSAGE Message generated by the user. (Complete;
* new-line will be added by display routine.)
* P_MESSAGE Partial Message -- Instigated by user, but
* pre-formatted and not complete. New-line
* will be added by follow-up routine.
+ * TRACER Message related to the trace-symbols option;
+ * either a creation or an invocation message.
*
**************************************************************************** */
@@ -108,6 +121,7 @@
#include "types.h"
#include "toke.h"
#include "stream.h"
+#include "emit.h"
#include "errhandler.h"
#include "scanner.h"
@@ -118,6 +132,9 @@
* lineno Current line-number being processed
* noerrors "Ignore Errors" flag, set by "-i" switch
* opc FCode Output Buffer Position Counter
+ * pci_hdr_end_ob_off
+ * Position in FCode Output Buffer of
+ * end of last PCI Header Block structure
* verbose If true, enable Advisory Messages
*
**************************************************************************** */
@@ -139,6 +156,7 @@
* warn_count Count of Warning Messages
* info_count Count of "Advisory" Messages
* user_msg_count Count of User-generated Messages
+ * trace_msg_count Count of Trace-Note Messages
* fatal_err_exit Exit code to be used for "Fatal" error.
* This is a special accommodation
* for the safe_malloc routine.
@@ -147,12 +165,13 @@
static bool print_msg ;
static int errs_to_print = ( FATAL | TKERROR | WARNING |
- MESSAGE | P_MESSAGE | FORCE_MSG ) ;
+ MESSAGE | P_MESSAGE | TRACER | FORCE_MSG ) ;
static int err_types_found = 0 ;
static int err_count = 0 ;
static int warn_count = 0 ;
static int info_count = 0 ;
static int user_msg_count = 0 ;
+static int trace_msg_count = 0 ;
static int fatal_err_exit = -1 ;
static FILE *message_dest; /* Would like to init to ERRMSG_DESTINATION
* here, but the compiler complains...
@@ -186,15 +205,14 @@ static const err_category error_categories[] = {
{ WARNING, "Warning" , "", "s", &warn_count , FALSE },
{ INFO, "Advisor" , "y", "ies", &info_count , FALSE },
{ MESSAGE , "Message" , "", "s", &user_msg_count , TRUE },
- { P_MESSAGE , "Message" , "", "s", &user_msg_count , FALSE }
+ { P_MESSAGE , "Message" , "", "s", &user_msg_count , FALSE },
+ { TRACER , "Trace-Note" , "", "s", &trace_msg_count , FALSE }
};
static const int num_categories =
( sizeof(error_categories) / sizeof(err_category) );
-#ifdef NEEDS_STRUPR
-
/* **************************************************************************
*
* Function name: toup
@@ -328,8 +346,6 @@ char *strlower( char *strung)
}
-#endif /* NEEDS_STRUPR */
-
/* **************************************************************************
*
* Function name: init_error_handler
@@ -359,6 +375,7 @@ char *strlower( char *strung)
* warn_count Count of Warning Messages
* info_count Count of "Advisory" Messages
* user_msg_count Count of User-generated Messages
+ * trace_msg_count Count of Trace-Note Messages
* Other Exotic Effects:
* Flush stdout if Error message destination is not stdout, to
* avoid collisions with stderr once Error Messaging begins.
@@ -371,13 +388,18 @@ char *strlower( char *strung)
void init_error_handler( void)
{
+ int indx ;
+
message_dest = ERRMSG_DESTINATION;
if ( verbose ) errs_to_print |= INFO ;
err_types_found = 0 ;
- err_count = 0 ;
- warn_count = 0 ;
- info_count = 0 ;
- user_msg_count = 0 ;
+
+ /* Start at indx = 1 to skip resetting FATALs */
+ for ( indx = 1; indx < num_categories ; indx ++ )
+ {
+ *(error_categories[indx].counter) = 0 ;
+ }
+
FFLUSH_STDOUT
}
@@ -397,6 +419,11 @@ void init_error_handler( void)
* iname Name of file currently being processed
* lineno Current line-number being processed
* fatal_err_exit Exit code for "Fatal" error, if applicable.
+ * opc FCode Output Buffer Position Counter
+ * pci_hdr_end_ob_off
+ * Position in FCode Output Buffer of end
+ * of last PCI Header Block structure
+
* Macro:
* ERRMSG_DESTINATION Error message destination;
* (Development-time switch)
@@ -444,6 +471,11 @@ void init_error_handler( void)
* Error-Category string also identifies the applicable
* Category Counter; increment it.
* Of course, there's no return from a FATAL error; it exits.
+ * The Message will show:
+ * The Error-Category (always)
+ * The Input File-name and Line Number (if input file was opened)
+ * The Output Buffer Position (if output has begun)
+ * The PCI-Block Position (if different from Output Buffer Pos'n)
*
**************************************************************************** */
@@ -490,14 +522,24 @@ void tokenization_error( int err_type, char* msg, ... )
{
va_list argp;
+ fprintf(ERRMSG_DESTINATION, "%s%s: ",
+ catgy_name, catgy_suffx);
if ( iname != NULL )
{
- fprintf(ERRMSG_DESTINATION, "%s%s: File %s, Line %d. ",
- catgy_name, catgy_suffx, iname, lineno);
- }else{
/* Don't print iname or lineno if no file opened. */
- fprintf(ERRMSG_DESTINATION, "%s%s: ",
- catgy_name, catgy_suffx);
+ fprintf(ERRMSG_DESTINATION, "File %s, Line %d. ",
+ iname, lineno);
+ }
+ if ( opc > 0 )
+ {
+ /* Don't print Output Position if no output started. */
+ fprintf(ERRMSG_DESTINATION, "(Output Position = %d). ", opc);
+ }
+ if ( pci_hdr_end_ob_off > 0 )
+ {
+ /* Don't print PCI-Block Position if no PCI-Block in effect. */
+ fprintf(ERRMSG_DESTINATION, "(PCI-Block Position = %d). ",
+ opc - pci_hdr_end_ob_off );
}
va_start(argp, msg);
@@ -618,7 +660,7 @@ static void print_where_started( bool show_started,
if ( may_show_incolon )
{
- in_last_colon();
+ in_last_colon( TRUE );
}else{
fprintf(message_dest, "\n");
}
@@ -765,7 +807,10 @@ void just_where_started( char * saved_ifile, unsigned int saved_lineno)
* Can be used to finish the line in either case.
*
* Inputs:
- * Parameters: NONE
+ * Parameters:
+ * say_in If TRUE, lead phrase with " in ".
+ * If FALSE, print even if not
+ * inside a Colon-def'n.
* Global Variables:
* incolon TRUE if Colon-definition is in progress
* last_colon_defname Name of last colon-definition
@@ -787,17 +832,17 @@ void just_where_started( char * saved_ifile, unsigned int saved_lineno)
* Because this routine does some of its own printing, it needs
* to check the residual state of print_msg first.
* The calling routine does not need to test incolon ; it can
- * call this to end the line in either case.
+ * call this (with TRUE) to end the line in either case.
*
**************************************************************************** */
-void in_last_colon( void )
+void in_last_colon( bool say_in )
{
if ( print_msg )
{
- if ( incolon )
+ if ( incolon || ( ! say_in ) )
{
- fprintf( message_dest, " in definition of %s ",
+ fprintf( message_dest, "%s definition of %s ", say_in ? " in" : "",
strupr( last_colon_defname) );
print_where_started( TRUE, FALSE,
last_colon_filename, last_colon_lineno, FALSE);
diff --git a/toke/errhandler.h b/toke/errhandler.h
index e714d69..59f286a 100644
--- a/toke/errhandler.h
+++ b/toke/errhandler.h
@@ -44,6 +44,7 @@
#define TKERROR 0x04000000
#define WARNING 0x00200000
#define INFO 0x00010000
+#define TRACER 0x00008000
#define MESSAGE 0x00000800
#define P_MESSAGE 0x00000040
#define FORCE_MSG 0x00000001
@@ -55,7 +56,7 @@ void print_started_at( char * saved_ifile, unsigned int saved_lineno);
void just_started_at( char * saved_ifile, unsigned int saved_lineno);
void where_started( char * saved_ifile, unsigned int saved_lineno);
void just_where_started( char * saved_ifile, unsigned int saved_lineno);
-void in_last_colon( void );
+void in_last_colon( bool say_in );
_PTR safe_malloc( size_t size, char *phrase);
bool error_summary( void ); /* Return TRUE if OK to produce output. */
@@ -88,16 +89,6 @@ bool error_summary( void ); /* Return TRUE if OK to produce output. */
#define FFLUSH_STDOUT /* Don't need to do anything here */
#endif /* Switchable error-message destination */
-/* Some systems don't seem to have strupr */
-#ifdef SYS_IS_GNU_Linux
-#define NEEDS_STRUPR
-#endif /* SYS_IS_GNU_Linux */
-#ifdef SYS_IS_AIX
-#define NEEDS_STRUPR
-#endif /* SYS_IS_AIX */
-/* ??? Should this instead be tuned to Proc'r is PPC ??? Why? */
-
-#ifdef NEEDS_STRUPR
/* **************************************************************************
*
@@ -114,6 +105,4 @@ extern char *strlower( char *strung);
#define strlwr strlower
-#endif /* NEEDS_STRUPR */
-
#endif /* _TOKE_ERRHANDLER_H */
diff --git a/toke/flowcontrol.c b/toke/flowcontrol.c
index b936fd2..11903cb 100644
--- a/toke/flowcontrol.c
+++ b/toke/flowcontrol.c
@@ -479,7 +479,7 @@ static bool control_stack_size_test( int min_depth )
retval = FALSE;
tokenization_error ( TKERROR,
"Control-Stack underflow at %s", strupr(statbuf) );
- in_last_colon();
+ in_last_colon( TRUE);
not_cs_underflow = FALSE; /* See expl'n early on in this file */
}
diff --git a/toke/macros.c b/toke/macros.c
index 17c01cb..6bc3070 100644
--- a/toke/macros.c
+++ b/toke/macros.c
@@ -57,13 +57,13 @@
#include <string.h>
#include <errno.h>
+#include "macros.h"
#include "errhandler.h"
#include "ticvocab.h"
#include "stream.h"
#include "scanner.h"
#include "dictionary.h"
#include "devnode.h"
-#include "macros.h"
/* **************************************************************************
*
@@ -297,7 +297,15 @@ static tic_mac_hdr_t macros_tbl[] = {
BUILTIN_MACRO( "blank", "bl fill") ,
BUILTIN_MACRO( "carret", "h# d") ,
BUILTIN_MACRO( ".d", "base @ swap h# a base ! . base !") ,
- BUILTIN_MACRO( "decode-bytes", ">r over r@ + swap r@ - rot r>") ,
+
+ /* Note: The Standard gives: ">r over r@ + swap r@ - rot r>"
+ * as its example of the macro for decode-bytes
+ * But here's one that does the same thing without
+ * using return-stack operations. And it's one step
+ * shorter, into the bargain!
+ */
+ BUILTIN_MACRO( "decode-bytes", "tuck - -rot 2dup + swap 2swap rot") ,
+
BUILTIN_MACRO( "3drop", "drop 2drop") ,
BUILTIN_MACRO( "3dup", "2 pick 2 pick 2 pick") ,
BUILTIN_MACRO( "erase", "0 fill") ,
@@ -473,9 +481,6 @@ void add_user_macro( void)
tic_hdr_t **target_vocab = current_definitions;
if ( in_tokz_esc ) target_vocab = &tokz_esc_vocab ;
- warn_if_duplicate( macroname);
- trace_creation( MACRO_DEF, macroname);
-
/* Tack on a new-line, so that a remark will appear
* to be properly terminated. This might trigger
* an undeserved multi-line warning if the Macro
@@ -489,7 +494,7 @@ void add_user_macro( void)
add_tic_entry( macroname, EVAL_MAC_FUNC,
(TIC_P_DEFLT_TYPE)macrobody,
- MACRO_DEF, mac_body_len,
+ MACRO_DEF, mac_body_len, FALSE,
EVAL_MAC_FUNC, target_vocab );
failure = FALSE;
}
diff --git a/toke/nextfcode.c b/toke/nextfcode.c
index c76015a..3f63ec0 100644
--- a/toke/nextfcode.c
+++ b/toke/nextfcode.c
@@ -556,8 +556,6 @@ void set_next_fcode( u16 new_fcode)
* Inputs:
* Parameters:
* test_fcode FCode to be tested
- * Global Variables:
- *
* Local Static Variables:
* ranges_exist If not TRUE, no need to test
* first_fc_range Start of Ranges to test
@@ -610,7 +608,7 @@ static fcode_range_t *find_overlap( u16 test_fcode)
* Parameters:
*
* Global Variables:
- * nextfcode
+ * nextfcode The FCode-number to be assigned
* Local Static Variables:
* ranges_exist TRUE if FCode Ranges have been created
* first_fc_range First entry in linked list of Ranges.
@@ -618,7 +616,6 @@ static fcode_range_t *find_overlap( u16 test_fcode)
*
* Outputs:
* Returned Value: NONE
- * Global Variables:
* Local Static Variables:
* changes_listed Reset to FALSE
* One of these two will be set to nextfcode
diff --git a/toke/parselocals.c b/toke/parselocals.c
index 84f460a..0c086b7 100644
--- a/toke/parselocals.c
+++ b/toke/parselocals.c
@@ -78,15 +78,18 @@ static const char* local_op = "@"; /* Initially Fetch */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#include "parselocals.h"
#include "ticvocab.h"
#include "dictionary.h"
#include "scanner.h"
-#include "parselocals.h"
#include "errhandler.h"
#include "clflags.h"
#include "stream.h"
+#include "emit.h"
#include "devnode.h"
#include "flowcontrol.h"
+#include "tracesyms.h"
/* **************************************************************************
*
@@ -335,8 +338,8 @@ static void add_local( TIC_P_DEFLT_TYPE lnum, char *lname)
lnamecopy = strdup( lname);
add_tic_entry( lnamecopy, invoke_local, lnum,
- LOCAL_VAL, 0, NULL, &local_names );
- trace_creation( LOCAL_VAL, lname);
+ LOCAL_VAL, 0, FALSE, NULL,
+ &local_names );
}
@@ -423,7 +426,7 @@ static bool gather_locals( bool initted, int *counter )
tokenization_error ( TKERROR,
"Excess separator -- %s -- found "
"in Local-Values declaration", statbuf);
- in_last_colon();
+ in_last_colon( TRUE);
continue;
}
}
@@ -570,7 +573,7 @@ static bool error_check_locals ( void )
if ( last_local_colon == lastcolon )
{
tokenization_error ( TKERROR, "Excess Locals Declaration");
- in_last_colon();
+ in_last_colon( TRUE);
retval = TRUE;
}else{
last_local_colon = lastcolon;
diff --git a/toke/scanner.c b/toke/scanner.c
index 16336af..e13a4ac 100644
--- a/toke/scanner.c
+++ b/toke/scanner.c
@@ -82,6 +82,9 @@ bool incolon = FALSE; /* TRUE if inside a colon definition */
bool haveend = FALSE; /* TRUE if the "end" code was read. */
int do_loop_depth = 0; /* How deep we are inside DO ... LOOP variants */
+/* State of headered-ness for name-creation */
+headeredness hdr_flag = FLAG_HEADERLESS ; /* Init'l default state */
+
/* Used for error-checking of IBM-style Locals */
int lastcolon; /* Location in output stream of latest colon-definition. */
@@ -92,6 +95,10 @@ unsigned int last_colon_lineno; /* Line number of last colon-def'n */
bool report_multiline = TRUE; /* False to suspend multiline warning */
unsigned int last_colon_abs_token_no;
+ /* Shared phrases */
+char *in_tkz_esc_mode = "in Tokenizer-Escape mode.\n";
+char *wh_defined = ", which is defined as a ";
+
/* **************************************************************************
* Local variables
**************************************************************************** */
@@ -103,13 +110,6 @@ static bool got_until_eof = FALSE ; /* TRUE to signal "unterminated" */
static unsigned int last_colon_do_depth = 0;
-/* State of headered-ness for name-creation */
-typedef enum headeredness_t {
- FLAG_HEADERLESS ,
- FLAG_EXTERNAL ,
- FLAG_HEADERS } headeredness ;
-static headeredness hdr_flag = FLAG_HEADERLESS ; /* Init'l default state */
-
/* Local variables having to do with: */
/* ... the state of the tokenization */
static bool is_instance = FALSE; /* Is "instance" is in effect? */
@@ -133,9 +133,6 @@ static bool dev_change_instance_warning = TRUE;
/* Has a gap developed between "instance" and its application? */
static bool instance_definer_gap = FALSE;
- /* Shared phrases */
-static char *in_tkz_esc_mode = "in Tokenizer-Escape mode.\n";
-
/* **************************************************************************
*
@@ -821,7 +818,7 @@ void warn_unterm( int severity, char *something, unsigned int saved_lineno)
unterm_is_colon = FALSE;
}else{
tokenization_error( severity, "Unterminated %s", something);
- in_last_colon();
+ in_last_colon( TRUE);
}
lineno = tmp;
}
@@ -1349,7 +1346,8 @@ static signed long get_string( bool pack_str)
* -delimiting whitespace character. Regard any sub-
* sequent whitespace characters as part of the string
*/
- if (*pc++=='\n') lineno++;
+ if ( *pc == '\n' ) lineno++;
+ pc++;
got_until_eof = TRUE ;
@@ -1564,7 +1562,8 @@ static void handle_user_message( char delim, bool print_it )
{
if ( *pc != '\n') pc++;
}else{
- if (*pc++=='\n') lineno++;
+ if ( *pc == '\n' ) lineno++;
+ pc++;
multiline_start = lineno;
check_multiline = TRUE;
}
@@ -1914,7 +1913,7 @@ void exit_scanner(void)
*
* Outputs:
* Returned Value: None
- * Local Static Variables:
+ * Global Variables:
* hdr_flag Adjusted to new setting
*
* Process Explanation:
@@ -2161,7 +2160,7 @@ static void must_be_deep_in_do( int how_deep )
tokenization_error( TKERROR,
"%s outside of %s structure", strupr(statbuf), deep_do);
- in_last_colon();
+ in_last_colon( TRUE);
}
}
@@ -2288,7 +2287,7 @@ static void ret_stk_balance_rpt( char *before_what, bool clear_it)
tokenization_error( WARNING,
"Possible Return-Stack %s before %s", what_flow, what_phr);
- in_last_colon();
+ in_last_colon( TRUE);
if ( clear_it )
{
@@ -2335,7 +2334,7 @@ static void ret_stk_access_rpt( void)
"Possible Return-Stack access attempt by %s "
"without value having been placed there",
strupr(statbuf) );
- in_last_colon();
+ in_last_colon( TRUE);
}
}
@@ -2462,7 +2461,7 @@ void check_name_length( signed long wlen )
*
**************************************************************************** */
-static bool definer_name(fwtoken definer, char **reslt_ptr)
+bool definer_name(fwtoken definer, char **reslt_ptr)
{
bool retval = TRUE;
switch (definer)
@@ -2533,6 +2532,11 @@ static bool definer_name(fwtoken definer, char **reslt_ptr)
* are needed, they, too, are the responsibility of the
* calling routine. The return value gives a helpful clue.
*
+ * Extraneous Remarks:
+ * We define a Macro -- kept in scanner.h --that will give the
+ * recommended length for the buffer passed to this routine.
+ * It will be called AS_WHAT_BUF_SIZE
+ *
**************************************************************************** */
bool as_a_what( fwtoken definer, char *as_what)
@@ -2639,7 +2643,7 @@ bool as_a_what( fwtoken definer, char *as_what)
*
**************************************************************************** */
-static char lookup_where_pt1_buf[32];
+static char lookup_where_pt1_buf[AS_WHAT_BUF_SIZE];
tic_hdr_t *lookup_word( char *stat_name, char **where_pt1, char **where_pt2 )
{
@@ -2883,7 +2887,10 @@ static void not_in_dict( char *stat_name)
*
* Outputs:
* Returned Value: NONE
- * Printout: Error message. Possible Advisory about
+ * Printout:
+ * Error message.
+ * Possible Advisory about where the word might be found.
+ * Trace-Note, if the word was on the Trace-List
*
* Error Detection:
* Error was detected by the calling routine...
@@ -2911,6 +2918,8 @@ static void tokenized_word_error( char *stat_name)
bool sav_in_tokz_esc = in_tokz_esc;
in_tokz_esc = INVERSE(sav_in_tokz_esc);
+ traced_name_error( stat_name);
+
found_somewhere = word_exists( stat_name, &where_pt1, &where_pt2);
if ( found_somewhere )
{
@@ -3073,88 +3082,6 @@ static void validate_instance(fwtoken definer)
/* **************************************************************************
*
- * Function name: trace_creation
- * Synopsis: If the word being created is on the Trace List,
- * display the appropriate message
- *
- * Inputs:
- * Parameters:
- * definer Internal token for the defining-word
- * nu_name The word being created
- * Global Variables:
- * verbose No point in doing all this if we're
- * not showing the message anyway...
- * in_tokz_esc TRUE if we are in Tokenizer-Escape mode
- * scope_is_global TRUE if "global" scope is in effect
- * current_device_node Current dev-node data-struct
- *
- * Outputs:
- * Returned Value: NONE
- * Printout:
- * Advisory Message, if the word is on the Trace List.
- *
- * Process Explanation:
- * The order of scope-checking is important:
- * A Local has no scope beyond the definition in which it occurs.
- * Tokenizer-Escape mode supercedes "Normal" mode, and renders
- * moot the differences between Global and Device scope.
- * Global scope is mutually exclusive with Device scope.
- * Device scope needs to identify where the Current device-node
- * began.
- *
- **************************************************************************** */
-
-void trace_creation( fwtoken definer, char *nu_name)
-{
- if ( verbose )
- {
- if ( is_on_trace_list( nu_name) )
- {
- char as_what[96] = "";
- bool show_last_colon = BOOLVAL( definer == LOCAL_VAL);
-
- as_a_what( definer, as_what); /* No need to check return value. */
-
- /* Scope-checking starts here, unless show_last_colon is TRUE.
- * Come out of this with as_what[] filled up and
- * terminated with a new-line, if appropriate,
- */
- while ( ! show_last_colon )
- {
- strcat( as_what, " ");
-
- if ( in_tokz_esc )
- {
- strcat( as_what, in_tkz_esc_mode);
- break;
- }
-
- if ( scope_is_global )
- {
- strcat( as_what, "with Global scope.\n");
- }else{
- /* In Device scope. Show the Current node. */
- strcat( as_what, in_what_node( current_device_node));
- }
- break;
-
- } /* Destination of BREAKs ... */
-
- tokenization_error(INFO, "Creating %s %s", nu_name, as_what);
-
- if ( show_last_colon )
- {
- in_last_colon();
- }else{
- show_node_start();
- }
-
- }
- }
-}
-
-/* **************************************************************************
- *
* Function name: create_word
* Synopsis:
*
@@ -3180,6 +3107,15 @@ void trace_creation( fwtoken definer, char *nu_name)
* nextfcode Incremented (by bump_fcode() )
* statbuf Advanced to next symbol; must be re-read
* pc Advanced, then restored to previous value
+ * define_token Normally TRUE. Made FALSE if the definition
+ * occurs inside a control-structure, (which
+ * is an Error); we allow the definition to
+ * proceed (so as to avoid "cascade" errors
+ * and catch other errors normally) but we
+ * suppress adding its token to the vocab,
+ * "hiding" it and "revealing" it (because
+ * there's nothing to hide).
+ * NOTE: Make this a Global. Use it in the routines it controls...
* Memory Allocated
* Copy of the name being defined, by support routine.
* Copy of input-source file name, for error-reporting
@@ -3249,7 +3185,8 @@ static bool create_word(fwtoken definer)
{
char defn_type_buffr[32] = "";
unsigned int old_lineno = lineno; /* For error message */
- bool define_token = TRUE;
+
+ define_token = TRUE;
{ /* Set up definition-type text for error-message */
@@ -3280,19 +3217,16 @@ static bool create_word(fwtoken definer)
}else{
bool emit_token_name = TRUE;
- /* Handle Tracing of new definitions */
- trace_creation( definer, statbuf);
-
/* Other Error or Warnings as applicable */
validate_instance( definer);
- warn_if_duplicate( statbuf);
- check_name_length( wlen);
/* Bump FCode; error-check as applicable */
assigning_fcode();
/* Define the new token, unless disallowed */
- add_to_current( statbuf, nextfcode, definer, define_token);
+ add_to_current( statbuf, nextfcode, definer);
+
+ check_name_length( wlen);
/* Emit appropriate FCodes: Type of def'n, */
switch ( hdr_flag )
@@ -3375,7 +3309,7 @@ static bool create_word(fwtoken definer)
static void cannot_apply( char *func_nam, char *targ_nam, fwtoken defr)
{
char *defr_name = "" ;
- const char *defr_phrase = ", which is defined as a " ;
+ char *defr_phrase = wh_defined ;
if ( ! definer_name(defr, &defr_name) )
{
@@ -3797,24 +3731,29 @@ void fcode_ender(void)
* Outputs:
* Returned Value: TRUE if successful (i.e., no error)
* Supplied Pointers:
- * *tok_entry The token entry, if no error
+ * *tok_entry The token entry, if no error.
+ * Unchanged if error.
* Global Variables:
* statbuf The next word in the input stream
* pc Restored to previous value if error
+ * Other Effects:
+ * Display Invocation Message if entry found and is being Traced
*
* Error Detection:
* The next word in the input stream is expected to be on the
* same line as the directive. The get_word_in_line()
* routine will check for that.
- * If the next word in the input stream is not a symbol
- * for which a single-token FCode number is assigned,
- * report an ERROR and restore PC to its previous value.
+ * If the next word in the input stream is a known symbol, but
+ * not one for which a single-token FCode number is assigned,
+ * report an ERROR and restore PC to its previous value. The
+ * supplied pointer tok_entry will remain unaltered.
*
**************************************************************************** */
static bool get_token(tic_hdr_t **tok_entry)
{
bool retval = FALSE;
+ tic_hdr_t *found;
u8 *save_pc;
/* Copy of command being processed, for error message */
@@ -3837,8 +3776,8 @@ static bool get_token(tic_hdr_t **tok_entry)
* need to search again, specifically within the list
* of FCode Tokens.
*/
- *tok_entry = lookup_with_definer( statbuf, &defr);
- if ( *tok_entry != NULL )
+ found = lookup_with_definer( statbuf, &defr);
+ if ( found != NULL )
{
/* Built-in FWords can be uniquely identified by their
* definer, BI_FWRD_DEFN . The definer for "shared"
@@ -3848,15 +3787,19 @@ static bool get_token(tic_hdr_t **tok_entry)
*/
if ( defr == BI_FWRD_DEFN )
{
- *tok_entry = lookup_token( statbuf);
- retval = BOOLVAL( *tok_entry != NULL );
+ found = lookup_token( statbuf);
+ retval = BOOLVAL( found != NULL );
}else{
- retval = entry_is_token( *tok_entry);
+ retval = entry_is_token( found);
}
}
- if ( INVERSE( retval) )
+ handle_invocation( found);
+
+ if ( retval)
{
+ *tok_entry = found;
+ }else{
cannot_apply( cmnd_cpy, strupr(statbuf), defr );
pc = save_pc;
}
@@ -4180,9 +4123,7 @@ static bool abort_quote( fwtoken tok)
* Two words will be read.
*
* Outputs:
- * Returned Value: TRUE if succeeded.
- * Global Variables:
- * statbuf New name will be copied back into here.
+ * Returned Value: NONE
* Memory Allocated
* The two words will be copied into freshly-allocated memory
* that will be passed to the create_..._alias() routine.
@@ -4195,16 +4136,15 @@ static bool abort_quote( fwtoken tok)
* If the ALIAS command was given during colon-definition, that
* can be handled by this tokenizer, but it is not supported
* by IEEE 1275-1994. Issue a WARNING.
- * If the new name is a copy of an existing word-name, issue a warning.
* If the word to which an alias is to be created does not exist
* in the appropriate mode -- relative to "Tokenizer-Escape" --
* that is an ERROR.
* If "instance" is in effect, the ALIAS command is an ERROR.
+ * Duplicate-name Warning is handled by support-routine.
*
* Process Explanation:
* Get two words -- the new name and the "old" word -- from the
* same line of input as the ALIAS command.
- * Copy the new name back into statbuf for use in trace_creation.
* Determine whether or not we are in "Tokenizer-Escape" mode.
* Subsequent searches will take place in that same mode.
* If the "new" name already exists, issue a warning.
@@ -4234,10 +4174,15 @@ static bool abort_quote( fwtoken tok)
* Revision History:
* Updated Tue, 10 Jan 2006 by David L. Paktor
* Convert to tic_hdr_t type vocabularies.
+ * Updated Fri, 22 Sep 2006 by David L. Paktor
+ * Move the warn_if_duplicate() call to the calling routine.
+ * Updated Wed, 11 Oct 2006 by David L. Paktor
+ * Move the Tracing and Duplicate-Warning message functions
+ * into support routine.
*
**************************************************************************** */
-static bool create_alias( void )
+static void create_alias( void )
{
char *new_alias ;
@@ -4257,30 +4202,6 @@ static bool create_alias( void )
{
char *old_name = strdup((char *)statbuf) ;
- /* Copy the "new" alias name back into statbuf.
- * This is a HACK ^H^H^H^H awkward way to retrofit
- * support for the trace_creation() function.
- */
- strcpy( statbuf, new_alias);
-
- /* We don't call trace_creation() here because we don't
- * know if the creation succeeded. However, we want
- * to issue a "Duplicate" warning based on the attempt,
- * even if it doesn't succeed.
- * We would prefer to have the "Trace" message precede the
- * "Duplicate" warning, but we don't think it's worth
- * the effort. When it becomes worthwhile, the way to
- * do it would be to factor out the block that handles
- * normal-tokenization versus "Tokenizer-Escape" mode;
- * condition the "Trace" message on its success-return,
- * show the "Duplicate" warning in any case, then show
- * the error-message and do the cleanup conditioned on
- * a failure-return.
- * That will also obviate the need for a return value from
- * this routine and for the copy-back into statbuf.
- */
- warn_if_duplicate(new_alias);
-
/*
* Here is where we begin trying the create_..._alias()
* routines for the vocabularies.
@@ -4293,7 +4214,7 @@ static bool create_alias( void )
if ( in_tokz_esc )
{
if ( create_tokz_esc_alias( new_alias, old_name) )
- return(TRUE);
+ return;
/*
* Handle the classes of operatives that are common between
@@ -4306,7 +4227,7 @@ static bool create_alias( void )
if ( found != NULL )
{
if ( create_core_alias( new_alias, old_name) )
- return(TRUE);
+ return;
}
}
}else{
@@ -4314,7 +4235,7 @@ static bool create_alias( void )
/* Can create aliases for "Locals", why not? */
if ( create_local_alias( new_alias, old_name) )
- return(TRUE);
+ return;
/*
* All other classes of operatives -- non-fcode forth
@@ -4325,19 +4246,19 @@ static bool create_alias( void )
*/
if ( create_current_alias( new_alias, old_name) )
- return(TRUE);
+ return;
} /* End of separate handling for normal-tokenization mode
* versus "Tokenizer-Escape" mode
*/
/* It's not a word, a macro or any of that other stuff. */
+ trace_create_failure( new_alias, old_name, 0);
tokenized_word_error(old_name);
free(old_name);
}
free (new_alias);
}
- return(FALSE);
}
@@ -4443,6 +4364,9 @@ void handle_internal( tic_param_t pfield)
unsigned int sav_lineno = lineno; /* For error message */
bool handy_toggle = TRUE ; /* Various uses... */
+ bool handy_toggle_too = TRUE ; /* Various other uses... */
+ char *handy_string = "";
+ int handy_int = 0;
#ifdef DEBUG_SCANNER
printf("%s:%d: debug: tokenizing control word '%s'\n",
@@ -4594,10 +4518,7 @@ void handle_internal( tic_param_t pfield)
break;
case ALIAS:
- if ( create_alias() )
- {
- trace_creation( ALIAS, statbuf);
- }
+ create_alias();
break;
case CONTROL:
@@ -4916,19 +4837,21 @@ void handle_internal( tic_param_t pfield)
break;
case FUNC_NAME:
- if ( test_in_colon( statbuf, TRUE, TKERROR, NULL) )
- {
if ( in_tokz_esc )
{
+ if ( incolon )
+ {
tokenization_error( P_MESSAGE, "Currently" );
- in_last_colon();
+ }else{
+ tokenization_error( P_MESSAGE, "After" );
+ }
+ in_last_colon( incolon);
}else{
emit_token("b(\")");
emit_string( last_colon_defname,
strlen( last_colon_defname) );
/* if ( hdr_flag == FLAG_HEADERLESS ) { WARNING } */
}
- }
break;
case IFILE_NAME:
@@ -5066,19 +4989,56 @@ void handle_internal( tic_param_t pfield)
break;
case RET_STK_FETCH:
- ret_stk_access_rpt();
- emit_token( "r@");
- break;
-
+ /* handy_toggle controls reloading other "handy_"s
+ * handy_toggle_too controls calling ret_stk_access_rpt()
+ * handy_int, if non-zero, passed to bump_ret_stk_depth()
+ */
+ /* First in series doesn't need to check handy_toggle */
+ handy_string = "r@";
+ /* Will call ret_stk_access_rpt() */
+ /* handy_toggle_too is already TRUE */
+ /* Will not call bump_ret_stk_depth() */
+ /* handy_int is already zero */
+ handy_toggle = FALSE;
case RET_STK_FROM:
- ret_stk_access_rpt();
- bump_ret_stk_depth( -1);
- emit_token( "r>");
- break;
-
+ if ( handy_toggle )
+ {
+ handy_string = "r>";
+ /* Will call ret_stk_access_rpt() */
+ /* handy_toggle_too is already TRUE */
+ /* Will call bump_ret_stk_depth( -1) */
+ handy_int = -1;
+ handy_toggle = FALSE;
+ }
case RET_STK_TO:
- bump_ret_stk_depth( 1);
- emit_token( ">r");
+ if ( handy_toggle )
+ {
+ handy_string = ">r";
+ /* Will not call ret_stk_access_rpt() */
+ handy_toggle_too = FALSE;
+ /* Will call bump_ret_stk_depth( 1) */
+ handy_int = 1;
+ /* Last in series doesn't need to reset handy_toggle */
+ }
+
+ /* handy_toggle is now free for other use */
+ handy_toggle = allow_ret_stk_interp;
+ if ( ! handy_toggle )
+ {
+ handy_toggle = test_in_colon(statbuf, TRUE, TKERROR, NULL );
+ }
+ if ( handy_toggle || noerrors )
+ {
+ if ( handy_toggle_too )
+ {
+ ret_stk_access_rpt();
+ }
+ if ( handy_int != 0 )
+ {
+ bump_ret_stk_depth( handy_int);
+ }
+ emit_token( handy_string);
+ }
break;
case PCIHDR:
@@ -5490,6 +5450,10 @@ void tokenize_one_word( signed long wlen )
if ( found != NULL )
{
tic_found = found;
+ if ( found->tracing)
+ {
+ invoking_traced_name( found);
+ }
found->funct( found->pfield);
return ;
}
diff --git a/toke/scanner.h b/toke/scanner.h
index 173c907..d601110 100644
--- a/toke/scanner.h
+++ b/toke/scanner.h
@@ -61,6 +61,13 @@ extern bool incolon; /* TRUE if inside a colon definition */
extern bool haveend; /* TRUE if the "end" code was read. */
extern int do_loop_depth; /* How deep we are inside DO ... LOOP variants */
+/* State of headered-ness for name-creation */
+typedef enum headeredness_t {
+ FLAG_HEADERLESS ,
+ FLAG_EXTERNAL ,
+ FLAG_HEADERS } headeredness ;
+extern headeredness hdr_flag;
+
/* For special-case error detection or reporting */
extern int lastcolon; /* Loc'n in output stream of latest colon-def'n. */
/* Used for error-checking of IBM-style Locals */
@@ -70,6 +77,10 @@ extern unsigned int last_colon_lineno; /* Line number of last colon-def'n */
extern bool report_multiline; /* False to suspend multiline warning */
extern unsigned int last_colon_abs_token_no;
+ /* Shared phrases */
+extern char *in_tkz_esc_mode;
+extern char *wh_defined;
+
/* ************************************************************************** *
*
* Function Prototypes / Functions Exported:
@@ -101,23 +112,27 @@ bool as_a_what( fwtoken definer, char *as_what);
tic_hdr_t *lookup_word( char *stat_name, char **where_pt1, char **where_pt2 );
bool word_exists( char *stat_name, char **where_pt1, char **where_pt2 );
void warn_if_duplicate ( char *stat_name);
-void trace_creation( fwtoken definer, char *nu_name);
void tokenize_one_word( signed long wlen );
void check_name_length( signed long wlen );
+bool definer_name(fwtoken definer, char **reslt_ptr);
void tokenize( void );
/* **************************************************************************
*
- * Macro Name: FUNC_CPY_BUF_SIZE
- * Size of a temporary buffer to retain a copy of
- * a function name taken from statbuf, when statbuf
- * will be used to return a value, but the function
- * name might still be needed for an error message.
+ * Macros:
+ * FUNC_CPY_BUF_SIZE Recommended size of a temporary buffer to retain
+ * a copy of a function name taken from statbuf,
+ * when statbuf will be used to return a value,
+ * but the function name might still be needed for
+ * an error message.
+ * AS_WHAT_BUF_SIZE Recommended size of the buffer passed to the
+ * as_a_what() routine.
*
**************************************************************************** */
#define FUNC_CPY_BUF_SIZE 40
+#define AS_WHAT_BUF_SIZE 32
#endif /* _TOKE_SCANNER_H */
diff --git a/toke/stream.c b/toke/stream.c
index b7793f1..1cecb6f 100644
--- a/toke/stream.c
+++ b/toke/stream.c
@@ -55,6 +55,21 @@
*
**************************************************************************** */
+
+/* **************************************************************************
+ *
+ * Still to be done:
+ * Re-arrange routine and variable locations to clarify the
+ * functions of this file and its companion, emit.c
+ * This file should be concerned primarily with management
+ * of the Inputs; emit.c should be primarily concerned
+ * with management of the Outputs.
+ * Hard to justify, pragmatically, but will make for easier
+ * maintainability down the proverbial road...
+ *
+ **************************************************************************** */
+
+
/* **************************************************************************
*
* Global Variables Exported
@@ -64,7 +79,6 @@
* iname Current Input File name
* lineno Current Line Number in Input File
* ostart Start of Output Buffer
- * opc FCode Output Buffer Position Counter
* oname Output File name
*
**************************************************************************** */
@@ -86,7 +100,7 @@ static unsigned int ilen; /* Length of Input Buffer */
/* output pointers */
u8 *ostart;
char *oname = NULL;
-unsigned int opc; /* Output Position Counter */
+
/* We want to limit exposure of this v'ble, so don't put it in .h file */
unsigned int olen; /* Length of Output Buffer */
@@ -1373,7 +1387,6 @@ void init_output( const char *in_name, const char *out_name )
olen = OUTPUT_SIZE;
ostart=safe_malloc(olen, "initting output buffer");
- opc = 0;
init_emit(); /* Init'l'zns needed by our companion file, emit.c */
printf("Binary output to %s ", oname);
@@ -1494,7 +1507,10 @@ void increase_output_buffer( void )
unsigned int rea_len;
olen = olen * 2;
rea_len = olen;
- if ( rea_len == 0 ) rea_len = (unsigned int)-1;
+ if ( rea_len == 0 )
+ {
+ rea_len = (unsigned int)-1;
+ }
tokenization_error( INFO,
"Output Buffer overflow. "
"Relocating and increasing to %d bytes.\n", rea_len);
diff --git a/toke/stream.h b/toke/stream.h
index cd11e9b..999fbc7 100644
--- a/toke/stream.h
+++ b/toke/stream.h
@@ -52,7 +52,6 @@ extern unsigned int abs_token_no; /* Absolute Token Number in Source Input */
/* output pointers */
extern char *oname; /* output file name */
-extern unsigned int opc; /* output buffer position counter */
/* **************************************************************************
*
diff --git a/toke/ticvocab.c b/toke/ticvocab.c
index 5214f8f..7a9006f 100644
--- a/toke/ticvocab.c
+++ b/toke/ticvocab.c
@@ -102,8 +102,13 @@
#include <stdlib.h>
#include <string.h>
+
#include "ticvocab.h"
#include "errhandler.h"
+#include "tracesyms.h"
+#include "scanner.h"
+#include "devnode.h"
+#include "vocabfuncts.h"
tic_hdr_t *tic_found;
@@ -133,8 +138,10 @@ tic_hdr_t *tic_found;
* precede this one in the voacbulary) gets entered into
* the link-pointer field of the first element of the array.
* For this reason, it is important that all TIC_HDR vocabulary
- * pointers that will be pased to this routine have their
+ * pointers that will be passed to this routine have their
* initial values explicitly declared NULL.
+ * If the user has asked to Trace any built-in name, the support
+ * routine will set its tracing field and dispay a message.
*
**************************************************************************** */
@@ -147,14 +154,16 @@ void init_tic_vocab( tic_hdr_t *tic_vocab_tbl,
{
tic_vocab_tbl[indx].next = *tic_vocab_ptr;
*tic_vocab_ptr = &tic_vocab_tbl[indx];
+ trace_builtin( &tic_vocab_tbl[indx]);
}
}
/* **************************************************************************
*
- * Function name: add_tic_entry
- * Synopsis: Add an entry to the given TIC_HDR -type vocabulary
+ * Function name: make_tic_entry
+ * Synopsis: Construct a new entry to a TIC_HDR -type vocab-list
+ * but do not add it to a vocabulary
*
* Inputs:
* Parameters:
@@ -163,13 +172,15 @@ void init_tic_vocab( tic_hdr_t *tic_vocab_tbl,
* tparam The "parameter field" value (may be a pointer)
* fw_defr FWord Token of the entry's Definer
* pfldsiz Size of "param field" (if a pointer to alloc'd mem)
+ * is_single TRUE if entry is a single-token FCode
* ign_fnc Pointer to "ignoring" routine for new entry
- * tic_vocab Pointer to ptr to "tail" of T.I.C.-type vocab-list
+ * trace_this TRUE if new entry is to be "Traced"
+ * tic_vocab Address of the variable that holds the latest
+ * pointer to the "tail" of the T.I.C.-type
+ * vocab-list to which we are adding.
*
* Outputs:
- * Returned Value: NONE
- * Supplied Pointers:
- * *tic_vocab Will point to new entry
+ * Returned Value: Pointer to the new entry
* Memory Allocated:
* For the new entry.
* When Freed?
@@ -183,18 +194,27 @@ void init_tic_vocab( tic_hdr_t *tic_vocab_tbl,
* newly-allocated memory-space. If the parameter field is
* actually a pointer, it, too, is presumed to already have
* been allocated.
- * Memory will be allocated for the entry itself; its pointers
- * will be entered and the given pointer-to-the-tail-of-the-
- * -vocabulary will be updated to point to the new entry.
+ * Memory will be allocated for the entry itself and the given
+ * data will be placed into its fields.
+ *
+ * Extraneous Remarks:
+ * This is a retro-fit; it's a factor of the add_tic_entry()
+ * routine, whose functionality has been expanded to include
+ * issuing the Trace-Note and Duplication Warning messages.
+ * Having it separate allows it to be called (internally) by
+ * create_split_alias(), which has special requirements for
+ * its call to trace_creation()
*
**************************************************************************** */
-void add_tic_entry( char *tname,
+static tic_hdr_t *make_tic_entry( char *tname,
void (*tfunct)(),
TIC_P_DEFLT_TYPE tparam,
fwtoken fw_defr,
int pfldsiz,
+ bool is_single,
void (*ign_fnc)(),
+ bool trace_this,
tic_hdr_t **tic_vocab )
{
tic_hdr_t *new_entry;
@@ -205,9 +225,89 @@ void add_tic_entry( char *tname,
new_entry->funct = tfunct;
new_entry->pfield.deflt_elem = tparam;
new_entry->fword_defr = fw_defr;
+ new_entry->is_token = is_single;
new_entry->ign_func = ign_fnc;
new_entry->pfld_size = pfldsiz;
+ new_entry->tracing = trace_this;
+ return( new_entry);
+}
+
+
+/* **************************************************************************
+ *
+ * Function name: add_tic_entry
+ * Synopsis: Add an entry to the given TIC_HDR -type vocabulary;
+ * issue the Creation Tracing and Duplicate-Name
+ * messages as applicable.
+ *
+ * Inputs:
+ * Parameters:
+ * tname Pointer to space containing entry's new name
+ * tfunct Pointer to the routine the new entry will call
+ * tparam The "parameter field" value (may be a pointer)
+ * fw_defr FWord Token of the entry's Definer
+ * pfldsiz Size of "param field" (if a ptr to alloc'd mem)
+ * is_single TRUE if entry is a single-token FCode
+ * ign_fnc Pointer to "ignoring" routine for new entry
+ * NOTE: No trace_this param here; it's only in make_tic_entry()
+ * tic_vocab Address of the variable that holds the latest
+ * pointer to the "tail" of the T.I.C.-type
+ * vocab-list to which we are adding.
+ * Global Variables:
+ * scope_is_global TRUE if "global" scope is in effect
+ * (passed to "Trace-Creation" message)
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Supplied Pointers:
+ * *tic_vocab Will point to new entry
+ * Printout:
+ * "Trace-Creation" message
+ *
+ * Error Detection:
+ * Warning on duplicate name (subject to command-line control)
+ *
+ * Process Explanation:
+ * The entry itself will be created by the make_tic_entry() routine.
+ * This routine will test whether the new name is to be Traced,
+ * and will pass that datum to the make_tic_entry() routine.
+ * If the new name is to be Traced, issue a Creation Tracing message.
+ * (We want it to appear first). Use the new entry.
+ * Because this routine will not be called for creating aliases, the
+ * second param to trace_creation() is NULL.
+ * Do the duplicate-name check _before_ linking the new entry in to
+ * the given vocabulary. We don't want the duplicate-name test
+ * to find the name in the new entry, only in pre-existing ones...
+ * Now we're ready to update the given pointer-to-the-tail-of-the-
+ * -vocabulary to point to the new entry.
+ *
+ **************************************************************************** */
+
+void add_tic_entry( char *tname,
+ void (*tfunct)(),
+ TIC_P_DEFLT_TYPE tparam,
+ fwtoken fw_defr,
+ int pfldsiz,
+ bool is_single,
+ void (*ign_fnc)(),
+ tic_hdr_t **tic_vocab )
+{
+ bool trace_this = is_on_trace_list( tname);
+ tic_hdr_t *new_entry = make_tic_entry( tname,
+ tfunct,
+ tparam,
+ fw_defr, pfldsiz,
+ is_single,
+ ign_fnc,
+ trace_this,
+ tic_vocab );
+
+ if ( trace_this )
+ {
+ trace_creation( new_entry, NULL, scope_is_global);
+ }
+ warn_if_duplicate( tname);
*tic_vocab = new_entry;
}
@@ -221,6 +321,7 @@ void add_tic_entry( char *tname,
* Parameters:
* tname The "target" name for which to look
* tic_vocab Pointer to the T. I. C. -type vocabulary
+ * in which to search
*
* Outputs:
* Returned Value: Pointer to the relevant entry, or
@@ -229,8 +330,8 @@ void add_tic_entry( char *tname,
* Extraneous Remarks:
* We don't set the global tic_found here because this routine
* is not always called when the found function is going to
- * be executed; sometimes it is called for error-detection,
- * for instance...
+ * be executed; sometimes it is called for error-detection;
+ * for instance, duplicate-name checking...
*
**************************************************************************** */
@@ -282,9 +383,11 @@ bool exists_in_tic_vocab( char *tname, tic_hdr_t *tic_vocab )
/* **************************************************************************
*
- * Function name: create_tic_alias
- * Synopsis: Create an Alias in a TIC_HDR -type vocabulary
+ * Function name: create_split_alias
+ * Synopsis: Create an Alias in one TIC_HDR -type vocabulary
+ * for a word in (optionally) another vocabulary.
* Return a "success" flag.
+ * This is the work-horse for create_tic_alias()
*
* Associated FORTH word: ALIAS
*
@@ -292,17 +395,24 @@ bool exists_in_tic_vocab( char *tname, tic_hdr_t *tic_vocab )
* Parameters:
* old_name Name of existing entry
* new_name New name for which to create an entry
- * *tic_vocab Pointer to the "tail" of the
- * T. I. C. -type vocab-list
+ * *src_vocab Pointer to the "tail" of the "Source"
+ * TIC_HDR -type vocab-list
+ * *dest_vocab Pointer to the "tail" of the "Destination"
+ * TIC_HDR -type vocab-list
*
* Outputs:
- * Returned Value: TRUE if old_name found in given vocab
+ * Returned Value: TRUE if old_name found in "Source" vocab
* Supplied Pointers:
- * *tic_vocab Will be updated to point to the new entry
+ * *dest_vocab Will be updated to point to the new entry
* Memory Allocated:
* For the new entry, by the support routine.
* When Freed?
- * When reset_tic_vocab() is applied to the same vocab-list.
+ * When reset_tic_vocab() is applied to "Destination" vocab-list.
+ * Printout:
+ * "Trace-Creation" message
+ *
+ * Error Detection:
+ * Warning on duplicate name (subject to command-line control)
*
* Process Explanation:
* Both the "old" and "new" names are presumed to already point to
@@ -314,27 +424,91 @@ bool exists_in_tic_vocab( char *tname, tic_hdr_t *tic_vocab )
* the reference to the old space will work, and the old
* entry's param-field memory space will not be freed with
* the alias-entry but only with the "old" entry.
+ * We will do both the "Creation-Tracing" announcement and the
+ * Duplicate Name Warning here. "Tracing" happens either if
+ * the entry for the old name has its tracing flag set, or
+ * if the new name is on the trace-list. The "source" vocab
+ * and the "dest" vocab can only be different when the "old"
+ * name has defined Global scope. We will pass that along
+ * to the trace_creation() routine.
+ * We're doing the "Tracing" and Duplicate-Name functions because
+ * we're applying the "Tracing" message to the "old" name's
+ * entry. Because of this, we must call make_tic_entry() to
+ * bypass add_tic_entry(), which now does its own "Tracing"
+ * and Duplicate-Name functions on the new entry.
*
**************************************************************************** */
-bool create_tic_alias( char *new_name, char *old_name, tic_hdr_t **tic_vocab )
+bool create_split_alias( char *new_name, char *old_name,
+ tic_hdr_t **src_vocab, tic_hdr_t **dest_vocab )
{
tic_hdr_t *found ;
bool retval = FALSE;
- found = lookup_tic_entry( old_name, *tic_vocab );
+ found = lookup_tic_entry( old_name, *src_vocab );
if ( found != NULL )
{
- add_tic_entry( new_name, found->funct,
+ bool trace_it = found->tracing;
+ if ( ! trace_it )
+ {
+ trace_it = is_on_trace_list( new_name);
+ }
+ if ( trace_it )
+ {
+ bool old_is_global = BOOLVAL( src_vocab != dest_vocab );
+ trace_creation( found, new_name, old_is_global);
+ }
+ warn_if_duplicate( new_name);
+
+ *dest_vocab = make_tic_entry( new_name,
+ found->funct,
found->pfield.deflt_elem,
- found->fword_defr,
- 0, found->ign_func, tic_vocab );
+ found->fword_defr, 0,
+ found->is_token,
+ found->ign_func,
+ trace_it,
+ dest_vocab );
retval = TRUE;
}
return ( retval );
}
+/* **************************************************************************
+ *
+ * Function name: create_tic_alias
+ * Synopsis: Create an Alias in a TIC_HDR -type vocabulary
+ * Return a "success" flag.
+ *
+ * Associated FORTH word: ALIAS
+ *
+ * Inputs:
+ * Parameters:
+ * old_name Name of existing entry
+ * new_name New name for which to create an entry
+ * *tic_vocab Pointer to the "tail" of the
+ * T. I. C. -type vocab-list
+ *
+ * Outputs:
+ * Returned Value: TRUE if old_name found in given vocab
+ * Supplied Pointers:
+ * *tic_vocab Will be updated to point to the new entry
+ * Memory Allocated:
+ * For the new entry, by the support routine.
+ * When Freed?
+ * When reset_tic_vocab() is applied to the same vocab-list.
+ *
+ * Process Explanation:
+ * The given vocabulary is both the "Source" and the "Destination".
+ * Pass them both to create_split_alias.
+
+ **************************************************************************** */
+
+bool create_tic_alias( char *new_name, char *old_name, tic_hdr_t **tic_vocab )
+{
+ return ( create_split_alias( new_name, old_name, tic_vocab, tic_vocab ) );
+}
+
/* **************************************************************************
*
diff --git a/toke/ticvocab.h b/toke/ticvocab.h
index 0d41466..51fd73d 100644
--- a/toke/ticvocab.h
+++ b/toke/ticvocab.h
@@ -52,18 +52,24 @@
* The function may re-cast it as needed.
* (5) The "Definer" of the entry; a member of the subset of FWord-
* -tokens that may be Definers.
- * (6) A Pointer to a routine to be run when the word is encountered
+ * (6) A flag indicating whether the item is one for which a
+ * single-token FCode number is assigned.
+ * (7) A Pointer to a routine to be run when the word is encountered
* in a Conditional Compilation section that is being ignored.
* Certain functions still need to be recognized in that state,
* and will require special behaviors; those that can be simply
* ignored will have a NULL pointer in this field. The function
* in this field, also, takes the "parameter field" item as its
* argument and has no return-value.
- * (7) The size of the data pointed to by the "parameter field" item,
+ * (8) The size of the data pointed to by the "parameter field" item,
* if it is a pointer to allocated data; used to allocate space
* for a copy of the p.f. when making an alias, and to indicate
* whether the space needs to be freed. Automatic procedures
* are too often fooled, so we don't leave things to chance...
+ * (9) A flag, set TRUE if the word is on the Trace List, to indicate
+ * that an Invocation Message should be displayed when the word
+ * is invoked.
+ *
* To accommodate C's insistence on strong-typing, we might need
* to define different "parameter field" structure-types; see
* description of "Parameter Field as a union", below.
@@ -176,8 +182,10 @@ typedef struct tic_hdr
void (*funct)(); /* Function for active processing */
tic_param_t pfield;
fwtoken fword_defr; /* FWord Token of entry's Definer */
+ bool is_token; /* Is entry a single-token FCode? */
void (*ign_func)(); /* Function in "Ignored" segment */
int pfld_size;
+ bool tracing; /* TRUE if Invoc'n Msg required */
} tic_hdr_t ;
/* **************************************************************************
@@ -203,8 +211,10 @@ typedef struct tic_fwt_hdr
void (*funct)(); /* Function for active processing */
tic_fwt_param_t pfield;
fwtoken fword_defr; /* FWord Token of entry's Definer */
+ bool is_token; /* Is entry a single-token FCode? */
void (*ign_func)(); /* Function in "Ignored" segment */
int pfld_size;
+ bool tracing; /* TRUE if Invoc'n Msg required */
} tic_fwt_hdr_t ;
@@ -237,8 +247,10 @@ typedef struct tic_mac_hdr
void (*funct)();
tic_mac_param_t pfield;
fwtoken fword_defr;
+ bool is_token; /* Is entry a single-token FCode? */
void (*ign_func)();
int pfld_size;
+ bool tracing; /* TRUE if Invoc'n Msg required */
} tic_mac_hdr_t ;
/* **************************************************************************
@@ -265,8 +277,10 @@ typedef struct tic_bool_hdr
void (*funct)();
tic_bool_param_t pfield;
fwtoken fword_defr;
+ bool is_token; /* Is entry a single-token FCode? */
void (*ign_func)();
int pfld_size;
+ bool tracing; /* TRUE if Invoc'n Msg required */
} tic_bool_hdr_t ;
@@ -292,10 +306,12 @@ typedef struct tic_bool_hdr
* Arguments:
* nam (string) Name of the entry as seen in the source
* func (routine-name) Name of internal function to call
+ * The item is not one for which single-token FCode number is assigned.
*
**************************************************************************** */
#define NO_PARAM_TIC(nam, func ) \
- { nam , (tic_hdr_t *)NULL , func , { 0 }, UNSPECIFIED , NULL , 0 }
+ { nam , (tic_hdr_t *)NULL , func , \
+ { 0 }, UNSPECIFIED , FALSE , NULL , 0 , FALSE }
/* **************************************************************************
@@ -307,11 +323,12 @@ typedef struct tic_bool_hdr
* Arguments:
* nam (string) Name of the entry as seen in the source
* func (routine-name) Name of internal function to call for both
- *
+ * The item is not one for which single-token FCode number is assigned.
*
**************************************************************************** */
#define NO_PARAM_IGN(nam, func ) \
- { nam , (tic_hdr_t *)NULL , func , { 0 }, UNSPECIFIED , func , 0 }
+ { nam , (tic_hdr_t *)NULL , func , \
+ { 0 }, UNSPECIFIED , FALSE , func , 0 , FALSE }
/* **************************************************************************
@@ -331,14 +348,15 @@ typedef struct tic_bool_hdr
* func (routine-name) Name of internal function to call
* pval (integer) The "param field" item
* definr (fword_token) "Definer" of the entry
+ * is_tok (bool) Is the "param" item a single-token FCode?
*
* The "param field" item will be recast to the required default type.
*
**************************************************************************** */
-#define VALPARAM_TIC(nam, func, pval, definr ) \
+#define VALPARAM_TIC(nam, func, pval, definr, is_tok ) \
{ nam , (tic_hdr_t *)NULL , func , \
- { (TIC_P_DEFLT_TYPE)(pval) }, definr , NULL , 0 }
+ { (TIC_P_DEFLT_TYPE)(pval) }, definr , is_tok , NULL , 0 , FALSE }
/* **************************************************************************
@@ -357,16 +375,17 @@ typedef struct tic_bool_hdr
* definr (fword_token) "Definer" of the entry
*
* The "param field" item will be recast to the required default type.
+ * The item is not one for which single-token FCode number is assigned.
*
**************************************************************************** */
#define DUALFUNC_TIC(nam, afunc, pval, ifunc, definr ) \
{ nam , (tic_hdr_t *)NULL , afunc , \
- { (TIC_P_DEFLT_TYPE)(pval) }, definr , ifunc , 0 }
+ { (TIC_P_DEFLT_TYPE)(pval) }, definr , FALSE , ifunc , 0 , FALSE }
/* Similar but a tic_fwt_hdr_t type structure */
#define DUFNC_FWT_PARM(nam, afunc, pval, ifunc, definr ) \
{ nam , (tic_fwt_hdr_t *)NULL , afunc , \
- { (TIC_FWT_P_DEFLT_TYPE)(pval) }, definr , ifunc , 0 }
+ { (TIC_FWT_P_DEFLT_TYPE)(pval) }, definr , FALSE , ifunc , 0 , FALSE }
/* **************************************************************************
@@ -381,11 +400,13 @@ typedef struct tic_bool_hdr
* definr (fword_token) "Definer" of the entry
*
* The "param field" item should not need be recast.
+ * The item is not one for which single-token FCode number is assigned.
*
**************************************************************************** */
#define FWORD_TKN_TIC(nam, func, fw_tokval, definr ) \
- { nam , (tic_fwt_hdr_t *)NULL , func , { fw_tokval }, definr , NULL , 0 }
+ { nam , (tic_fwt_hdr_t *)NULL , func , { fw_tokval }, \
+ definr , FALSE , NULL , 0 , FALSE }
/* **************************************************************************
* Macro Name: DUALFUNC_FWT_TIC
@@ -401,10 +422,12 @@ typedef struct tic_bool_hdr
* definr (fword_token) "Definer" of the entry
*
* The "param field" item should not need be recast.
+ * The item is not one for which single-token FCode number is assigned.
*
**************************************************************************** */
#define DUALFUNC_FWT_TIC(nam, afunc, fw_tokval, ifunc, definr ) \
- { nam , (tic_fwt_hdr_t *)NULL , afunc , { fw_tokval }, definr , ifunc , 0 }
+ { nam , (tic_fwt_hdr_t *)NULL , afunc , { fw_tokval }, \
+ definr , FALSE , ifunc , 0 , FALSE }
/* **************************************************************************
* Macro Name: BUILTIN_MAC_TIC
@@ -420,11 +443,13 @@ typedef struct tic_bool_hdr
* The "definer" will be MACRO_DEF
* Builtin Macros do not need to be expanded while Ignoring, so
* the ign_func will be NULL
+ * The item is not one for which single-token FCode number is assigned.
*
**************************************************************************** */
#define BUILTIN_MAC_TIC(nam, func, alias ) \
- { nam , (tic_mac_hdr_t *)NULL , func , { alias }, MACRO_DEF , NULL , 0 }
+ { nam , (tic_mac_hdr_t *)NULL , func , { alias }, \
+ MACRO_DEF , FALSE , NULL , 0 , FALSE }
/* **************************************************************************
@@ -441,12 +466,13 @@ typedef struct tic_bool_hdr
* For all of the Condtionals, the "Ignoring" function is the same
* as the "Active" function.
* The "definer" will be COMMON_FWORD
+ * The item is not one for which single-token FCode number is assigned.
*
**************************************************************************** */
#define BUILTIN_BOOL_TIC(nam, func, bool_vbl ) \
{ nam , (tic_bool_hdr_t *)NULL , func , { &bool_vbl }, \
- COMMON_FWORD , func , 0 }
+ COMMON_FWORD , FALSE , func , 0 , FALSE }
/* **************************************************************************
@@ -465,14 +491,15 @@ void add_tic_entry( char *tname,
TIC_P_DEFLT_TYPE tparam,
fwtoken fw_defr,
int pfldsiz,
+ bool is_single,
void (*ign_fnc)(),
tic_hdr_t **tic_vocab );
tic_hdr_t *lookup_tic_entry( char *tname, tic_hdr_t *tic_vocab );
bool exists_in_tic_vocab( char *tname, tic_hdr_t *tic_vocab );
bool handle_tic_vocab( char *tname, tic_hdr_t *tic_vocab );
-bool create_tic_alias( char *new_name,
- char *old_name,
- tic_hdr_t **tic_vocab );
+bool create_split_alias( char *new_name, char *old_name,
+ tic_hdr_t **src_vocab, tic_hdr_t **dest_vocab );
+bool create_tic_alias( char *new_name, char *old_name, tic_hdr_t **tic_vocab );
void reset_tic_vocab( tic_hdr_t **tic_vocab, tic_hdr_t *reset_position );
#endif /* _TOKE_TICVOCAB_H */
diff --git a/toke/toke.c b/toke/toke.c
index fdd8d8b..9f0dbf9 100644
--- a/toke/toke.c
+++ b/toke/toke.c
@@ -46,7 +46,8 @@
#include "stack.h"
#include "emit.h"
-#define TOKE_VERSION "1.0.1"
+#define TOKE_VERSION "1.0.2"
+#define TOKE_COPYRIGHT_DATE "2001-2006"
#include "vocabfuncts.h"
#include "scanner.h"
@@ -102,8 +103,8 @@ static void print_copyright(void)
printf( "Welcome to toke - OpenBIOS tokenizer v" TOKE_VERSION "\n"
CORE_COPYR "\n" IBM_COPYR "\n"
"This program is free software; you may redistribute it "
- "under the terms of\nthe GNU General Public License v2. This "
- "program has absolutely no warranty.\n\n");
+ "under the terms of\nthe GNU General Public License v2. "
+ "This program has absolutely no warranty.\n\n");
#ifdef DEVEL
/* Temporary hack during development... */
printf( "\tTokenizer Compiled " DATE_STAMP "\n" );
@@ -352,6 +353,7 @@ static void get_args( int argc, char **argv )
list_cl_flag_settings();
display_include_list();
}
+ show_trace_list();
save_cl_flags();
}
@@ -378,6 +380,8 @@ int main(int argc, char **argv)
print_copyright();
get_args( argc, argv );
+ init_error_handler();
+
init_stack();
init_dictionary();
diff --git a/toke/tokzesc.c b/toke/tokzesc.c
index 703b393..2fc1cbe 100644
--- a/toke/tokzesc.c
+++ b/toke/tokzesc.c
@@ -45,8 +45,9 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
-#include "ticvocab.h"
+
#include "tokzesc.h"
+#include "ticvocab.h"
#include "stack.h"
#include "emit.h"
#include "stream.h"
@@ -54,6 +55,7 @@
#include "errhandler.h"
#include "strsubvocab.h"
#include "nextfcode.h"
+#include "tracesyms.h"
#undef TOKZTEST /* Define for testing only; else undef */
#ifdef TOKZTEST /* For testing only */
@@ -215,7 +217,8 @@ static void tokz_esc_emit_byte ( tic_param_t pfield )
* Inputs:
* Parameters:
* the_num Pointer to where to put the number
- * the_action Phrase to be used in ERROR message
+ * setting_fc TRUE if number is to be set as next fcode,
+ * FALSE if the number is to be emitted
* Data-Stack Items:
* Top: Value to be retrieved
*
@@ -224,21 +227,44 @@ static void tokz_esc_emit_byte ( tic_param_t pfield )
* Supplied Pointers:
* *the_num Value retrieved from the data-stack
*
+ * Process Explanation:
+ * From the value of setting_fc we will deduce both the legal
+ * minimum and the phrase to be used in the ERROR message.
+ * If the number is to be emitted, it can be any legal FCode
+ * token number down to 0x10 but if it is to be set, the
+ * legal minimum is 0x0800.
+ * In either case, 0x0fff is the legal maximum.
+ *
* Error Detection:
* If the number on the stack is larger than 16 bits, truncate
* it, with a WARNING message.
- * If the (possibly truncated) number from the stack is larger
- * than the legal maximum for an FCode (0x0fff), or
- * less than the legal minimum (0x0800), issue an ERROR,
+ * If the (possibly truncated) number taken from the stack is
+ * larger than the legal maximum for an FCode, or if it is
+ * less than the legal minimum, issue an ERROR message,
* leave the_num unchanged and return FALSE.
*
+ * Extraneous Remarks:
+ * If this function is ever used in more than the two ways allowed
+ * by the setting_fc parameter, then the Right Thing would
+ * be to define a local ENUM type for the possible uses, and
+ * use a SWITCH statement to set the internal variables. (But
+ * I really don't see any way that could become necessary...)
+ *
**************************************************************************** */
-static bool get_fcode_from_stack( u16 *the_num, char *the_action)
+static bool get_fcode_from_stack( u16 *the_num, bool setting_fc)
{
bool retval = FALSE;
+ char *the_action = "emit FCode value of";
+ u16 legal_minimum = 0x10;
long num_on_stk = dpop();
u16 test_fcode = (u16)num_on_stk;
+
+ if ( setting_fc )
+ {
+ the_action = "set next fcode to";
+ legal_minimum = 0x800;
+ }
if ( test_fcode != num_on_stk )
{
tokenization_error( WARNING,
@@ -246,7 +272,7 @@ static bool get_fcode_from_stack( u16 *the_num, char *the_action)
"Truncating to 0x%03x.\n",
strupr(statbuf), num_on_stk, test_fcode);
}
- if ( ( test_fcode >= 0x800 ) && ( test_fcode <= 0xfff ) )
+ if ( ( test_fcode >= legal_minimum ) && ( test_fcode <= 0xfff ) )
{
retval = TRUE;
*the_num = test_fcode;
@@ -279,7 +305,7 @@ static void tokz_esc_next_fcode( tic_param_t pfield )
{
u16 test_fcode;
- if ( get_fcode_from_stack( &test_fcode, "set next fcode to") )
+ if ( get_fcode_from_stack( &test_fcode, TRUE) )
{
if ( test_fcode == nextfcode )
{
@@ -318,7 +344,7 @@ static void tokz_emit_fcode( tic_param_t pfield )
{
u16 test_fcode;
- if ( get_fcode_from_stack( &test_fcode, "Emit FCode value of") )
+ if ( get_fcode_from_stack( &test_fcode, FALSE) )
{
tokenization_error( INFO,
"Emitting FCode value of 0x%x\n", test_fcode);
@@ -462,8 +488,8 @@ static void do_constant ( tic_param_t pfield )
* Error Detection:
* Failure to allocate memory is a Fatal Error.
* Warning on excessively long name
- * Warning on duplicate name
* Name to be defined not in same file, ERROR
+ * Warning on duplicate name handled by support routine
*
* Process Explanation:
* Get the next word, STRDUP it (which implicitly allocates memory).
@@ -493,11 +519,6 @@ static void create_constant( tic_param_t pfield )
* the lines from here to the end of the
* routine should be re-factored...
*/
- trace_creation( CONST, statbuf);
-
- warn_if_duplicate( statbuf );
- check_name_length( wlen );
-
c_name_space = strdup( statbuf );
add_tic_entry(
@@ -505,9 +526,11 @@ static void create_constant( tic_param_t pfield )
do_constant,
(TIC_P_DEFLT_TYPE)valu,
CONST ,
- 0 , NULL,
+ 0 , FALSE , NULL,
&tokz_esc_vocab );
+ check_name_length( wlen );
+
}
/* **************************************************************************
@@ -538,7 +561,7 @@ static const char close_paren = ')' ;
**************************************************************************** */
#define TKZESC_CONST(nam, pval) \
- VALPARAM_TIC(nam, do_constant, pval, CONST )
+ VALPARAM_TIC(nam, do_constant, pval, CONST, FALSE )
#define TKZ_ESC_FUNC(nam, afunc, pval, ifunc) \
DUALFUNC_TIC(nam, afunc, pval, ifunc, UNSPECIFIED)
@@ -586,6 +609,11 @@ static const tic_hdr_t *built_in_tokz_esc =
* Synopsis: Initialize the "Tokenizer Escape" Vocabulary
* link-pointers dynamically.
*
+ * Process Explanation:
+ * While this is going on, set in_tokz_esc to TRUE; clear it
+ * when done. This will be used by the trace_builtin
+ * routine...
+ *
**************************************************************************** */
void init_tokz_esc_vocab ( void )
@@ -593,10 +621,12 @@ void init_tokz_esc_vocab ( void )
static const int tokz_esc_vocab_max_indx =
sizeof(tokz_esc_vocab_tbl)/sizeof(tic_hdr_t) ;
+ in_tokz_esc = TRUE;
tokz_esc_vocab = NULL ; /* Belt-and-suspenders... */
init_tic_vocab(tokz_esc_vocab_tbl,
tokz_esc_vocab_max_indx,
&tokz_esc_vocab );
+ in_tokz_esc = FALSE;
}
/* **************************************************************************
diff --git a/toke/tracesyms.c b/toke/tracesyms.c
index 1577708..275cec9 100644
--- a/toke/tracesyms.c
+++ b/toke/tracesyms.c
@@ -33,31 +33,96 @@
/* **************************************************************************
*
+ * Revision History:
+ * Wed, 04 Oct 2006 by David L. Paktor
+ * Issue a message when a name on the trace list is invoked (as well
+ * as when it is created), but keep a limit on the speed penalty.
+ * (I.e., don't scan the trace-list for every symbol invoked.)
+ * Instead, we are going to install a function that prints the
+ * message; this requires scanning only once at creation time,
+ * which is already a necessity. There are too many permutations
+ * of "action" functions to define a separate set that combine
+ * with the invocation-message, so we will have a separate field
+ * for the invocation-message function, which will be NULL if
+ * the entry is not being traced. (If, however, it is faster
+ * to execute a null function than to first test for a NULL,
+ * then we can define a null function and put _that_ into the
+ * invocation-message-function field...
+ * Wed, 11 Oct 2006 by David L. Paktor
+ * We have reduced the Invocation Message Function to a single common
+ * routine; we will add a field that is a simple flag indicating
+ * if the entry is being traced. At the common point where the
+ * entry's function is called, we will test the flag to decide
+ * whether call the Invocation Message routine.
+ *
+ **************************************************************************** */
+
+/* **************************************************************************
+ *
* Functions Exported:
* add_to_trace_list Add the given name to the Trace List
- * show_initial_traces Show pre-defined names the user
- * asked to Trace (if any)
* is_on_trace_list Indicate whether the given name is
* on the Trace List
+ * tracing_fcode Show a token's assigned FCode-token
+ * in a consistent format.
+ * trace_creation Display a Trace-Note when a word known
+ * to be on the Trace List is created.
+ * trace_create_failure Display a Trace-Note indicating a failed
+ * attempt to create a word, if it is
+ * on the Trace List.
+ * traced_name_error Display a Trace-Note indicating a failed
+ * attempt to invoke an undefined word,
+ * if it is on the Trace List.
+ * invoking_traced_name Display a Trace-Note when a word known
+ * to be on the Trace List is invoked.
+ * handle_invocation Test whether a word is on the Trace List;
+ * if so, display a Trace-Note.
+ * show_trace_list Display the trace-list (if any) at
+ * the start of the run
+ * trace_builtin Test whether a pre-defined name is on
+ * the Trace List; issue a Trace-Note
+ * and set the entry's tracing flag.
*
**************************************************************************** */
+/* **************************************************************************
+ *
+ * Global Variables Exported
+ * split_alias_message Back-channel way to permit a certain
+ * message about an alias to a Global
+ * definition only having local scope
+ * to become a Trace-Note instead of
+ * an Advisory when one of the names
+ * is being Traced.
+ *
+ **************************************************************************** */
+
+
#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
#include "tracesyms.h"
#include "errhandler.h"
+#include "scanner.h"
+#include "vocabfuncts.h"
+#include "devnode.h"
+#include "toke.h"
+int split_alias_message = INFO;
/* **************************************************************************
*
* Internal Static Variables
- * trace_list Pointer to last entry in the Trace List linked-list
- * data structure
- *
- *
+ * trace_list Pointer to the first entry in the Trace List
+ * linked-list data structure
+ * trace_list_last Pointer to the last entry in the Trace List;
+ * the list will be forward-linked
+ * tracing_symbols TRUE if "Trace-Symbols" is in effect.
*
**************************************************************************** */
+
/* **************************************************************************
*
* Internal (Static) Structures:
@@ -65,35 +130,38 @@
*
* Fields:
* tracee Name of the symbol to be traced
- * prev Pointer to previous entry in the linked-list
+ * next Pointer to next entry in the forward-linked-list
*
**************************************************************************** */
typedef struct trace_entry {
char *tracee;
- struct trace_entry *prev;
+ struct trace_entry *next;
} trace_entry_t;
static trace_entry_t *trace_list = NULL;
+static trace_entry_t *trace_list_last = NULL;
-
+static bool tracing_symbols = FALSE;
/* **************************************************************************
*
* Function name: add_to_trace_list
* Synopsis: Add the given name to the Trace List
*
- *
* Inputs:
* Parameters:
* trace_symb Name of the symbol to be added
* Local Static Variables:
* trace_list Pointer to the Trace List
+ * trace_list_last Pointer to last entry in the Trace List
*
* Outputs:
* Returned Value: NONE
* Local Static Variables:
- * trace_list Points to new entry in Trace List
+ * trace_list Points to first entry in Trace List
+ * trace_list_last Pointer to new entry in the Trace List
+ * tracing_symbols Set to TRUE
* Memory Allocated
* For Trace List entry
* For copy of Symbol Name
@@ -101,6 +169,12 @@ static trace_entry_t *trace_list = NULL;
* Never. Well, only on termination of the program. Trace-list
* endures for the entire batch of tokenizations.
*
+ * Process Explanation:
+ * The list will be forward-linked so that the display of the list
+ * can be in the same order as specified by the User. It will
+ * take a little extra effort, but having it come out that way
+ * satisfies the "Rule of Least Astonishment"...
+ *
* Error Detection:
* Memory allocation failure is a FATAL error.
*
@@ -111,9 +185,16 @@ void add_to_trace_list( char *trace_symb)
trace_entry_t *new_t_l_entry = safe_malloc( sizeof( trace_entry_t),
"adding to trace-list");
new_t_l_entry->tracee = strdup( trace_symb);
- new_t_l_entry->prev = trace_list;
+ new_t_l_entry->next = NULL;
+ if ( trace_list != NULL )
+ {
+ trace_list_last->next = new_t_l_entry;
+ }else{
trace_list = new_t_l_entry;
+ tracing_symbols = TRUE;
+ }
+ trace_list_last = new_t_l_entry;
}
@@ -126,6 +207,7 @@ void add_to_trace_list( char *trace_symb)
* Parameters:
* symb_name Symbol-name to test
* Local Static Variables:
+ * tracing_symbols Skip the search if FALSE
* trace_list Pointer to the Trace List
*
* Outputs:
@@ -136,6 +218,8 @@ void add_to_trace_list( char *trace_symb)
bool is_on_trace_list( char *symb_name)
{
bool retval = FALSE;
+ if ( tracing_symbols )
+ {
trace_entry_t *test_entry = trace_list;
while ( test_entry != NULL )
{
@@ -144,7 +228,8 @@ bool is_on_trace_list( char *symb_name)
retval = TRUE;
break;
}
- test_entry = test_entry->prev;
+ test_entry = test_entry->next;
+ }
}
return ( retval );
}
@@ -152,21 +237,504 @@ bool is_on_trace_list( char *symb_name)
/* **************************************************************************
*
- * Still to be done:
- * Implement a function -- name it show_initial_traces --
- * that will show any pre-defined names the user asked
- * to Trace. That is, if any of the names the user asked
- * to Trace belongs to a pre-defined function, macro or
- * directive, then, at the beginning of the output, issue
- * Advisory Messages identifying the scope of those names.
- *
- * E.g, if the user had -T 3DUP -T SWAP the function would
- * issue Messages like:
- * 3DUP is pre-defined as a Macro with Global scope
- * SWAP is pre-defined with Global scope
- * SWAP is pre-defined in Tokenizer-Escape mode
+ * Function name: tracing_fcode
+ * Synopsis: Fill the given buffer with the string showing the
+ * assigned FCode-token given. Produce a consistent
+ * format for all messages that include this phrase.
+ *
+ * Inputs:
+ * Parameters:
+ * fc_phrase_buff Pointer to buffer for the phrase
+ * fc_token_num Assigned FCode-token number.
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Supplied Pointers:
+ * fc_phrase_buff Filled with the phrase.
+ *
+ * Process Explanation:
+ * It is the responsibility of the calling routine to make sure
+ * that the buffer passed as the fc_phrase_buff parameter
+ * is sufficiently large for the phrase.
+ * This routine will test fc_token_num and leave the buffer
+ * unchanged if it is not greater than zero, relieving the
+ * calling routine of that chore.
+ *
+ * Extraneous Remarks:
+ * We will export, in tracesyms.h , a Macro that will give the
+ * recommended length for the buffer passed to this routine.
+ * It will be called TRACING_FCODE_LENGTH
+ *
+ **************************************************************************** */
+
+void tracing_fcode( char *fc_phrase_buff, u16 fc_token_num)
+{
+ if ( fc_token_num > 0 )
+ {
+ sprintf( fc_phrase_buff,
+ " (FCode token = 0x%03x)", fc_token_num);
+ }
+}
+
+/* **************************************************************************
+ *
+ * Function name: trace_creation
+ * Synopsis: Display the appropriate message when a word, known
+ * to be on the Trace List, is created.
+ *
+ * Inputs:
+ * Parameters:
+ * trace_entry The TIC entry of the name
+ * nu_name If creating an Alias, the "new" name,
+ * otherwise NULL.
+ * is_global TRUE if trace_entry has Global scope.
+ * Global Variables:
+ * in_tokz_esc TRUE if we are in Tokenizer-Escape mode
+ * current_device_node Where the new definition's scope is,
+ * if it's not Global or Tokzr-Escape.
+ * hdr_flag State of name-creation headered-ness
+ * in_tkz_esc_mode String for announcing Tokz-Esc mode
+ * wh_defined String, = ", which is defined as a "
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Global Variables:
+ * split_alias_message Set to TRACER if creating an Alias.
+ * Printout:
+ * Trace-Note Message.
+ * If not an ALIAS, takes the form:
+ * Creating <name> <(if is_single:FCode Token = xxx)>
+ * as a{n External,Headered,Headerless} <Type>
+ * <with scope>
+ * If it is an ALIAS, takes the form:
+ * Creating <new-name> as a{n External,Headered,Headerless}
+ * ALIAS to <old-name> <(if is_single:FCode Token = xxx)>,
+ * which is defined [ as a <Type>] <with scope>
+ * Headered-ness, of course, only applies to words with a
+ * single-token FCode.
+ * The <with scope> phrase is:
+ * If we are in Tokz-Esc mode, "in Tokenizer-Escape mode".
+ * If the TIC entry is a Local, the current colon-definition.
+ * If the TIC entry is Global in scope, "with Global scope"
+ * Otherwise, the identification of the current device-node.
+ *
+ * Process Explanation:
+ * The calling routine will already have verified that the
+ * name is on the trace-list.
+ * The name will already have been entered into a TIC_HDR vocab;
+ *
+ * The order of scope-checking is important:
+ * A Local has no scope beyond the definition in which it occurs.
+ * Tokenizer-Escape mode supercedes "Normal" mode, and renders
+ * moot the differences between Global and Device scope.
+ * Global scope is mutually exclusive with Device scope.
+ * Device scope needs to identify where the Current device-node
+ * began.
+ *
+ **************************************************************************** */
+
+void trace_creation( tic_hdr_t *trace_entry,
+ char *nu_name,
+ bool is_global)
+{
+ char fc_token_display[TRACING_FCODE_LENGTH] = "";
+ char *head_ness = "";
+ char *defr_name = "" ;
+ char *defr_phrase = "" ;
+ char *with_scope = "" ;
+ bool def_is_local = BOOLVAL( trace_entry->fword_defr == LOCAL_VAL);
+ bool creating_alias = BOOLVAL( nu_name != NULL );
+
+ if ( creating_alias )
+ {
+ head_ness = "n";
+ split_alias_message = TRACER;
+ }
+
+ if ( in_tokz_esc )
+ {
+ with_scope = in_tkz_esc_mode;
+ }else{
+ if ( ! def_is_local )
+ {
+ if ( is_global )
+ {
+ with_scope = "with Global scope.\n";
+ }else{
+ with_scope = in_what_node( current_device_node);
+ }
+ }
+
+ if ( trace_entry->is_token )
+ {
+ tracing_fcode( fc_token_display,
+ (u16)trace_entry->pfield.deflt_elem );
+ /* Headered-ness only applies to FCode definitions */
+ /* But not to aliases to FCode definitions */
+ if ( ! creating_alias )
+ {
+ switch ( hdr_flag )
+ {
+ case FLAG_HEADERS:
+ head_ness = " Headered";
+ break;
+
+ case FLAG_EXTERNAL:
+ head_ness = "n External";
+ break;
+
+ default: /* FLAG_HEADERLESS */
+ head_ness = " Headerless";
+ }
+ }
+ }
+
+ }
+
+
+ if ( definer_name(trace_entry->fword_defr, &defr_name) )
+ {
+ defr_phrase = wh_defined;
+ }else{
+ /* Even if we don't have a Type for the "old" word
+ * we still have its scope. If the "new" word's
+ * scope is different, the "split-alias message"
+ * will take care of it.
+ */
+ if ( creating_alias )
+ {
+ defr_phrase = ", which is defined" ;
+ }
+ }
+
+ if ( creating_alias )
+ {
+ /*
+ * Creating <new-name> as a{n External,Headered,Headerless}
+ * ALIAS to <old-name> <(if is_single:FCode Token = xxx)>,
+ * [which is defined as a <Type> <with scope>]
+ */
+ tokenization_error(TRACER,
+ "Creating %s" /* nu_name */
+ " as a%s ALIAS to %s" /* head_ness trace_entry->name */
+ "%s" /* fc_token_display */
+ "%s%s " /* defr_phrase defr_name */
+ "%s", /* with_scope */
+ nu_name, head_ness, trace_entry->name,
+ fc_token_display, defr_phrase, defr_name, with_scope );
+ }else{
+ /*
+ * Creating <name> <(if is_single:FCode Token = xxx)>
+ * as a{n External,Headered,Headerless} <Type>
+ * [ <with scope> ]
+ */
+ tokenization_error(TRACER,
+ "Creating %s" /* trace_entry->name */
+ "%s" /* fc_token_display */
+ " as a%s %s " /* head_ness defr_name */
+ "%s", /* with_scope */
+ trace_entry->name,
+ fc_token_display, head_ness, defr_name, with_scope );
+ }
+ /*
+ * The <with scope> phrase is:
+ * If we are in Tokz-Esc mode, "in Tokenizer-Escape mode".
+ * (Already handled. No more to do here)
+ * If the TIC entry is a Local, the current colon-definition.
+ * If the TIC entry is Global in scope, "with Global scope"
+ * (identified by NULL in_vocab).
+ * Otherwise, the identification of the current device-node.
+ */
+
+
+ if ( ! in_tokz_esc )
+ {
+ if ( def_is_local )
+ {
+ in_last_colon( TRUE);
+ }else{
+ show_node_start();
+ }
+ }
+
+}
+
+
+/* **************************************************************************
+ *
+ * Function name: trace_create_failure
+ * Synopsis: Display a Trace-Note indicating a failed attempt
+ * to create a word, if it is on the Trace List.
*
- * The names would, of course, remain on the Trace List and
- * any re-definitions of them would be reported.
+ * Inputs:
+ * Parameters:
+ * new_name The name of the word you failed to create
+ * old_name If attempted to create an Alias, the
+ * "old" name, otherwise NULL.
+ * fc_tokn FCode-Token that might have been assigned
+ * to the "new" name. Zero if none.
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Printout:
+ * Failed to create <new_name> [FCode Token = <xxx>]
+ * [ as an ALIAS to <old_name>]\n"
*
**************************************************************************** */
+
+void trace_create_failure( char *new_name, char *old_name, u16 fc_tokn)
+{
+ bool not_alias = BOOLVAL( old_name == NULL );
+ bool do_it = is_on_trace_list( new_name);
+
+ if ( ( ! do_it ) && ( ! not_alias ) )
+ {
+ do_it = is_on_trace_list( old_name);
+ }
+
+ if ( do_it )
+ {
+ char fc_token_display[TRACING_FCODE_LENGTH] = "";
+ char *as_alias = not_alias ? "" : " as an ALIAS to ";
+ char *alias_name = not_alias ? "" : old_name;
+
+ if ( fc_tokn > 0 )
+ {
+ tracing_fcode( fc_token_display, fc_tokn);
+ }
+ tokenization_error(TRACER,
+ "Failed to create %s" /* new_name */
+ "%s" /* fc_token_display */
+ "%s" /* as_alias */
+ "%s\n", /* alias_name */
+ new_name, fc_token_display,
+ as_alias, alias_name);
+ }
+}
+
+
+/* **************************************************************************
+ *
+ * Function name: traced_name_error
+ * Synopsis: Display a Trace-Note indicating a failed attempt
+ * to invoke an undefined word, if it is on the
+ * Trace List.
+ *
+ * Inputs:
+ * Parameters:
+ * trace_name The name being invoked
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Printout:
+ * A Trace-Note message indicating a attempt to "invoke" the name
+ *
+ * Error Detection:
+ * Error was detected by calling routine
+ *
+ * Process Explanation:
+ * Test if the name is on the trace-list, first.
+ *
+ **************************************************************************** */
+
+void traced_name_error( char *trace_name)
+{
+ if ( is_on_trace_list( trace_name ) )
+ {
+ tokenization_error(TRACER, "Attempt to invoke (undefined) %s.\n",
+ trace_name);
+ }
+}
+
+/* **************************************************************************
+ *
+ * Function name: invoking_traced_name
+ * Synopsis: Print a message indicating that the given name,
+ * (which is on the trace-list) is being invoked.
+ * If available, show the name's assigned FCode-
+ * -token, definition-type, and scope.
+ *
+ * Inputs:
+ * Parameters:
+ * trace_entry The TIC entry of the name
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Printout:
+ * A Trace-Note message:
+ * Invoking <name> [FCode Token = <xxx>] [defined as a <Type>]
+ *
+ * Process Explanation:
+ * Although we could test the entry here to see whether it is
+ * being traced, we do not want to incur the speed penalty
+ * of the overhead of unconditionally calling a routine that,
+ * in most cases, will not do anything, every time a token
+ * is processed. We believe it is faster for the calling
+ * routine to conduct that test.
+ * Therefore, this routine will pre-suppose that the "tracing"
+ * field of the entry is TRUE.
+ *
+ **************************************************************************** */
+
+void invoking_traced_name( tic_hdr_t *trace_entry)
+{
+
+ char fc_token_display[TRACING_FCODE_LENGTH] = "";
+ char *defr_name = "" ;
+ char *defr_phrase = "" ;
+ char *defr_space = "" ;
+
+ if ( trace_entry->is_token )
+ {
+ tracing_fcode( fc_token_display,
+ (u16)trace_entry->pfield.deflt_elem );
+ }
+
+ if ( definer_name(trace_entry->fword_defr, &defr_name) )
+ {
+ defr_phrase = " defined as a";
+ defr_space = " " ;
+
+ }
+
+ tokenization_error(TRACER,
+ "Invoking %s" /* <name> */
+ "%s" /* fc_token_display */
+ "%s%s" /* defr_phrase defr_space */
+ "%s.\n", /* defr_name */
+ trace_entry->name,
+ fc_token_display,
+ defr_phrase, defr_space,
+ defr_name);
+
+}
+
+/* **************************************************************************
+ *
+ * Function name: handle_invocation
+ * Synopsis: Test whether the entry is being traced;
+ * if so, print the Trace-Note message.
+ *
+ * Inputs:
+ * Parameters:
+ * trace_entry The TIC entry to be tested.
+ * No harm if NULL
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Printout:
+ * A Trace-Note message, by invoking_traced_name() if
+ * the entry's tracing field is set.
+ *
+ * Extraneous Remarks:
+ * In cases that do not occur every time a token is processed,
+ * we can trade-off a small price in speed for convenience
+ * of coding. Call this routine judiciously...
+ *
+ **************************************************************************** */
+
+void handle_invocation( tic_hdr_t *trace_entry)
+{
+ if ( trace_entry != NULL )
+ {
+ if ( trace_entry->tracing)
+ {
+ invoking_traced_name( trace_entry);
+ }
+ }
+}
+
+
+/* **************************************************************************
+ *
+ * Function name: show_trace_list
+ * Synopsis: Display the trace-list (if any) at the start of the run
+ *
+ * Inputs:
+ * Parameters: NONE
+ * Local Static Variables:
+ * tracing_symbols Skip the display if FALSE
+ * trace_list Pointer to the Trace List
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Printout:
+ * List of symbols being traced; nothing if not tracing.
+ *
+ * Error Detection:
+ * Memory allocation failure is a FATAL error.
+ *
+ **************************************************************************** */
+
+void show_trace_list( void)
+{
+ if ( tracing_symbols )
+ {
+ trace_entry_t *test_entry;
+ printf("\nTracing these symbols:");
+ for ( test_entry = trace_list;
+ test_entry != NULL;
+ test_entry = test_entry->next )
+ {
+ printf(" %s", test_entry->tracee);
+
+ }
+ printf("\n");
+ }
+
+}
+
+/* **************************************************************************
+ *
+ * Function name: trace_builtin
+ * Synopsis: If the given built-in token, function, macro or
+ * directive is one the user asked to have Traced,
+ * issue a Trace-Note describing it, and set the
+ * TIC_HDR entry's tracing field to TRUE.
+ * Called while initializing vocab-lists.
+ *
+ * Inputs:
+ * Parameters:
+ * trace_entry The TIC entry of the built-in name
+ * Global Variables:
+ * in_tokz_esc TRUE if initializing the vocab-list
+ * for Tokenizer-Escape mode.
+ * in_tkz_esc_mode String for announcing Tokz-Esc mode
+ * Local Static Variables:
+ *
+ * Outputs:
+ * Returned Value: NONE
+ * Supplied Pointers:
+ * trace_entry->tracing Set TRUE, if the entry's name is on
+ * the Trace List.
+ * Printout:
+ * Trace-Note: <name> <(if is_single:FCode Token = xxx)>
+ * is a built-in {word|<Type>} [in Tokz-Esc mode]
+ *
+ **************************************************************************** */
+
+void trace_builtin( tic_hdr_t *trace_entry)
+{
+ if (is_on_trace_list( trace_entry->name ) )
+ {
+ char fc_token_display[TRACING_FCODE_LENGTH] = "";
+ char *defr_name = "word";
+ char *ws_space = in_tokz_esc ? " " : "";
+ char *with_scope = in_tokz_esc ? in_tkz_esc_mode : ".\n";
+ if ( trace_entry->is_token )
+ {
+ tracing_fcode( fc_token_display,
+ (u16)trace_entry->pfield.deflt_elem );
+ }
+ definer_name(trace_entry->fword_defr, &defr_name);
+ trace_entry->tracing = TRUE;
+ tokenization_error(TRACER,
+ "%s" /* <name> */
+ "%s " /* fc_token_display */
+ "is a built-in %s" /* defr_name */
+ "%s%s", /* ws_space with_scope */
+ trace_entry->name,
+ fc_token_display, defr_name, ws_space, with_scope );
+ }
+}
+
diff --git a/toke/tracesyms.h b/toke/tracesyms.h
index b50f7fe..506edaf 100644
--- a/toke/tracesyms.h
+++ b/toke/tracesyms.h
@@ -35,6 +35,16 @@
**************************************************************************** */
#include "types.h"
+#include "ticvocab.h"
+#include "devnode.h"
+
+/* ************************************************************************** *
+ *
+ * Global Variables Exported
+ *
+ **************************************************************************** */
+
+extern int split_alias_message;
/* ************************************************************************** *
*
@@ -44,5 +54,25 @@
void add_to_trace_list( char *trace_symb);
bool is_on_trace_list( char *symb_name);
+void tracing_fcode( char *fc_phrase_buff, u16 fc_token_num);
+void trace_creation( tic_hdr_t *trace_entry,
+ char *nu_name,
+ bool is_global);
+void trace_create_failure( char *new_name, char *old_name, u16 fc_tokn);
+void traced_name_error( char *trace_name);
+void invoking_traced_name( tic_hdr_t *trace_entry);
+void handle_invocation( tic_hdr_t *trace_entry);
+void show_trace_list( void);
+void trace_builtin( tic_hdr_t *trace_entry);
+
+/* ************************************************************************** *
+ *
+ * Macro:
+ * TRACING_FCODE_LENGTH
+ * Adequate length for the buffer passed to tracing_fcode()
+ *
+ **************************************************************************** */
+
+#define TRACING_FCODE_LENGTH 32
#endif /* _TOKE_TRACESYMS_H */
diff --git a/toke/vocabfuncts.h b/toke/vocabfuncts.h
index 7eb97dd..98ecdf3 100644
--- a/toke/vocabfuncts.h
+++ b/toke/vocabfuncts.h
@@ -47,6 +47,8 @@
**************************************************************************** */
extern bool scope_is_global;
+extern bool define_token;
+
/* ************************************************************************** *
*
@@ -66,8 +68,7 @@ bool exists_in_current( char *tname);
tic_hdr_t *lookup_in_dev_node( char *tname);
void add_to_current( char *name,
TIC_P_DEFLT_TYPE fc_token,
- fwtoken definer,
- bool define_token);
+ fwtoken definer);
void hide_last_colon ( void );
void reveal_last_colon ( void );
bool create_current_alias( char *new_name, char *old_name );