From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28987 invoked by alias); 25 Aug 2009 17:51:21 -0000 Received: (qmail 28973 invoked by uid 22791); 25 Aug 2009 17:51:19 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_66,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 25 Aug 2009 17:51:13 +0000 Received: from int-mx07.intmail.prod.int.phx2.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7PHpB5V031162 for ; Tue, 25 Aug 2009 13:51:11 -0400 Received: from [IPv6:::1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx07.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7PHp7Ws006436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 25 Aug 2009 13:51:10 -0400 Message-ID: <4A94248B.20701@redhat.com> Date: Tue, 25 Aug 2009 18:07:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 MIME-Version: 1.0 To: tromey@redhat.com CC: gdb-patches@sourceware.org Subject: Re: [RFA] Token cleanup in c-exp.y References: <4A9313C2.3050907@redhat.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------080905020709030809030109" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00423.txt.bz2 This is a multi-part message in MIME format. --------------080905020709030809030109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 934 On 08/25/2009 08:45 AM, Tom Tromey wrote: >>>>>> "Keith" == Keith Seitz 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 * 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. --------------080905020709030809030109 Content-Type: text/plain; name="token-fix2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="token-fix2.patch" Content-length: 1659 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) --------------080905020709030809030109--