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
|
/*****************************************************************************/
/* Copyright (C) 2020 NORMAN MEGILL nm at alum.mit.edu */
/* License terms: GNU General Public License */
/*****************************************************************************/
/*34567890123456 (79-character line to adjust editor window) 2345678901234567*/
/* Command line syntax specification for Metamath */
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "mmvstr.h"
#include "mmdata.h"
#include "mmcmdl.h"
#include "mminou.h"
#include "mmpfas.h"
#include "mmunif.h" /* For g_hentyFilter, g_userMaxUnifTrials, g_minSubstLen */
#include "mmwtex.h"
#include "mmword.h"
/* Global variables */
pntrString *g_rawArgPntr = NULL_PNTRSTRING;
nmbrString *g_rawArgNmbr = NULL_NMBRSTRING;
long g_rawArgs = 0;
pntrString *g_fullArg = NULL_PNTRSTRING;
vstring g_fullArgString = ""; /* 1-Nov-2013 nm g_fullArg as one string */
vstring g_commandPrompt = "";
vstring g_commandLine = "";
long g_showStatement = 0;
vstring g_logFileName = "";
vstring g_texFileName = "";
flag g_PFASmode = 0; /* Proof assistant mode, invoked by PROVE command */
flag g_queryMode = 0; /* If 1, explicit questions will be asked even if
a field in the input command line is optional */
flag g_sourceChanged = 0; /* Flag that user made some change to the source file*/
flag g_proofChanged = 0; /* Flag that user made some change to proof in progress*/
flag g_commandEcho = 0; /* Echo full command */
flag g_memoryStatus = 0; /* Always show memory */
/* 31-Dec-2017 nm */
flag g_sourceHasBeenRead = 0; /* 1 if a source file has been read in */
/* 31-Dec-2017 nm */
vstring g_rootDirectory = ""; /* Directory prefix to use for included files */
flag processCommandLine(void)
{
vstring defaultArg = "";
vstring tmpStr = "";
long i;
g_queryMode = 0; /* If 1, explicit questions will be asked even if
a field is optional */
pntrLet(&g_fullArg, NULL_PNTRSTRING);
if (!g_toolsMode) {
if (!g_PFASmode) {
/* Normal mode */
let(&tmpStr, cat("DBG|",
"HELP|READ|WRITE|PROVE|SHOW|SEARCH|SAVE|SUBMIT|OPEN|CLOSE|",
/* 10-Dec-2018 nm Added MARKUP */
"SET|FILE|BEEP|EXIT|QUIT|ERASE|VERIFY|MARKUP|MORE|TOOLS|",
"MIDI|<HELP>",
NULL));
} else {
/* Proof assistant mode */
let(&tmpStr, cat("DBG|",
"HELP|WRITE|SHOW|SEARCH|SAVE|SUBMIT|OPEN|CLOSE|",
/* 9-Jun-2016 nm Added _EXIT_PA */
"SET|FILE|BEEP|EXIT|_EXIT_PA|QUIT|VERIFY|INITIALIZE|ASSIGN|REPLACE|",
/* 11-Sep-2016 nm Added EXPAND */
"LET|UNIFY|IMPROVE|MINIMIZE_WITH|EXPAND|MATCH|DELETE|UNDO|REDO|",
/* 10-Dec-2018 nm Added MARKUP */
"MARKUP|MORE|TOOLS|MIDI|<HELP>",
NULL));
}
if (!getFullArg(0,tmpStr)) {
goto pclbad;
}
if (cmdMatches("HELP")) {
/* 15-Jan-2018 nm Added MARKUP */
if (!getFullArg(1, cat("LANGUAGE|PROOF_ASSISTANT|MM-PA|",
"BEEP|EXIT|QUIT|READ|ERASE|",
"OPEN|CLOSE|SHOW|SEARCH|SET|VERIFY|SUBMIT|SYSTEM|PROVE|FILE|WRITE|",
/* 10-Dec-2018 nm Added MARKUP */
"MARKUP|ASSIGN|REPLACE|MATCH|UNIFY|LET|INITIALIZE|DELETE|IMPROVE|",
/* 11-Sep-2016 nm Added EXPAND */
"MINIMIZE_WITH|EXPAND|UNDO|REDO|SAVE|DEMO|INVOKE|CLI|EXPLORE|TEX|",
"LATEX|HTML|COMMENTS|BIBLIOGRAPHY|MORE|",
"TOOLS|MIDI|$|<$>", NULL))) goto pclbad;
if (cmdMatches("HELP OPEN")) {
/*if (!getFullArg(2, "LOG|TEX|HTML|<LOG>")) goto pclbad;*/
/* 2-Oct-2017 nm Removed HTML */
if (!getFullArg(2, "LOG|TEX|<LOG>")) goto pclbad;
goto pclgood;
}
if (cmdMatches("HELP CLOSE")) {
/*if (!getFullArg(2, "LOG|TEX|HTML|<LOG>")) goto pclbad;*/
/* 2-Oct-2017 nm Removed HTML */
if (!getFullArg(2, "LOG|TEX|<LOG>")) goto pclbad;
goto pclgood;
}
if (cmdMatches("HELP SHOW")) {
if (!getFullArg(2, cat("MEMORY|SETTINGS|LABELS|SOURCE|STATEMENT|",
"PROOF|NEW_PROOF|USAGE|TRACE_BACK|ELAPSED_TIME|",
"DISCOURAGED|<MEMORY>",
NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("HELP SET")) {
if (!getFullArg(2, cat(
"ECHO|SCROLL|WIDTH|HEIGHT|UNDO|UNIFICATION_TIMEOUT|",
"DISCOURAGEMENT|",
"CONTRIBUTOR|", /* 14-May-2017 nm */
"ROOT_DIRECTORY|", /* 31-Dec-2017 nm */
"EMPTY_SUBSTITUTION|SEARCH_LIMIT|JEREMY_HENTY_FILTER|<ECHO>",
NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("HELP VERIFY")) {
if (!getFullArg(2, "PROOF|MARKUP|<PROOF>"))
goto pclbad;
goto pclgood;
}
if (cmdMatches("HELP WRITE")) {
if (!getFullArg(2,
"SOURCE|THEOREM_LIST|BIBLIOGRAPHY|RECENT_ADDITIONS|<SOURCE>"))
goto pclbad;
goto pclgood;
}
if (cmdMatches("HELP FILE")) {
if (!getFullArg(2, "SEARCH"))
goto pclbad;
goto pclgood;
}
if (cmdMatches("HELP SAVE")) {
if (!getFullArg(2,
"PROOF|NEW_PROOF|<PROOF>"))
goto pclbad;
goto pclgood;
}
goto pclgood;
} /* cmdMatches("HELP") */
if (cmdMatches("READ")) {
if (!getFullArg(1, "& What is the name of the source input file? "))
goto pclbad;
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, "VERIFY|<VERIFY>")) goto pclbad;
} else {
break;
}
break; /* Break if only 1 switch is allowed */
} /* End while for switch loop */
goto pclgood;
}
if (cmdMatches("WRITE")) {
if (!getFullArg(1,
"SOURCE|THEOREM_LIST|BIBLIOGRAPHY|RECENT_ADDITIONS|<SOURCE>"))
goto pclbad;
if (cmdMatches("WRITE SOURCE")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2, cat(
"* What is the name of the source output file <",
g_input_fn, ">? ", NULL)))
goto pclbad;
if (!strcmp(g_input_fn, g_fullArg[2])) {
print2(
"The input file will be renamed %s~1.\n", g_input_fn);
}
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
/* 3-May-2017 nm Removed CLEAN */
"FORMAT|REWRAP",
/* 31-Dec-2017 nm Added SPLIT, NO_VERSIONING, KEEP_INCLUDES */
/* 24-Aug-2020 nm Added EXTRACT */
"|SPLIT|NO_VERSIONING|KEEP_INCLUDES|EXTRACT",
"|<REWRAP>", NULL)))
goto pclbad;
/* 24-Aug-2020 nm Added EXTRACT */
if (lastArgMatches("EXTRACT")) {
i++;
if (!getFullArg(i, "* What statement label? "))
goto pclbad;
}
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
} /* End while for switch loop */
goto pclgood;
}
if (cmdMatches("WRITE THEOREM_LIST")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"THEOREMS_PER_PAGE|SHOW_LEMMAS|HTML|ALT_HTML|NO_VERSIONING",
"|<THEOREMS_PER_PAGE>", NULL)))
goto pclbad;
if (lastArgMatches("THEOREMS_PER_PAGE")) {
i++;
if (!getFullArg(i, "# How many theorems per page <100>? "))
goto pclbad;
}
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
}
goto pclgood;
}
if (cmdMatches("WRITE BIBLIOGRAPHY")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2, cat(
"* What is the bibliography HTML input/output file <",
"mmbiblio.html", ">? ", NULL)))
goto pclbad;
print2(
"The old file will be renamed %s~1.\n", g_fullArg[2]);
goto pclgood;
}
if (cmdMatches("WRITE RECENT_ADDITIONS")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2, cat(
"* What is the Recent Additions HTML input/output file <",
"mmrecent.html", ">? ", NULL)))
goto pclbad;
print2(
"The old file will be renamed %s~1.\n", g_fullArg[2]);
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"LIMIT|HTML|ALT_HTML",
"|<LIMIT>", NULL)))
goto pclbad;
if (lastArgMatches("LIMIT")) {
i++;
if (!getFullArg(i, "# How many most recent theorems <100>? "))
goto pclbad;
}
} else {
break;
}
/*break;*/ /* Break if only 1 switch is allowed */
}
goto pclgood;
}
}
if (cmdMatches("OPEN")) {
/*if (!getFullArg(1, "LOG|TEX|HTML|<LOG>")) goto pclbad;*/
/* 2-Oct-2017 nm Removed HTML */
if (!getFullArg(1, "LOG|TEX|<LOG>")) goto pclbad;
if (cmdMatches("OPEN LOG")) {
if (g_logFileOpenFlag) {
printLongLine(cat(
"?Sorry, the log file \"", g_logFileName, "\" is currently open. ",
"Type CLOSE LOG to close the current log if you want to open another one."
, NULL), "", " ");
goto pclbad;
}
if (!getFullArg(2, "* What is the name of logging output file? "))
goto pclbad;
}
if (cmdMatches("OPEN TEX")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (g_texFileOpenFlag) {
printLongLine(cat(
"?Sorry, the LaTeX file \"", g_texFileName, "\" is currently open. ",
"Type CLOSE TEX to close the current LaTeX file",
" if you want to open another one."
, NULL), "", " ");
goto pclbad;
}
if (!getFullArg(2, "* What is the name of LaTeX output file? "))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"NO_HEADER|OLD_TEX|<NO_HEADER>", NULL)))
goto pclbad;
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
} /* End while for switch loop */
}
/* 2-Oct-2017 nm OPEN HTML is obsolete */
/*******
if (cmdMatches("OPEN HTML")) {
if (g_texFileOpenFlag) {
printLongLine(cat(
"?Sorry, the HTML file \"",g_texFileName, "\" is currently open. ",
"Type CLOSE HTML to close the current HTML file",
" if you want to open another one."
, NULL), "", " ");
goto pclbad;
}
if (!getFullArg(2, "@ What is the name of HTML output file? "))
goto pclbad;
/@ Get any switches @/
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"NO_HEADER|<NO_HEADER>", NULL)))
goto pclbad;
} else {
break;
}
break; /@ Break if only 1 switch is allowed @/
} /@ End while for switch loop @/
}
****/
goto pclgood;
}
if (cmdMatches("CLOSE")) {
/*if (!getFullArg(1, "LOG|TEX|HTML|<LOG>")) goto pclbad;*/
/* 2-Oct-2017 nm Removed HTML */
if (!getFullArg(1, "LOG|TEX|<LOG>")) goto pclbad;
goto pclgood;
}
if (cmdMatches("FILE")) {
if (!getFullArg(1, cat("SEARCH", NULL))) goto pclbad;
if (cmdMatches("FILE SEARCH")) {
if (!getFullArg(2, "& What is the name of the file to search? "))
goto pclbad;
if (!getFullArg(3, "* What is the string to search for? "))
goto pclbad;
/* Get any switches */
i = 3;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (i == 4) {
if (!getFullArg(i, cat(
"FROM_LINE|TO_LINE|<FROM_LINE>", NULL)))
goto pclbad;
} else {
if (!getFullArg(i, cat(
"FROM_LINE|TO_LINE|<TO_LINE>", NULL)))
goto pclbad;
}
if (lastArgMatches("FROM_LINE")) {
i++;
if (!getFullArg(i, "# From what line number <1>? "))
goto pclbad;
}
if (lastArgMatches("TO_LINE")) {
i++;
if (!getFullArg(i, "# To what line number <999999>? "))
goto pclbad;
}
if (lastArgMatches("WINDOW")) { /* ???Not implemented yet */
i++;
if (!getFullArg(i, "# How big a window around matched lines <0>? "))
goto pclbad;
}
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
} /* End while for switch loop */
goto pclgood;
} /* End if (cmdMatches("FILE SEARCH")) */
goto pclgood;
}
if (cmdMatches("SHOW")) {
if (!g_PFASmode) {
if (!getFullArg(1, cat(
"SETTINGS|LABELS|STATEMENT|SOURCE|PROOF|MEMORY|TRACE_BACK|",
"USAGE|ELAPSED_TIME|DISCOURAGED|<SETTINGS>", NULL)))
goto pclbad;
} else {
if (!getFullArg(1, cat("NEW_PROOF|",
"SETTINGS|LABELS|STATEMENT|SOURCE|PROOF|MEMORY|TRACE_BACK|",
"USAGE|ELAPSED_TIME|DISCOURAGED|<SETTINGS>",
NULL)))
goto pclbad;
}
if (g_showStatement) {
if (g_showStatement < 1 || g_showStatement > g_statements) bug(1110);
let(&defaultArg, cat(" <",g_Statement[g_showStatement].labelName, ">",
NULL));
} else {
let(&defaultArg, "");
}
if (cmdMatches("SHOW TRACE_BACK")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
cat("* What is the statement label", defaultArg, "? ", NULL)))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
/* 19-May-2013 nm Added MATCH */
"ALL|ESSENTIAL|AXIOMS|TREE|DEPTH|COUNT_STEPS|MATCH|TO",
"|<ALL>", NULL)))
goto pclbad;
if (lastArgMatches("DEPTH")) {
i++;
if (!getFullArg(i, "# How many indentation levels <999>? "))
goto pclbad;
}
/* 13-May-2013 nm Added MATCH */
if (lastArgMatches("MATCH")) {
i++;
if (!getFullArg(i, "* What statement label? "))
goto pclbad;
}
/* 18-Jul-2015 nm Added TO */
if (lastArgMatches("TO")) {
i++;
if (!getFullArg(i, "* What statement label? "))
goto pclbad;
}
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End if (cmdMatches("SHOW TRACE_BACK")) */
if (cmdMatches("SHOW USAGE")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
cat("* What is the statement label", defaultArg, "? ", NULL)))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"DIRECT|RECURSIVE|ALL",
"|<DIRECT>", NULL)))
goto pclbad;
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End if (cmdMatches("SHOW USAGE")) */
if (cmdMatches("SHOW LABELS")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
"* What are the labels to match (* = wildcard) <*>?"))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat("ALL|LINEAR|<ALL>", NULL)))
goto pclbad;
} else {
break;
}
/*break;*/ /* Break if only 1 switch is allowed */
}
goto pclgood;
}
if (cmdMatches("SHOW STATEMENT")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
cat("* What is the statement label", defaultArg, "? ", NULL)))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"FULL|COMMENT|TEX|OLD_TEX|HTML|ALT_HTML|TIME|BRIEF_HTML",
/* 12-May-2009 sa Added MNEMONICS */
"|BRIEF_ALT_HTML|MNEMONICS|NO_VERSIONING|<FULL>", NULL)))
goto pclbad;
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
}
goto pclgood;
}
if (cmdMatches("SHOW SOURCE")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
cat("* What is the statement label", defaultArg, "? ", NULL))) {
goto pclbad;
}
goto pclgood;
}
if (cmdMatches("SHOW PROOF")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
cat("* What is the statement label", defaultArg, "? ", NULL)))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"ESSENTIAL|ALL|UNKNOWN|FROM_STEP|TO_STEP|DEPTH",
/*"|REVERSE|VERBOSE|NORMAL|COMPRESSED",*/
"|REVERSE|VERBOSE|NORMAL|PACKED|COMPRESSED|EXPLICIT",
"|FAST", /* 2-Mar-2016 nm */
"|OLD_COMPRESSION", /* 27-Dec-2013 nm */
/* 14-Sep-2010 nm Added OLD_TEX */
"|STATEMENT_SUMMARY|DETAILED_STEP|TEX|OLD_TEX|HTML",
"|LEMMON|START_COLUMN|NO_REPEATED_STEPS",
"|RENUMBER|SIZE|<ESSENTIAL>", NULL)))
goto pclbad;
if (lastArgMatches("FROM_STEP")) {
i++;
if (!getFullArg(i, "# From what step <1>? "))
goto pclbad;
}
if (lastArgMatches("TO_STEP")) {
i++;
if (!getFullArg(i, "# To what step <9999>? "))
goto pclbad;
}
if (lastArgMatches("DEPTH")) {
i++;
if (!getFullArg(i, "# How many indentation levels <999>? "))
goto pclbad;
}
if (lastArgMatches("DETAILED_STEP")) {
i++;
if (!getFullArg(i, "# Display details of what step <1>? "))
goto pclbad;
}
if (lastArgMatches("START_COLUMN")) {
i++;
if (!getFullArg(i, cat(
"# At what column should the formula start <",
str((double)DEFAULT_COLUMN), ">? ", NULL)))
goto pclbad;
}
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End if (cmdMatches("SHOW PROOF")) */
if (cmdMatches("SHOW NEW_PROOF")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"ESSENTIAL|ALL|UNKNOWN|FROM_STEP|TO_STEP|DEPTH",
/*"|REVERSE|VERBOSE|NORMAL|COMPRESSED",*/
"|REVERSE|VERBOSE|NORMAL|PACKED|COMPRESSED|EXPLICIT",
"|OLD_COMPRESSION", /* 27-Dec-2013 nm */
"|NOT_UNIFIED|TEX|HTML",
"|LEMMON|START_COLUMN|NO_REPEATED_STEPS",
"|RENUMBER|<ESSENTIAL>", NULL)))
goto pclbad;
if (lastArgMatches("FROM_STEP")) {
i++;
if (!getFullArg(i, "# From what step <1>? "))
goto pclbad;
}
if (lastArgMatches("TO_STEP")) {
i++;
if (!getFullArg(i, "# To what step <9999>? "))
goto pclbad;
}
if (lastArgMatches("DEPTH")) {
i++;
if (!getFullArg(i, "# How many indentation levels <999>? "))
goto pclbad;
}
if (lastArgMatches("START_COLUMN")) {
i++;
if (!getFullArg(i, cat(
"# At what column should the formula start <",
str((double)DEFAULT_COLUMN), ">? ", NULL)))
goto pclbad;
}
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End if (cmdMatches("SHOW NEW_PROOF")) */
goto pclgood;
} /* End of SHOW */
if (cmdMatches("SEARCH")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(1,
"* What are the labels to match (* = wildcard) <*>?"))
goto pclbad;
if (!getFullArg(2, "* Search for what math symbol string? "))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat("ALL|COMMENTS|JOIN|<ALL>", NULL)))
goto pclbad;
} else {
break;
}
/*break;*/ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End of SEARCH */
if (cmdMatches("SAVE")) {
if (!g_PFASmode) {
if (!getFullArg(1,
"PROOF|<PROOF>"))
goto pclbad;
} else {
if (!getFullArg(1, cat("NEW_PROOF|",
"PROOF|<NEW_PROOF>",
NULL)))
goto pclbad;
}
if (g_showStatement) {
if (g_showStatement < 0) bug(1111);
let(&defaultArg, cat(" <",g_Statement[g_showStatement].labelName, ">", NULL));
} else {
let(&defaultArg, "");
}
if (cmdMatches("SAVE PROOF")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
cat("* What is the statement label", defaultArg, "? ", NULL)))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"NORMAL|PACKED|COMPRESSED|EXPLICIT",
"|FAST|OLD_COMPRESSION", /* 27-Dec-2013 nm */
"|TIME|<NORMAL>", NULL)))
goto pclbad;
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End if (cmdMatches("SAVE PROOF")) */
if (cmdMatches("SAVE NEW_PROOF")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"NORMAL|PACKED|COMPRESSED|EXPLICIT",
/* 27-Dec-2013 nm Added / OLD_COMPRESSION */
/* 3-May-2016 nm Added / OVERRIDE */
"|OLD_COMPRESSION|OVERRIDE",
"|<NORMAL>", NULL)))
goto pclbad;
} else {
break;
}
/*break;*/ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End if (cmdMatches("SAVE NEW_PROOF")) */
goto pclgood;
} /* End of SAVE */
if (cmdMatches("PROVE")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!g_proveStatement) g_proveStatement = g_showStatement;
if (g_proveStatement) {
let(&defaultArg, cat(" <",g_Statement[g_proveStatement].labelName, ">", NULL));
} else {
let(&defaultArg, "");
}
if (!getFullArg(1,
cat("* What is the label of the statement you want to try proving",
defaultArg, "? ", NULL)))
goto pclbad;
/* 10-May-2016 nm */
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, "OVERRIDE|<OVERRIDE>")) goto pclbad;
} else {
break;
}
break; /* Break if only 1 switch is allowed */
} /* End while for switch loop */
goto pclgood;
}
/* Commands in Proof Assistant mode */
if (cmdMatches("MATCH")) {
if (!getFullArg(1,
"STEP|ALL|<ALL>")) goto pclbad;
if (cmdMatches("MATCH STEP")) {
if (!getFullArg(2, "# What step number? ")) goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"MAX_ESSENTIAL_HYP|<MAX_ESSENTIAL_HYP>", NULL)))
goto pclbad;
if (lastArgMatches("MAX_ESSENTIAL_HYP")) {
i++;
if (!getFullArg(i,
"# Maximum number of essential hypotheses to allow for a match <0>? "))
goto pclbad;
}
} else {
break;
}
break; /* Break if only 1 switch is allowed */
}
goto pclgood;
}
if (cmdMatches("MATCH ALL")) {
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"ESSENTIAL|MAX_ESSENTIAL_HYP|<ESSENTIAL>", NULL)))
goto pclbad;
if (lastArgMatches("MAX_ESSENTIAL_HYP")) {
i++;
if (!getFullArg(i,
"# Maximum number of essential hypotheses to allow for a match <0>? "))
goto pclbad;
}
} else {
break;
}
/*break;*/ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End if (cmdMatches("MATCH ALL")) */
goto pclgood;
}
if (cmdMatches("INITIALIZE")) {
if (!getFullArg(1,
"STEP|ALL|USER|<ALL>")) goto pclbad; /* 16-Apr-06 nm Added USER */
if (cmdMatches("INITIALIZE STEP")) {
if (!getFullArg(2, "# What step number? ")) goto pclbad;
}
goto pclgood;
}
/* 26-Aug-2006 nm Changed "IMPROVE STEP <step>" to just "IMPROVE <step>"
for user convenience (and consistency with "ASSIGN" command) */
if (cmdMatches("IMPROVE")) {
if (!getFullArg(1,
"* What step number, or FIRST, or LAST, or ALL <ALL>? ")) goto pclbad;
/* 11-Dec-05 nm */
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i,
/* 3-May-2016 nm Added / OVERRIDE */
/* 5-Aug-2020 nm Added / INCLUDE_MATHBOXES */
"DEPTH|NO_DISTINCT|1|2|3|SUBPROOFS|OVERRIDE|INCLUDE_MATHBOXES|<DEPTH>")
) goto pclbad;
if (lastArgMatches("DEPTH")) {
i++;
if (!getFullArg(i,
"# What is maximum depth for searching statements with $e hypotheses <0>? "))
goto pclbad;
}
} else {
break;
}
/*break;*/ /* Do this if only 1 switch is allowed */
} /* end while */
goto pclgood;
} /* end if IMPROVE */
/* ------- Old version before 26-Aug-2006 -------
if (cmdMatches("IMPROVE")) {
if (!getFullArg(1,
"STEP|ALL|FIRST|LAST|<ALL>")) goto pclbad;
if (cmdMatches("IMPROVE STEP")) {
if (!getFullArg(2, "# What step number? ")) goto pclbad;
}
if (cmdMatches("IMPROVE STEP") || cmdMatches("IMPROVE ALL")
|| cmdMatches("IMPROVE LAST") || cmdMatches("IMPROVE FIRST")) {
/@ 11-Dec-05 nm @/
/@ Get switches @/
if (cmdMatches("IMPROVE STEP")) {
i = 2;
} else {
i = 1;
}
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i,
"DEPTH|NO_DISTINCT|<DEPTH>")
) goto pclbad;
if (lastArgMatches("DEPTH")) {
i++;
if (!getFullArg(i,
"# What is maximum depth for searching statements with $e hypotheses <0>? "))
goto pclbad;
}
} else {
break;
}
/@break;@/ /@ Do this if only 1 switch is allowed @/
} /@ end while @/
goto pclgood;
} /@ end if IMPROVE STEP or IMPROVE ALL @/
}
------- End of old version ------- */
if (cmdMatches("MINIMIZE_WITH")) {
if (!getFullArg(1, "* What statement label? ")) goto pclbad;
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
/*
"BRIEF|VERBOSE|ALLOW_GROWTH|NO_DISTINCT|EXCEPT|",
"REVERSE|INCLUDE_MATHBOXES|FORBID|<BRIEF>", NULL)))
*/
"VERBOSE|MAY_GROW|EXCEPT|OVERRIDE|INCLUDE_MATHBOXES|",
"ALLOW_NEW_AXIOMS|NO_NEW_AXIOMS_FROM|FORBID|TIME|<VERBOSE>",
NULL)))
/* 7-Jan-06 nm Added EXCEPT */
/* 28-Jun-2011 nm Added INCLUDE_MATHBOXES */
/* 10-Nov-2011 nm Added REVERSE */
/* 25-Jun-2014 nm Removed REVERSE, NO_DISTINCT */
/* 22-Nov-2014 nm Added NO_NEW_AXIOMS_FROM */
/* 3-May-2016 nm Added / OVERRIDE */
/* 4-Aug-2019 nm Added ALLOW_NEW_AXIOMS; changed
ALLOW_GROWTH to MAY_GROW */
goto pclbad;
/* 7-Jan-06 nm Added EXCEPT */
if (lastArgMatches("EXCEPT")) {
i++;
if (!getFullArg(i, "* What statement label match pattern? "))
goto pclbad;
}
/* 4-Aug-2019 nm Added ALLOW_NEW_AXIOMS */
if (lastArgMatches("ALLOW_NEW_AXIOMS")) {
i++;
if (!getFullArg(i, "* What statement label match pattern? "))
goto pclbad;
}
/* 22-Nov-2014 nm Added NO_NEW_AXIOMS_FROM */
if (lastArgMatches("NO_NEW_AXIOMS_FROM")) {
i++;
if (!getFullArg(i, "* What statement label match pattern? "))
goto pclbad;
}
/* 20-May-2013 nm Added FORBID */
if (lastArgMatches("FORBID")) {
i++;
if (!getFullArg(i, "* What statement label match pattern? "))
goto pclbad;
}
} else {
break;
}
/*break;*/ /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* end of MINIMIZE_WITH */
/* 11-Sep-2016 nm */
if (cmdMatches("EXPAND")) {
if (!getFullArg(1, "* What statement label? ")) goto pclbad;
goto pclgood;
}
if (cmdMatches("UNIFY")) {
if (!getFullArg(1,
"STEP|ALL|<ALL>")) goto pclbad;
if (cmdMatches("UNIFY STEP")) {
if (!getFullArg(2, "# What step number? ")) goto pclbad;
goto pclgood;
}
if (cmdMatches("UNIFY ALL")) {
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"INTERACTIVE|<INTERACTIVE>", NULL)))
goto pclbad;
} else {
break;
}
break; /* Break if only 1 switch is allowed */
}
goto pclgood;
} /* End if (cmdMatches("UNIFY ALL")) */
}
if (cmdMatches("DELETE")) {
if (!getFullArg(1,
"STEP|ALL|FLOATING_HYPOTHESES|<STEP>")) goto pclbad;
if (lastArgMatches("STEP")) {
if (!getFullArg(2, "# What step number? ")) goto pclbad;
goto pclgood;
}
goto pclgood;
}
/*???OBSOL???*/
if (cmdMatches("ADD")) {
if (!getFullArg(1,
"UNIVERSE|<UNIVERSE>")) goto pclbad;
/* Note: further parsing below */
}
if (cmdMatches("REPLACE")) {
/* 14-Sep-2012 nm Added FIRST, LAST */
if (!getFullArg(1, "* What step number, or FIRST, or LAST <LAST>? "))
goto pclbad;
if (!getFullArg(2, "* With what statement label? ")) goto pclbad;
/* Get any switches */
i = 2;
/* 3-May-2016 nm Added / OVERRIDE */
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"OVERRIDE|<OVERRIDE>", NULL)))
goto pclbad;
} else {
break;
}
break; /* Break if only 1 switch is allowed */
}
goto pclgood;
}
if (cmdMatches("LET")) {
if (!getFullArg(1, "STEP|VARIABLE|<STEP>")) goto pclbad;
if (cmdMatches("LET STEP")) {
if (!getFullArg(2, "* What step number, or FIRST, or LAST <LAST>? "))
goto pclbad;
}
if (cmdMatches("LET VARIABLE")) {
if (!getFullArg(2, "* Assign what variable (format $nn)? ")) goto pclbad;
}
if (!getFullArg(3, "=|<=>")) goto pclbad;
if (!getFullArg(4, "* With what math symbol string? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("ASSIGN")) {
if (!getFullArg(1,
"* What step number, or FIRST, or LAST <LAST>? ")) goto pclbad;
/* 11-Dec-05 nm */
if (!getFullArg(2, "* With what statement label? ")) goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat( /* 3-May-2016 nm Added / OVERRIDE */
"NO_UNIFY|OVERRIDE|<NO_UNIFY>", NULL)))
goto pclbad;
} else {
break;
}
/*break;*/ /* Break if only 1 switch is allowed */
}
goto pclgood;
}
if (cmdMatches("UNDO")) {
goto pclgood;
}
if (cmdMatches("REDO")) {
goto pclgood;
}
if (cmdMatches("SET")) {
let(&tmpStr, cat(
/*"ECHO|SCROLL|UNIVERSE|",*/
"WIDTH|HEIGHT|UNDO|ECHO|SCROLL|",
"DEBUG|MEMORY_STATUS|SEARCH_LIMIT|UNIFICATION_TIMEOUT|",
"DISCOURAGEMENT|", /* 10-Jul-2016 nm */
"CONTRIBUTOR|", /* 14-May-2017 nm */
"ROOT_DIRECTORY|", /* 31-Dec-2017 nm */
"EMPTY_SUBSTITUTION|JEREMY_HENTY_FILTER|<WIDTH>", NULL));
if (!getFullArg(1,tmpStr)) goto pclbad;
if (cmdMatches("SET DEBUG")) {
if (!getFullArg(2, "FLAG|OFF|<OFF>")) goto pclbad;
if (lastArgMatches("FLAG")) {
if (!getFullArg(3, "4|5|6|7|8|9|<5>")) goto pclbad;
}
goto pclgood;
}
if (cmdMatches("SET ECHO")) {
if (g_commandEcho) {
if (!getFullArg(2, "ON|OFF|<OFF>")) goto pclbad;
} else {
if (!getFullArg(2, "ON|OFF|<ON>")) goto pclbad;
}
goto pclgood;
}
if (cmdMatches("SET SCROLL")) {
if (g_scrollMode == 1) {
if (!getFullArg(2, "CONTINUOUS|PROMPTED|<CONTINUOUS>")) goto pclbad;
} else {
if (!getFullArg(2, "CONTINUOUS|PROMPTED|<PROMPTED>")) goto pclbad;
}
goto pclgood;
}
if (cmdMatches("SET DISCOURAGEMENT")) { /* 10-Jul-2016 nm */
if (g_globalDiscouragement) {
if (!getFullArg(2, "ON|OFF|<OFF>")) goto pclbad;
} else {
if (!getFullArg(2, "ON|OFF|<ON>")) goto pclbad;
}
goto pclgood;
}
if (cmdMatches("SET MEMORY_STATUS")) {
if (g_memoryStatus) {
if (!getFullArg(2, "ON|OFF|<OFF>")) goto pclbad;
} else {
if (!getFullArg(2, "ON|OFF|<ON>")) goto pclbad;
}
goto pclgood;
}
if (cmdMatches("SET JEREMY_HENTY_FILTER")) {
if (g_hentyFilter) {
if (!getFullArg(2, "ON|OFF|<OFF>")) goto pclbad;
} else {
if (!getFullArg(2, "ON|OFF|<ON>")) goto pclbad;
}
goto pclgood;
}
if (cmdMatches("SET CONTRIBUTOR")) {
if (!getFullArg(2, cat(
"* What is the contributor name for SAVE (NEW_)PROOF <",
g_contributorName, ">? ", NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SET ROOT_DIRECTORY")) {
if (!getFullArg(2, cat(
"* What is the root directory path (use space if none) <",
g_rootDirectory, ">? ", NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SET SEARCH_LIMIT")) {
if (!getFullArg(2, cat(
"# What is search limit for IMPROVE command <",
str((double)g_userMaxProveFloat), ">? ", NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SET UNIFICATION_TIMEOUT")) {
if (!getFullArg(2, cat(
"# What is maximum number of unification trials <",
str((double)g_userMaxUnifTrials), ">? ", NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SET WIDTH")) {
if (!getFullArg(2, cat(
"# What is maximum line length on your screen <",
str((double)g_screenHeight), ">? ", NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SET HEIGHT")) {
if (!getFullArg(2, cat(
"# What is number of lines your screen displays <",
str((double)g_screenHeight), ">? ", NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SET UNDO")) {
if (!getFullArg(2, cat(
"# What is the maximum number of UNDOs <",
str((double)(processUndoStack(NULL, PUS_GET_SIZE, "", 0))),
">? ", NULL)))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SET EMPTY_SUBSTITUTION")) {
if (g_minSubstLen == 0) {
if (!getFullArg(2, "ON|OFF|<OFF>")) goto pclbad;
} else {
if (!getFullArg(2, "ON|OFF|<ON>")) goto pclbad;
}
goto pclgood;
}
} /* end if SET */
/************** 31-Dec-2017 nm Delete unused stuff
if (cmdMatches("INPUT")) {
if (!getFullArg(1, "PROOF|<PROOF>")) goto pclbad;
goto pclgood;
}
if (cmdMatches("SET UNIVERSE") || cmdMatches("ADD UNIVERSE") ||
cmdMatches("DELETE UNIVERSE")) {
/@ Get a list of statement labels @/
i = 1;
while (1) {
i++;
/@??? The user will never be asked this. @/
if (!getFullArg(i, "@ Statement label or '@' or '$f'|$<$>? "))
goto pclbad;
if (lastArgMatches("")) goto pclgood; /@ End of argument list @/
} /@ end while @/
} /@ end if xxx UNIVERSE @/
************/
if (cmdMatches("ERASE")) {
goto pclgood;
}
if (cmdMatches("MORE")) {
if (!getFullArg(1,
"* What is the name of the file to display? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("TOOLS")) {
goto pclgood;
}
if (cmdMatches("VERIFY")) {
if (!getFullArg(1,
"PROOF|MARKUP|<PROOF>"))
goto pclbad;
if (cmdMatches("VERIFY PROOF")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
"* What are the labels to match (* = wildcard) <*>?"))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"SYNTAX_ONLY",
"|<SYNTAX_ONLY>", NULL)))
goto pclbad;
} else {
break;
}
break; /* Break if only 1 switch is allowed */
}
goto pclgood;
}
/* 7-Nov-2015 nm */
if (cmdMatches("VERIFY MARKUP")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(2,
"* What are the labels to match (* = wildcard) <*>?"))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"DATE_SKIP|FILE_SKIP|TOP_DATE_SKIP|VERBOSE",
"|UNDERSCORE_SKIP|MATHBOX_SKIP|<DATE_SKIP>", NULL)))
goto pclbad;
} else {
break;
}
/* break; */ /* Break if only 1 switch is allowed */
}
goto pclgood;
}
}
if (cmdMatches("DBG")) {
/* The debug command fetches an arbitrary 2nd arg in quotes, to be handled
in whatever way is needed for debugging. */
if (!getFullArg(1, "* What is the debugging string? "))
goto pclbad;
goto pclgood;
}
/* 10-Dec-2018 nm Added MARKUP command*/
if (cmdMatches("MARKUP")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(1,
"* What is the name of the input file with markup? "))
goto pclbad;
if (!getFullArg(2,
"* What is the name of the HTML output file? "))
goto pclbad;
/* Get any switches */
i = 2;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"HTML|ALT_HTML|SYMBOLS|LABELS|NUMBER_AFTER_LABEL|BIB_REFS",
"|UNDERSCORES|CSS|<ALT_HTML>", NULL)))
goto pclbad;
} else {
break;
}
/*break;*/ /* Break if only 1 switch is allowed */
}
goto pclgood;
}
if (cmdMatches("MIDI")) {
if (g_sourceHasBeenRead == 0) {
print2("?No source file has been read in. Use READ first.\n");
goto pclbad;
}
if (!getFullArg(1,
"* Statement label to create MIDI for (* matches any substring) <*>?"))
goto pclbad;
/* Get any switches */
i = 1;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat("PARAMETER|<PARAMETER>", NULL)))
goto pclbad;
i++;
if (!getFullArg(i,
"* What is the parameter string <FSH>?"))
goto pclbad;
} else {
break;
}
break; /* Break if only 1 switch is allowed */
}
goto pclgood;
}
if (cmdMatches("EXIT") || cmdMatches("QUIT")
|| cmdMatches("_EXIT_PA")) { /* 9-Jun-2016 nm */
/* Get any switches */
i = 0;
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"FORCE|<FORCE>", NULL)))
goto pclbad;
} else {
break;
}
break; /* Break if only 1 switch is allowed */
} /* End while for switch loop */
goto pclgood;
}
} else { /* g_toolsMode */
/* Text tools mode */
let(&tmpStr, cat(
"HELP|SUBMIT|",
"ADD|DELETE|SUBSTITUTE|S|SWAP|CLEAN|INSERT|BREAK|BUILD|MATCH|SORT|",
"UNDUPLICATE|DUPLICATE|UNIQUE|REVERSE|RIGHT|PARALLEL|NUMBER|COUNT|",
"COPY|C|TYPE|T|TAG|UPDATE|BEEP|B|EXIT|QUIT|<HELP>", NULL));
if (!getFullArg(0,tmpStr))
goto pclbad;
if (cmdMatches("HELP")) {
if (!getFullArg(1, cat(
"ADD|DELETE|SUBSTITUTE|S|SWAP|CLEAN|INSERT|BREAK|BUILD|MATCH|SORT|",
"UNDUPLICATE|DUPLICATE|UNIQUE|REVERSE|RIGHT|PARALLEL|NUMBER|COUNT|",
"TYPE|T|TAG|UPDATE|BEEP|B|EXIT|QUIT|",
"COPY|C|SUBMIT|SYSTEM|CLI|",
"$|<$>", NULL))) goto pclbad;
goto pclgood;
}
if (cmdMatches("ADD") || cmdMatches("TAG")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2, "* String to add to beginning of each line <>? "))
goto pclbad;
if (!getFullArg(3, "* String to add to end of each line <>? "))
goto pclbad;
if (cmdMatches("TAG")) {
if (!getFullArg(4,
"* String to match to start range (null = any line) <>? "))
goto pclbad;
if (!getFullArg(5,
"# Which occurrence of start match to start range <1>? "))
goto pclbad;
if (!getFullArg(6,
"* String to match to end range (null = any line) <>? "))
goto pclbad;
if (!getFullArg(7,
"# Which occurrence of end match to end range <1>? "))
goto pclbad;
}
goto pclgood;
}
if (cmdMatches("DELETE")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2,
"* String from which to start deleting (CR = beginning of line) <>? "))
goto pclbad;
if (!getFullArg(3,
"* String at which to stop deleting (CR = end of line) <>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("CLEAN")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2,
"* Subcommand(s) (D,B,E,R,Q,T,U,P,G,C,L,V) <B,E,R>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SWAP")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2,
"* Character string to match between the halves to be swapped? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SUBSTITUTE") || cmdMatches("S")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2, "* String to replace? "))
goto pclbad;
if (!getFullArg(3, "* Replace it with <>? "))
goto pclbad;
if (!getFullArg(4,
"* Which occurrence in the line (1,2,... or ALL or EACH) <1>? "))
goto pclbad;
if (!getFullArg(5,
"* Additional match required on line (null = match all) <>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("INSERT")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2, "* String to insert in each line <!>? "))
goto pclbad;
if (!getFullArg(3, "# Column at which to insert the string <1>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("BREAK")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2,
"* Special characters to use as token delimiters <()[],=:;{}>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("MATCH")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2,
"* String to match on each line (null = any non-blank line) <>? "))
goto pclbad;
if (!getFullArg(3,
"* Output those lines containing the string (Y) or those not (N) <Y>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("SORT")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
if (!getFullArg(2,
"* String to start key on each line (null string = column 1) <>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("UNDUPLICATE") || cmdMatches("DUPLICATE") ||
cmdMatches("UNIQUE") || cmdMatches("REVERSE") || cmdMatches("BUILD")
|| cmdMatches("RIGHT")) {
if (!getFullArg(1, "& Input/output file? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("COUNT")) {
if (!getFullArg(1, "& Input file? "))
goto pclbad;
if (!getFullArg(2,
"* String to count <;>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("COPY") || cmdMatches("C")) {
if (!getFullArg(1, "* Comma-separated list of input files? "))
goto pclbad;
if (!getFullArg(2, "* Output file? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("NUMBER")) {
if (!getFullArg(1, "* Output file <n.tmp>? "))
goto pclbad;
if (!getFullArg(2, "# First number <1>? "))
goto pclbad;
if (!getFullArg(3, "# Last number <10>? "))
goto pclbad;
if (!getFullArg(4, "# Increment <1>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("TYPE") || cmdMatches("T")) {
if (!getFullArg(1, "& File to display on the screen? "))
goto pclbad;
if (!getFullArg(2, "* Num. lines to type or ALL (nothing = 10) <$>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("UPDATE")) {
print2(
"Warning: Do not comment out code - delete it before running UPDATE! If\n");
print2(
"rerunning UPDATE, do not tamper with \"start/end of deleted section\" comments!\n");
print2(
"Edit out tag on header comment line! Review the output file!\n");
if (!getFullArg(1, "& Original (reference) program input file? "))
goto pclbad;
if (!getFullArg(2, "& Edited program input file? "))
goto pclbad;
if (!getFullArg(3, cat(
"* Edited program output file with revisions tagged <",
g_fullArg[2], ">? ", NULL)))
goto pclbad;
if (!strcmp(g_fullArg[2], g_fullArg[3])) {
print2(
"The input file will be renamed %s~1.\n", g_fullArg[2]);
}
if (!getFullArg(4,
cat("* Revision tag for added lines </* #",
str((double)(highestRevision(g_fullArg[1]) + 1)), " */>? ", NULL)))
goto pclbad;
if (!getFullArg(5,
"# Successive lines required for match (more = better sync) <3>? "))
goto pclbad;
goto pclgood;
}
if (cmdMatches("PARALLEL")) {
if (!getFullArg(1, "& Left file? "))
goto pclbad;
if (!getFullArg(2, "& Right file? "))
goto pclbad;
if (!getFullArg(3, cat("* Output file <",
g_fullArg[1], ">? ", NULL)))
goto pclbad;
if (!getFullArg(4,
cat("* String to insert between the 2 input lines <>? ", NULL)))
goto pclbad;
goto pclgood;
}
/* g_toolsMode - no qualifiers for EXIT */
if (cmdMatches("EXIT") || cmdMatches("QUIT")) {
goto pclgood;
}
} /* if !g_toolsMode ... else ... */
if (cmdMatches("SUBMIT")) {
if (g_toolsMode) {
let(&tmpStr, " <tools.cmd>");
} else {
let(&tmpStr, " <mm.cmd>");
}
if (!getFullArg(1, cat("& What is the name of command file to run",
tmpStr, "? ", NULL))) {
goto pclbad;
}
/* 23-Oct-2006 nm Added / SILENT qualifier */
/* Get any switches */
i = 1; /* Number of command words before switch */
while (1) {
i++;
if (!getFullArg(i, "/|$|<$>")) goto pclbad;
if (lastArgMatches("/")) {
i++;
if (!getFullArg(i, cat(
"SILENT",
"|<SILENT>", NULL)))
goto pclbad;
} else {
break;
}
break; /* Break if only 1 switch is allowed */
} /* End while for switch loop */
goto pclgood;
}
if (cmdMatches("BEEP") || cmdMatches("B")) {
goto pclgood;
}
/* Command in master list but not intercepted -- really a bug */
print2("?This command has not been implemented yet.\n");
print2("(This is really a bug--please report it.)\n");
goto pclbad;
/* Should never get here */
pclgood:
/* Strip off the last g_fullArg if a null argument was added by getFullArg
in the case when "$" (nothing) is allowed */
if (!strcmp(g_fullArg[pntrLen(g_fullArg) - 1], chr(3))) {
let((vstring *)(&g_fullArg[pntrLen(g_fullArg) - 1]), ""); /* Deallocate */
pntrLet(&g_fullArg, pntrLeft(g_fullArg, pntrLen(g_fullArg) - 1));
}
if (pntrLen(g_fullArg) > g_rawArgs) bug(1102);
if (pntrLen(g_fullArg) < g_rawArgs) {
let(&tmpStr, cat("?Too many arguments. Use quotes around arguments with special",
" characters and around Unix file names with \"/\"s.", NULL));
printCommandError(cat(g_commandPrompt, g_commandLine, NULL), pntrLen(g_fullArg),
tmpStr);
goto pclbad;
}
/* 1-Nov-2013 nm Create a single string containing the g_fullArg tokens */
let(&g_fullArgString, "");
for (i = 0; i < pntrLen(g_fullArg); i++) {
let(&g_fullArgString, cat(g_fullArgString, " ", g_fullArg[i], NULL));
}
let(&g_fullArgString, right(g_fullArgString, 2)); /* Strip leading space */
/* Deallocate memory */
let(&defaultArg, "");
let(&tmpStr, "");
return (1);
pclbad:
/* Deallocate memory */
let(&defaultArg, "");
let(&tmpStr, "");
return (0);
} /* processCommandLine */
flag getFullArg(long arg, vstring cmdList1)
{
/* This function converts the user's abbreviated keyword in
g_rawArgPntr[arg] to a full, upper-case keyword,
in g_fullArg[arg], matching
the available choices in cmdList. */
/* Special cases: cmdList = "# xxx <yyy>?" - get an integer */
/* cmdList = "* xxx <yyy>?" - get any string;
don't convert to upper case
cmdList = "& xxx <yyy>?" - same as * except
verify it is a file that exists */
/* "$" means a null argument is acceptable; put it in as
special character chr(3) so it can be recognized */
pntrString *possCmd = NULL_PNTRSTRING;
long possCmds, i, j, k, m, p, q;
vstring defaultCmd = "";
vstring infoStr = "";
vstring tmpStr = "";
vstring tmpArg = "";
vstring errorLine = "";
vstring keyword = "";
vstring cmdList = "";
FILE *tmpFp;
let(&cmdList,cmdList1); /* In case cmdList1 gets deallocated when it comes
directly from a vstring function such as cat() */
let(&errorLine, cat(g_commandPrompt,g_commandLine, NULL));
/* Handle special case - integer expected */
if (cmdList[0] == '#') {
let(&defaultCmd,
seg(cmdList,instr(1,cmdList, "<"),instr(1,cmdList, ">")));
/* If the argument has not been entered, prompt the user for it */
if (g_rawArgs <= arg) {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, 0));
g_rawArgs++;
if (g_rawArgs <= arg) bug(1103);
g_queryMode = 1;
tmpArg = cmdInput1(right(cmdList,3));
let(&errorLine,right(cmdList,3));
if (tmpArg[0] == 0) { /* Use default argument */
let(&tmpArg, seg(defaultCmd,2,len(defaultCmd) - 1));
}
let((vstring *)(&g_rawArgPntr[arg]), tmpArg);
g_rawArgNmbr[arg] = len(cmdList) - 1;/* Line position for error msgs */
} /* End of asking user for additional argument */
/* Make sure that the argument is a non-negative integer */
let(&tmpArg,g_rawArgPntr[arg]);
if (tmpArg[0] == 0) { /* Use default argument */
/* (This code is needed in case of null string passed directly) */
let(&tmpArg, seg(defaultCmd,2,len(defaultCmd) - 1));
}
let(&tmpStr, str(val(tmpArg)));
let(&tmpStr, cat(string(len(tmpArg)-len(tmpStr),'0'), tmpStr, NULL));
if (strcmp(tmpStr, tmpArg)) {
printCommandError(errorLine, arg,
"?A number was expected here.");
goto return0;
}
let(&keyword, str(val(tmpArg)));
goto return1;
}
/* Handle special case - any arbitrary string is OK */
/* '*' means any string, '&' means a file */
/* However, "|$<$>" also allows null string (no argument) */
if (cmdList[0] == '*' || cmdList[0] == '&') {
let(&defaultCmd,
seg(cmdList,instr(1,cmdList, "<"),instr(1,cmdList, ">")));
/* If the argument has not been entered, prompt the user for it */
if (g_rawArgs <= arg) {
if (!strcmp(defaultCmd, "<$>")) { /* End of command acceptable */
/* Note: in this case, user will never be prompted for anything. */
let(&keyword,chr(3));
goto return1;
}
g_rawArgs++;
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, 0));
if (g_rawArgs <= arg) bug(1104);
g_queryMode = 1;
tmpArg = cmdInput1(right(cmdList,3));
/* Strip off any quotes around it
and tolerate lack of trailing quote */
/******* (This is no longer done - it is confusing to the user.)
if (tmpArg[0] == '\'' || tmpArg[0] == '\"') {
if (tmpArg[0] == tmpArg[len(tmpArg) - 1]) {
let(&tmpArg, right(left(tmpArg, len(tmpArg) - 1), 2));
} else {
let(&tmpArg, right(tmpArg, 2));
}
}
*******/
let(&errorLine,right(cmdList,3));
if (tmpArg[0] == 0) { /* Use default argument */
let(&tmpArg, seg(defaultCmd,2,len(defaultCmd) - 1));
}
let((vstring *)(&g_rawArgPntr[arg]), tmpArg);
g_rawArgNmbr[arg] = len(cmdList) - 1; /* Line position for error msgs */
} /* End of asking user for additional argument */
let(&keyword,g_rawArgPntr[arg]);
/* 1-Nov-2013 nm */
/* Convert abbreviations of FIRST, LAST, ALL to
full keywords. The rest of the program works fine without doing this,
but it provides better cosmetic appearance when the command is echoed
such as in during the UNDO command. */
if (cmdList[0] == '*') {
if ((keyword[0] == 'f' || keyword[0] == 'F')
&& instr(1, cmdList, " FIRST") != 0)
let(&keyword, "FIRST");
if ((keyword[0] == 'l' || keyword[0] == 'L')
&& instr(1, cmdList, " LAST") != 0)
let(&keyword, "LAST");
if ((keyword[0] == 'a' || keyword[0] == 'A')
&& instr(1, cmdList, " ALL") != 0)
let(&keyword, "ALL");
}
if (keyword[0] == 0) { /* Use default argument */
/* This case handles blank arguments on completely input command line */
let(&keyword, seg(defaultCmd,2,len(defaultCmd) - 1));
}
if (cmdList[0] == '&') {
/* See if file exists */
let(&tmpStr, cat(g_rootDirectory, keyword, NULL)); /* 9-Jan-2018 nm */
tmpFp = fopen(tmpStr, "r");
if (!tmpFp) {
let(&tmpStr, cat(
/*"?Sorry, couldn't open the file \"", keyword, "\".", NULL));*/
"?Sorry, couldn't open the file \"", tmpStr, "\".", NULL)); /* 9-Jan-2018 nm */
printCommandError(errorLine, arg, tmpStr);
goto return0;
}
fclose(tmpFp);
}
goto return1;
}
/* Parse the choices available */
possCmds = 0;
p = 0;
while (1) {
q = p;
p = instr(p + 1, cat(cmdList, "|", NULL), "|");
if (!p) break;
pntrLet(&possCmd,pntrAddElement(possCmd));
let((vstring *)(&possCmd[possCmds]),seg(cmdList,q+1,p-1));
possCmds++;
}
if (!strcmp(left(possCmd[possCmds - 1],1), "<")) {
/* Get default argument, if any */
defaultCmd = possCmd[possCmds - 1]; /* re-use old allocation */
if (!strcmp(defaultCmd, "<$>")) {
let(&defaultCmd, "<nothing>");
}
pntrLet(&possCmd,pntrLeft(possCmd,possCmds - 1));
possCmds--;
}
if (!strcmp(possCmd[possCmds - 1], "$")) {
/* Change "$" to "nothing" for printouts */
let((vstring *)(&possCmd[possCmds - 1]), "nothing");
}
/* Create a string used for queries and error messages */
if (possCmds < 1) bug(1105);
if (possCmds == 1) {
let(&infoStr,possCmd[0]);
}
if (possCmds == 2) {
let(&infoStr, cat(possCmd[0], " or ",
possCmd[1], NULL));
}
if (possCmds > 2) {
let(&infoStr, "");
for (i = 0; i < possCmds - 1; i++) {
let(&infoStr, cat(infoStr,possCmd[i], ", ", NULL));
}
let(&infoStr, cat(infoStr, "or ",possCmd[possCmds - 1], NULL));
}
/* If the argument has not been entered, prompt the user for it */
if (g_rawArgs <= arg && (strcmp(possCmd[possCmds - 1], "nothing")
|| g_queryMode == 1)) {
let(&tmpStr, infoStr);
if (defaultCmd[0] != 0) {
let(&tmpStr, cat(tmpStr, " ",defaultCmd, NULL));
}
let(&tmpStr, cat(tmpStr, "? ", NULL));
g_queryMode = 1;
if (possCmds != 1) {
tmpArg = cmdInput1(tmpStr);
} else {
/* There is only one possibility, so don't ask user */
/* Don't print the message when "end-of-list" is the only possibility. */
if (!strcmp(cmdList, "$|<$>")) {
let(&tmpArg, possCmd[0]);
print2("The command so far is: ");
for (i = 0; i < arg; i++) {
print2("%s ", g_fullArg[i]);
}
print2("%s\n", tmpArg);
}
}
let(&errorLine,tmpStr);
if (tmpArg[0] == 0) { /* Use default argument */
let(&tmpArg, seg(defaultCmd,2,len(defaultCmd) - 1));
}
if (strcmp(tmpArg, "nothing")) {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, 0));
g_rawArgs++;
if (g_rawArgs <= arg) bug(1106);
let((vstring *)(&g_rawArgPntr[arg]), tmpArg);
g_rawArgNmbr[arg] = len(tmpStr) + 1; /* Line position for error msgs */
}
} /* End of asking user for additional argument */
if (g_rawArgs <= arg) {
/* No argument was specified, and "nothing" is a valid argument */
let(&keyword,chr(3));
goto return1;
}
let(&tmpArg,edit(g_rawArgPntr[arg], 32)); /* Convert to upper case */
j = 0;
k = 0;
m = len(tmpArg);
let(&tmpStr, "");
/* Scan the possible arguments for a match */
for (i = 0; i < possCmds; i++) {
if (!strcmp(possCmd[i], tmpArg)) {
/* An exact match was found, so ignore any other matches
and use this one */
k = 1;
j = i;
break;
}
if (!strcmp(left(possCmd[i], m), tmpArg)) {
if (!k) {
let(&tmpStr, possCmd[i]);
} else {
let(&tmpStr, cat(tmpStr, ", ", possCmd[i], NULL));
}
j = i; /* Save match position */
k++; /* Number of matches */
}
}
if (k < 1 || k > 1) {
if (k < 1) {
let(&tmpStr, cat("?Expected ", infoStr, ".", NULL));
} else {
if (k == 2) {
p = instr(1,tmpStr, ", ");
let(&tmpStr, cat(left(tmpStr,p-1), " or",right(tmpStr,p+1), NULL));
} else {
p = len(tmpStr) - 1;
while (tmpStr[p] != ',') p--;
let(&tmpStr, cat(left(tmpStr,p+1), " or",right(tmpStr,p+2), NULL));
}
let(&tmpStr, cat("?Ambiguous keyword - please specify ",tmpStr, ".", NULL));
}
printCommandError(errorLine, arg, tmpStr);
goto return0;
}
let(&keyword,possCmd[j]);
goto return1;
return1:
if (keyword[0] == 0) {
if (g_rawArgs > arg && strcmp(defaultCmd, "<>")) {
/* otherwise, "nothing" was specified */
printCommandError("", arg,
"?No default answer is available - please be explicit.");
goto return0;
}
}
/* Add new field to g_fullArg */
pntrLet(&g_fullArg,pntrAddElement(g_fullArg));
if (pntrLen(g_fullArg) != arg + 1) bug(1107);
let((vstring *)(&g_fullArg[arg]),keyword);
/* Deallocate memory */
j = pntrLen(possCmd);
for (i = 0; i < j; i++) let((vstring *)(&possCmd[i]), "");
pntrLet(&possCmd, NULL_PNTRSTRING);
let(&defaultCmd, "");
let(&infoStr, "");
let(&tmpStr, "");
let(&tmpArg, "");
let(&errorLine, "");
let(&keyword, "");
let(&cmdList, "");
return(1);
return0:
/* Deallocate memory */
j = pntrLen(possCmd);
for (i = 0; i < j; i++) let((vstring *)(&possCmd[i]), "");
pntrLet(&possCmd, NULL_PNTRSTRING);
let(&defaultCmd, "");
let(&infoStr, "");
let(&tmpStr, "");
let(&tmpArg, "");
let(&errorLine, "");
let(&keyword, "");
let(&cmdList, "");
return(0);
} /* getFullArg */
void parseCommandLine(vstring line)
{
/* This function breaks up line into individual tokens
and puts them into g_rawArgPntr[]. g_rawArgs is the number of tokens.
g_rawArgPntr[] is the starting position of each token on the line;
the first character on the line has position 1, not 0.
Spaces, tabs, and newlines are considered white space. Special
one-character
tokens don't have to be surrounded by white space. Characters
inside quotes are considered to be one token, and the quotes are
removed.
*/
/* Warning: Don't deallocate these vstring constants */
/*vstring specialOneCharTokens = "()/,=:";*/
vstring tokenWhiteSpace = " \t\n";
vstring tokenComment = "!";
vstring tmpStr = ""; /* Dummy vstring to clean up temp alloc stack */
flag mode;
long tokenStart, i, p, lineLen;
vstring specialOneCharTokens = "";
/* Initialization to avoid compiler warning (should not be theoretically
necessary) */
tokenStart = 0;
if (!g_toolsMode) {
/* 5-Nov-99: We only really need / and =
Took out the others so user will have less need to put quotes around
e.g. single tokens in SEARCH command
let(&specialOneCharTokens, "()/,=:");
*/
let(&specialOneCharTokens, "/="); /* List of special one-char tokens */
} else {
let(&specialOneCharTokens, "");
}
lineLen = len(line);
/* mode: 0 means look for start of token, 1 means look for end of
token, 2 means look for trailing single quote, 3 means look for
trailing double quote */
/* 2/20/99 - only "!" at beginning of line now acts as comment
- This was done because sometimes ! might be legal as part of a command */
mode = 0;
for (p = 0; p < lineLen; p++) {
let(&tmpStr, ""); /* Clean up temp alloc stack to prevent overflow */
if (mode == 0) {
/* If character is white space, ignore it */
if (instr(1,tokenWhiteSpace,chr(line[p]))) {
continue;
}
/* If character is comment, we're done */
if (p == 0 && /* 2/20/99 */ instr(1,tokenComment,chr(line[p]))) {
break;
}
/* If character is a special token, get it but don't change mode */
if (instr(1,specialOneCharTokens,chr(line[p]))) {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, p+1));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]), chr(line[p]));
g_rawArgs++;
continue;
}
/* If character is a quote, set start and change mode */
if (line[p] == '\'') {
mode = 2;
tokenStart = p + 2;
continue;
}
if (line[p] == '\"') {
mode = 3;
tokenStart = p + 2;
continue;
}
/* Character must be start of a token */
mode = 1;
tokenStart = p + 1;
continue;
}
if (mode == 1) {
/* If character is white space, end token and change mode */
if (instr(1,tokenWhiteSpace,chr(line[p]))) {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, tokenStart));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]), seg(line, tokenStart, p));
g_rawArgs++;
mode = 0;
continue;
}
/* If character is comment, we're done */
/* 2/20/99 - see above
if (instr(1,tokenComment,chr(line[p]))) {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, tokenStart));
let((vstring *)(&g_rawArgPntr[g_rawArgs]), seg(line,tokenStart,p));
g_rawArgs++;
mode = 0;
break;
}
2/20/99 */
/* If character is a special token, get it and change mode */
if (instr(1,specialOneCharTokens,chr(line[p]))) {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, tokenStart));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]),seg(line, tokenStart, p));
g_rawArgs++;
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, p + 1));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]), chr(line[p]));
g_rawArgs++;
mode = 0;
continue;
}
/* If character is a quote, set start and change mode */
if (line[p] == '\'') {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, tokenStart));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]),seg(line, tokenStart,p));
g_rawArgs++;
mode = 2;
tokenStart = p + 2;
continue;
}
if (line[p] == '\"') {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, tokenStart));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]),seg(line, tokenStart,p));
g_rawArgs++;
mode = 3;
tokenStart = p + 2;
continue;
}
/* Character must be continuation of the token */
continue;
}
if (mode == 2 || mode == 3) {
/* If character is a quote, end quote and change mode */
if (line[p] == '\'' && mode == 2) {
mode = 0;
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, tokenStart));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]), seg(line,tokenStart,p));
g_rawArgs++;
continue;
}
if (line[p] == '\"' && mode == 3) {
mode = 0;
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, tokenStart));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]),seg(line, tokenStart,p));
g_rawArgs++;
continue;
}
/* Character must be continuation of quoted token */
continue;
}
}
/* Finished scanning the line. Finish processing last token. */
if (mode != 0) {
pntrLet(&g_rawArgPntr, pntrAddElement(g_rawArgPntr));
nmbrLet(&g_rawArgNmbr, nmbrAddElement(g_rawArgNmbr, tokenStart));
/* Save token start */
let((vstring *)(&g_rawArgPntr[g_rawArgs]),seg(line,tokenStart,p));
g_rawArgs++;
}
/* Add length of command line prompt to each argument, to
align the error message pointer */
for (i = 0; i < g_rawArgs; i++) {
g_rawArgNmbr[i] = g_rawArgNmbr[i] + len(g_commandPrompt);
}
/* Deallocate */
let(&specialOneCharTokens, "");
} /* parseCommandLine */
flag lastArgMatches(vstring argString)
{
/* This functions checks to see if the last field was argString */
if (!strcmp(argString, g_fullArg[pntrLen(g_fullArg)-1])) {
return (1);
} else {
return (0);
}
} /* lastArgMatches */
flag cmdMatches(vstring cmdString)
{
/* This function checks that fields 0 through n of g_fullArg match
cmdString (separated by spaces). */
long i, j, k;
vstring tmpStr = "";
/* Count the number of spaces */
k = len(cmdString);
j = 0;
for (i = 0; i < k; i++) {
if (cmdString[i] == ' ') j++;
}
k = pntrLen(g_fullArg);
for (i = 0; i <= j; i++) {
if (j >= k) {
/* Command to match is longer than the user's command; assume no match */
let(&tmpStr, "");
return (0);
}
let(&tmpStr, cat(tmpStr, " ", g_fullArg[i], NULL));
}
if (!strcmp(cat(" ", cmdString, NULL), tmpStr)) {
let(&tmpStr, "");
return (1);
} else {
let(&tmpStr, "");
return (0);
}
} /* cmdMatches */
long switchPos(vstring swString)
{
/* This function checks that fields i through j of g_fullArg match
swString (separated by spaces). The first character of swString
should be "/" and must be separated from the first field
of swString with a space. The position of the "/" in g_fullArg
is returned if swString is there, otherwise 0 is returned (the first
position in g_fullArg is considered 1, not 0). */
/* Example: if g_fullArg (combined into one string) is
"DISPLAY PROOF / UNKNOWN / START_STEP = 10 / ESSENTIAL"
and swString is "/ START_STEP", switchPos will return 5. */
long i, j, k;
vstring tmpStr = "";
vstring swString1 = "";
if (swString[0] != '/') bug(1108);
/* Add a space after the "/" if there is none */
if (swString[1] != ' ') {
let(&swString1, cat("/ ", right(swString,2), " ", NULL));
} else {
let(&swString1,swString);
}
/* Build the complete command */
k = pntrLen(g_fullArg);
for (i = 0; i < k; i++) {
let(&tmpStr, cat(tmpStr,g_fullArg[i], " ", NULL));
}
k = instr(1,tmpStr,swString1);
if (!k) {
let(&swString1, "");
let(&tmpStr, "");
return (0);
}
let(&tmpStr,left(tmpStr,k));
/* Count the number of spaces - it will be the g_fullArg position */
k = len(tmpStr);
j = 0;
for (i = 0; i < k; i++) {
if (tmpStr[i] == ' ') j++;
}
let(&tmpStr, "");
let(&swString1, "");
return (j + 1);
} /* switchPos */
void printCommandError(vstring line1, long arg, vstring errorMsg)
{
/* Warning: errorMsg should not a temporarily allocated string such
as the direct output of cat() */
vstring errorPointer = "";
vstring line = "";
long column, tokenLength, j;
let(&line,line1); /* Prevent deallocation in case line1 is
direct return from string function such as cat() */
if (!line[0]) {
/* Empty line - don't print an error pointer */
print2("%s\n", errorMsg);
let(&line, "");
return;
}
column = g_rawArgNmbr[arg];
tokenLength = len(g_rawArgPntr[arg]);
for (j = 0; j < column - 1; j++) {
/* Make sure that tabs on the line with the error are accounted for so
that the error pointer lines up correctly */
if (j >= len(line)) bug(1109);
if (line[j] == '\t') {
let(&errorPointer, cat(errorPointer, "\t", NULL));
} else {
if (line[j] == '\n') {
let(&errorPointer, "");
} else {
let(&errorPointer, cat(errorPointer, " ", NULL));
}
}
}
for (j = 0; j < tokenLength; j++)
let(&errorPointer, cat(errorPointer, "^", NULL));
print2("%s\n", errorPointer);
printLongLine(errorMsg, "", " ");
let(&errorPointer, "");
let(&line, "");
} /* printCommandError */
/* 4-May-2017 Ari Ferrera */
void freeCommandLine() {
long i, j;
j = pntrLen(g_rawArgPntr);
for (i = 0; i < j; i++) let((vstring *)(&g_rawArgPntr[i]), "");
j = pntrLen(g_fullArg);
for (i = 0; i < j; i++) let((vstring *)(&g_fullArg[i]), "");
pntrLet(&g_fullArg, NULL_PNTRSTRING);
pntrLet(&g_rawArgPntr, NULL_PNTRSTRING);
nmbrLet(&g_rawArgNmbr, NULL_NMBRSTRING);
let(&g_fullArgString, "");
}
|