Tag a file with "unsigned" variables...

General questions regarding the usage of CodeLite
Nova
CodeLite Curious
Posts: 2
Joined: Tue Feb 17, 2009 6:48 pm
Contact:

Tag a file with "unsigned" variables...

Post by Nova »

Hello, everybody

I just downloaded CodeLite, and I have to say I love it! :D
I just have one question: it seems that CodeLite is not able to parse a variable, if the variable name is declared as "unsigned", as in the example below:

Code: Select all

void Test()
{
    static int8 u8VarA;
    int8 u8VarB;
    unsigned int8 u8VarC;

}
This will autocomplete only u8VarA and u8VarB, since u8VarC is not "seen".

Any idea on why this happens, and any workaroud available?
Thanks and kind regards
Marco Novaro
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Tag a file with "unsigned" variables...

Post by eranif »

The long answer:

My grammar file contains this rule:

Code: Select all

basic_type_name_inter:    LE_INT			{ $$ = $1; }
				| 	LE_CHAR			{ $$ = $1; }
				| 	LE_SHORT		{ $$ = $1; }
				| 	LE_LONG			{ $$ = $1; }
				| 	LE_FLOAT		{ $$ = $1; }
				| 	LE_DOUBLE		{ $$ = $1; }
				| 	LE_SIGNED		{ $$ = $1; }
				| 	LE_UNSIGNED		{ $$ = $1; }
				| 	LE_VOID			{ $$ = $1; }
				;

basic_type_name:	LE_UNSIGNED basic_type_name_inter 	{ $$ = $1 + " " + $2; }
				|	LE_SIGNED basic_type_name_inter 	{ $$ = $1 + " " + $2; }
				|	LE_LONG LE_LONG 					{ $$ = $1 + " " + $2; }
				|	LE_LONG LE_INT 						{ $$ = $1 + " " + $2; }
				|	basic_type_name_inter 			  	{ $$ = $1; }
				;
Which basically means that only the basic types are supported with unsgned.
To overcome this limitation, you could also do this:

Code: Select all

typedef unsigned int8 uint8;
uint8 u8VarC;
Eran
Make sure you have read the HOW TO POST thread
Nova
CodeLite Curious
Posts: 2
Joined: Tue Feb 17, 2009 6:48 pm
Contact:

Re: Tag a file with "unsigned" variables...

Post by Nova »

..I see.
...and I know this is a "strange" C syntax (it's actually written for the Freescale eTPU, where BTW I also have the type int24 -24 bits).

But, I can't understand why the "static int8" works fine and, at the end, why you can't just manage "unsigned" the same way. ;)

Thanks for the fast and accurate reply.
Marco
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Tag a file with "unsigned" variables...

Post by eranif »

Nova wrote:But, I can't understand why the "static int8" works fine and, at the end, why you can't just manage "unsigned" the same way.
This is because the 'static' is not part of the variable type, while unsigned *is* part of the type.

CodeLite currently simply ignores the 'static' variable by not including it as part of the grammar - this can not be dont for the 'unsigned'

For example, doing what you suggested ("ignoring" the unsigned) will cause wrong code completion:

If you have a method with such signature:

Code: Select all

void foo(unsigned int8 bar);
by ignoring the 'unsigned', codelite will provide the following as calltip:

Code: Select all

void foo(int8 bar);
since the 'unsigned' will be omitted - which is wrong.

Eran
Make sure you have read the HOW TO POST thread
Post Reply