On 21 April 2010 12:32, Tomohiro Matsuyama <t...@cx4a.org> 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.

Reply via email to