GNU Binutils with patches for OS216
修订版 | 147b898422f13f616722d0690214d70fe3f7f302 (tree) |
---|---|
时间 | 2003-12-20 15:05:40 |
作者 | Daniel Jacobowitz <drow@fals...> |
Commiter | Daniel Jacobowitz |
* cp-names.y (tokentab2, tokentab3): Remove.
(HANDLE_TOKEN2, HANDLE_TOKEN3): New macros.
(yylex): Use them.
@@ -1,5 +1,11 @@ | ||
1 | 1 | 2003-12-19 Daniel Jacobowitz <drow@mvista.com> |
2 | 2 | |
3 | + * cp-names.y (tokentab2, tokentab3): Remove. | |
4 | + (HANDLE_TOKEN2, HANDLE_TOKEN3): New macros. | |
5 | + (yylex): Use them. | |
6 | + | |
7 | +2003-12-19 Daniel Jacobowitz <drow@mvista.com> | |
8 | + | |
3 | 9 | * cp-names.y (%union): Remove typed_val_float. |
4 | 10 | (INT, FLOAT): Change to type comp. |
5 | 11 | (CONSTRUCTION_VTABLE): Change to untyped. |
@@ -1413,36 +1413,6 @@ struct token | ||
1413 | 1413 | int opcode; |
1414 | 1414 | }; |
1415 | 1415 | |
1416 | -static const struct token tokentab3[] = | |
1417 | - { | |
1418 | - {">>=", ASSIGN_MODIFY, BINOP_RSH}, | |
1419 | - {"<<=", ASSIGN_MODIFY, BINOP_LSH}, | |
1420 | - }; | |
1421 | - | |
1422 | -static const struct token tokentab2[] = | |
1423 | - { | |
1424 | - {"+=", ASSIGN_MODIFY, BINOP_ADD}, | |
1425 | - {"-=", ASSIGN_MODIFY, BINOP_SUB}, | |
1426 | - {"*=", ASSIGN_MODIFY, BINOP_MUL}, | |
1427 | - {"/=", ASSIGN_MODIFY, BINOP_DIV}, | |
1428 | - {"%=", ASSIGN_MODIFY, BINOP_REM}, | |
1429 | - {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR}, | |
1430 | - {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND}, | |
1431 | - {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR}, | |
1432 | - {"++", INCREMENT, BINOP_END}, | |
1433 | - {"--", DECREMENT, BINOP_END}, | |
1434 | - {"->", ARROW, BINOP_END}, | |
1435 | - {"&&", ANDAND, BINOP_END}, | |
1436 | - {"||", OROR, BINOP_END}, | |
1437 | - {"::", COLONCOLON, BINOP_END}, | |
1438 | - {"<<", LSH, BINOP_END}, | |
1439 | - {">>", RSH, BINOP_END}, | |
1440 | - {"==", EQUAL, BINOP_END}, | |
1441 | - {"!=", NOTEQUAL, BINOP_END}, | |
1442 | - {"<=", LEQ, BINOP_END}, | |
1443 | - {">=", GEQ, BINOP_END} | |
1444 | - }; | |
1445 | - | |
1446 | 1416 | #define HANDLE_SPECIAL(string, len, comp) \ |
1447 | 1417 | if (strncmp (tokstart, string, len) == 0) \ |
1448 | 1418 | { \ |
@@ -1451,6 +1421,22 @@ static const struct token tokentab2[] = | ||
1451 | 1421 | return DEMANGLER_SPECIAL; \ |
1452 | 1422 | } |
1453 | 1423 | |
1424 | +#define HANDLE_TOKEN2(string, token, op) \ | |
1425 | + if (lexptr[1] == string[1]) \ | |
1426 | + { \ | |
1427 | + lexptr += 2; \ | |
1428 | + yylval.opname = string; \ | |
1429 | + return token; \ | |
1430 | + } | |
1431 | + | |
1432 | +#define HANDLE_TOKEN3(string, token, op) \ | |
1433 | + if (lexptr[1] == string[1] && lexptr[2] == string[2]) \ | |
1434 | + { \ | |
1435 | + lexptr += 2; \ | |
1436 | + yylval.opname = string; \ | |
1437 | + return token; \ | |
1438 | + } | |
1439 | + | |
1454 | 1440 | /* Read one token, getting characters through lexptr. */ |
1455 | 1441 | |
1456 | 1442 | static int |
@@ -1458,7 +1444,6 @@ yylex (void) | ||
1458 | 1444 | { |
1459 | 1445 | int c; |
1460 | 1446 | int namelen; |
1461 | - unsigned int i; | |
1462 | 1447 | char *tokstart; |
1463 | 1448 | char *tokptr; |
1464 | 1449 | int tempbufindex; |
@@ -1472,26 +1457,6 @@ yylex (void) | ||
1472 | 1457 | unquoted_expr = 1; |
1473 | 1458 | |
1474 | 1459 | tokstart = lexptr; |
1475 | - /* See if it is a special token of length 3. */ | |
1476 | - for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++) | |
1477 | - if (tokstart[0] == tokentab3[i].operator[0] | |
1478 | - && tokstart[1] == tokentab3[i].operator[1] | |
1479 | - && tokstart[2] == tokentab3[i].operator[2]) | |
1480 | - { | |
1481 | - lexptr += 3; | |
1482 | - yylval.opname = tokentab3[i].operator; | |
1483 | - return tokentab3[i].token; | |
1484 | - } | |
1485 | - | |
1486 | - /* See if it is a special token of length 2. */ | |
1487 | - for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++) | |
1488 | - if (tokstart[0] == tokentab2[i].operator[0] | |
1489 | - && tokstart[1] == tokentab2[i].operator[1]) | |
1490 | - { | |
1491 | - lexptr += 2; | |
1492 | - yylval.opname = tokentab2[i].operator; | |
1493 | - return tokentab2[i].token; | |
1494 | - } | |
1495 | 1460 | |
1496 | 1461 | switch (c = *tokstart) |
1497 | 1462 | { |
@@ -1561,6 +1526,10 @@ yylex (void) | ||
1561 | 1526 | /* FALL THRU into number case. */ |
1562 | 1527 | |
1563 | 1528 | case '-': |
1529 | + HANDLE_TOKEN2 ("-=", ASSIGN_MODIFY, BINOP_SUB); | |
1530 | + HANDLE_TOKEN2 ("--", DECREMENT, BINOP_END); | |
1531 | + HANDLE_TOKEN2 ("->", ARROW, BINOP_END); | |
1532 | + | |
1564 | 1533 | /* For construction vtables. This is kind of hokey. */ |
1565 | 1534 | if (strncmp (tokstart, "-in-", 4) == 0) |
1566 | 1535 | { |
@@ -1643,22 +1612,66 @@ yylex (void) | ||
1643 | 1612 | } |
1644 | 1613 | |
1645 | 1614 | case '+': |
1615 | + HANDLE_TOKEN2 ("+=", ASSIGN_MODIFY, BINOP_ADD); | |
1616 | + HANDLE_TOKEN2 ("++", INCREMENT, BINOP_END); | |
1617 | + lexptr++; | |
1618 | + return c; | |
1646 | 1619 | case '*': |
1620 | + HANDLE_TOKEN2 ("*=", ASSIGN_MODIFY, BINOP_MUL); | |
1621 | + lexptr++; | |
1622 | + return c; | |
1647 | 1623 | case '/': |
1624 | + HANDLE_TOKEN2 ("/=", ASSIGN_MODIFY, BINOP_DIV); | |
1625 | + lexptr++; | |
1626 | + return c; | |
1648 | 1627 | case '%': |
1628 | + HANDLE_TOKEN2 ("%=", ASSIGN_MODIFY, BINOP_REM); | |
1629 | + lexptr++; | |
1630 | + return c; | |
1649 | 1631 | case '|': |
1632 | + HANDLE_TOKEN2 ("|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR); | |
1633 | + HANDLE_TOKEN2 ("||", OROR, BINOP_END); | |
1634 | + lexptr++; | |
1635 | + return c; | |
1650 | 1636 | case '&': |
1637 | + HANDLE_TOKEN2 ("&=", ASSIGN_MODIFY, BINOP_BITWISE_AND); | |
1638 | + HANDLE_TOKEN2 ("&&", ANDAND, BINOP_END); | |
1639 | + lexptr++; | |
1640 | + return c; | |
1651 | 1641 | case '^': |
1652 | - case '~': | |
1642 | + HANDLE_TOKEN2 ("^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR); | |
1643 | + lexptr++; | |
1644 | + return c; | |
1653 | 1645 | case '!': |
1654 | - case '@': | |
1646 | + HANDLE_TOKEN2 ("!=", NOTEQUAL, BINOP_END); | |
1647 | + lexptr++; | |
1648 | + return c; | |
1655 | 1649 | case '<': |
1650 | + HANDLE_TOKEN2 ("<=", LEQ, BINOP_END); | |
1651 | + HANDLE_TOKEN2 ("<<", LSH, BINOP_END); | |
1652 | + HANDLE_TOKEN3 ("<<=", ASSIGN_MODIFY, BINOP_LSH); | |
1653 | + lexptr++; | |
1654 | + return c; | |
1656 | 1655 | case '>': |
1656 | + HANDLE_TOKEN2 (">=", GEQ, BINOP_END); | |
1657 | + HANDLE_TOKEN2 (">>", RSH, BINOP_END); | |
1658 | + HANDLE_TOKEN3 (">>=", ASSIGN_MODIFY, BINOP_RSH); | |
1659 | + lexptr++; | |
1660 | + return c; | |
1661 | + case '=': | |
1662 | + HANDLE_TOKEN2 ("==", EQUAL, BINOP_END); | |
1663 | + lexptr++; | |
1664 | + return c; | |
1665 | + case ':': | |
1666 | + HANDLE_TOKEN2 ("::", COLONCOLON, BINOP_END); | |
1667 | + lexptr++; | |
1668 | + return c; | |
1669 | + | |
1657 | 1670 | case '[': |
1658 | 1671 | case ']': |
1659 | 1672 | case '?': |
1660 | - case ':': | |
1661 | - case '=': | |
1673 | + case '@': | |
1674 | + case '~': | |
1662 | 1675 | case '{': |
1663 | 1676 | case '}': |
1664 | 1677 | symbol: |