From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19453 invoked by alias); 21 Apr 2010 14:22:29 -0000 Received: (qmail 19440 invoked by uid 22791); 21 Apr 2010 14:22:27 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SARE_MSGID_LONG45 X-Spam-Check-By: sourceware.org Received: from mail-ww0-f47.google.com (HELO mail-ww0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Apr 2010 14:22:21 +0000 Received: by wwb18 with SMTP id 18so4416473wwb.20 for ; Wed, 21 Apr 2010 07:22:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.73.9 with HTTP; Wed, 21 Apr 2010 07:21:57 -0700 (PDT) In-Reply-To: <4BCED45A.6040609@cx4a.org> References: <4BCED45A.6040609@cx4a.org> From: =?ISO-8859-1?Q?Manuel_L=F3pez=2DIb=E1=F1ez?= Date: Wed, 21 Apr 2010 14:47:00 -0000 Received: by 10.216.183.213 with SMTP id q63mr2860271wem.220.1271859738322; Wed, 21 Apr 2010 07:22:18 -0700 (PDT) Message-ID: Subject: Re: Code assistance with GCC To: Tomohiro Matsuyama Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2010-04/txt/msg00439.txt.bz2 On 21 April 2010 12:32, Tomohiro Matsuyama wrote: > Hi, all > > I have been working on implementing a tool-set of code assistance called > GCCSense, which enables code-completion for C/C++ in editors or a terminal. > > http://cx4a.org/software/gccsense/ > > GCCSense depends on its own GCC which has special options for code > assistance such like -code-completion-at: That seems like a really cool project. > Plugin might be a solution for them. Finally, however, I found that there is > no proper plugin entrances for code assistance. As you may understand if you > read an attached patch, GCCSense needs to handle quickly a special token for > code-completion after particular tokens such as "." and "->" in parser > phase. > > Is there any good solution for this ? I think the approach of adding phantom tokens is going to be unmaintainable. The C++ parser depends too much on tentative parsing, so things need to fail for the parser to work. When you add tokens like that, you alter the behaviour of when tentative parse fails and succeeds. The plugin approach would need a lot of hooks in the parser and too many internal details exposed, I think. This would be easier if the C++ parser was more like a library with an external interface that can be extended. Then, probably you would be able to reuse most of the C++ parser but extend/override the functions that parse "." and "->" expression. That still may cause trouble with tentative parse, but I think it will be less unpredictable and a matter of catching all corner cases. Of course, this would require substantial changes to the C++ parser, but perhaps if done in a proper way, those changes would be welcome and beneficial. > Or could you implement such plugin entrances for code assistance ? I am curious about the answer to this. Because I am not sure of the cost of each plugin hook we add, GCC is already too slow and the demand is only going to increase. Cheers, Manuel.