Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: junior07 on February 04, 2006, 11:59:16 am

Title: Some parser-related questions
Post by: junior07 on February 04, 2006, 11:59:16 am
Hi all !
I am playing a little with C::B as I am looking for a free C++ IDE (free means no money of course, but open source is even better  :D)

Well, back to technical stuff.
I was testing the code completion feature as it is a key functionality for me. I find it useful as a reminder, in particular for structure and class members.
But I notice a few problems :
- structures defined with the "typedef" keyword are not handled properly
- classes with several "public" areas are not handled properly.

So I went to the SVN source codes and have a look at the ParserThread code.
I noticed that "typedef" was voluntarily not taken into account. Why does this behavior have been designed ? When I comment out references to "typedef" (in fact "kw_typedef" so that the parser ignore it), the parser seems to run better. What's wrong with this ?

Concerning classes, I have not looked at it yet, but it seems there are problems when handling nested public/protected/private portions in class definitions. Any remarks on it ?

Have a nice WE
Junior
Title: Re: Some parser-related questions
Post by: rickg22 on February 04, 2006, 04:52:00 pm
it's not that typedef was taken out. It's that it was NEVER implemented :P

About public / private etc., I really don't know... could you post an example?
Title: Re: Some parser-related questions
Post by: Game_Ender on February 04, 2006, 05:00:19 pm
If you want to spend time on the codecompletion plugin you might want to take a stab at integrating the CTags based parser here: Eranfs CTags Based Parser (http://forums.codeblocks.org/index.php?topic=1889.msg16037#msg16037).  It supports templates, typedefs, and hopefully is a little more stable on Linux, but that will have to be tested.

Rickg22-  Thanks for all the work on the CodeCompletion plugin, it has proved much in the last month.
Title: Re: Some parser-related questions
Post by: junior07 on February 04, 2006, 09:51:14 pm
it's not that typedef was taken out. It's that it was NEVER implemented :P

About public / private etc., I really don't know... could you post an example?

I don't understand why you say it has never been implemented because it appears in the file parserthread.cpp used for parsing :

Code
const wxString kw_typedef(_T("typedef"));

Code
else if (token==ParserConsts::kw_typedef
||
token==ParserConsts::colon)
{
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
m_Str.Clear();
}

Code
else if (token==ParserConsts::kw_typedef ||
token==ParserConsts::kw_return ||
token==ParserConsts::colon)
{
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
m_Str.Clear();
}

So, to my mind, typedef seems to be taken into account. But I wonder how those who originally wrote this code were thinking they should deal with this statement. It seems they ignore it.

For the second point (public/protected/private sections handling), I'm trying to reproduce the behavior I noticed this morning, but can't get it yet. Maybe was dreaming. I have experimented lots of code tuning.

Anyway, keep on this wonderful work guys, I learn to be able to help in a near future !
Title: Re: Some parser-related questions
Post by: thomas on February 04, 2006, 09:56:30 pm
Quote
I don't understand why you say it has never been implemented because it appears in the file parserthread.cpp used for parsing
It is parsed like all keywords, but its semantics are not implemented.
Title: Re: Some parser-related questions
Post by: junior07 on February 04, 2006, 10:01:30 pm
Excuse me, I don't understand what you mean.
When I comment out the references to typedef in the code I give above, the parser seems to behaves correctly. For example, it copes with a "typedef struct" correctly, allowing the use of the code completion whereas it was not possible with the typedef references uncommented.

Can you explain more ?
Thanks
Title: Re: Some parser-related questions
Post by: thomas on February 04, 2006, 10:13:26 pm
If you comment out the "typedef" code, then
Code
StructTypename::

will probably display the code completion menu.

But if something like
Code
StructTypename a;
a.

really works, then I should be very, very surprised, as there is no code that handles this (to my knowledge).
I may of course be wrong... did not write the parser in the first place :lol:
Title: Re: Some parser-related questions
Post by: junior07 on February 05, 2006, 08:19:57 pm
You're right !
I realize this morning I was using the "original" name of the struct on which I was using typedef and not the new defined one. Am I understandable ? I think I'm a bit tired !
Well, I may take the time to study the internals of the code completion plugin to help to make it evolve.