Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: daniloz on March 22, 2011, 02:04:05 pm

Title: Problem with parenthesis in definition
Post by: daniloz on March 22, 2011, 02:04:05 pm
Hi,

The following code is not correctly parsed by CC (see screenshot):
Code
void main ()
{
int* aaa;
int *aab;
int* aac[10];
int (*aad);
int (*aae)[10];


aa
}

Actually, what I want done is "int (*aae)[10]"... I know it's a bit obscure, but that what I need... ;-)
Title: Re: Problem with parenthesis in definition
Post by: ollydbg on March 22, 2011, 03:20:55 pm
dear daniloz, you need to know how the cc's parser works.
it just do some heuristic pattern match (with out any type information), thus from my point of view, it is hard to parse these definitions. though you can fix someone( some pattern, you still lose in other ones), you can look at the cc's code, mostly parserthread.cpp.

That's why I suggest use a full parser framework, either clang or gcc to get all the information(we say AST in compiler theory :D)
But this may have some other cost.

clang sounds good, but I prefer gcc :D

PS:
to parse this statement:
Code
int (*aae)[10];

you need at least a tree structure and using some shunting-yard like algorithm.