diff options
author | Daniel Jacobowitz <drow@false.org> | 2003-12-20 06:05:40 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2003-12-20 06:05:40 +0000 |
commit | 147b898422f13f616722d0690214d70fe3f7f302 (patch) | |
tree | 59c8ff4323a29589c2b82b82c06761fced55a5ec /gdb | |
parent | f0ab26d1c4ff6a3dee140dcf35eff7c272175d8c (diff) | |
download | gdb-147b898422f13f616722d0690214d70fe3f7f302.zip gdb-147b898422f13f616722d0690214d70fe3f7f302.tar.gz gdb-147b898422f13f616722d0690214d70fe3f7f302.tar.bz2 |
* cp-names.y (tokentab2, tokentab3): Remove.
(HANDLE_TOKEN2, HANDLE_TOKEN3): New macros.
(yylex): Use them.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog.cplus | 6 | ||||
-rw-r--r-- | gdb/cp-names.y | 123 |
2 files changed, 74 insertions, 55 deletions
diff --git a/gdb/ChangeLog.cplus b/gdb/ChangeLog.cplus index f1fabe2..a1ab61b 100644 --- a/gdb/ChangeLog.cplus +++ b/gdb/ChangeLog.cplus @@ -1,5 +1,11 @@ 2003-12-19 Daniel Jacobowitz <drow@mvista.com> + * cp-names.y (tokentab2, tokentab3): Remove. + (HANDLE_TOKEN2, HANDLE_TOKEN3): New macros. + (yylex): Use them. + +2003-12-19 Daniel Jacobowitz <drow@mvista.com> + * cp-names.y (%union): Remove typed_val_float. (INT, FLOAT): Change to type comp. (CONSTRUCTION_VTABLE): Change to untyped. diff --git a/gdb/cp-names.y b/gdb/cp-names.y index 791bbd2..69f6026 100644 --- a/gdb/cp-names.y +++ b/gdb/cp-names.y @@ -1413,36 +1413,6 @@ struct token int opcode; }; -static const struct token tokentab3[] = - { - {">>=", ASSIGN_MODIFY, BINOP_RSH}, - {"<<=", ASSIGN_MODIFY, BINOP_LSH}, - }; - -static const struct token tokentab2[] = - { - {"+=", ASSIGN_MODIFY, BINOP_ADD}, - {"-=", ASSIGN_MODIFY, BINOP_SUB}, - {"*=", ASSIGN_MODIFY, BINOP_MUL}, - {"/=", ASSIGN_MODIFY, BINOP_DIV}, - {"%=", ASSIGN_MODIFY, BINOP_REM}, - {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR}, - {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND}, - {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR}, - {"++", INCREMENT, BINOP_END}, - {"--", DECREMENT, BINOP_END}, - {"->", ARROW, BINOP_END}, - {"&&", ANDAND, BINOP_END}, - {"||", OROR, BINOP_END}, - {"::", COLONCOLON, BINOP_END}, - {"<<", LSH, BINOP_END}, - {">>", RSH, BINOP_END}, - {"==", EQUAL, BINOP_END}, - {"!=", NOTEQUAL, BINOP_END}, - {"<=", LEQ, BINOP_END}, - {">=", GEQ, BINOP_END} - }; - #define HANDLE_SPECIAL(string, len, comp) \ if (strncmp (tokstart, string, len) == 0) \ { \ @@ -1451,6 +1421,22 @@ static const struct token tokentab2[] = return DEMANGLER_SPECIAL; \ } +#define HANDLE_TOKEN2(string, token, op) \ + if (lexptr[1] == string[1]) \ + { \ + lexptr += 2; \ + yylval.opname = string; \ + return token; \ + } + +#define HANDLE_TOKEN3(string, token, op) \ + if (lexptr[1] == string[1] && lexptr[2] == string[2]) \ + { \ + lexptr += 2; \ + yylval.opname = string; \ + return token; \ + } + /* Read one token, getting characters through lexptr. */ static int @@ -1458,7 +1444,6 @@ yylex (void) { int c; int namelen; - unsigned int i; char *tokstart; char *tokptr; int tempbufindex; @@ -1472,26 +1457,6 @@ yylex (void) unquoted_expr = 1; tokstart = lexptr; - /* See if it is a special token of length 3. */ - for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++) - if (tokstart[0] == tokentab3[i].operator[0] - && tokstart[1] == tokentab3[i].operator[1] - && tokstart[2] == tokentab3[i].operator[2]) - { - lexptr += 3; - yylval.opname = tokentab3[i].operator; - return tokentab3[i].token; - } - - /* See if it is a special token of length 2. */ - for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++) - if (tokstart[0] == tokentab2[i].operator[0] - && tokstart[1] == tokentab2[i].operator[1]) - { - lexptr += 2; - yylval.opname = tokentab2[i].operator; - return tokentab2[i].token; - } switch (c = *tokstart) { @@ -1561,6 +1526,10 @@ yylex (void) /* FALL THRU into number case. */ case '-': + HANDLE_TOKEN2 ("-=", ASSIGN_MODIFY, BINOP_SUB); + HANDLE_TOKEN2 ("--", DECREMENT, BINOP_END); + HANDLE_TOKEN2 ("->", ARROW, BINOP_END); + /* For construction vtables. This is kind of hokey. */ if (strncmp (tokstart, "-in-", 4) == 0) { @@ -1643,22 +1612,66 @@ yylex (void) } case '+': + HANDLE_TOKEN2 ("+=", ASSIGN_MODIFY, BINOP_ADD); + HANDLE_TOKEN2 ("++", INCREMENT, BINOP_END); + lexptr++; + return c; case '*': + HANDLE_TOKEN2 ("*=", ASSIGN_MODIFY, BINOP_MUL); + lexptr++; + return c; case '/': + HANDLE_TOKEN2 ("/=", ASSIGN_MODIFY, BINOP_DIV); + lexptr++; + return c; case '%': + HANDLE_TOKEN2 ("%=", ASSIGN_MODIFY, BINOP_REM); + lexptr++; + return c; case '|': + HANDLE_TOKEN2 ("|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR); + HANDLE_TOKEN2 ("||", OROR, BINOP_END); + lexptr++; + return c; case '&': + HANDLE_TOKEN2 ("&=", ASSIGN_MODIFY, BINOP_BITWISE_AND); + HANDLE_TOKEN2 ("&&", ANDAND, BINOP_END); + lexptr++; + return c; case '^': - case '~': + HANDLE_TOKEN2 ("^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR); + lexptr++; + return c; case '!': - case '@': + HANDLE_TOKEN2 ("!=", NOTEQUAL, BINOP_END); + lexptr++; + return c; case '<': + HANDLE_TOKEN2 ("<=", LEQ, BINOP_END); + HANDLE_TOKEN2 ("<<", LSH, BINOP_END); + HANDLE_TOKEN3 ("<<=", ASSIGN_MODIFY, BINOP_LSH); + lexptr++; + return c; case '>': + HANDLE_TOKEN2 (">=", GEQ, BINOP_END); + HANDLE_TOKEN2 (">>", RSH, BINOP_END); + HANDLE_TOKEN3 (">>=", ASSIGN_MODIFY, BINOP_RSH); + lexptr++; + return c; + case '=': + HANDLE_TOKEN2 ("==", EQUAL, BINOP_END); + lexptr++; + return c; + case ':': + HANDLE_TOKEN2 ("::", COLONCOLON, BINOP_END); + lexptr++; + return c; + case '[': case ']': case '?': - case ':': - case '=': + case '@': + case '~': case '{': case '}': symbol: |