/usr/share/picolisp/src64/sym.l is in picolisp 17.12+20180218-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 | # 07apr17abu
# (c) Software Lab. Alexander Burger
### Compare long names ###
(code 'cmpLongAX_F 0)
push X # Keep X
do
cmp (A DIG) (X DIG) # Equal?
if ne # No
pop X
ret
end
ld A (A BIG)
ld X (X BIG)
big A # A on last digit?
if z # Yes
big X # X also on last digit?
if nz # No
lt # A is smaller
pop X
ret
end
cmp A X # Equal?
pop X
ret
end
cnt X # A not on last digit. X on last digit?
until nz # Yes
gt # A is greater
pop X
ret
(code 'nextIsInternEXYZ_FE 0) # Y
ld Y ((Z)) # Get next tree
ld Z (Z CDR)
### Is symbol interned? ###
# E symbol
# X name
# Z more
(code 'isInternEXYZ_FCE 0) # Y
ld C 0 # Default current namespace
cnt X # Short name?
if nz # Yes
10 ld Y (Y) # Y on first tree
do
atom Y # Empty?
if nz # Yes
atom Z # More namespaces?
jnz ret # Return NO
null C # Found in current?
ldnz C (Z) # Yes, keep next namespace
ld Y ((Z)) # Get next tree
ld Z (Z CDR)
jmp 10 # Try next
end
ld A ((Y) TAIL) # Next symbol
call nameA_A # Get name
cmp A X # Equal?
while ne # No
if lt
ld Y ((Y CDR) CDR) # Symbol is smaller
else
ld Y ((Y CDR)) # Symbol is greater
end
loop
null E # Given symbol?
if z # No
ld E (Y) # Found one
else
cmp E (Y) # Same Symbol?
if nz # No
ld C (Z) # Try next namespace if any
ld Y (C)
ld Z (Z CDR)
jmp 10
end
end
ret # Return YES
end
# Long name
20 ld Y (Y CDR) # Y on second tree
do
atom Y # Empty?
if nz # Yes
atom Z # More namespaces?
jnz ret # Return NO
null C # Found in current?
ldnz C (Z) # Yes, keep next namespace
ld Y ((Z)) # Get next tree
ld Z (Z CDR)
jmp 20 # Try next
end
ld A ((Y) TAIL) # Next symbol
call nameA_A # Get name
call cmpLongAX_F # Equal?
while ne # No
if lt
ld Y ((Y CDR) CDR) # Symbol is smaller
else
ld Y ((Y CDR)) # Symbol is greater
end
loop
null E # Given symbol?
if z # No
ld E (Y) # Found one
else
cmp E (Y) # Same Symbol?
if nz # No
ld C (Z) # Try next namespace if any
ld Y (C)
ld Z (Z CDR)
jmp 20
end
end
ret # Return YES
### Intern a symbol/name ###
# E symbol
# X name
# Y tree
# Z more
(code 'internEXYZ_FE 0)
cnt X # Short name?
if nz # Yes
ld C (Y) # C on first tree
atom C # Empty?
if nz # Yes
atom Z # More namespaces?
if z # Yes
push Y
call nextIsInternEXYZ_FE # Check
pop Y
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_X # Cons into a new node
ld (X) E
ld (X CDR) Nil
ld (Y) X # Store in first tree
lt # Return new symbol
ret
end
do
ld A ((C) TAIL) # Next symbol
call nameA_A # Get name
cmp A X # Equal?
if eq # Yes
ld E (C) # Found symbol
ret
end
if lt # Symbol is smaller
atom (C CDR) # Already has link?
if nz # No
atom Z # More namespaces?
if z # Yes
push C
call nextIsInternEXYZ_FE # Check
pop C
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_A # Cons into a new node
ld (A) E
ld (A CDR) Nil
call consA_X # Cons into a new link
ld (X) Nil
ld (X CDR) A
ld (C CDR) X
lt # Return new symbol
ret
end
ld C (C CDR)
atom (C CDR) # CDR of link?
ldz C (C CDR) # Yes: Get CDR of link in C
if nz # No
atom Z # More namespaces?
if z # Yes
push C
call nextIsInternEXYZ_FE # Check
pop C
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_A # Cons into a new node
ld (A) E
ld (A CDR) Nil
ld (C CDR) A # Store in CDR of link
lt # Return new symbol
ret
end
else # Symbol is greater
atom (C CDR) # Already has link?
if nz # No
atom Z # More namespaces?
if z # Yes
push C
call nextIsInternEXYZ_FE # Check
pop C
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_A # Cons into a new node
ld (A) E
ld (A CDR) Nil
call consA_X # Cons into a new link
ld (X) A
ld (X CDR) Nil
ld (C CDR) X
lt # Return new symbol
ret
end
ld C (C CDR)
atom (C) # CAR of link?
ldz C (C) # Yes: Get CAR of link in C
if nz # No
atom Z # More namespaces?
if z # Yes
push C
call nextIsInternEXYZ_FE # Check
pop C
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_A # Cons into a new node
ld (A) E
ld (A CDR) Nil
ld (C) A # Store in CAR of link
lt # Return new symbol
ret
end
end
loop
end
# Long name
ld C (Y CDR) # C on second tree
atom C # Empty?
if nz # Yes
atom Z # More namespaces?
if z # Yes
push Y
call nextIsInternEXYZ_FE # Check
pop Y
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_X # Cons into a new node
ld (X) E
ld (X CDR) Nil
ld (Y CDR) X # Store in second tree
lt # Return new symbol
ret
end
do
ld A ((C) TAIL) # Next symbol
call nameA_A # Get name
call cmpLongAX_F # Equal?
if eq # Yes
ld E (C) # Found symbol
ret
end
if lt # Symbol is smaller
atom (C CDR) # Already has link?
if nz # No
atom Z # More namespaces?
if z # Yes
push C
call nextIsInternEXYZ_FE # Check
pop C
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_A # Cons into a new node
ld (A) E
ld (A CDR) Nil
call consA_X # Cons into a new link
ld (X) Nil
ld (X CDR) A
ld (C CDR) X
lt # Return new symbol
ret
end
ld C (C CDR)
atom (C CDR) # CDR of link?
ldz C (C CDR) # Yes: Get CDR of link in C
if nz # No
atom Z # More namespaces?
if z # Yes
push C
call nextIsInternEXYZ_FE # Check
pop C
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_A # Cons into a new node
ld (A) E
ld (A CDR) Nil
ld (C CDR) A # Store in CDR of link
lt # Return new symbol
ret
end
else # Symbol is greater
atom (C CDR) # Already has link?
if nz # No
atom Z # More namespaces?
if z # Yes
push C
call nextIsInternEXYZ_FE # Check
pop C
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_A # Cons into a new node
ld (A) E
ld (A CDR) Nil
call consA_X # Cons into a new link
ld (X) A
ld (X CDR) Nil
ld (C CDR) X
lt # Return new symbol
ret
end
ld C (C CDR)
atom (C) # CAR of link?
ldz C (C) # Yes: Get CAR of link in C
if nz # No
atom Z # More namespaces?
if z # Yes
push C
call nextIsInternEXYZ_FE # Check
pop C
jeq Ret # Return if found
end
null E # New symbol?
if z
call consSymX_E # Yes
end
call consE_A # Cons into a new node
ld (A) E
ld (A CDR) Nil
ld (C) A # Store in CAR of link
lt # Return new symbol
ret
end
end
loop
(code 'findSymX_E 0) # Y
ld E 0 # No symbol yet
ld A (EnvIntern)
ld Y ((A)) # First tree
push Z
ld Z (A CDR) # More namespaces
call internEXYZ_FE # New internal symbol?
pop Z
jge Ret # No
ld (E) Nil # Init to 'NIL'
ret
(code 'isEnvInternEX_FCE 0) # Y
ld A (EnvIntern)
ld Y ((A)) # First tree
push Z
ld Z (A CDR) # More namespaces
call isInternEXYZ_FCE # Internal symbol?
pop Z
ret
# X name
(code 'externX_E 0) # C
push Y
call need3 # Reserve 3 cells
ld Y (Extern) # Y on external symbol tree
ld C 0 # Level counter
do
inc C # Next level
ld E (Y) # Next symbol
ld A (E TAIL) # Get name
call nameA_A
and A (hex "3FFFFFFFFFFFFFF7") # Mask status and extern bits
cmp A X # Equal to key?
while ne # No
if lt # Symbol is smaller
ld E (Y CDR) # Get link cell
atom E # Already has link?
if z # Yes
ld Y (E CDR) # Right node?
atom Y
continue z # Yes
else
call cons_E # New link cell
ld (Y CDR) E
ld (E) Nil
end
call cons_A # New right node
ld (E CDR) A
else # Symbol is greater
ld E (Y CDR) # Get link cell
atom E # Already has link?
if z # Yes
ld Y (E) # Left node?
atom Y
continue z # Yes
else
call cons_E # New link cell
ld (Y CDR) E
ld (E CDR) Nil
end
call cons_A # New left node
ld (E) A
end
inc (ExtCnt) # Increment count
call cons_E # New symbol
ld (E) X # Set name
or (E) SYM # Set 'extern' tag
or E SYM # Make symbol
ld (A) E # Store in node
ld (A CDR) Nil
ld (E) Nil # Init to 'NIL'
break T
loop
ld A 1 # 2 ** (C/2)
shr C 1
shl A C
cmp A (ExtCnt) # Tree too deep?
if gt # Yes
ld Y (Extern) # Y on external symbol tree again
ld A (ExtSkip) # Levels to skip
inc A # Increment
cmp A C # Beyond half depth?
if gt # Yes
ld (ExtSkip) 0 # Don't skip
else
ld C A # Skip
ld (ExtSkip) A # Save new value
do
ld A ((Y) TAIL) # Get name
ld Y (Y CDR) # Get link cell
call nameA_A
and A (hex "3FFFFFFFFFFFFFF7") # Mask status and extern bits
cmp A X # Compare name with key
if lt
ld Y (Y CDR) # Go left if symbol is smaller
else
ld Y (Y) # else go right
end
dec C # Done?
until z # Yes
end
do
ld A ((Y) TAIL) # Get name
call nameA_A
and A (hex "3FFFFFFFFFFFFFF7") # Mask status and extern bits
cmp A X # Equal to key?
while ne # No
ld C (Y CDR) # Get link cell
if lt # Symbol is smaller
ld A (C CDR) # A on right node
atom (A CDR) # Right link?
break nz # No
xchg (A) (Y) # Pivot left
ld A (A CDR) # A also on the link
ld Y (A CDR) # Rotate pointers
ld (A CDR) (A)
ld (A) (C)
ld (C) (C CDR)
ld (C CDR) Y
else # Symbol is greater
ld A (C) # A on left node
atom (A CDR) # Left link?
break nz # No
xchg (A) (Y) # Pivot right
ld A (A CDR) # A also on the link
ld Y (A) # Rotate pointers
ld (A) (A CDR)
ld (A CDR) (C CDR)
ld (C CDR) (C)
ld (C) Y
end
loop
end
pop Y
ret
### Unintern a symbol ###
# E symbol
# X name
# Y tree
(code 'uninternEXY 0)
cmp X ZERO # Name?
jeq ret # No
cnt X # Short name?
if nz # Yes
do # Y on first tree
ld C (Y) # Next node
atom C # Empty?
jnz ret # Yes
ld A ((C) TAIL) # Next symbol
call nameA_A # Get name
cmp A X # Equal?
if eq # Yes
cmp E (C) # Correct symbol?
jne Ret # No
ld A (C CDR) # Get subtrees
atom (A) # Left branch?
if nz # No
ld (Y) (A CDR) # Use right branch
ret
end
atom (A CDR) # Right branch?
if nz # No
ld (Y) (A) # Use left branch
ret
end
ld A (A CDR) # A on right branch
ld Y (A CDR) # Y on sub-branches
atom (Y) # Left?
if nz # No
ld (C) (A) # Insert right sub-branch
ld ((C CDR) CDR) (Y CDR)
ret
end
ld Y (Y) # Left sub-branch
do
ld X (Y CDR) # More left branches?
atom (X)
while z # Yes
ld A Y # Go down left
ld Y (X)
loop
ld (C) (Y) # Insert left sub-branch
ld ((A CDR)) (X CDR)
ret
end
ld C (C CDR)
if lt # Symbol is smaller
atom C # Link?
jnz ret # No
lea Y (C CDR) # Go right
else # Symbol is greater
atom C # Link?
jnz ret # No
ld Y C # Go left
end
loop
end
# Long name
lea Y (Y CDR)
do # Y on second tree
ld C (Y) # Get next node
atom C # Empty?
jnz ret # Yes
ld A ((C) TAIL) # Next symbol
call nameA_A # Get name
call cmpLongAX_F # Equal?
if eq # Yes
cmp E (C) # Correct symbol?
jne Ret # No
ld A (C CDR) # Get subtrees
atom (A) # Left branch?
if nz # No
ld (Y) (A CDR) # Use right branch
ret
end
atom (A CDR) # Right branch?
if nz # No
ld (Y) (A) # Use left branch
ret
end
ld A (A CDR) # A on right branch
ld Y (A CDR) # Y on sub-branches
atom (Y) # Left?
if nz # No
ld (C) (A) # Insert right sub-branch
ld ((C CDR) CDR) (Y CDR)
ret
end
ld Y (Y) # Left sub-branch
do
ld X (Y CDR) # More left branches?
atom (X)
while z # Yes
ld A Y # Go down left
ld Y (X)
loop
ld (C) (Y) # Insert left sub-branch
ld ((A CDR)) (X CDR)
ret
end
ld C (C CDR)
if lt # Symbol is smaller
atom C # Link?
jnz ret # No
lea Y (C CDR) # Go right
else # Symbol is greater
atom C # Link?
jnz ret # No
ld Y C # Go left
end
loop
(code 'nameA_A 0)
off A SYM # Clear 'extern' tag
do
num A # Find name
jnz ret
ld A (A CDR) # Skip property
loop
(code 'nameE_E 0)
off E SYM # Clear 'extern' tag
do
num E # Find name
jnz ret
ld E (E CDR) # Skip property
loop
(code 'nameX_X 0)
off X SYM # Clear 'extern' tag
do
num X # Find name
jnz ret
ld X (X CDR) # Skip property
loop
(code 'nameY_Y 0)
off Y SYM # Clear 'extern' tag
do
num Y # Find name
jnz ret
ld Y (Y CDR) # Skip property
loop
# (name 'sym ['sym2]) -> sym
(code 'doName 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval 'sym'
eval
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
ld Y (Y CDR) # Second arg?
atom Y
if nz # No
cmp E Nil # NIL?
if ne # No
ld X (E TAIL)
sym X # External symbol?
if z # No
call nameX_X # Get name
call consSymX_E # Make new transient symbol
else
call nameX_X # Get name
call packExtNmX_E # Pack it
end
end
else
cmp E Nil # NIL?
jeq renErrEX # Yes
sym (E TAIL) # External symbol?
jnz renErrEX # Yes
push X # Save expression
push Y
ld X (E TAIL)
call nameX_X # Get name
call isEnvInternEX_FCE # Internal symbol?
pop Y
pop X
jz renErrEX # Yes
link
push E # <L I> First (transient) symbol
link
ld E (Y)
eval # Eval second arg
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
ld X (E TAIL)
call nameX_X # Get name
push X # Save new name
ld E (L I) # Get first symbol
ld X (E TAIL)
call nameX_X # Get name
ld Y Transient
call uninternEXY # Unintern
lea Y (E TAIL)
do
num (Y) # Find name
while z
lea Y ((Y) CDR)
loop
pop (Y) # Store name of second
drop
end
pop Y
pop X
ret
# Make single-char symbol
(code 'mkCharA_A 0)
cmp A (hex "80") # ASCII?
if ge # No
cmp A (hex "800") # Double-byte?
if lt # Yes
ld (Buf) B # 110xxxxx 10xxxxxx
shr A 6 # Upper five bits
and B (hex "1F")
or B (hex "C0")
xchg B (Buf) # Save first byte
and A (hex "3F") # Lower 6 bits
or B (hex "80")
shl A 8 # into second byte
ld B (Buf) # Get first byte
else
cmp A TOP # Special "top" character?
if eq # Yes
ld B (hex "FF") # Above legal UTF-8
zxt
else
push C
ld C A # 1110xxxx 10xxxxxx 10xxxxxx
shr A 12 # Hightest four bits
and B (hex "0F")
or B (hex "E0")
ld (Buf) B # Save first byte
ld A C
shr A 6 # Middle six bits
and A (hex "3F")
or B (hex "80")
shl A 8 # into second byte
xchg A C
and A (hex "3F") # Lowest 6 bits
or B (hex "80") # Add third byte
shl A 16 # into third byte
or A C # Combine with second byte
ld B (Buf) # and first byte
pop C
end
end
end
shl A 4 # Make short name
or A CNT
push A # Save character
call cons_A # New cell
pop (A) # Set name
or A SYM # Make symbol
ld (A) A # Set value to itself
ret
(code 'mkStrE_E 0)
null E # NULL pointer?
jz retNil
nul (E) # Empty string?
jz retNil
push C
push X
link
push ZERO # <L I> Name
ld C 4 # Build name
ld X S
link
do
ld B (E)
call byteSymBCX_CX # Pack byte
inc E # Next byte
nul (E) # Any?
until z
call cons_E # Cons symbol
ld (E) (L I) # Set name
or E SYM # Make symbol
ld (E) E # Set value to itself
drop
pop X
pop C
ret
(code 'mkStrEZ_A 0)
push X
link
push ZERO # <L I> Name
ld C 4 # Build name
ld X S
link
do
ld B (E)
call byteSymBCX_CX # Pack byte
cmp E Z # Reached Z?
while ne # No
inc E # Next byte
nul (E) # Any?
until z
call cons_A # Cons symbol
ld (A) (L I) # Set name
or A SYM # Make symbol
ld (A) A # Set value to itself
drop
pop X
ret
(code 'firstByteA_B 0)
sym A # External symbol?
if z # No
call nameA_A # Get name
cnt A # Short?
if nz # Yes
shr A 4 # Normalize
else
ld A (A DIG) # Get first digit
end
ret
end
ld A 0
ret
(code 'firstCharE_A 0)
ld A 0
cmp E Nil # NIL?
if ne # No
push X
ld X (E TAIL)
sym X # External symbol?
if z # No
call nameX_X # Get name
ld C 0
call symCharCX_FACX # Get first character
end
pop X
end
ret
(code 'isBlankE_F 0)
num E # Symbol?
jnz ret # No
sym E
jz retGt # No
cmp E Nil # NIL?
jeq ret # Yes
sym (E TAIL) # External symbol?
jnz ret # Yes
push X
ld X (E TAIL)
call nameX_X # Get name
ld C 0
do
call symByteCX_FACX # Next byte
while nz
cmp B 32 # Larger than blank?
break gt # Yes
loop
pop X
ret
# (sp? 'any) -> flg
(code 'doSpQ 2)
ld E ((E CDR)) # Get arg
eval # Eval it
call isBlankE_F # Blank?
ld E TSym # Yes
ldnz E Nil
ret
# (pat? 'any) -> sym | NIL
(code 'doPatQ 2)
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Number?
jnz retNil # Yes
sym E # Symbol?
jz retNil # No
ld A (E TAIL)
call firstByteA_B # starting with "@"?
cmp B (char "@")
ldnz E Nil # No
ret
# (fun? 'any) -> any
(code 'doFunQ 2)
ld E ((E CDR)) # Get arg
eval # Eval it
call funqE_FE # Function definition?
ldnz E Nil # No
ret
# (getd 'any) -> fun | NIL
(code 'doGetd 2)
ld E ((E CDR)) # E on arg
eval # Eval it
num E # No number?
if z # Yes
sym E # Symbol?
if nz # Yes
push E
ld E (E) # Get value
call funqE_FE # Function definition?
pop E
if eq # Yes
ld E (E) # Return value
ret
end
cmp (E) Nil # Value NIL?
if eq # Yes
ld C E
call sharedLibC_FA # Dynamically loaded?
if nz # Yes
ld E A # Return function pointer
ret
end
end
end
end
ld E Nil
ret
# (all ['NIL | 'T | '0 | 'sym | '(NIL . flg) | '(T . flg) | '(0)]) -> lst
(code 'doAll 2)
push X
push Y
ld E ((E CDR)) # Eval arg
eval
atom E # Direct tree?
if z # Yes
cmp (E) Nil # Internal trees?
if eq # Yes
ld A (((EnvIntern)))
cmp (E CDR) Nil # Short names?
ldz E (A) # Yes
ldnz E (A I)
else
cmp (E) TSym # Transient trees?
ldnz E (Extern) # No: External symbols
if eq # Yes
cmp (E CDR) Nil # Short names?
ldz E (Transient) # Yes
ldnz E (Transient I)
end
end
else
cmp E Nil # Nil?
if eq # Yes
ld Y (EnvIntern) # Namespace list
do
ld X (((Y)) I) # Internal symbols
call consTreeXE_E
ld X (((Y)))
call consTreeXE_E
ld Y (Y CDR) # More?
atom Y
until nz # No
else
cmp E TSym # T?
if eq # Yes
ld E Nil
ld X (Transient I) # Transient symbols
call consTreeXE_E
ld X (Transient)
else
cmp E ZERO # Zero?
if eq # Yes
ld E Nil
ld X (Extern) # External symbols
else
ld Y (E) # Given namespace
ld E Nil
ld X (Y I)
call consTreeXE_E
ld X (Y)
end
end
call consTreeXE_E
end
end
pop Y
pop X
ret
# Build sorted list from tree
(code 'consTreeXE_E 0)
atom X # Tree empty?
jnz ret # Yes
link
push X # <L II> Tree
push Nil # <L I> TOS
link
do
do
ld A (X CDR) # Get subtrees
atom (A CDR) # Right subtree?
while z # Yes
ld C X # Go right
ld X (A CDR) # Invert tree
ld (A CDR) (L I) # TOS
ld (L I) C
loop
ld (L II) X # Save tree
do
call consE_A # Cons value
ld (A) (X)
ld (A CDR) E
ld E A # into E
ld A (X CDR) # Left subtree?
atom (A)
if z # Yes
ld C X # Go left
ld X (A) # Invert tree
ld (A) (L I) # TOS
or C SYM # First visit
ld (L I) C
ld (L II) X # Save tree
break T
end
do
ld A (L I) # TOS
cmp A Nil # Empty?
jeq 90 # Done
sym A # Second visit?
if z # Yes
ld C (A CDR) # Nodes
ld (L I) (C CDR) # TOS on up link
ld (C CDR) X
ld X A
ld (L II) X # Save tree
break T
end
off A SYM # Set second visit
ld C (A CDR) # Nodes
ld (L I) (C)
ld (C) X
ld X A
ld (L II) X # Save tree
loop
loop
loop
90 drop # Return E
ret
# (symbols) -> lst
# (symbols 'lst) -> lst
# (symbols 'lst . prg) -> any
# (symbols 'sym1 'sym2 ..) -> lst
(code 'doSymbols 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
atom Y # Any?
if nz # No
ld E (EnvIntern) # Return current namespaces
else
ld E (Y) # Eval first
eval
atom E # List?
if z # Yes
ld Y (Y CDR) # 'prg'?
atom Y
if z # Yes
xchg (EnvIntern) E # Set new namespaces
link
push E # <L I> Save current
link
prog Y # Run 'prog'
ld (EnvIntern) (L I) # Restore namespaces
drop
pop Y
pop X
ret
end
else
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
cmp (E) Nil # New namespace?
if ne # No
atom (E) # Value must be a pair
jnz symNsErrEX
else
call consE_C # Create namespace cell
ld (C) Nil # Initialize
ld (C CDR) Nil
ld (E) C
end
call consE_C # Cons symbol with NIL
ld (C) E
ld (C CDR) Nil
link
push C # <L I> Save
link
push Z
do
ld Z C # Keey in Z
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld E (Y)
eval # Eval next arg
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
atom (E) # Value must be a pair
jnz symNsErrEX
call consE_C # Cons with NIL
ld (C) E
ld (C CDR) Nil
ld (Z CDR) C # Concatenate
loop
ld E (L I) # Get new list
pop Z
drop
end
xchg (EnvIntern) E # Set new symbol namespaces, return old
end
pop Y
pop X
ret
# (intern 'sym ['flg]) -> sym
(code 'doIntern 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y)
eval # Eval first
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
ld X (E TAIL)
call nameX_X # Get name
cmp X ZERO # Any?
if ne # Yes
push Z
link
push E # <L I> Save symbol
link
ld E ((Y CDR)) # Eval 'flg'
eval
ld A (EnvIntern) # Internals
ld Y ((A)) # First tree
cmp E Nil # 'flg'?
if eq # No
ld E 0 # No symbol yet
ldz Z (A CDR) # Search all namespaces
else
ld E (L I) # Get symbol
ld Z Nil # Search only current namespace
end
call internEXYZ_FE
drop
pop Z
pop Y
pop X
ret
end
ld E Nil
pop Y
pop X
ret
# (extern 'sym) -> sym | NIL
(code 'doExtern 2)
push X
push Y
ld X E
ld E ((E CDR)) # E on arg
eval # Eval it
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
ld X (E TAIL)
call nameX_X # Get name
cmp X ZERO # Any?
if ne # Yes
ld C 0 # Character index
call symCharCX_FACX # First char
cmp B (char "{") # Open brace?
if eq # Yes
call symCharCX_FACX # Skip it
end
ld E 0 # Init file number
do
cmp B (char "@") # File done?
while ge # No
cmp B (char "O") # In A-O range?
jgt 90 # Yes
sub B (char "@")
shl E 4 # Add to file number
add E A
call symCharCX_FACX # Next char?
jz 90 # No
loop
cmp B (char "0") # Octal digit?
jlt 90
cmp B (char "7")
jgt 90 # No
sub B (char "0")
zxt
ld Y A # Init object ID
do
call symCharCX_FACX # Next char?
while nz # Yes
cmp B (char "}") # Closing brace?
while ne # No
cmp B (char "0") # Octal digit?
jlt 90
cmp B (char "7")
jgt 90 # No
sub B (char "0")
shl Y 3 # Add to object ID
add Y A
loop
ld C Y # Object ID
call extNmCE_X # Build external symbol name
call externX_E # New external symbol
call isLifeE_F # Alive?
ldnz E Nil # No
pop Y
pop X
ret
end
90 ld E Nil
pop Y
pop X
ret
# (==== ['sym ..]) -> NIL
(code 'doHide 2)
ld A Nil # Clear transient index trees
ld (Transient) A
ld (Transient I) A
push X
push Y
push Z
ld X E
ld Z (E CDR) # Args
do
atom Z # More?
while z # Yes
ld E (Z) # Eval next
eval
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
push X
push Z
ld X (E TAIL)
call nameX_X # Get name
ld Y Transient # Insert transient
ld Z Nil # No more namespaces
call internEXYZ_FE
pop Z
pop X
ld Z (Z CDR) # Z on rest
loop
pop Z
pop Y
pop X
ret
# (box? 'any) -> sym | NIL
(code 'doBoxQ 2)
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Number?
jnz retNil # Yes
sym E # Symbol?
jz retNil # No
ld A (E TAIL)
call nameA_A # Get name
cmp A ZERO # Any?
jne retNil
ret
# (str? 'any) -> sym | NIL
(code 'doStrQ 2)
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Number?
jnz retNil # Yes
sym E # Symbol?
jz retNil # No
sym (E TAIL) # External symbol?
jnz retNil # Yes
push X
push Y
ld X (E TAIL) # Get name
call nameX_X
call isEnvInternEX_FCE # Internal symbol?
ldz E Nil # Return NIL
pop Y
pop X
ret
# (ext? 'any) -> sym | NIL
(code 'doExtQ 2)
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Number?
jnz retNil # Yes
sym E # Symbol?
jz retNil # No
ld A (E TAIL)
sym A # External symbol?
jz retNil # No
call isLifeE_F # Alive?
ldnz E Nil # No
ret
# (touch 'sym) -> sym
(code 'doTouch 2)
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
ret
# (zap 'sym) -> sym
(code 'doZap 2)
push X
ld X E
ld E ((E CDR)) # E on arg
eval # Eval it
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
ld A (E TAIL)
sym A # External symbol?
if nz # Yes
call dbZapE # Mark as "deleted"
else
push Y
ld X (E TAIL)
call nameX_X # Get name
ld Y (((EnvIntern)))
call uninternEXY # Unintern symbol
pop Y
end
pop X
ret
# (chop 'any) -> lst
(code 'doChop 2)
ld E ((E CDR)) # Get arg
eval # Eval it
atom E # Atomic?
if nz # Yes
cmp E Nil # NIL?
if ne # No
push X
call xSymE_E # Extract symbol
ld X (E TAIL)
call nameX_X # Get name
sym (E TAIL) # External symbol?
if z # No
ld C 0
call symCharCX_FACX # First char?
if nz # Yes
push Y
link
push X # Save name
link
call mkCharA_A # Make single character
call consA_Y # Cons it
ld (Y) A
ld (Y CDR) Nil # with NIL
tuck Y # <L I> Result
link
do
call symCharCX_FACX # Next char
while nz
call mkCharA_A # Make char
call consA_E # Cons it
ld (E) A
ld (E CDR) Nil
ld (Y CDR) E # Append to result
ld Y E
loop
ld E (L I) # Get result
drop
pop Y
else
ld E Nil # Else return NIL
end
else # External symbol
call chopExtNmX_E
end
pop X
end
end
ret
# (pack 'any ..) -> sym
(code 'doPack 2)
push X
push Y
push Z
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
link
push E # <L III> 'any'
push ZERO # <L II> Safe
push ZERO # <L I> Result
ld C 4 # Build name
ld X S
link
do
call packECX_CX
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld Z C # Save C
ld E (Y) # Eval next arg
eval
ld (L III) E # Save
ld C Z
loop
ld X (L I) # Get result
call consSymX_E # Make transient symbol
drop
pop Z
pop Y
pop X
ret
(code 'packECX_CX 0)
atom E # Atomic?
if z # No
cmp S (StkLimit) # Stack check
jlt stkErr
do # List
push (E CDR) # Save rest
ld E (E) # Recurse on CAR
call packECX_CX
pop E # Done?
atom E
until nz # Yes
end
cmp E Nil # NIL?
jeq ret # Yes
num E # Number?
if z # No
sym (E TAIL) # External symbol?
if nz # Yes
ld B (char "{")
call byteSymBCX_CX # Pack "{"
push C # Save status
push X
ld X (E TAIL) # Get name
call nameX_X
call packExtNmX_E # Pack name
ld (L II) E # Save
pop X # Restore status
pop C
call packExt # Pack external symbol
ld B (char "}")
jmp byteSymBCX_CX # Pack "}"
end
else
ld A 0 # Scale
call fmtNum0AE_E # Convert to symbol
ld (L II) E # Save
end
: packExt
push C # Save status
push X
ld X (E TAIL)
call nameX_X # Get name
ld C 0
do
call symByteCX_FACX # Next char
while nz
xchg C (S I) # Swap status
xchg X (S)
call byteSymBCX_CX # Pack byte
xchg X (S) # Swap status
xchg C (S I)
loop
pop X # Restore status
pop C
ret
# (glue 'any 'lst) -> sym
(code 'doGlue 2)
push X
push Y
ld X (E CDR) # Args
ld E (X) # Eval first
eval
link
push E # <L IV> 'any'
ld X (X CDR) # X on rest
ld E (X) # Eval second
eval+
push E # <L III> 'lst'
push ZERO # <L II> Number safe
push ZERO # <L I> Result
ld C 4 # Build name
ld X S
link
atom E # Any items?
if z # Yes
ld Y E # 'lst'
do
ld E (Y) # Get next item
call packECX_CX # Pack it
ld Y (Y CDR) # More?
atom Y
while z # Yes
ld E (L IV) # Get 'any'
call packECX_CX # Pack it
loop
ld X (L I) # Get result
call consSymX_E # Make transient symbol
end
drop
pop Y
pop X
ret
# (text 'any1 'any ..) -> sym
(code 'doText 2)
push X
push Y
ld X (E CDR) # Args
call evSymX_E # Eval first
cmp E Nil # NIL?
if ne # No
ld E (E TAIL)
call nameE_E # Get name
link
push E # <(L) -I> Name of 'any1'
do
ld X (X CDR) # Next arg
atom X # Any?
while z # Yes
ld E (X) # Eval next arg
eval+
push E # and save it
loop
push ZERO # <L II> Number safe
push ZERO # <L I> Result
ld X S
link
push 4 # <S I> Build name
push X # <S> Pack status
ld X ((L) -I) # Get name of 'any1'
ld C 0 # Index
do
call symByteCX_FACX # Next char?
while nz
cmp B (char "@") # Pattern?
if ne # No
10 xchg C (S I) # Swap status
xchg X (S)
call byteSymBCX_CX # Pack byte
xchg X (S) # Swap status
xchg C (S I)
continue T
end
call symByteCX_FACX # Next char after "@"?
while nz
cmp B (char "@") # "@@"?
jeq 10 # Yes
sub B (char "0") # >= "1"?
if gt # Yes
cmp B 9 # > 9?
if gt
sub B 7 # Adjust for letter
end
shl A 3 # Vector index
lea E ((L) -I) # Point above first 'any' arg
sub E A # Get arg address
lea A (L II) # Address of number save
cmp E A # Arg address too low?
if gt # No
ld E (E)
xchg C (S I) # Swap status
xchg X (S)
call packECX_CX # Pack it
xchg X (S) # Swap status
xchg C (S I)
end
end
loop
ld X (L I) # Get result
call consSymX_E # Make transient symbol
drop
end
pop Y
pop X
ret
(code 'preCEXY_F 0)
do
call symByteCX_FACX # First string done?
jz ret # Yes
ld (Buf) B # Keep
xchg C E # Second string
xchg X Y
call symByteCX_FACX # Next byte?
jz retGt # No
cmp (Buf) B # Equal?
jne ret # No
xchg C E # First string
xchg X Y
loop
(code 'subStrAE_F 0)
cmp A Nil # NIL?
jeq ret # Yes
ld A (A TAIL) # First symbol
call nameA_A # Get name
cmp A ZERO # None?
jeq ret # Yes
ld E (E TAIL) # Second symbol
call nameE_E # Get name
cmp E ZERO # Any?
jeq retGt # No
push X
push Y
push Z
push A # <S I> First name
ld Z E # Second name
push 0 # <S> Second index
do
ld X (S I) # First name
ld C 0 # First index
ld Y Z # Second name
ld E (S) # Second index
call preCEXY_F # Prefix?
while ne # No
ld A (S)
shr A 8 # New round in second index?
if z # Yes
cmp Z ZERO # Second done?
if eq # Yes
gt # 'nz'
break T
end
cnt Z # Short?
if nz # Yes
ld A Z # Get short
shr A 4 # Normalize
ld Z ZERO # Clear for next round
else
ld A (Z DIG) # Get next digit
ld Z (Z BIG)
end
end
ld (S) A
loop
lea S (S II) # Drop locals
pop Z
pop Y
pop X
ret # 'z' or 'nz'
# (pre? 'any1 'any2) -> any2 | NIL
(code 'doPreQ 2)
push X
push Y
push Z
ld X (E CDR) # X on args
call evSymX_E # Eval first
link
push E # <L I> 'any1'
link
ld X (X CDR) # Next arg
call evSymX_E # Eval second
ld X (L I) # 'any1'
cmp X Nil # NIL?
if ne # No
ld Z E # Keep second in Z
ld X (X TAIL) # 'any1'
call nameX_X # First name
ld C 0
ld E (E TAIL) # 'any2'
call nameE_E # Second name
ld Y E
ld E 0
call preCEXY_F # Prefix?
ld E Nil
ldz E Z # Yes
end
drop
pop Z
pop Y
pop X
ret
# (sub? 'any1 'any2) -> any2 | NIL
(code 'doSubQ 2)
push X
ld X (E CDR) # X on args
call evSymX_E # Eval first
link
push E # <L I> 'any1'
link
ld X (X CDR) # Next arg
call evSymX_E # Eval second
ld A (L I) # 'any1'
ld X E # Keep second in X
call subStrAE_F # Substring?
ld E Nil
ldz E X # Yes
drop
pop X
ret
# (val 'var) -> any
(code 'doVal 2)
push X
ld X E
ld E ((E CDR)) # E on arg
eval # Eval it
num E # Need variable
jnz varErrEX
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbFetchEX # Fetch it
end
end
ld E (E) # Return value
pop X
ret
# (set 'var 'any ..) -> any
(code 'doSet 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
link
push ZERO # <L I> Safe
link
do
ld E (Y) # Eval next
eval
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
ld (L I) E # Save it
ld Y (Y CDR) # Next arg
ld E (Y)
eval # Eval 'any'
ld ((L I)) E # Set value
ld Y (Y CDR) # Next arg
atom Y # Any?
until nz # No
drop
pop Y
pop X
ret
# (setq var 'any ..) -> any
(code 'doSetq 2)
push X
push Y
push Z
ld X E
ld Y (E CDR) # Y on args
do
ld E (Y) # Next var
call needVarEX # Need variable
ld Z E # Keep in Z
ld Y (Y CDR) # Eval next arg
ld E (Y)
eval
ld (Z) E # Store value
ld Y (Y CDR) # More args?
atom Y
until nz # No
pop Z
pop Y
pop X
ret
# (swap 'var 'any) -> any
(code 'doSwap 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
link
push E # <L I> 'var'
link
ld E ((Y CDR)) # Eval next arg
eval
xchg E ((L I)) # Swap value
drop
pop Y
pop X
ret
# (xchg 'var 'var ..) -> any
(code 'doXchg 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
link
push ZERO # <L I> Safe
link
do
ld E (Y) # Eval next
eval
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
ld (L I) E # Save it
ld Y (Y CDR) # Next arg
ld E (Y)
eval # Eval next arg
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
ld C (L I) # Get first 'var'
ld A (C) # Get value
ld (C) (E) # Set new
ld (E) A
ld Y (Y CDR) # Next arg
atom Y # Any?
until nz # No
ld E A # Return last
drop
pop Y
pop X
ret
# (on var ..) -> T
(code 'doOn 2)
ld A (E CDR)
do
ld ((A)) TSym # Set next arg to 'T'
ld A (A CDR) # More?
atom A
until nz # No
ld E TSym
ret
# (off var ..) -> NIL
(code 'doOff 2)
ld A (E CDR)
do
ld ((A)) Nil # Set next arg to 'Nil'
ld A (A CDR) # More?
atom A
until nz # No
ld E Nil
ret
# (onOff var ..) -> flg
(code 'doOnOff 2)
ld A (E CDR)
do
ld C (A) # Get next arg
cmp (C) Nil # Value NIL?
ld E TSym # Negate
ldnz E Nil
ld (C) E # Set new value
ld A (A CDR) # More?
atom A
until nz # No
ret # Return last
# (zero var ..) -> 0
(code 'doZero 2)
ld A (E CDR)
do
ld ((A)) ZERO # Set next arg to '0'
ld A (A CDR) # More?
atom A
until nz # No
ld E ZERO
ret
# (one var ..) -> 1
(code 'doOne 2)
ld A (E CDR)
do
ld ((A)) ONE # Set next arg to '1'
ld A (A CDR) # More?
atom A
until nz # No
ld E ONE
ret
# (default sym 'any ..) -> any
(code 'doDefault 2)
push X
push Y
push Z
ld X E
ld Y (E CDR) # Y on args
do
ld E (Y) # Next var
ld Y (Y CDR)
call needVarEX # Need variable
ld Z E # Keep in Z
cmp (Z) Nil # Value 'NIL'?
if eq # Yes
ld E (Y) # Eval next arg
eval
ld (Z) E # Store value
end
ld Y (Y CDR) # More args?
atom Y
until nz # No
ld E (Z) # Return value
pop Z
pop Y
pop X
ret
# (push 'var 'any ..) -> any
(code 'doPush 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
link
push E # <L I> 'var'
link
ld Y (Y CDR) # Second arg
do
ld E (Y)
eval # Eval next arg
call consE_A # Cons into value
ld (A) E
ld C (L I) # 'var'
ld (A CDR) (C)
ld (C) A
ld Y (Y CDR) # Next arg
atom Y # Any?
until nz # No
drop
pop Y
pop X
ret
# (push1 'var 'any ..) -> any
(code 'doPush1 2)
push X
push Y
push Z
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
link
push E # <L I> 'var'
link
ld Y (Y CDR) # Second arg
do
ld E (Y)
eval # Eval next arg
ld C ((L I)) # Value of 'var'
do # 'member'
atom C # List?
while z # Yes
ld A (C)
ld Z E # Preserve E
call equalAE_F # Member?
ld E Z
jeq 10 # Yes
ld C (C CDR)
loop
call consE_A # Cons into value
ld (A) E
ld C (L I) # 'var'
ld (A CDR) (C)
ld (C) A
10 ld Y (Y CDR) # Next arg
atom Y # Any?
until nz # No
drop
pop Z
pop Y
pop X
ret
# (push1q 'var 'any ..) -> any
(code 'doPush1q 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
link
push E # <L I> 'var'
link
ld Y (Y CDR) # Second arg
do
ld E (Y)
eval # Eval next arg
ld C ((L I)) # Value of 'var'
do # 'memq'
atom C # List?
while z # Yes
cmp E (C) # Member?
jeq 10 # Yes
ld C (C CDR)
loop
call consE_A # Cons into value
ld (A) E
ld C (L I) # 'var'
ld (A CDR) (C)
ld (C) A
10 ld Y (Y CDR) # Next arg
atom Y # Any?
until nz # No
drop
pop Y
pop X
ret
# (pop 'var) -> any
(code 'doPop 2)
push X
ld X E
ld E ((E CDR)) # E on arg
eval # Eval it
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
ld A E # 'var' in A
ld E (A) # Get value
atom E # List?
if z # Yes
ld (A) (E CDR) # Set to CDR
ld E (E) # Return CAR
end
pop X
ret
# (++ var) -> any
(code 'doPopq 2)
ld A ((E CDR)) # 'var' in A
ld E (A) # Get value
atom E # List?
if z # Yes
ld (A) (E CDR) # Set to CDR
ld E (E) # Return CAR
end
ret
# (cut 'cnt 'var) -> lst
(code 'doCut 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
call evCntXY_FE # Eval 'cnt'
if nsz # Yes
ld Y ((Y CDR)) # Second arg
xchg E Y # 'cnt' in Y
eval # Eval 'var'
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
atom (E) # List value?
ldnz E (E)
if z # Yes
call consE_X # Cons first cell
ld C (E) # Get value
ld (X) (C) # CAR
ld (X CDR) Nil
link
push E # <L II> 'var'
push X # <L I> 'lst'
link
do
ld C (C CDR) # More elements?
atom C
while z # Yes
dec Y # Count?
while nz # Yes
call cons_A # Copy next cell
ld (A) (C)
ld (A CDR) Nil
ld (X CDR) A # Append to result
ld X (X CDR)
loop
ld ((L II)) C # Set new value
ld E (L I) # Get result
drop
end
pop Y
pop X
ret
end
ld E Nil
pop Y
pop X
ret
# (del 'any 'var ['flg]) -> lst
(code 'doDel 2)
push X
push Y
push Z
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
link
push E # <L II> 'any'
ld Y (Y CDR)
ld E (Y) # Eval second
eval+
push E # <L I> 'var'
link
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
ld E ((Y CDR)) # Eval 'flg'
eval
ld X ((L I)) # Get value of 'var'
ld Y E # 'flg' in Y
lea Z ((L I) -I) # Point to "CAR" of dummy cell
do
ld C X # Search in rest
do
atom C # Done?
jnz 90 # Yes
ld A (L II) # 'any'
ld E (C) # Equal to CAR?
call equalAE_F
while ne # No
ld C (C CDR) # Next
loop
do
cmp X C # Reached found cell?
while ne # No
call cons_A # Copy traversed cells
ld (A) (X)
ld X (X CDR)
ld (A CDR) X
ld (Z CDR) A # Append to result
ld Z A
loop
ld X (X CDR) # Skip found cell
ld (Z CDR) X
cmp Y Nil # 'flg'?
until eq # Yes
90 ld E ((L I)) # Get result
drop
pop Z
pop Y
pop X
ret
# (queue 'var 'any) -> any
(code 'doQueue 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
link
push E # <L I> 'var'
link
ld E ((Y CDR)) # Eval next arg
eval
call consE_C # Build cell
ld (C) E
ld (C CDR) Nil
ld X (L I) # Get 'var'
ld Y (X) # Value
atom Y # Atomic?
if nz # Yes
ld (X) C # Store first cell
else
do
atom (Y CDR) # Find last cell
while z
ld Y (Y CDR)
loop
ld (Y CDR) C
end
drop
pop Y
pop X
ret
# (fifo 'var ['any ..]) -> any
(code 'doFifo 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
call needVarEX # Need variable
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
end
link
push E # <L I> 'var'
link
ld Y (Y CDR) # More args?
atom Y
if z # Yes
ld E (Y) # Eval 'any'
eval
call consE_A # Cons into new cell
ld (A) E
ld C (L I) # Get 'var'
ld X (C) # Value in X
atom X # List?
if z # Yes
ld (A CDR) (X CDR) # Concat to value
ld (X CDR) A
else
ld (A CDR) A # Circular cell
ld (C) X # Set new value
end
ld X A
do
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld E (Y) # Eval next 'any'
eval
call consE_A # Cons into new cell
ld (A) E
ld (A CDR) (X CDR) # Concat to value
ld (X CDR) A
ld X A
loop
ld ((L I)) X # Set new value
else
ld C (L I) # Get 'var'
ld X (C) # Value in X
atom X # Any?
if nz # No
ld E Nil
else
cmp X (X CDR) # Single cell?
if eq # Yes
ld E (X) # Return CAR
ld (C) Nil # Clear value
else
ld E ((X CDR)) # Return CADR
ld (X CDR) ((X CDR) CDR) # Cut cell
end
end
end
drop
pop Y
pop X
ret
# (idx 'var 'any 'flg) -> lst
# (idx 'var 'any) -> lst
# (idx 'var) -> lst
(code 'doIdx 2)
push X
ld X E
ld E ((E CDR)) # Eval first arg
eval
call needVarEX # Need variable
ld X ((X CDR) CDR) # Second arg?
atom X
if nz # No
ld X (E) # Get tree
ld E Nil # Cons a list
call consTreeXE_E
else
push Y
link
push E # <L II> 'var'
ld E (X)
eval+ # Eval second arg
push E # <L I> 'any'
link # Save it
ld Y E # Keep in Y
ld X (X CDR) # Third arg?
atom X
if nz # No
ld X (L II) # Get 'var'
call idxGetXY_E # Find
else
ld E (X) # Eval last arg
eval
ld X (L II) # Get 'var'
cmp E Nil # Delete?
if ne # No
call idxPutXY_E # Insert
else
call idxDelXY_E # Delete
end
end
drop
pop Y
end
pop X
ret
(code 'idxGetXY_E 0)
ld X (X) # Get value of 'var'
do
atom X # More nodes?
ld E Nil
while z # Yes
ld A Y # Get key
ld E (X) # Compare with node value
call compareAE_F # Found?
ld E X
while ne # No
if lt
ld X ((X CDR)) # Smaller
else
ld X ((X CDR) CDR) # Greater
end
loop
ret
(code 'idxPutXY_E 0)
atom (X) # First insert?
if nz # Yes
call cons_A # Cons new node
ld (A) Y # 'any'
ld (A CDR) Nil
ld (X) A # Set 'var'
ld E Nil # return NIL
else
ld X (X) # Get value of 'var'
do
ld A Y # Get key
ld E (X) # Compare with node value
call compareAE_F # Equal?
ld E X
while ne # No
ld A (X CDR)
if ge # Greater
atom A # Already has link?
if nz # No
call cons_A # Cons into a new node
ld (A) Y # key
ld (A CDR) Nil
call consA_C # Cons a new link
ld (C) Nil
ld (C CDR) A
ld (X CDR) C
ld E Nil # Return NIL
ret
end
ld X A
atom (X CDR) # CDR of link?
ldz X (X CDR) # Yes: Get CDR of link in X
if nz # No
call cons_A # Else cons into a new node
ld (A) Y # key
ld (A CDR) Nil
ld (X CDR) A # Store in CDR of link
ld E Nil # Return NIL
ret
end
else # Smaller
atom A # Already has link?
if nz # No
call cons_A # Cons into a new node
ld (A) Y # key
ld (A CDR) Nil
call consA_C # Cons a new link
ld (C) A
ld (C CDR) Nil
ld (X CDR) C
ld E Nil # Return NIL
ret
end
ld X A
atom (X) # CAR of link?
ldz X (X) # Yes: Get CAR of link in X
if nz # No
call cons_A # Else cons into a new node
ld (A) Y # key
ld (A CDR) Nil
ld (X) A # Store in CAR of link
ld E Nil # Return NIL
ret
end
end
loop
end
ret
(code 'idxDelXY_E 0)
do
atom (X) # Next node?
ld E Nil
while z # Yes
ld A Y # Get key
ld E ((X)) # Compare with node value
call compareAE_F # Equal?
if eq # Yes
ld C (X) # Found subtree
ld E C # Preset return value
ld A (C CDR) # Get subtrees
atom (A) # Left branch?
if nz # No
ld (X) (A CDR) # Use right branch
ret
end
atom (A CDR) # Right branch?
if nz # No
ld (X) (A) # Use left branch
ret
end
ld A (A CDR) # A on right branch
ld X (A CDR) # X on sub-branches
atom (X) # Left?
if nz # No
ld (C) (A) # Insert right sub-branch
ld ((C CDR) CDR) (X CDR)
ret
end
push E # Save return value
ld X (X) # Left sub-branch
do
ld E (X CDR) # More left branches?
atom (E)
while z # Yes
ld A X # Go down left
ld X (E)
loop
ld (C) (X) # Insert left sub-branch
ld ((A CDR)) (E CDR)
pop E
ret
end
ld E Nil
ld X ((X) CDR)
if ge # Node value is greater
atom X # Link?
break nz # No
lea X (X CDR) # Go right
else # Node value is smaller
atom X # Link?
break nz # No
end
loop
ret
# (lup 'lst 'any) -> lst
# (lup 'lst 'any 'any2) -> lst
(code 'doLup 2)
push X
ld X (E CDR) # Args
ld E (X) # Eval first
eval
atom E # List?
if z # Yes
link
push E # <L V> 'lst'
ld X (X CDR) # Eval second
ld E (X)
eval+ # 'any'
ld X (X CDR) # Next arg?
atom X
if nz # No
pop X # Get 'lst' in X
pop L # Discard partial stack frame
push Y
ld Y E # Get 'any' in Y
do
ld E (X) # CAR of 'lst'
cmp E TSym # Is it T?
if eq # Yes
ld X ((X CDR)) # Go to CADR
else
atom E # Atomic?
if nz # Yes
ld X ((X CDR) CDR) # Go to CDDR
else
ld A Y # Key 'any'
ld E (E) # CAAR of 'lst'
call compareAE_F # Equal?
if eq # Yes
ld E (X) # Return CAR of 'lst'
pop Y
pop X
ret
end
if lt
ld X ((X CDR)) # Smaller
else
ld X ((X CDR) CDR) # Greater
end
end
end
atom X # Reached leaf?
until nz # Yes
ld E Nil # Return NIL
pop Y
else
push E # <L IV> "from" key
ld E (X) # Eval next
eval+
push E # <L III> "to" key
push Nil # <L II> TOS
push Nil # <L I> Result
link
ld X (L V) # Get 'lst' in X
do
do
ld A (X CDR)
atom (A CDR) # Right subtree?
while z # Yes
ld E (X) # CAR of 'lst'
cmp E TSym # Is it T?
while ne # No
atom E # Atomic?
jnz 10 # Yes
ld A (L III) # "to" key
ld E (E) # CAAR of 'lst'
call compareAE_F # Greater or equal?
while ge # Yes
10 ld C X # Go right
ld A (X CDR)
ld X (A CDR) # Invert tree
ld (A CDR) (L II) # TOS
ld (L II) C
loop
ld (L V) X # Save tree
do
ld E (X) # CAR of 'lst'
atom E # Atomic?
if z # No
ld A (L IV) # "from" key
ld E (E) # CAAR of 'lst'
call compareAE_F # Less or equal?
if le # Yes
ld A (L III) # "to" key
ld E ((X)) # CAAR of 'lst'
call compareAE_F # Greater or equal?
if ge # Yes
call cons_A # Cons value
ld (A) (X)
ld (A CDR) (L I) # Into result
ld (L I) A
end
ld A (X CDR) # Left subtree?
atom (A)
if z # Yes
ld C X # Go left
ld X (A) # Invert tree
ld (A) (L II) # TOS
or C SYM # First visit
ld (L II) C
ld (L V) X # Save tree
break T
end
end
end
do
ld A (L II) # TOS
cmp A Nil # Empty?
if eq # Yes
ld E (L I) # Return result
drop
pop X
ret
end
sym A # Second visit?
if z # Yes
ld C (A CDR) # Nodes
ld (L II) (C CDR) # TOS on up link
ld (C CDR) X
ld X A
ld (L V) X # Save tree
break T
end
off A SYM # Set second visit
ld C (A CDR) # Nodes
ld (L II) (C)
ld (C) X
ld X A
ld (L V) X # Save tree
loop
loop
loop
end
end
pop X
ret
### Property access ###
(code 'putACE 0)
push X
ld X (A TAIL) # Properties
num X # Any?
if z # Yes
off X SYM # Clear 'extern' tag
atom (X) # First property atomic?
if nz # Yes
cmp C (X) # Found flag?
if eq # Yes
cmp E Nil # Value NIL?
if eq # Yes
10 ld X (X CDR) # Remove property
sym (A TAIL) # Extern?
if nz # Yes
or X SYM # Set 'extern' tag
end
ld (A TAIL) X
20 pop X
ret
end
cmp E TSym # Value T?
jeq 20 # No change
push C
call consE_C # New property cell
ld (C) E
pop (C CDR)
ld (X) C
pop X
ret
end
else
cmp C ((X) CDR) # Found property?
if eq # Yes
cmp E Nil # Value NIL?
jeq 10 # Yes
cmp E TSym # Value T?
if ne # No
ld ((X)) E # Set new value
else
ld (X) C # Change to flag
end
pop X
ret
end
end
push Y
do
ld Y (X CDR) # Next property
atom Y # Any?
while z # Yes
atom (Y) # Atomic?
if nz # Yes
cmp C (Y) # Found flag?
if eq # Yes
cmp E Nil # Value NIL?
if eq # Yes
ld (X CDR) (Y CDR) # Remove cell
else
cmp E TSym # Value T?
if ne # No
push C
call consE_C # New property cell
ld (C) E
pop (C CDR)
ld (Y) C # Store
end
ld (X CDR) (Y CDR) # Unlink cell
ld X (A TAIL) # Get tail
sym X # Extern?
if z # No
ld (Y CDR) X # Insert cell in front
else
off X SYM # Clear 'extern' tag
ld (Y CDR) X # Insert cell in front
or Y SYM # Set 'extern' tag
end
ld (A TAIL) Y
pop Y
pop X
ret
end
end
else
cmp C ((Y) CDR) # Found property?
if eq # Yes
cmp E Nil # Value NIL?
if eq # Yes
ld (X CDR) (Y CDR) # Remove cell
else
cmp E TSym # Value T?
if ne # No
ld ((Y)) E # Set new value
else
ld (Y) C # Change to flag
end
ld (X CDR) (Y CDR) # Unlink cell
ld X (A TAIL) # Get tail
sym X # Extern?
if z # No
ld (Y CDR) X # Insert cell in front
else
off X SYM # Clear 'extern' tag
ld (Y CDR) X # Insert cell in front
or Y SYM # Set 'extern' tag
end
ld (A TAIL) Y
pop Y
pop X
ret
end
end
end
ld X Y
loop
pop Y
ld X (A TAIL) # Get properties again
end
cmp E Nil # Value Non-NIL?
if ne # Yes
cmp E TSym # Flag?
if ne # No
push C
call consE_C # New property cell
ld (C) E
pop (C CDR)
end
push C
call consC_C # New first property
pop (C)
sym X # Extern?
if z # No
ld (C CDR) X
else
off X SYM # Clear 'extern' tag
ld (C CDR) X
or C SYM # Set 'extern' tag
end
ld (A TAIL) C # Set new tail
end
pop X
ret
(code 'getnECX_E 0)
num E # Need symbol or pair
jnz argErrEX
atom E # List?
if z # Yes
num C # Numeric key?
if nz # Yes
shr C 4 # Positive?
if nx # Yes
jz retNil # Return NIL if zero
do
dec C # nth
jz retE_E
ld E (E CDR)
loop
end
# Key is negative
do
ld E (E CDR)
dec C # nth
until z
ret
end
do # asoq
atom (E) # CAR atomic?
if z # No
cmp C ((E)) # Found?
break eq # Yes
end
ld E (E CDR) # Next
atom E # Done?
jnz retNil # Return NIL
loop
ld E ((E) CDR) # Return CDAR
ret
end
# E is symbolic
sym (E TAIL) # External symbol?
if nz # Yes
call dbFetchEX # Fetch it
end
(code 'getEC_E 0)
cmp C ZERO # Key is zero?
jeq retE_E # Get value
ld A (E TAIL) # Get tail
num A # No properties?
jnz retNil # Return NIL
off A SYM # Clear 'extern' tag
atom (A) # First property atomic?
if nz # Yes
cmp C (A) # Found flag?
jeq retT # Return T
else
cmp C ((A) CDR) # Found property?
if eq # Yes
ld E ((A)) # Return value
ret
end
end
push X
do
ld X (A CDR) # Next property
atom X # Any?
while z # Yes
atom (X) # Atomic?
if nz # Yes
cmp C (X) # Found flag?
if eq # Yes
ld (A CDR) (X CDR) # Unlink cell
ld A (E TAIL) # Get tail
sym A # Extern?
if z # No
ld (X CDR) A # Insert cell in front
else
off A SYM # Clear 'extern' tag
ld (X CDR) A # Insert cell in front
or X SYM # Set 'extern' tag
end
ld (E TAIL) X
ld E TSym # Return T
pop X
ret
end
else
cmp C ((X) CDR) # Found property?
if eq # Yes
ld (A CDR) (X CDR) # Unlink cell
ld A (E TAIL) # Get tail
sym A # Extern?
if z # No
ld (X CDR) A # Insert cell in front
ld (E TAIL) X
ld E ((X)) # Return value
else
off A SYM # Clear 'extern' tag
ld (X CDR) A # Insert cell in front
ld A ((X)) # Return value
or X SYM # Set 'extern' tag
ld (E TAIL) X
ld E A
end
pop X
ret
end
end
ld A X
loop
ld E Nil # Return NIL
pop X
ret
(code 'propEC_E 0)
push X
ld A (E TAIL) # Get tail
num A # Properties?
if z # Yes
off A SYM # Clear 'extern' tag
atom (A) # First property atomic?
if nz # Yes
cmp C (A) # Found flag?
if eq # Yes
ld E C # Return key
pop X
ret
end
else
cmp C ((A) CDR) # Found property?
if eq # Yes
ld E (A) # Return property
pop X
ret
end
end
do
ld X (A CDR) # Next property
atom X # Any?
while z # Yes
atom (X) # Atomic?
if nz # Yes
cmp C (X) # Found flag?
if eq # Yes
ld (A CDR) (X CDR) # Unlink cell
ld A (E TAIL) # Get tail
sym A # Extern?
if z # No
ld (X CDR) A # Insert cell in front
else
off A SYM # Clear 'extern' tag
ld (X CDR) A # Insert cell in front
or X SYM # Set 'extern' tag
end
ld (E TAIL) X
ld E C # Return key
pop X
ret
end
else
cmp C ((X) CDR) # Found property?
if eq # Yes
ld (A CDR) (X CDR) # Unlink cell
ld A (E TAIL) # Get tail
sym A # Extern?
if z # No
ld (X CDR) A # Insert cell in front
ld (E TAIL) X
ld E (X) # Return property
else
off A SYM # Clear 'extern' tag
ld (X CDR) A # Insert cell in front
ld A (X) # Return property
or X SYM # Set 'extern' tag
ld (E TAIL) X
ld E A
end
pop X
ret
end
end
ld A X
loop
end
call cons_A # New property cell
ld (A) Nil # (NIL . key)
ld (A CDR) C
call consA_C # New first property
ld (C) A
ld X (E TAIL) # Get tail
sym X # Extern?
if z # No
ld (C CDR) X
else
off X SYM # Clear 'extern' tag
ld (C CDR) X
or C SYM # Set 'extern' tag
end
ld (E TAIL) C # Set new tail
ld E A # Return first (new) cell
pop X
ret
# (put 'sym1|lst ['sym2|cnt ..] 'sym|0 'any) -> any
(code 'doPut 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
link
push E # <L II> 'sym1|lst' item
ld Y (Y CDR)
ld E (Y) # Eval second
eval+
push E # <L I> 'sym2|cnt' key
link
do
ld Y (Y CDR) # Args
atom (Y CDR) # More than one?
while z # Yes
ld C E # Key
ld E (L II) # Current item
call getnECX_E
ld (L II) E # Store item
ld E (Y)
eval # Eval next arg
ld (L I) E # Save it
loop
ld E (L II) # Get item
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
ld E (Y) # Eval 'any'
eval
ld A (L II) # Get symbol
ld C (L I) # Get key
sym (A TAIL) # External symbol?
if nz # Yes
push E # Save 'any'
ld E A # Get symbol
cmp C Nil # Volatile property?
if ne # No
call dbTouchEX # Touch it
else
call dbFetchEX # else fetch
end
ld A E
pop E
end
cmp C ZERO # Key is zero?
if eq # Yes
call checkVarAX # Check variable
ld (A) E # Set value
else
call putACE # Put value or propery
end
drop
pop Y
pop X
ret
# (get 'sym1|lst ['sym2|cnt ..]) -> any
(code 'doGet 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
ld Y (Y CDR) # Next arg?
atom Y
if z # Yes
link
push E # <L I> 'sym|lst' item
link
do
ld E (Y)
eval # Eval next arg
ld C E # Key
ld E (L I) # Current item
call getnECX_E
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld (L I) E # Save item
loop
drop
end
pop Y
pop X
ret
# (prop 'sym1|lst ['sym2|cnt ..] 'sym) -> var
(code 'doProp 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
link
push E # <L II> 'sym|lst' item
ld Y (Y CDR) # Next arg
ld E (Y)
eval+ # Eval next arg
push E # <L I> 'sym2|cnt' key
link
do
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld C E # Key
ld E (L II) # Current item
call getnECX_E
ld (L II) E # Store item
ld E (Y)
eval # Eval next arg
ld (L I) E # Save it
loop
ld E (L II) # Get item
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
cmp E Nil # Can't be NIL
jeq protErrEX
ld C (L I) # Get key
sym (E TAIL) # External symbol?
if nz # Yes
cmp C Nil # Volatile property?
if ne # No
call dbTouchEX # Touch symbol
else
call dbFetchEX # else fetch
end
end
call propEC_E
drop
pop Y
pop X
ret
# (; 'sym1|lst [sym2|cnt ..]) -> any
(code 'doSemicol 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
ld Y (Y CDR) # Next arg?
atom Y
if z # Yes
link
push E # <L I> 'sym|lst' item
link
do
ld C (Y) # Key
ld E (L I) # Current item
call getnECX_E
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld (L I) E # Save item
loop
drop
end
pop Y
pop X
ret
# (=: sym|0 [sym1|cnt .. sym2|0] 'any) -> any
(code 'doSetCol 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (This) # Get value of This
ld C (Y) # sym1|cnt
ld Y (Y CDR) # Args
atom (Y CDR) # More than one?
if z # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbFetchEX # Fetch it
end
call getEC_E
do
ld C (Y) # sym2|cnt
ld Y (Y CDR) # Args
atom (Y CDR) # More than one?
while z # Yes
call getnECX_E
loop
end
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
sym (E TAIL) # External symbol?
if nz # Yes
cmp C Nil # Volatile property?
if ne # No
call dbTouchEX # Touch symbol
else
call dbFetchEX # else fetch
end
end
push C # Save key
push E # Save symbol
ld E (Y) # Eval 'any'
eval
pop A # Retrieve symbol
pop C # and key
cmp C ZERO # Key is zero?
if eq # Yes
call checkVarAX # Check variable
ld (A) E # Set value
else
call putACE # Put value or propery
end
pop Y
pop X
ret
# (: sym|0 [sym1|cnt ..]) -> any
(code 'doCol 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (This) # Get value of This
sym (E TAIL) # External symbol?
if nz # Yes
call dbFetchEX # Fetch it
end
ld C (Y) # Next key
call getEC_E
do
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld C (Y) # Next key
call getnECX_E
loop
pop Y
pop X
ret
# (:: sym|0 [sym1|cnt .. sym2]) -> var
(code 'doPropCol 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (This) # Get value of This
ld C (Y) # Next key
atom (Y CDR) # More than one arg?
if z # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbFetchEX # Fetch it
end
call getEC_E
do
ld Y (Y CDR)
ld C (Y) # Next key
atom (Y CDR) # More than one arg?
while z # Yes
call getnECX_E
loop
end
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
cmp E Nil # Can't be NIL
jeq protErrEX
sym (E TAIL) # External symbol?
if nz # Yes
cmp C Nil # Volatile property?
if ne # No
call dbTouchEX # Touch symbol
else
call dbFetchEX # else fetch
end
end
call propEC_E
pop Y
pop X
ret
# (putl 'sym1|lst1 ['sym2|cnt ..] 'lst) -> lst
(code 'doPutl 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
link
push E # <L II> 'sym|lst' item
ld Y (Y CDR) # Next arg
ld E (Y)
eval+ # Eval next arg
push E # <L I> 'sym2|cnt' key
link
do
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld C E # Key
ld E (L II) # Current item
call getnECX_E
ld (L II) E # Store item
ld E (Y)
eval # Eval next arg
ld (L I) E # Save it
loop
ld E (L II) # Get item
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
cmp E Nil # Can't be NIL
jeq protErrEX
sym (E TAIL) # External symbol?
if nz # Yes
call dbTouchEX # Touch it
end
ld X (E TAIL) # Skip old properties
off X SYM # Clear 'extern' tag
do
num X # More properties?
while z # Yes
ld X (X CDR)
loop
ld Y (L I) # New property list
do
atom Y # Any?
while z # Yes
ld C (Y)
atom C # Flag?
if nz # Yes
ld A X
call consA_X # New property cell
ld (X) C
ld (X CDR) A
else
cmp (C) Nil # Value Nil?
if ne # No
cmp (C) TSym # Flag?
if eq # Yes
ld C (C CDR) # Get key
end
ld A X
call consA_X # New property cell
ld (X) C
ld (X CDR) A
end
end
ld Y (Y CDR)
loop
sym (E TAIL) # Extern?
if nz # Yes
or X SYM # Set 'extern' tag
end
ld (E TAIL) X
ld E (L I) # Return new property list
drop
pop Y
pop X
ret
# (getl 'sym1|lst1 ['sym2|cnt ..]) -> lst
(code 'doGetl 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
link
push E # <L I> 'sym|lst' item
link
do
ld Y (Y CDR) # More args?
atom Y
while z
ld E (Y)
eval # Eval next arg
ld C E # Key
ld E (L I) # Current item
call getnECX_E
ld (L I) E # Save item
loop
num E # Need symbol
jnz symErrEX
sym E
jz symErrEX
sym (E TAIL) # External symbol?
if nz # Yes
call dbFetchEX # Fetch it
end
ld X (E TAIL) # Get tail
num X # No properties?
if nz # Yes
ld E Nil
else
off X SYM # Clear 'extern' tag
call cons_C # Copy first cell
ld (C) (X)
ld (C CDR) Nil
tuck C # Save it
link
do
ld X (X CDR) # More properties?
atom X
while z # Yes
call cons_A # Copy next cell
ld (A) (X)
ld (A CDR) Nil
ld (C CDR) A # Append
ld C A
loop
ld E (L I) # Get result
end
drop
pop Y
pop X
ret
# (wipe 'sym|lst) -> sym|lst
(code 'doWipe 2)
push X
ld X E
ld E ((E CDR)) # Get arg
eval # Eval it
cmp E Nil # NIL?
if ne # No
atom E # List?
if nz # No
call wipeEX # Wipe it
else
push E # Save
ld C E # Get list
do
ld E (C) # Next symbol
call wipeEX # Wipe it
ld C (C CDR)
atom C # More?
until nz # No
pop E
end
end
pop X
ret
(code 'wipeEX 0)
call needSymEX # Need variable
ld A (E TAIL) # Get tail
sym A # Extern?
if z # No
call nameA_A # Get name
ld (E) Nil # Clear value
ld (E TAIL) A # And properties
ret
end
call nameA_A # Get name
shl A 1 # Dirty?
if nx # No
shl A 1 # Loaded?
if x # Yes
ror A 2 # Set "not loaded"
ld (E) Nil # Clear value
or A SYM # Set 'extern' tag
ld (E TAIL) A
end
end
ret
# (meta 'obj|typ 'sym ['sym2|cnt ..]) -> any
(code 'doMeta 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
link
push E # <L I> 'obj|typ'
link
num E # Need symbol or pair
jnz argErrEX
sym E # Symbol?
if nz # Yes
sym (E TAIL) # External symbol?
if nz # Yes
call dbFetchEX # Fetch it
end
ld (L I) (E) # Get value
end
ld Y (Y CDR) # Next arg
ld E (Y)
eval # Eval next arg
ld C E # Key
ld X (L I) # 'obj|typ'
call metaCX_E # Fetch
do
ld Y (Y CDR) # More args?
atom Y
while z # Yes
ld (L I) E # Save item
ld E (Y)
eval # Eval next arg
ld C E # Key
ld E (L I) # Current item
call getnECX_E
loop
drop
pop Y
pop X
ret
(code 'metaCX_E 0)
do
atom X # List?
jnz retNil # No
ld E (X) # Next item
num E # Symbol?
if z
sym E
if nz # Yes
call getEC_E # Propery
cmp E Nil # found?
jne Ret # No
cmp S (StkLimit) # Stack check
jlt stkErr
push X
ld X ((X)) # Try in superclass(es)
call metaCX_E
pop X
cmp E Nil # found?
jne Ret # No
end
end
ld X (X CDR)
loop
### Case mappings from the GNU Kaffe Project ###
(code 'caseDataA_AC 0)
ld C A # Keep character in C
shr A 4 # Make index
off A 1
ld2 (A CaseBlocks) # Get blocks entry
add A C # Add character
and A (hex "FFFF") # Limit to 16 bits
add A A # Adjust index
ld2 (A CaseData) # Get case data
ret
# (low? 'any) -> sym | NIL
(code 'doLowQ 2)
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Number?
jnz retNil # Yes
sym E # Symbol?
jz retNil # No
call firstCharE_A # Get first character
cmp A TOP # Special "top" character?
jeq retNil # Yes
call caseDataA_AC # Get case info
and B (hex "1F") # Character type
cmp B CHAR_LOWERCASE # Lower case?
ldnz E Nil # No
ret
# (upp? 'any) -> sym | NIL
(code 'doUppQ 2)
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Number?
jnz retNil # Yes
sym E # Symbol?
jz retNil # No
call firstCharE_A # Get first character
cmp A TOP # Special "top" character?
jeq retNil # Yes
call caseDataA_AC # Get case info
and B (hex "1F") # Character type
cmp B CHAR_UPPERCASE # Lower case?
ldnz E Nil # No
ret
# (lowc 'any) -> any
(code 'doLowc 2)
push X
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Number?
if z # No
sym E # Symbol?
if nz # Yes
cmp E Nil # NIL?
if ne # No
sym (E TAIL) # External symbol?
if z # No
ld E (E TAIL)
call nameE_E # Get name
link
push E # <L II> Name
push ZERO # <L I> Result
ld X S
link
push 4 # <S I> Build name
push X # <S> Pack status
ld X (L II) # Get name
ld C 0 # Index
do
call symCharCX_FACX # Next char?
while nz
ld E C # Save C
cmp A TOP # Special "top" character?
if ne # No
call caseDataA_AC # Get case info
and A (hex "FFFF")
shr A 6 # Make index
off A 1
ld2 (A CaseLower) # Get lower case entry
add A C # plus character
and A (hex "FFFF")
end
ld C (S I) # Swap status
xchg X (S)
call charSymACX_CX # Pack char
xchg X (S) # Swap status
ld (S I) C
ld C E # Restore C
loop
ld X (L I) # Get result
call consSymX_E # Make transient symbol
drop
end
end
end
end
pop X
ret
# (uppc 'any) -> any
(code 'doUppc 2)
push X
ld E ((E CDR)) # Get arg
eval # Eval it
num E # Number?
if z # No
sym E # Symbol?
if nz # Yes
cmp E Nil # NIL?
if ne # No
sym (E TAIL) # External symbol?
if z # No
ld E (E TAIL)
call nameE_E # Get name
link
push E # <L II> Name
push ZERO # <L I> Result
ld X S
link
push 4 # <S I> Build name
push X # <S> Pack status
ld X (L II) # Get name
ld C 0 # Index
do
call symCharCX_FACX # Next char?
while nz
ld E C # Save C
cmp A TOP # Special "top" character?
if ne # No
call caseDataA_AC # Get case info
and A (hex "FFFF")
shr A 6 # Make index
off A 1
ld2 (A CaseUpper) # Get upper case entry
add A C # plus character
and A (hex "FFFF")
end
ld C (S I) # Swap status
xchg X (S)
call charSymACX_CX # Pack char
xchg X (S) # Swap status
ld (S I) C
ld C E # Restore C
loop
ld X (L I) # Get result
call consSymX_E # Make transient symbol
drop
end
end
end
end
pop X
ret
# (fold 'any ['cnt]) -> sym
(code 'doFold 2)
push X
push Y
ld X E
ld Y (E CDR) # Y on args
ld E (Y) # Eval first
eval
num E # Number?
if z # No
sym E # Symbol?
if nz # Yes
cmp E Nil # NIL?
if ne
sym (E TAIL) # External symbol?
if z # No
ld E (E TAIL)
call nameE_E # Get name
link
push E # <L II> Name
push ZERO # <L I> Result
link
ld Y (Y CDR) # Next arg?
atom Y
if nz # No
push 0 # <S II> Default 'cnt' zero
else
call evCntXY_FE # Eval 'cnt'
push E # <S II> 'cnt'
end
push 4 # <S I> Build name
lea X (L I)
push X # <S> Pack status
ld X (L II) # Get name
ld C 0 # Index
do
call symCharCX_FACX # Next char?
while nz
cmp A TOP # Special "top" character?
continue eq # Yes
ld E C # Save C
call isLetterOrDigitA_F # Letter or digit?
if nz # Yes
call caseDataA_AC # Get case info
and A (hex "FFFF")
shr A 6 # Make index
off A 1
ld2 (A CaseLower) # Get lower case entry
add A C # plus character
and A (hex "FFFF")
ld C (S I) # Swap status
xchg X (S)
call charSymACX_CX # Pack char
xchg X (S) # Swap status
ld (S I) C
dec (S II) # Decrement 'cnt'
break z
end
ld C E # Restore C
loop
ld X (L I) # Get result
call consSymX_E # Make transient symbol
drop
end
end
end
end
pop Y
pop X
ret
(code 'isLetterOrDigitA_F 0) # C
push A
call caseDataA_AC # Get case info
and B (hex "1F") # Character type
ld C 1
zxt
shl C A
test C (| CHAR_DIGIT CHAR_LETTER)
pop A
ret
# vi:et:ts=3:sw=3
|