From: Keith Seitz <keiths@redhat.com>
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Token cleanup in c-exp.y
Date: Tue, 25 Aug 2009 18:07:00 -0000 [thread overview]
Message-ID: <4A94248B.20701@redhat.com> (raw)
In-Reply-To: <m3skffvqvl.fsf@fleche.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 934 bytes --]
On 08/25/2009 08:45 AM, Tom Tromey wrote:
>>>>>> "Keith" == Keith Seitz<keiths@redhat.com> writes:
>
> Keith> + {".*", DOT_STAR, BINOP_END, 0}
>
> After reading the follow-up comments I realized that this needs a couple
> little changes.
>
> The last field should be 1 here, and then the tokentab2 and tokentab3
> logic in yylex needs the same cxx_only treatment as ident_tokens.
Yes, indeed. I've fixed that
> I suppose that the "::" operator also needs to be C++-only.
I don't think we can do that. "::" is also used by gdb for non-language
constructs like filename::function and function::variable. There are
several scattered tests on this already.
New patch attached.
Keith
2009-08-25 Keith Seitz <keiths@redhat.com>
* c-exp.y (tokentab3): Add new token, ARROW_STAR. Changed all users.
(tokentab2): Add new token, DOT_STAR. Changed all users.
(yylex): Add cxx_only check for tokentab2 and tokentab3 searches.
[-- Attachment #2: token-fix2.patch --]
[-- Type: text/plain, Size: 1659 bytes --]
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.60
diff -u -p -r1.60 c-exp.y
--- c-exp.y 25 Aug 2009 00:23:07 -0000 1.60
+++ c-exp.y 25 Aug 2009 17:35:52 -0000
@@ -1683,6 +1683,8 @@ static const struct token tokentab2[] =
{"->", ARROW, BINOP_END, 0},
{"&&", ANDAND, BINOP_END, 0},
{"||", OROR, BINOP_END, 0},
+ /* "::" is *not* only C++: gdb overrides its meaning in several
+ different ways, e.g., 'filename'::func, function::variable. */
{"::", COLONCOLON, BINOP_END, 0},
{"<<", LSH, BINOP_END, 0},
{">>", RSH, BINOP_END, 0},
@@ -1690,7 +1692,7 @@ static const struct token tokentab2[] =
{"!=", NOTEQUAL, BINOP_END, 0},
{"<=", LEQ, BINOP_END, 0},
{">=", GEQ, BINOP_END, 0},
- {".*", DOT_STAR, BINOP_END, 0}
+ {".*", DOT_STAR, BINOP_END, 1}
};
/* Identifier-like tokens. */
@@ -1849,6 +1851,10 @@ yylex (void)
for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
{
+ if (tokentab3[i].cxx_only
+ && parse_language->la_language != language_cplus)
+ break;
+
lexptr += 3;
yylval.opcode = tokentab3[i].opcode;
return tokentab3[i].token;
@@ -1858,6 +1864,10 @@ yylex (void)
for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
{
+ if (tokentab2[i].cxx_only
+ && parse_language->la_language != language_cplus)
+ break;
+
lexptr += 2;
yylval.opcode = tokentab2[i].opcode;
if (in_parse_field && tokentab2[i].token == ARROW)
next prev parent reply other threads:[~2009-08-25 17:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-24 23:06 Keith Seitz
2009-08-24 23:08 ` Tom Tromey
2009-08-25 5:03 ` Keith Seitz
2009-08-25 13:45 ` Pierre Muller
2009-08-25 14:10 ` Jiang Jilin
2009-08-25 15:11 ` Andreas Schwab
2009-08-25 15:28 ` Matt Rice
2009-08-25 15:46 ` Tom Tromey
2009-08-25 15:47 ` Tom Tromey
2009-08-25 18:07 ` Keith Seitz [this message]
2009-08-25 18:41 ` Tom Tromey
2009-08-25 18:42 ` Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A94248B.20701@redhat.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox