Tags out of gcc

2014-10-04 Thread Adrian May
Hi All,

I have this brainstorm which I'd like to get some feedback on.

I reckon it's a bad idea to make source browsing info with a separate
program like cscope or etags. I reckon it's the compiler's job.

Why? (1) Because only the compiler can do it authoritatively, after
all, it decides what's in your executable. (2) Doing it properly
involves following #ifdefs and #includes, which the compiler already
does. (3) Because the types of tag you want are defined by the
language. (4) Because there's very little to it after parsing, which
the compiler is already doing.

I imagine doing it for c++ and outputting cscope format which is
reasonably expressive and popular.

I have no idea how hard it would be, but if I can bug people for help
I'd be willing to give it a shot.

Is there any interest in something like that?

Adrian.

PS: I'm not talking about local text completion here. I"m talking
about finding your way around a huge project where cscope etc give 50
different definitions of any important function because they can't
follow the #ifdefs.


Re: Tags out of gcc

2014-10-04 Thread Adrian May
Well it seems to be able to report a lot of syntax errors even if
they're close together, so it must be getting back on its feet fairly
quickly. I don't know how that works. Maybe it just scoots along to
the next semicolon or maybe you explicitly have productions like "if
(syntax error) { ... }".

What I also don't know is what the parser outputs if there's an error.
Can it say "he tried to define bool foo() at line 123 but the body was
erroneous", or does it just stdout the error message and forget there
was ever an attempt to define foo?


On 4 October 2014 18:17, Richard Kenner  wrote:
>> I reckon it's a bad idea to make source browsing info with a separate
>> program like cscope or etags. I reckon it's the compiler's job.
>
> One of the issues with soure browsing is that you want to be able to do
> it in the presence of syntax errors.  That can make it harder for the
> compiler to do it since it's usually not doing a robust parse in the
> presense of errors.


Re: Tags out of gcc

2014-10-04 Thread Adrian May
At first sight, I prefer the hooks approach. Not just cos I'm a noob
(although that is a compelling reason in itself) but also because it
happens during the main compile. A separate innovation could have
different flags so it wouldn't be authoritative anymore.

But it absolutely has to follow the preprocessor, so how do I do that?
I'm a bit surprised about that being a problem cos when I look at
preprocessor output it looks very convenient - I get one big file but
it's full of clues as to where it all came from. Perhaps I have to
hook those clues.

Adrian