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
|
/* A Bison parser, made from exparse.y
by GNU bison 1.30. */
#define EXBISON 1 /* Identify Bison output. */
# define MINTOKEN 257
# define CHAR 258
# define INT 259
# define INTEGER 260
# define UNSIGNED 261
# define FLOATING 262
# define STRING 263
# define VOID 264
# define BREAK 265
# define CALL 266
# define CASE 267
# define CONSTANT 268
# define CONTINUE 269
# define DECLARE 270
# define DEFAULT 271
# define DYNAMIC 272
# define ELSE 273
# define EXIT 274
# define FOR 275
# define FUNCTION 276
# define ITERATE 277
# define ID 278
# define IF 279
# define LABEL 280
# define MEMBER 281
# define NAME 282
# define POS 283
# define PRAGMA 284
# define PRE 285
# define PRINTF 286
# define PROCEDURE 287
# define QUERY 288
# define RETURN 289
# define SPRINTF 290
# define SWITCH 291
# define WHILE 292
# define F2I 293
# define F2S 294
# define I2F 295
# define I2S 296
# define S2B 297
# define S2F 298
# define S2I 299
# define F2X 300
# define I2X 301
# define S2X 302
# define X2F 303
# define X2I 304
# define X2S 305
# define OR 306
# define AND 307
# define EQ 308
# define NE 309
# define LE 310
# define GE 311
# define LS 312
# define RS 313
# define UNARY 314
# define INC 315
# define DEC 316
# define CAST 317
# define MAXTOKEN 318
#line 1 "exparse.y"
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* expression library grammar and compiler
*
* NOTE: procedure arguments not implemented yet
*/
#include <stdio.h>
#include <ast.h>
#undef RS /* hp.pa <signal.h> grabs this!! */
#line 21 "exparse.y"
typedef union
{
struct Exnode_s*expr;
double floating;
struct Exref_s* reference;
struct Exid_s* id;
Sflong_t integer;
int op;
char* string;
void* user;
struct Exbuf_s* buffer;
} EXSTYPE;
#line 128 "exparse.y"
#include "exgram.h"
#ifndef EXDEBUG
# define EXDEBUG 1
#endif
#include <stdio.h>
#define EXFINAL 214
#define EXFLAG -32768
#define EXNTBASE 89
/* EXTRANSLATE(EXLEX) -- Bison token number corresponding to EXLEX. */
#define EXTRANSLATE(x) ((unsigned)(x) <= 318 ? extranslate[x] : 127)
/* EXTRANSLATE[EXLEX] -- Bison token number corresponding to EXLEX. */
static const char extranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 74, 2, 2, 2, 73, 60, 2,
80, 85, 71, 69, 52, 70, 88, 72, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 55, 84,
63, 53, 64, 54, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 86, 2, 87, 59, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 82, 58, 83, 75, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 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, 56, 57, 61, 62,
65, 66, 67, 68, 76, 77, 78, 79, 81
};
#if EXDEBUG != 0
static const short exprhs[] =
{
0, 0, 3, 4, 7, 8, 13, 14, 17, 21,
24, 25, 30, 37, 43, 53, 59, 60, 69, 73,
77, 81, 82, 85, 88, 90, 93, 97, 100, 102,
106, 107, 112, 114, 116, 117, 120, 121, 123, 127,
132, 136, 140, 144, 148, 152, 156, 160, 164, 168,
172, 176, 180, 184, 188, 192, 196, 200, 204, 208,
209, 210, 218, 221, 224, 227, 230, 235, 240, 245,
250, 253, 256, 259, 262, 265, 267, 269, 271, 273,
275, 277, 279, 281, 283, 286, 290, 292, 293, 296,
297, 301, 302, 304, 306, 310, 311, 313, 315, 317,
321, 322, 326, 327, 329, 333, 336, 339, 340, 343,
345, 346, 347
};
static const short exrhs[] =
{
93, 90, 0, 0, 90, 91, 0, 0, 26, 55,
92, 93, 0, 0, 93, 94, 0, 82, 93, 83,
0, 106, 84, 0, 0, 16, 95, 101, 84, 0,
25, 80, 107, 85, 94, 105, 0, 21, 80, 112,
85, 94, 0, 21, 80, 106, 84, 106, 84, 106,
85, 94, 0, 38, 80, 107, 85, 94, 0, 0,
37, 80, 107, 96, 85, 82, 97, 83, 0, 11,
106, 84, 0, 15, 106, 84, 0, 35, 106, 84,
0, 0, 97, 98, 0, 99, 93, 0, 100, 0,
99, 100, 0, 13, 110, 55, 0, 17, 55, 0,
102, 0, 101, 52, 102, 0, 0, 28, 103, 113,
124, 0, 28, 0, 18, 0, 0, 19, 94, 0,
0, 107, 0, 80, 107, 85, 0, 80, 16, 85,
107, 0, 107, 63, 107, 0, 107, 70, 107, 0,
107, 71, 107, 0, 107, 72, 107, 0, 107, 73,
107, 0, 107, 67, 107, 0, 107, 68, 107, 0,
107, 64, 107, 0, 107, 65, 107, 0, 107, 66,
107, 0, 107, 61, 107, 0, 107, 62, 107, 0,
107, 60, 107, 0, 107, 58, 107, 0, 107, 59,
107, 0, 107, 69, 107, 0, 107, 57, 107, 0,
107, 56, 107, 0, 107, 52, 107, 0, 0, 0,
107, 54, 108, 107, 55, 109, 107, 0, 74, 107,
0, 75, 107, 0, 70, 107, 0, 69, 107, 0,
22, 80, 115, 85, 0, 20, 80, 107, 85, 0,
33, 80, 115, 85, 0, 111, 80, 115, 85, 0,
112, 123, 0, 77, 112, 0, 112, 77, 0, 78,
112, 0, 112, 78, 0, 110, 0, 14, 0, 8,
0, 6, 0, 9, 0, 7, 0, 32, 0, 34,
0, 36, 0, 24, 121, 0, 18, 114, 121, 0,
28, 0, 0, 86, 87, 0, 0, 86, 107, 87,
0, 0, 116, 0, 107, 0, 116, 52, 107, 0,
0, 16, 0, 118, 0, 119, 0, 118, 52, 119,
0, 0, 16, 120, 104, 0, 0, 122, 0, 88,
24, 122, 0, 88, 24, 0, 88, 28, 0, 0,
53, 107, 0, 123, 0, 0, 0, 80, 125, 117,
126, 85, 82, 93, 83, 0
};
#endif
#if EXDEBUG != 0
/* EXRLINE[EXN] -- source line where rule number EXN was defined. */
static const short exrline[] =
{
0, 136, 157, 158, 161, 176, 196, 200, 215, 219,
223, 223, 227, 235, 248, 263, 271, 271, 282, 294,
298, 310, 340, 343, 372, 373, 376, 397, 403, 404,
411, 411, 451, 452, 455, 459, 465, 469, 472, 476,
480, 522, 526, 530, 534, 538, 542, 546, 550, 554,
558, 562, 566, 570, 574, 578, 582, 591, 595, 604,
604, 605, 643, 660, 664, 668, 672, 676, 682, 687,
711, 735, 743, 751, 755, 759, 762, 769, 774, 779,
784, 791, 792, 793, 796, 800, 816, 828, 832, 838,
842, 848, 852, 860, 865, 871, 875, 881, 884, 888,
899, 900, 909, 913, 925, 944, 948, 953, 957, 964,
965, 978, 982
};
#endif
#if EXDEBUG != 0 || defined EXERROR_VERBOSE
/* EXTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
static const char *const extname[] =
{
"$", "error", "$undefined.", "MINTOKEN", "CHAR", "INT", "INTEGER",
"UNSIGNED", "FLOATING", "STRING", "VOID", "BREAK", "CALL", "CASE",
"CONSTANT", "CONTINUE", "DECLARE", "DEFAULT", "DYNAMIC", "ELSE", "EXIT",
"FOR", "FUNCTION", "ITERATE", "ID", "IF", "LABEL", "MEMBER", "NAME",
"POS", "PRAGMA", "PRE", "PRINTF", "PROCEDURE", "QUERY", "RETURN",
"SPRINTF", "SWITCH", "WHILE", "F2I", "F2S", "I2F", "I2S", "S2B", "S2F",
"S2I", "F2X", "I2X", "S2X", "X2F", "X2I", "X2S", "','", "'='", "'?'",
"':'", "OR", "AND", "'|'", "'^'", "'&'", "EQ", "NE", "'<'", "'>'", "LE",
"GE", "LS", "RS", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "'~'",
"UNARY", "INC", "DEC", "CAST", "'('", "MAXTOKEN", "'{'", "'}'", "';'",
"')'", "'['", "']'", "'.'", "program", "action_list", "action", "@1",
"statement_list", "statement", "@2", "@3", "switch_list", "switch_item",
"case_list", "case_item", "dcl_list", "dcl_item", "@4", "name",
"else_opt", "expr_opt", "expr", "@5", "@6", "constant", "print",
"variable", "array", "index", "args", "arg_list", "formals",
"formal_list", "formal_item", "@7", "members", "member", "assign",
"initialize", "@8", "@9", NULL
};
#endif
/* EXR1[EXN] -- Symbol number of symbol that rule EXN derives. */
static const short exr1[] =
{
0, 89, 90, 90, 92, 91, 93, 93, 94, 94,
95, 94, 94, 94, 94, 94, 96, 94, 94, 94,
94, 97, 97, 98, 99, 99, 100, 100, 101, 101,
103, 102, 104, 104, 105, 105, 106, 106, 107, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 107, 107, 107, 107, 108,
109, 107, 107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 107, 110, 110, 110, 110,
110, 111, 111, 111, 112, 112, 112, 113, 113, 114,
114, 115, 115, 116, 116, 117, 117, 117, 118, 118,
120, 119, 121, 121, 121, 122, 122, 123, 123, 124,
125, 126, 124
};
/* EXR2[EXN] -- Number of symbols composing right hand side of rule EXN. */
static const short exr2[] =
{
0, 2, 0, 2, 0, 4, 0, 2, 3, 2,
0, 4, 6, 5, 9, 5, 0, 8, 3, 3,
3, 0, 2, 2, 1, 2, 3, 2, 1, 3,
0, 4, 1, 1, 0, 2, 0, 1, 3, 4,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 0,
0, 7, 2, 2, 2, 2, 4, 4, 4, 4,
2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
1, 1, 1, 1, 2, 3, 1, 0, 2, 0,
3, 0, 1, 1, 3, 0, 1, 1, 1, 3,
0, 3, 0, 1, 3, 2, 2, 0, 2, 1,
0, 0, 8
};
/* EXDEFACT[S] -- default rule to reduce with in state S when EXTABLE
doesn't specify something else to do. Zero means the default is an
error. */
static const short exdefact[] =
{
6, 2, 78, 80, 77, 79, 36, 76, 36, 10,
89, 0, 0, 0, 102, 0, 86, 81, 0, 82,
36, 83, 0, 0, 0, 0, 0, 0, 0, 0,
0, 6, 1, 7, 0, 37, 75, 0, 107, 0,
0, 0, 0, 102, 0, 36, 91, 0, 84, 103,
0, 91, 0, 0, 0, 65, 64, 62, 63, 71,
73, 0, 0, 36, 0, 3, 9, 0, 59, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 91, 0, 72,
74, 70, 18, 19, 30, 0, 28, 0, 85, 0,
0, 107, 93, 0, 92, 105, 106, 0, 0, 20,
16, 0, 0, 38, 8, 4, 58, 0, 57, 56,
53, 54, 52, 50, 51, 40, 47, 48, 49, 45,
46, 55, 41, 42, 43, 44, 0, 108, 87, 0,
11, 90, 67, 36, 36, 66, 0, 0, 104, 36,
68, 0, 36, 39, 6, 0, 69, 0, 107, 29,
0, 13, 94, 105, 34, 0, 15, 5, 60, 88,
110, 109, 31, 36, 36, 12, 21, 0, 95, 0,
35, 0, 61, 100, 111, 97, 98, 36, 0, 0,
17, 22, 6, 24, 0, 0, 0, 14, 0, 27,
23, 25, 33, 32, 101, 0, 100, 99, 26, 6,
36, 112, 0, 0, 0
};
static const short exdefgoto[] =
{
212, 32, 65, 154, 1, 33, 41, 151, 181, 191,
192, 193, 95, 96, 138, 204, 175, 34, 35, 117,
177, 36, 37, 38, 158, 43, 103, 104, 184, 185,
186, 194, 48, 49, 91, 172, 178, 195
};
static const short expact[] =
{
-32768, 66,-32768,-32768,-32768,-32768, 429,-32768, 429,-32768,
-67, -43, -41, -38, -12, 3,-32768,-32768, 5,-32768,
429,-32768, 9, 13, 429, 429, 429, 429, -1, -1,
398,-32768, 22,-32768, -6, 540,-32768, 30, -32, 27,
31, 88, 429, -12, 429, 429, 429, -8,-32768,-32768,
429, 429, 40, 429, 429,-32768,-32768,-32768,-32768,-32768,
-32768, 42, 230, 165, 70,-32768,-32768, 429,-32768, 429,
429, 429, 429, 429, 429, 429, 429, 429, 429, 429,
429, 429, 429, 429, 429, 429, 429, 429, 429,-32768,
-32768,-32768,-32768,-32768,-32768, -40,-32768, 154,-32768, 308,
44, -42, 423, 45, 77, 43,-32768, 456, 47,-32768,
540, 486, 429,-32768,-32768,-32768, 423, 429, 557, 573,
588, 602, 615, 628, 628, 639, 639, 639, 639, 49,
49, -2, -2,-32768,-32768,-32768, 48, 423, 51, 88,
-32768,-32768,-32768, 429, 321,-32768, 429, 1,-32768, 321,
-32768, 57, 321,-32768,-32768, 518,-32768, 58, -39,-32768,
50,-32768, 423,-32768, 128, 69,-32768, 66,-32768,-32768,
-32768,-32768,-32768, 429, 321,-32768,-32768, 429, 133, 68,
-32768, -4, 423, 71,-32768, 102,-32768, 321, 99, 100,
-32768,-32768, 15,-32768, -10, 73, 143,-32768, 105,-32768,
66,-32768,-32768,-32768,-32768, 80,-32768,-32768,-32768,-32768,
243,-32768, 163, 164,-32768
};
static const short expgoto[] =
{
-32768,-32768,-32768,-32768, -31, -35,-32768,-32768,-32768,-32768,
-32768, -27,-32768, 28,-32768,-32768,-32768, -5, -20,-32768,
-32768, -22,-32768, 67,-32768,-32768, -49,-32768,-32768,-32768,
-26,-32768, 126, 72, 17,-32768,-32768,-32768
};
#define EXLAST 712
static const short extable[] =
{
63, 39, 108, 40, 55, 56, 57, 58, 202, 188,
62, 88, 139, 189, 88, 52, 105, 10, 203, 42,
106, 88, 97, 14, 99, 163, 102, 16, 188, 106,
107, 102, 189, 110, 111, 89, 90, 44, 136, 45,
100, 170, 46, 144, 140, 89, 90, 116, 64, 118,
119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
129, 130, 131, 132, 133, 134, 135, 102, 137, 84,
85, 86, 2, 3, 4, 5, 47, 6, 66, 190,
7, 8, 9, 50, 10, 51, 11, 12, 13, 53,
14, 15, 153, 54, 16, 59, 60, 155, 17, 18,
19, 20, 21, 22, 23, 2, 3, 4, 5, 161,
87, 92, 101, 7, 164, 93, 94, 166, 82, 83,
84, 85, 86, 167, 109, 115, 162, 112, 143, 146,
145, 147, 150, 156, 173, 24, 25, 157, 160, 180,
26, 27, 165, 28, 29, 169, 30, 174, 31, 183,
-36, 176, 197, 187, 196, 199, -96, 182, 205, 206,
208, 200, 209, 213, 214, 201, 198, 159, 179, 98,
207, 2, 3, 4, 5, 171, 6, 148, 210, 7,
8, 9, 0, 10, 0, 11, 12, 13, 0, 14,
15, 0, 0, 16, 0, 0, 0, 17, 18, 19,
20, 21, 22, 23, 0, 0, 67, 0, 68, 0,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 0, 0,
0, 0, 0, 0, 24, 25, 0, 0, 0, 26,
27, 141, 28, 29, 0, 30, 0, 31, 114, 2,
3, 4, 5, 0, 6, 0, 0, 7, 8, 9,
0, 10, 0, 11, 12, 13, 0, 14, 15, 0,
0, 16, 0, 0, 0, 17, 18, 19, 20, 21,
22, 23, 67, 0, 68, 0, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 0, 0, 0, 0, 0, 0,
0, 0, 24, 25, 0, 113, 0, 26, 27, 0,
28, 29, 0, 30, 0, 31, 211, 2, 3, 4,
5, 0, 6, 0, 0, 7, 8, 9, 0, 10,
0, 11, 12, 13, 0, 14, 15, 0, 0, 16,
0, 0, 0, 17, 18, 19, 20, 21, 22, 23,
67, 0, 68, 0, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 0, 0, 0, 0, 0, 0, 0, 0,
24, 25, 0, 142, 0, 26, 27, 0, 28, 29,
0, 30, 0, 31, 2, 3, 4, 5, 0, 0,
0, 0, 7, 0, 61, 0, 10, 0, 11, 0,
13, 0, 14, 0, 0, 0, 16, 0, 0, 0,
17, 18, 19, 0, 21, 2, 3, 4, 5, 0,
0, 0, 0, 7, 0, 0, 0, 10, 0, 11,
0, 13, 0, 14, 0, 0, 0, 16, 0, 0,
0, 17, 18, 19, 0, 21, 0, 24, 25, 0,
0, 0, 26, 27, 0, 28, 29, 68, 30, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 0, 24, 25,
0, 0, 0, 26, 27, 0, 28, 29, 67, 30,
68, 0, 69, 70, 71, 72, 73, 74, 75, 76,
77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
68, 149, 69, 70, 71, 72, 73, 74, 75, 76,
77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
67, 152, 68, 168, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 67, 0, 68, 0, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
86, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86,-32768,
-32768, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86,-32768,-32768,-32768,-32768, 80, 81, 82, 83,
84, 85, 86
};
static const short excheck[] =
{
31, 6, 51, 8, 24, 25, 26, 27, 18, 13,
30, 53, 52, 17, 53, 20, 24, 18, 28, 86,
28, 53, 42, 24, 44, 24, 46, 28, 13, 28,
50, 51, 17, 53, 54, 77, 78, 80, 87, 80,
45, 80, 80, 85, 84, 77, 78, 67, 26, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 71,
72, 73, 6, 7, 8, 9, 88, 11, 84, 83,
14, 15, 16, 80, 18, 80, 20, 21, 22, 80,
24, 25, 112, 80, 28, 28, 29, 117, 32, 33,
34, 35, 36, 37, 38, 6, 7, 8, 9, 144,
80, 84, 45, 14, 149, 84, 28, 152, 69, 70,
71, 72, 73, 154, 84, 55, 146, 85, 84, 52,
85, 88, 85, 85, 84, 69, 70, 86, 143, 174,
74, 75, 85, 77, 78, 87, 80, 19, 82, 16,
84, 82, 187, 85, 52, 55, 85, 177, 85, 16,
55, 192, 82, 0, 0, 192, 188, 139, 173, 43,
196, 6, 7, 8, 9, 158, 11, 105, 209, 14,
15, 16, -1, 18, -1, 20, 21, 22, -1, 24,
25, -1, -1, 28, -1, -1, -1, 32, 33, 34,
35, 36, 37, 38, -1, -1, 52, -1, 54, -1,
56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
66, 67, 68, 69, 70, 71, 72, 73, -1, -1,
-1, -1, -1, -1, 69, 70, -1, -1, -1, 74,
75, 87, 77, 78, -1, 80, -1, 82, 83, 6,
7, 8, 9, -1, 11, -1, -1, 14, 15, 16,
-1, 18, -1, 20, 21, 22, -1, 24, 25, -1,
-1, 28, -1, -1, -1, 32, 33, 34, 35, 36,
37, 38, 52, -1, 54, -1, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, -1, -1, -1, -1, -1, -1,
-1, -1, 69, 70, -1, 85, -1, 74, 75, -1,
77, 78, -1, 80, -1, 82, 83, 6, 7, 8,
9, -1, 11, -1, -1, 14, 15, 16, -1, 18,
-1, 20, 21, 22, -1, 24, 25, -1, -1, 28,
-1, -1, -1, 32, 33, 34, 35, 36, 37, 38,
52, -1, 54, -1, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, -1, -1, -1, -1, -1, -1, -1, -1,
69, 70, -1, 85, -1, 74, 75, -1, 77, 78,
-1, 80, -1, 82, 6, 7, 8, 9, -1, -1,
-1, -1, 14, -1, 16, -1, 18, -1, 20, -1,
22, -1, 24, -1, -1, -1, 28, -1, -1, -1,
32, 33, 34, -1, 36, 6, 7, 8, 9, -1,
-1, -1, -1, 14, -1, -1, -1, 18, -1, 20,
-1, 22, -1, 24, -1, -1, -1, 28, -1, -1,
-1, 32, 33, 34, -1, 36, -1, 69, 70, -1,
-1, -1, 74, 75, -1, 77, 78, 54, 80, 56,
57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
67, 68, 69, 70, 71, 72, 73, -1, 69, 70,
-1, -1, -1, 74, 75, -1, 77, 78, 52, 80,
54, -1, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
-1, -1, -1, -1, -1, -1, -1, -1, 52, -1,
54, 85, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
52, 85, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 52, -1, 54, -1, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 58, 59, 60, 61, 62, 63, 64, 65, 66,
67, 68, 69, 70, 71, 72, 73, 59, 60, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/usr/share/bison/bison.simple"
/* Skeleton output parser for bison,
Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* This is the parser code that is written into each bison parser when
the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
#ifndef EXSTACK_USE_ALLOCA
# ifdef alloca
# define EXSTACK_USE_ALLOCA 1
# else /* alloca not defined */
# ifdef __GNUC__
# define EXSTACK_USE_ALLOCA 1
# define alloca __builtin_alloca
# else /* not GNU C. */
# if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
# define EXSTACK_USE_ALLOCA 1
# include <alloca.h>
# else /* not sparc */
/* We think this test detects Watcom and Microsoft C. */
/* This used to test MSDOS, but that is a bad idea since that
symbol is in the user namespace. */
# if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
# if 0
/* No need for malloc.h, which pollutes the namespace; instead,
just don't use alloca. */
# include <malloc.h>
# endif
# else /* not MSDOS, or __TURBOC__ */
# if defined(_AIX)
/* I don't know what this was needed for, but it pollutes the
namespace. So I turned it off. rms, 2 May 1997. */
/* #include <malloc.h> */
#pragma alloca
# define EXSTACK_USE_ALLOCA 1
# else /* not MSDOS, or __TURBOC__, or _AIX */
# if 0
/* haible@ilog.fr says this works for HPUX 9.05 and up, and on
HPUX 10. Eventually we can turn this on. */
# ifdef __hpux
# define EXSTACK_USE_ALLOCA 1
# define alloca __builtin_alloca
# endif /* __hpux */
# endif
# endif /* not _AIX */
# endif /* not MSDOS, or __TURBOC__ */
# endif /* not sparc */
# endif /* not GNU C */
# endif /* alloca not defined */
#endif /* EXSTACK_USE_ALLOCA not defined */
#ifndef EXSTACK_USE_ALLOCA
# define EXSTACK_USE_ALLOCA 0
#endif
#if EXSTACK_USE_ALLOCA
# define EXSTACK_ALLOC alloca
#else
# define EXSTACK_ALLOC malloc
#endif
#define exerrok (exerrstatus = 0)
#define exclearin (exchar = EXEMPTY)
#define EXEMPTY -2
#define EXEOF 0
#define EXACCEPT goto exacceptlab
#define EXABORT goto exabortlab
#define EXERROR goto exerrlab1
/* Like EXERROR except do call exerror. This remains here temporarily
to ease the transition to the new meaning of EXERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define EXFAIL goto exerrlab
#define EXRECOVERING() (!!exerrstatus)
#define EXBACKUP(Token, Value) \
do \
if (exchar == EXEMPTY && exlen == 1) \
{ \
exchar = (Token); \
exlval = (Value); \
exchar1 = EXTRANSLATE (exchar); \
EXPOPSTACK; \
goto exbackup; \
} \
else \
{ \
exerror ("syntax error: cannot back up"); \
EXERROR; \
} \
while (0)
#define EXTERROR 1
#define EXERRCODE 256
/* EXLLOC_DEFAULT -- Compute the default location (before the actions
are run).
When EXLLOC_DEFAULT is run, CURRENT is set the location of the
first token. By default, to implement support for ranges, extend
its range to the last symbol. */
#ifndef EXLLOC_DEFAULT
# define EXLLOC_DEFAULT(Current, Rhs, N) \
Current.last_line = Rhs[N].last_line; \
Current.last_column = Rhs[N].last_column;
#endif
/* EXLEX -- calling `exlex' with the right arguments. */
#if EXPURE
# if EXLSP_NEEDED
# ifdef EXLEX_PARAM
# define EXLEX exlex (&exlval, &exlloc, EXLEX_PARAM)
# else
# define EXLEX exlex (&exlval, &exlloc)
# endif
# else /* !EXLSP_NEEDED */
# ifdef EXLEX_PARAM
# define EXLEX exlex (&exlval, EXLEX_PARAM)
# else
# define EXLEX exlex (&exlval)
# endif
# endif /* !EXLSP_NEEDED */
#else /* !EXPURE */
# define EXLEX exlex ()
#endif /* !EXPURE */
/* Enable debugging if requested. */
#if EXDEBUG
# define EXDPRINTF(Args) \
do { \
if (exdebug) \
fprintf Args; \
} while (0)
/* Nonzero means print parse trace. [The following comment makes no
sense to me. Could someone clarify it? --akim] Since this is
uninitialized, it does not stop multiple parsers from coexisting.
*/
int exdebug;
#else /* !EXDEBUG */
# define EXDPRINTF(Args)
#endif /* !EXDEBUG */
/* EXINITDEPTH -- initial size of the parser's stacks. */
#ifndef EXINITDEPTH
# define EXINITDEPTH 200
#endif
/* EXMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used). */
#if EXMAXDEPTH == 0
# undef EXMAXDEPTH
#endif
#ifndef EXMAXDEPTH
# define EXMAXDEPTH 10000
#endif
/* Define __ex_memcpy. Note that the size argument
should be passed with type unsigned int, because that is what the non-GCC
definitions require. With GCC, __builtin_memcpy takes an arg
of type size_t, but it can handle unsigned int. */
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
# define __ex_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
#else /* not GNU C or C++ */
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
# ifndef __cplusplus
__ex_memcpy (to, from, count)
char *to;
const char *from;
unsigned int count;
# else /* __cplusplus */
__ex_memcpy (char *to, const char *from, unsigned int count)
# endif
{
register const char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#endif
#line 216 "/usr/share/bison/bison.simple"
/* The user can define EXPARSE_PARAM as the name of an argument to be passed
into exparse. The argument should have type void *.
It should actually point to an object.
Grammar actions can access the variable by casting it
to the proper pointer type. */
#ifdef EXPARSE_PARAM
# ifdef __cplusplus
# define EXPARSE_PARAM_ARG void *EXPARSE_PARAM
# define EXPARSE_PARAM_DECL
# else /* !__cplusplus */
# define EXPARSE_PARAM_ARG EXPARSE_PARAM
# define EXPARSE_PARAM_DECL void *EXPARSE_PARAM;
# endif /* !__cplusplus */
#else /* !EXPARSE_PARAM */
# define EXPARSE_PARAM_ARG
# define EXPARSE_PARAM_DECL
#endif /* !EXPARSE_PARAM */
/* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__
# ifdef EXPARSE_PARAM
int exparse (void *);
# else
int exparse (void);
# endif
#endif
/* EX_DECL_VARIABLES -- depending whether we use a pure parser,
variables are global, or local to EXPARSE. */
#define _EX_DECL_VARIABLES \
/* The lookahead symbol. */ \
int exchar; \
\
/* The semantic value of the lookahead symbol. */ \
EXSTYPE exlval; \
\
/* Number of parse errors so far. */ \
int exnerrs;
#if EXLSP_NEEDED
# define EX_DECL_VARIABLES \
_EX_DECL_VARIABLES \
\
/* Location data for the lookahead symbol. */ \
EXLTYPE exlloc;
#else
# define EX_DECL_VARIABLES \
_EX_DECL_VARIABLES
#endif
/* If nonreentrant, generate the variables here. */
#if !EXPURE
EX_DECL_VARIABLES
#endif /* !EXPURE */
int
exparse (EXPARSE_PARAM_ARG)
EXPARSE_PARAM_DECL
{
/* If reentrant, generate the variables here. */
#if EXPURE
EX_DECL_VARIABLES
#endif /* !EXPURE */
register int exstate;
register int exn;
/* Number of tokens to shift before error messages enabled. */
int exerrstatus;
/* Lookahead token as an internal (translated) token number. */
int exchar1 = 0;
/* Three stacks and their tools:
`exss': related to states,
`exsv': related to semantic values,
`exls': related to locations.
Refer to the stacks thru separate pointers, to allow exoverflow
to reallocate them elsewhere. */
/* The state stack. */
short exssa[EXINITDEPTH];
short *exss = exssa;
register short *exssp;
/* The semantic value stack. */
EXSTYPE exvsa[EXINITDEPTH];
EXSTYPE *exvs = exvsa;
register EXSTYPE *exvsp;
#if EXLSP_NEEDED
/* The location stack. */
EXLTYPE exlsa[EXINITDEPTH];
EXLTYPE *exls = exlsa;
EXLTYPE *exlsp;
#endif
#if EXLSP_NEEDED
# define EXPOPSTACK (exvsp--, exssp--, exlsp--)
#else
# define EXPOPSTACK (exvsp--, exssp--)
#endif
int exstacksize = EXINITDEPTH;
int exfree_stacks = 0;
/* The variables used to return semantic value and location from the
action routines. */
EXSTYPE exval;
# if EXLSP_NEEDED
EXLTYPE exloc;
# endif
/* When reducing, the number of symbols on the RHS of the reduced
rule. */
int exlen;
EXDPRINTF ((stderr, "Starting parse\n"));
exstate = 0;
exerrstatus = 0;
exnerrs = 0;
exchar = EXEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
exssp = exss;
exvsp = exvs;
#if EXLSP_NEEDED
exlsp = exls;
#endif
goto exsetstate;
/*------------------------------------------------------------.
| exnewstate -- Push a new state, which is found in exstate. |
`------------------------------------------------------------*/
exnewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks.
*/
exssp++;
exsetstate:
*exssp = exstate;
if (exssp >= exss + exstacksize - 1)
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into memory.
*/
EXSTYPE *exvs1 = exvs;
short *exss1 = exss;
#if EXLSP_NEEDED
EXLTYPE *exls1 = exls;
#endif
/* Get the current used size of the three stacks, in elements. */
int size = exssp - exss + 1;
#ifdef exoverflow
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. */
# if EXLSP_NEEDED
/* This used to be a conditional around just the two extra args,
but that might be undefined if exoverflow is a macro. */
exoverflow ("parser stack overflow",
&exss1, size * sizeof (*exssp),
&exvs1, size * sizeof (*exvsp),
&exls1, size * sizeof (*exlsp),
&exstacksize);
# else
exoverflow ("parser stack overflow",
&exss1, size * sizeof (*exssp),
&exvs1, size * sizeof (*exvsp),
&exstacksize);
# endif
exss = exss1; exvs = exvs1;
# if EXLSP_NEEDED
exls = exls1;
# endif
#else /* no exoverflow */
/* Extend the stack our own way. */
if (exstacksize >= EXMAXDEPTH)
{
exerror ("parser stack overflow");
if (exfree_stacks)
{
free (exss);
free (exvs);
# if EXLSP_NEEDED
free (exls);
# endif
}
return 2;
}
exstacksize *= 2;
if (exstacksize > EXMAXDEPTH)
exstacksize = EXMAXDEPTH;
# if !EXSTACK_USE_ALLOCA
exfree_stacks = 1;
# endif
exss = (short *) EXSTACK_ALLOC (exstacksize * sizeof (*exssp));
__ex_memcpy ((char *)exss, (char *)exss1,
size * (unsigned int) sizeof (*exssp));
exvs = (EXSTYPE *) EXSTACK_ALLOC (exstacksize * sizeof (*exvsp));
__ex_memcpy ((char *)exvs, (char *)exvs1,
size * (unsigned int) sizeof (*exvsp));
# if EXLSP_NEEDED
exls = (EXLTYPE *) EXSTACK_ALLOC (exstacksize * sizeof (*exlsp));
__ex_memcpy ((char *)exls, (char *)exls1,
size * (unsigned int) sizeof (*exlsp));
# endif
#endif /* no exoverflow */
exssp = exss + size - 1;
exvsp = exvs + size - 1;
#if EXLSP_NEEDED
exlsp = exls + size - 1;
#endif
EXDPRINTF ((stderr, "Stack size increased to %d\n", exstacksize));
if (exssp >= exss + exstacksize - 1)
EXABORT;
}
EXDPRINTF ((stderr, "Entering state %d\n", exstate));
goto exbackup;
/*-----------.
| exbackup. |
`-----------*/
exbackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* exresume: */
/* First try to decide what to do without reference to lookahead token. */
exn = expact[exstate];
if (exn == EXFLAG)
goto exdefault;
/* Not known => get a lookahead token if don't already have one. */
/* exchar is either EXEMPTY or EXEOF
or a valid token in external form. */
if (exchar == EXEMPTY)
{
EXDPRINTF ((stderr, "Reading a token: "));
exchar = EXLEX;
}
/* Convert token to internal form (in exchar1) for indexing tables with */
if (exchar <= 0) /* This means end of input. */
{
exchar1 = 0;
exchar = EXEOF; /* Don't call EXLEX any more */
EXDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
exchar1 = EXTRANSLATE (exchar);
#if EXDEBUG
/* We have to keep this `#if EXDEBUG', since we use variables
which are defined only if `EXDEBUG' is set. */
if (exdebug)
{
fprintf (stderr, "Next token is %d (%s", exchar, extname[exchar1]);
/* Give the individual parser a way to print the precise
meaning of a token, for further debugging info. */
# ifdef EXPRINT
EXPRINT (stderr, exchar, exlval);
# endif
fprintf (stderr, ")\n");
}
#endif
}
exn += exchar1;
if (exn < 0 || exn > EXLAST || excheck[exn] != exchar1)
goto exdefault;
exn = extable[exn];
/* exn is what to do for this token type in this state.
Negative => reduce, -exn is rule number.
Positive => shift, exn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (exn < 0)
{
if (exn == EXFLAG)
goto exerrlab;
exn = -exn;
goto exreduce;
}
else if (exn == 0)
goto exerrlab;
if (exn == EXFINAL)
EXACCEPT;
/* Shift the lookahead token. */
EXDPRINTF ((stderr, "Shifting token %d (%s), ", exchar, extname[exchar1]));
/* Discard the token being shifted unless it is eof. */
if (exchar != EXEOF)
exchar = EXEMPTY;
*++exvsp = exlval;
#if EXLSP_NEEDED
*++exlsp = exlloc;
#endif
/* Count tokens shifted since error; after three, turn off error
status. */
if (exerrstatus)
exerrstatus--;
exstate = exn;
goto exnewstate;
/*-----------------------------------------------------------.
| exdefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
exdefault:
exn = exdefact[exstate];
if (exn == 0)
goto exerrlab;
goto exreduce;
/*-----------------------------.
| exreduce -- Do a reduction. |
`-----------------------------*/
exreduce:
/* exn is the number of a rule to reduce with. */
exlen = exr2[exn];
/* If EXLEN is nonzero, implement the default value of the action:
`$$ = $1'.
Otherwise, the following line sets EXVAL to the semantic value of
the lookahead token. This behavior is undocumented and Bison
users should not rely upon it. Assigning to EXVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that EXVAL may be used uninitialized. */
exval = exvsp[1-exlen];
#if EXLSP_NEEDED
/* Similarly for the default location. Let the user run additional
commands if for instance locations are ranges. */
exloc = exlsp[1-exlen];
EXLLOC_DEFAULT (exloc, (exlsp - exlen), exlen);
#endif
#if EXDEBUG
/* We have to keep this `#if EXDEBUG', since we use variables which
are defined only if `EXDEBUG' is set. */
if (exdebug)
{
int i;
fprintf (stderr, "Reducing via rule %d (line %d), ",
exn, exrline[exn]);
/* Print the symbols being reduced, and their result. */
for (i = exprhs[exn]; exrhs[i] > 0; i++)
fprintf (stderr, "%s ", extname[exrhs[i]]);
fprintf (stderr, " -> %s\n", extname[exr1[exn]]);
}
#endif
switch (exn) {
case 1:
#line 137 "exparse.y"
{
if (exvsp[-1].expr && !(expr.program->disc->flags & EX_STRICT))
{
if (expr.program->main.value && !(expr.program->disc->flags & EX_RETAIN))
exfreenode(expr.program, expr.program->main.value);
if (exvsp[-1].expr->op == S2B)
{
Exnode_t* x;
x = exvsp[-1].expr;
exvsp[-1].expr = x->data.operand.left;
x->data.operand.left = 0;
exfreenode(expr.program, x);
}
expr.program->main.lex = PROCEDURE;
expr.program->main.value = exnewnode(expr.program, PROCEDURE, 1, exvsp[-1].expr->type, NiL, exvsp[-1].expr);
}
;
break;}
case 4:
#line 161 "exparse.y"
{
register Dtdisc_t* disc;
if (expr.procedure)
exerror("no nested function definitions");
exvsp[-1].id->lex = PROCEDURE;
expr.procedure = exvsp[-1].id->value = exnewnode(expr.program, PROCEDURE, 1, exvsp[-1].id->type, NiL, NiL);
expr.procedure->type = INTEGER;
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
exerror("out of space [frame discipline]");
disc->key = offsetof(Exid_t, name);
if (!(expr.procedure->data.procedure.frame = dtopen(disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
exerror("out of space [frame table]");
expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
;
break;}
case 5:
#line 176 "exparse.y"
{
expr.procedure = 0;
if (expr.program->frame)
{
expr.program->symbols = expr.program->frame->view;
dtview(expr.program->frame, NiL);
}
if (exvsp[0].expr && exvsp[0].expr->op == S2B)
{
Exnode_t* x;
x = exvsp[0].expr;
exvsp[0].expr = x->data.operand.left;
x->data.operand.left = 0;
exfreenode(expr.program, x);
}
exvsp[-3].id->value->data.operand.right = excast(expr.program, exvsp[0].expr, exvsp[-3].id->type, NiL, 0);
;
break;}
case 6:
#line 197 "exparse.y"
{
exval.expr = 0;
;
break;}
case 7:
#line 201 "exparse.y"
{
if (!exvsp[-1].expr)
exval.expr = exvsp[0].expr;
else if (!exvsp[0].expr)
exval.expr = exvsp[-1].expr;
else if (exvsp[-1].expr->op == CONSTANT)
{
exfreenode(expr.program, exvsp[-1].expr);
exval.expr = exvsp[0].expr;
}
else exval.expr = exnewnode(expr.program, ';', 1, exvsp[0].expr->type, exvsp[-1].expr, exvsp[0].expr);
;
break;}
case 8:
#line 216 "exparse.y"
{
exval.expr = exvsp[-1].expr;
;
break;}
case 9:
#line 220 "exparse.y"
{
exval.expr = (exvsp[-1].expr && exvsp[-1].expr->type == STRING) ? exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-1].expr, NiL) : exvsp[-1].expr;
;
break;}
case 10:
#line 223 "exparse.y"
{expr.declare=exvsp[0].id->type;;
break;}
case 11:
#line 224 "exparse.y"
{
exval.expr = exvsp[-1].expr;
;
break;}
case 12:
#line 228 "exparse.y"
{
if (exvsp[-3].expr->type == STRING)
exvsp[-3].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-3].expr, NiL);
else if (!INTEGRAL(exvsp[-3].expr->type))
exvsp[-3].expr = excast(expr.program, exvsp[-3].expr, INTEGER, NiL, 0);
exval.expr = exnewnode(expr.program, exvsp[-5].id->index, 1, INTEGER, exvsp[-3].expr, exnewnode(expr.program, ':', 1, exvsp[-1].expr ? exvsp[-1].expr->type : 0, exvsp[-1].expr, exvsp[0].expr));
;
break;}
case 13:
#line 236 "exparse.y"
{
exval.expr = exnewnode(expr.program, ITERATE, 0, INTEGER, NiL, NiL);
exval.expr->data.generate.array = exvsp[-2].expr;
if (!exvsp[-2].expr->data.variable.index || exvsp[-2].expr->data.variable.index->op != DYNAMIC)
exerror("simple index variable expected");
exval.expr->data.generate.index = exvsp[-2].expr->data.variable.index->data.variable.symbol;
if (exvsp[-2].expr->op == ID && exval.expr->data.generate.index->type != INTEGER)
exerror("integer index variable expected");
exfreenode(expr.program, exvsp[-2].expr->data.variable.index);
exvsp[-2].expr->data.variable.index = 0;
exval.expr->data.generate.statement = exvsp[0].expr;
;
break;}
case 14:
#line 249 "exparse.y"
{
if (!exvsp[-4].expr)
{
exvsp[-4].expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exvsp[-4].expr->data.constant.value.integer = 1;
}
else if (exvsp[-4].expr->type == STRING)
exvsp[-4].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-4].expr, NiL);
else if (!INTEGRAL(exvsp[-4].expr->type))
exvsp[-4].expr = excast(expr.program, exvsp[-4].expr, INTEGER, NiL, 0);
exval.expr = exnewnode(expr.program, exvsp[-8].id->index, 1, INTEGER, exvsp[-4].expr, exnewnode(expr.program, ';', 1, 0, exvsp[-2].expr, exvsp[0].expr));
if (exvsp[-6].expr)
exval.expr = exnewnode(expr.program, ';', 1, INTEGER, exvsp[-6].expr, exval.expr);
;
break;}
case 15:
#line 264 "exparse.y"
{
if (exvsp[-2].expr->type == STRING)
exvsp[-2].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-2].expr, NiL);
else if (!INTEGRAL(exvsp[-2].expr->type))
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, INTEGER, NiL, 0);
exval.expr = exnewnode(expr.program, exvsp[-4].id->index, 1, INTEGER, exvsp[-2].expr, exnewnode(expr.program, ';', 1, 0, NiL, exvsp[0].expr));
;
break;}
case 16:
#line 271 "exparse.y"
{expr.declare=exvsp[0].expr->type;;
break;}
case 17:
#line 272 "exparse.y"
{
register Switch_t* sw = expr.swstate;
exval.expr = exnewnode(expr.program, exvsp[-7].id->index, 1, INTEGER, exvsp[-5].expr, exnewnode(expr.program, DEFAULT, 1, 0, sw->defcase, sw->firstcase));
expr.swstate = expr.swstate->prev;
if (sw->base)
free(sw->base);
if (sw != &swstate)
free(sw);
;
break;}
case 18:
#line 283 "exparse.y"
{
loopop:
if (!exvsp[-1].expr)
{
exvsp[-1].expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exvsp[-1].expr->data.constant.value.integer = 1;
}
else if (!INTEGRAL(exvsp[-1].expr->type))
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, INTEGER, NiL, 0);
exval.expr = exnewnode(expr.program, exvsp[-2].id->index, 1, INTEGER, exvsp[-1].expr, NiL);
;
break;}
case 19:
#line 295 "exparse.y"
{
goto loopop;
;
break;}
case 20:
#line 299 "exparse.y"
{
if (exvsp[-1].expr)
{
if (expr.procedure && !expr.procedure->type)
exerror("return in void function");
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, expr.procedure ? expr.procedure->type : INTEGER, NiL, 0);
}
exval.expr = exnewnode(expr.program, RETURN, 1, exvsp[-1].expr ? exvsp[-1].expr->type : 0, exvsp[-1].expr, NiL);
;
break;}
case 21:
#line 311 "exparse.y"
{
register Switch_t* sw;
int n;
if (expr.swstate)
{
if (!(sw = newof(0, Switch_t, 1, 0)))
{
exerror("out of space [switch]");
sw = &swstate;
}
sw->prev = expr.swstate;
}
else sw = &swstate;
expr.swstate = sw;
sw->type = expr.declare;
sw->firstcase = 0;
sw->lastcase = 0;
sw->defcase = 0;
sw->def = 0;
n = 8;
if (!(sw->base = newof(0, Extype_t*, n, 0)))
{
exerror("out of space [case]");
n = 0;
}
sw->cur = sw->base;
sw->last = sw->base + n;
;
break;}
case 23:
#line 344 "exparse.y"
{
register Switch_t* sw = expr.swstate;
int n;
exval.expr = exnewnode(expr.program, CASE, 1, 0, exvsp[0].expr, NiL);
if (sw->cur > sw->base)
{
if (sw->lastcase)
sw->lastcase->data.select.next = exval.expr;
else sw->firstcase = exval.expr;
sw->lastcase = exval.expr;
n = sw->cur - sw->base;
sw->cur = sw->base;
exval.expr->data.select.constant = (Extype_t**)exalloc(expr.program, (n + 1) * sizeof(Extype_t*));
memcpy(exval.expr->data.select.constant, sw->base, n * sizeof(Extype_t*));
exval.expr->data.select.constant[n] = 0;
}
else exval.expr->data.select.constant = 0;
if (sw->def)
{
sw->def = 0;
if (sw->defcase)
exerror("duplicate default in switch");
else sw->defcase = exvsp[0].expr;
}
;
break;}
case 26:
#line 377 "exparse.y"
{
int n;
if (expr.swstate->cur >= expr.swstate->last)
{
n = expr.swstate->cur - expr.swstate->base;
if (!(expr.swstate->base = newof(expr.swstate->base, Extype_t*, 2 * n, 0)))
{
exerror("too many case labels for switch");
n = 0;
}
expr.swstate->cur = expr.swstate->base + n;
expr.swstate->last = expr.swstate->base + 2 * n;
}
if (expr.swstate->cur)
{
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, expr.swstate->type, NiL, 0);
*expr.swstate->cur++ = &(exvsp[-1].expr->data.constant.value);
}
;
break;}
case 27:
#line 398 "exparse.y"
{
expr.swstate->def = 1;
;
break;}
case 29:
#line 405 "exparse.y"
{
if (exvsp[0].expr)
exval.expr = exvsp[-2].expr ? exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[-2].expr, exvsp[0].expr) : exvsp[0].expr;
;
break;}
case 30:
#line 411 "exparse.y"
{expr.id=exvsp[0].id;;
break;}
case 31:
#line 412 "exparse.y"
{
exval.expr = 0;
exvsp[-3].id->type = expr.declare;
if (exvsp[0].expr && exvsp[0].expr->op == PROCEDURE)
{
exvsp[-3].id->lex = PROCEDURE;
exvsp[-3].id->value = exvsp[0].expr;
}
else
{
exvsp[-3].id->lex = DYNAMIC;
exvsp[-3].id->value = exnewnode(expr.program, 0, 0, 0, NiL, NiL);
if (exvsp[-1].integer && !exvsp[-3].id->local.pointer)
{
Dtdisc_t* disc;
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
exerror("out of space [associative array]");
disc->key = offsetof(Exassoc_t, name);
if (!(exvsp[-3].id->local.pointer = (char*)dtopen(disc, Dtoset)))
exerror("%s: cannot initialize associative array", exvsp[-3].id->name);
}
if (exvsp[0].expr)
{
if (exvsp[0].expr->type != exvsp[-3].id->type)
{
exvsp[0].expr->type = exvsp[-3].id->type;
exvsp[0].expr->data.operand.right = excast(expr.program, exvsp[0].expr->data.operand.right, exvsp[-3].id->type, NiL, 0);
}
exvsp[0].expr->data.operand.left = exnewnode(expr.program, DYNAMIC, 0, exvsp[-3].id->type, NiL, NiL);
exvsp[0].expr->data.operand.left->data.variable.symbol = exvsp[-3].id;
exval.expr = exvsp[0].expr;
}
else if (!exvsp[-1].integer)
exvsp[-3].id->value->data.value = exzero(exvsp[-3].id->type);
}
;
break;}
case 34:
#line 456 "exparse.y"
{
exval.expr = 0;
;
break;}
case 35:
#line 460 "exparse.y"
{
exval.expr = exvsp[0].expr;
;
break;}
case 36:
#line 466 "exparse.y"
{
exval.expr = 0;
;
break;}
case 38:
#line 473 "exparse.y"
{
exval.expr = exvsp[-1].expr;
;
break;}
case 39:
#line 477 "exparse.y"
{
exval.expr = (exvsp[0].expr->type == exvsp[-2].id->type) ? exvsp[0].expr : excast(expr.program, exvsp[0].expr, exvsp[-2].id->type, NiL, 0);
;
break;}
case 40:
#line 481 "exparse.y"
{
int rel;
relational:
rel = INTEGER;
goto coerce;
binary:
rel = 0;
coerce:
if (!exvsp[-2].expr->type)
{
if (!exvsp[0].expr->type)
exvsp[-2].expr->type = exvsp[0].expr->type = rel ? STRING : INTEGER;
else exvsp[-2].expr->type = exvsp[0].expr->type;
}
else if (!exvsp[0].expr->type) exvsp[0].expr->type = exvsp[-2].expr->type;
if (exvsp[-2].expr->type != exvsp[0].expr->type)
{
if (exvsp[-2].expr->type == STRING)
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, exvsp[0].expr->type, exvsp[0].expr, 0);
else if (exvsp[0].expr->type == STRING)
exvsp[0].expr = excast(expr.program, exvsp[0].expr, exvsp[-2].expr->type, exvsp[-2].expr, 0);
else if (exvsp[-2].expr->type == FLOATING)
exvsp[0].expr = excast(expr.program, exvsp[0].expr, FLOATING, exvsp[-2].expr, 0);
else if (exvsp[0].expr->type == FLOATING)
exvsp[-2].expr = excast(expr.program, exvsp[-2].expr, FLOATING, exvsp[0].expr, 0);
}
if (!rel)
rel = (exvsp[-2].expr->type == STRING) ? STRING : ((exvsp[-2].expr->type == UNSIGNED) ? UNSIGNED : exvsp[0].expr->type);
exval.expr = exnewnode(expr.program, exvsp[-1].op, 1, rel, exvsp[-2].expr, exvsp[0].expr);
if (!expr.program->errors && exvsp[-2].expr->op == CONSTANT && exvsp[0].expr->op == CONSTANT)
{
expr.program->vc = expr.program->vm;
exval.expr->data.constant.value = exeval(expr.program, exval.expr, NiL);
expr.program->vc = expr.program->ve;
exval.expr->binary = 0;
exval.expr->op = CONSTANT;
exfreenode(expr.program, exvsp[-2].expr);
exfreenode(expr.program, exvsp[0].expr);
}
;
break;}
case 41:
#line 523 "exparse.y"
{
goto binary;
;
break;}
case 42:
#line 527 "exparse.y"
{
goto binary;
;
break;}
case 43:
#line 531 "exparse.y"
{
goto binary;
;
break;}
case 44:
#line 535 "exparse.y"
{
goto binary;
;
break;}
case 45:
#line 539 "exparse.y"
{
goto binary;
;
break;}
case 46:
#line 543 "exparse.y"
{
goto binary;
;
break;}
case 47:
#line 547 "exparse.y"
{
goto relational;
;
break;}
case 48:
#line 551 "exparse.y"
{
goto relational;
;
break;}
case 49:
#line 555 "exparse.y"
{
goto relational;
;
break;}
case 50:
#line 559 "exparse.y"
{
goto relational;
;
break;}
case 51:
#line 563 "exparse.y"
{
goto relational;
;
break;}
case 52:
#line 567 "exparse.y"
{
goto binary;
;
break;}
case 53:
#line 571 "exparse.y"
{
goto binary;
;
break;}
case 54:
#line 575 "exparse.y"
{
goto binary;
;
break;}
case 55:
#line 579 "exparse.y"
{
goto binary;
;
break;}
case 56:
#line 583 "exparse.y"
{
logical:
if (exvsp[-2].expr->type == STRING)
exvsp[-2].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-2].expr, NiL);
if (exvsp[0].expr->type == STRING)
exvsp[0].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[0].expr, NiL);
goto binary;
;
break;}
case 57:
#line 592 "exparse.y"
{
goto logical;
;
break;}
case 58:
#line 596 "exparse.y"
{
if (exvsp[-2].expr->op == CONSTANT)
{
exfreenode(expr.program, exvsp[-2].expr);
exval.expr = exvsp[0].expr;
}
else exval.expr = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[-2].expr, exvsp[0].expr);
;
break;}
case 59:
#line 604 "exparse.y"
{expr.nolabel=1;;
break;}
case 60:
#line 604 "exparse.y"
{expr.nolabel=0;;
break;}
case 61:
#line 605 "exparse.y"
{
if (!exvsp[-3].expr->type)
{
if (!exvsp[0].expr->type)
exvsp[-3].expr->type = exvsp[0].expr->type = INTEGER;
else exvsp[-3].expr->type = exvsp[0].expr->type;
}
else if (!exvsp[0].expr->type)
exvsp[0].expr->type = exvsp[-3].expr->type;
if (exvsp[-6].expr->type == STRING)
exvsp[-6].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[-6].expr, NiL);
else if (!INTEGRAL(exvsp[-6].expr->type))
exvsp[-6].expr = excast(expr.program, exvsp[-6].expr, INTEGER, NiL, 0);
if (exvsp[-3].expr->type != exvsp[0].expr->type)
{
if (exvsp[-3].expr->type == STRING || exvsp[0].expr->type == STRING)
exerror("if statement string type mismatch");
else if (exvsp[-3].expr->type == FLOATING)
exvsp[0].expr = excast(expr.program, exvsp[0].expr, FLOATING, NiL, 0);
else if (exvsp[0].expr->type == FLOATING)
exvsp[-3].expr = excast(expr.program, exvsp[-3].expr, FLOATING, NiL, 0);
}
if (exvsp[-6].expr->op == CONSTANT)
{
if (exvsp[-6].expr->data.constant.value.integer)
{
exval.expr = exvsp[-3].expr;
exfreenode(expr.program, exvsp[0].expr);
}
else
{
exval.expr = exvsp[0].expr;
exfreenode(expr.program, exvsp[-3].expr);
}
exfreenode(expr.program, exvsp[-6].expr);
}
else exval.expr = exnewnode(expr.program, '?', 1, exvsp[-3].expr->type, exvsp[-6].expr, exnewnode(expr.program, ':', 1, exvsp[-3].expr->type, exvsp[-3].expr, exvsp[0].expr));
;
break;}
case 62:
#line 644 "exparse.y"
{
iunary:
if (exvsp[0].expr->type == STRING)
exvsp[0].expr = exnewnode(expr.program, S2B, 1, INTEGER, exvsp[0].expr, NiL);
else if (!INTEGRAL(exvsp[0].expr->type))
exvsp[0].expr = excast(expr.program, exvsp[0].expr, INTEGER, NiL, 0);
unary:
exval.expr = exnewnode(expr.program, exvsp[-1].op, 1, exvsp[0].expr->type == UNSIGNED ? INTEGER : exvsp[0].expr->type, exvsp[0].expr, NiL);
if (exvsp[0].expr->op == CONSTANT)
{
exval.expr->data.constant.value = exeval(expr.program, exval.expr, NiL);
exval.expr->binary = 0;
exval.expr->op = CONSTANT;
exfreenode(expr.program, exvsp[0].expr);
}
;
break;}
case 63:
#line 661 "exparse.y"
{
goto iunary;
;
break;}
case 64:
#line 665 "exparse.y"
{
goto unary;
;
break;}
case 65:
#line 669 "exparse.y"
{
exval.expr = exvsp[0].expr;
;
break;}
case 66:
#line 673 "exparse.y"
{
exval.expr = exnewnode(expr.program, FUNCTION, 1, T(exvsp[-3].id->type), call(0, exvsp[-3].id, exvsp[-1].expr), exvsp[-1].expr);
;
break;}
case 67:
#line 677 "exparse.y"
{
if (!INTEGRAL(exvsp[-1].expr->type))
exvsp[-1].expr = excast(expr.program, exvsp[-1].expr, INTEGER, NiL, 0);
exval.expr = exnewnode(expr.program, EXIT, 1, INTEGER, exvsp[-1].expr, NiL);
;
break;}
case 68:
#line 683 "exparse.y"
{
exval.expr = exnewnode(expr.program, CALL, 1, exvsp[-3].id->type, NiL, exvsp[-1].expr);
exval.expr->data.call.procedure = exvsp[-3].id;
;
break;}
case 69:
#line 688 "exparse.y"
{
exval.expr = exnewnode(expr.program, exvsp[-3].id->index, 0, exvsp[-3].id->type, NiL, NiL);
if (exvsp[-1].expr && exvsp[-1].expr->data.operand.left->type == INTEGER)
{
exval.expr->data.print.descriptor = exvsp[-1].expr->data.operand.left;
exvsp[-1].expr = exvsp[-1].expr->data.operand.right;
}
else switch (exvsp[-3].id->index)
{
case QUERY:
exval.expr->data.print.descriptor = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exval.expr->data.print.descriptor->data.constant.value.integer = 2;
break;
case PRINTF:
exval.expr->data.print.descriptor = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exval.expr->data.print.descriptor->data.constant.value.integer = 1;
break;
case SPRINTF:
exval.expr->data.print.descriptor = 0;
break;
}
exval.expr->data.print.args = preprint(exvsp[-1].expr);
;
break;}
case 70:
#line 712 "exparse.y"
{
if (exvsp[0].expr)
{
if (exvsp[-1].expr->op == ID && !expr.program->disc->setf)
exerror("%s: variable assignment not supported", exvsp[-1].expr->data.variable.symbol->name);
else
{
if (!exvsp[-1].expr->type)
exvsp[-1].expr->type = exvsp[0].expr->type;
#if 0
else if (exvsp[0].expr->type != exvsp[-1].expr->type && exvsp[-1].expr->type >= 0200)
#else
else if (exvsp[0].expr->type != exvsp[-1].expr->type)
#endif
{
exvsp[0].expr->type = exvsp[-1].expr->type;
exvsp[0].expr->data.operand.right = excast(expr.program, exvsp[0].expr->data.operand.right, exvsp[-1].expr->type, NiL, 0);
}
exvsp[0].expr->data.operand.left = exvsp[-1].expr;
exval.expr = exvsp[0].expr;
}
}
;
break;}
case 71:
#line 736 "exparse.y"
{
pre:
if (exvsp[0].expr->type == STRING)
exerror("++ and -- invalid for string variables");
exval.expr = exnewnode(expr.program, exvsp[-1].op, 0, exvsp[0].expr->type, exvsp[0].expr, NiL);
exval.expr->subop = PRE;
;
break;}
case 72:
#line 744 "exparse.y"
{
pos:
if (exvsp[-1].expr->type == STRING)
exerror("++ and -- invalid for string variables");
exval.expr = exnewnode(expr.program, exvsp[0].op, 0, exvsp[-1].expr->type, exvsp[-1].expr, NiL);
exval.expr->subop = POS;
;
break;}
case 73:
#line 752 "exparse.y"
{
goto pre;
;
break;}
case 74:
#line 756 "exparse.y"
{
goto pos;
;
break;}
case 76:
#line 763 "exparse.y"
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, exvsp[0].id->type, NiL, NiL);
if (!expr.program->disc->reff)
exerror("%s: identifier references not supported", exvsp[0].id->name);
else exval.expr->data.constant.value = (*expr.program->disc->reff)(expr.program, exval.expr, exvsp[0].id, NiL, NiL, EX_SCALAR, expr.program->disc);
;
break;}
case 77:
#line 770 "exparse.y"
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, FLOATING, NiL, NiL);
exval.expr->data.constant.value.floating = exvsp[0].floating;
;
break;}
case 78:
#line 775 "exparse.y"
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
exval.expr->data.constant.value.integer = exvsp[0].integer;
;
break;}
case 79:
#line 780 "exparse.y"
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, STRING, NiL, NiL);
exval.expr->data.constant.value.string = exvsp[0].string;
;
break;}
case 80:
#line 785 "exparse.y"
{
exval.expr = exnewnode(expr.program, CONSTANT, 0, UNSIGNED, NiL, NiL);
exval.expr->data.constant.value.integer = exvsp[0].integer;
;
break;}
case 84:
#line 797 "exparse.y"
{
exval.expr = makeVar(expr.program, exvsp[-1].id, 0, 0, exvsp[0].reference);
;
break;}
case 85:
#line 801 "exparse.y"
{
Exnode_t* n;
n = exnewnode(expr.program, DYNAMIC, 0, exvsp[-2].id->type, NiL, NiL);
n->data.variable.symbol = exvsp[-2].id;
n->data.variable.reference = 0;
if (((n->data.variable.index = exvsp[-1].expr) == 0) != (exvsp[-2].id->local.pointer ==
0))
exerror("%s: is%s an array", exvsp[-2].id->name, exvsp[-2].id->local.pointer ? "" : " not");
if (exvsp[0].reference) {
n->data.variable.dyna =exnewnode(expr.program, 0, 0, 0, NiL, NiL);
exval.expr = makeVar(expr.program, exvsp[-2].id, exvsp[-1].expr, n, exvsp[0].reference);
}
else exval.expr = n;
;
break;}
case 86:
#line 817 "exparse.y"
{
exval.expr = exnewnode(expr.program, ID, 0, STRING, NiL, NiL);
exval.expr->data.variable.symbol = exvsp[0].id;
exval.expr->data.variable.reference = 0;
exval.expr->data.variable.index = 0;
exval.expr->data.variable.dyna = 0;
if (!(expr.program->disc->flags & EX_UNDECLARED))
exerror("unknown identifier");
;
break;}
case 87:
#line 829 "exparse.y"
{
exval.integer = 0;
;
break;}
case 88:
#line 833 "exparse.y"
{
exval.integer = 1;
;
break;}
case 89:
#line 839 "exparse.y"
{
exval.expr = 0;
;
break;}
case 90:
#line 843 "exparse.y"
{
exval.expr = exvsp[-1].expr;
;
break;}
case 91:
#line 849 "exparse.y"
{
exval.expr = 0;
;
break;}
case 92:
#line 853 "exparse.y"
{
exval.expr = exvsp[0].expr->data.operand.left;
exvsp[0].expr->data.operand.left = exvsp[0].expr->data.operand.right = 0;
exfreenode(expr.program, exvsp[0].expr);
;
break;}
case 93:
#line 861 "exparse.y"
{
exval.expr = exnewnode(expr.program, ',', 1, 0, exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[0].expr, NiL), NiL);
exval.expr->data.operand.right = exval.expr->data.operand.left;
;
break;}
case 94:
#line 866 "exparse.y"
{
exvsp[-2].expr->data.operand.right = exvsp[-2].expr->data.operand.right->data.operand.right = exnewnode(expr.program, ',', 1, exvsp[-2].expr->type, exvsp[0].expr, NiL);
;
break;}
case 95:
#line 872 "exparse.y"
{
exval.expr = 0;
;
break;}
case 96:
#line 876 "exparse.y"
{
exval.expr = 0;
if (exvsp[0].id->type)
exerror("(void) expected");
;
break;}
case 98:
#line 885 "exparse.y"
{
exval.expr = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
;
break;}
case 99:
#line 889 "exparse.y"
{
register Exnode_t* x;
register Exnode_t* y;
exval.expr = exvsp[-2].expr;
for (x = exvsp[-2].expr; y = x->data.operand.right; x = y);
x->data.operand.right = exnewnode(expr.program, ',', 1, exvsp[0].expr->type, exvsp[0].expr, NiL);
;
break;}
case 100:
#line 899 "exparse.y"
{expr.declare=exvsp[0].id->type;;
break;}
case 101:
#line 900 "exparse.y"
{
exval.expr = exnewnode(expr.program, ID, 0, exvsp[0].id->type, NiL, NiL);
exval.expr->data.variable.symbol = exvsp[0].id;
exvsp[0].id->lex = DYNAMIC;
exvsp[0].id->value = exnewnode(expr.program, 0, 0, 0, NiL, NiL);
expr.procedure->data.procedure.arity++;
;
break;}
case 102:
#line 910 "exparse.y"
{
exval.reference = expr.refs = expr.lastref = 0;
;
break;}
case 103:
#line 914 "exparse.y"
{
Exref_t* r;
r = ALLOCATE(expr.program, Exref_t);
r->symbol = exvsp[0].id;
expr.refs = r;
expr.lastref = r;
r->next = 0;
r->index = 0;
exval.reference = expr.refs;
;
break;}
case 104:
#line 926 "exparse.y"
{
Exref_t* r;
Exref_t* l;
r = ALLOCATE(expr.program, Exref_t);
r->symbol = exvsp[0].id;
r->index = 0;
r->next = 0;
l = ALLOCATE(expr.program, Exref_t);
l->symbol = exvsp[-1].id;
l->index = 0;
l->next = r;
expr.refs = l;
expr.lastref = r;
exval.reference = expr.refs;
;
break;}
case 105:
#line 945 "exparse.y"
{
exval.id = exvsp[0].id;
;
break;}
case 106:
#line 949 "exparse.y"
{
exval.id = exvsp[0].id;
;
break;}
case 107:
#line 954 "exparse.y"
{
exval.expr = 0;
;
break;}
case 108:
#line 958 "exparse.y"
{
exval.expr = exnewnode(expr.program, '=', 1, exvsp[0].expr->type, NiL, exvsp[0].expr);
exval.expr->subop = exvsp[-1].op;
;
break;}
case 110:
#line 965 "exparse.y"
{
register Dtdisc_t* disc;
if (expr.procedure)
exerror("no nested function definitions");
expr.procedure = exnewnode(expr.program, PROCEDURE, 1, expr.declare, NiL, NiL);
if (!(disc = newof(0, Dtdisc_t, 1, 0)))
exerror("out of space [frame discipline]");
disc->key = offsetof(Exid_t, name);
if (!(expr.procedure->data.procedure.frame = dtopen(disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
exerror("out of space [frame table]");
expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
expr.program->formals = 1;
;
break;}
case 111:
#line 978 "exparse.y"
{
expr.program->formals = 0;
expr.id->lex = PROCEDURE;
expr.id->type = expr.declare;
;
break;}
case 112:
#line 983 "exparse.y"
{
exval.expr = expr.procedure;
expr.procedure = 0;
if (expr.program->frame)
{
expr.program->symbols = expr.program->frame->view;
dtview(expr.program->frame, NiL);
}
exval.expr->data.operand.left = exvsp[-5].expr;
exval.expr->data.operand.right = excast(expr.program, exvsp[-1].expr, exval.expr->type, NiL, 0);
/*
* NOTE: procedure definition was slipped into the
* declaration initializer statement production,
* therefore requiring the statement terminator
*/
exunlex(expr.program, ';');
;
break;}
}
#line 610 "/usr/share/bison/bison.simple"
exvsp -= exlen;
exssp -= exlen;
#if EXLSP_NEEDED
exlsp -= exlen;
#endif
#if EXDEBUG
if (exdebug)
{
short *ssp1 = exss - 1;
fprintf (stderr, "state stack now");
while (ssp1 != exssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
*++exvsp = exval;
#if EXLSP_NEEDED
*++exlsp = exloc;
#endif
/* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
exn = exr1[exn];
exstate = expgoto[exn - EXNTBASE] + *exssp;
if (exstate >= 0 && exstate <= EXLAST && excheck[exstate] == *exssp)
exstate = extable[exstate];
else
exstate = exdefgoto[exn - EXNTBASE];
goto exnewstate;
/*------------------------------------.
| exerrlab -- here on detecting error |
`------------------------------------*/
exerrlab:
/* If not already recovering from an error, report this error. */
if (!exerrstatus)
{
++exnerrs;
#ifdef EXERROR_VERBOSE
exn = expact[exstate];
if (exn > EXFLAG && exn < EXLAST)
{
int size = 0;
char *msg;
int x, count;
count = 0;
/* Start X at -exn if nec to avoid negative indexes in excheck. */
for (x = (exn < 0 ? -exn : 0);
x < (int) (sizeof (extname) / sizeof (char *)); x++)
if (excheck[x + exn] == x)
size += strlen (extname[x]) + 15, count++;
size += strlen ("parse error, unexpected `") + 1;
size += strlen (extname[EXTRANSLATE (exchar)]);
msg = (char *) malloc (size);
if (msg != 0)
{
strcpy (msg, "parse error, unexpected `");
strcat (msg, extname[EXTRANSLATE (exchar)]);
strcat (msg, "'");
if (count < 5)
{
count = 0;
for (x = (exn < 0 ? -exn : 0);
x < (int) (sizeof (extname) / sizeof (char *)); x++)
if (excheck[x + exn] == x)
{
strcat (msg, count == 0 ? ", expecting `" : " or `");
strcat (msg, extname[x]);
strcat (msg, "'");
count++;
}
}
exerror (msg);
free (msg);
}
else
exerror ("parse error; also virtual memory exceeded");
}
else
#endif /* EXERROR_VERBOSE */
exerror ("parse error");
}
goto exerrlab1;
/*--------------------------------------------------.
| exerrlab1 -- error raised explicitly by an action |
`--------------------------------------------------*/
exerrlab1:
if (exerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
/* return failure if at end of input */
if (exchar == EXEOF)
EXABORT;
EXDPRINTF ((stderr, "Discarding token %d (%s).\n",
exchar, extname[exchar1]));
exchar = EXEMPTY;
}
/* Else will try to reuse lookahead token after shifting the error
token. */
exerrstatus = 3; /* Each real token shifted decrements this */
goto exerrhandle;
/*-------------------------------------------------------------------.
| exerrdefault -- current state does not do anything special for the |
| error token. |
`-------------------------------------------------------------------*/
exerrdefault:
#if 0
/* This is wrong; only states that explicitly want error tokens
should shift them. */
/* If its default is to accept any token, ok. Otherwise pop it. */
exn = exdefact[exstate];
if (exn)
goto exdefault;
#endif
/*---------------------------------------------------------------.
| exerrpop -- pop the current state because it cannot handle the |
| error token |
`---------------------------------------------------------------*/
exerrpop:
if (exssp == exss)
EXABORT;
exvsp--;
exstate = *--exssp;
#if EXLSP_NEEDED
exlsp--;
#endif
#if EXDEBUG
if (exdebug)
{
short *ssp1 = exss - 1;
fprintf (stderr, "Error: state stack now");
while (ssp1 != exssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
/*--------------.
| exerrhandle. |
`--------------*/
exerrhandle:
exn = expact[exstate];
if (exn == EXFLAG)
goto exerrdefault;
exn += EXTERROR;
if (exn < 0 || exn > EXLAST || excheck[exn] != EXTERROR)
goto exerrdefault;
exn = extable[exn];
if (exn < 0)
{
if (exn == EXFLAG)
goto exerrpop;
exn = -exn;
goto exreduce;
}
else if (exn == 0)
goto exerrpop;
if (exn == EXFINAL)
EXACCEPT;
EXDPRINTF ((stderr, "Shifting error token, "));
*++exvsp = exlval;
#if EXLSP_NEEDED
*++exlsp = exlloc;
#endif
exstate = exn;
goto exnewstate;
/*-------------------------------------.
| exacceptlab -- EXACCEPT comes here. |
`-------------------------------------*/
exacceptlab:
if (exfree_stacks)
{
free (exss);
free (exvs);
#if EXLSP_NEEDED
free (exls);
#endif
}
return 0;
/*-----------------------------------.
| exabortlab -- EXABORT comes here. |
`-----------------------------------*/
exabortlab:
if (exfree_stacks)
{
free (exss);
free (exvs);
#if EXLSP_NEEDED
free (exls);
#endif
}
return 1;
}
#line 1004 "exparse.y"
#include "exgram.h"
|