Context-awareness in Cpp parser

David Nolden david.nolden.kdevelop at art-master.de
Tue May 31 11:51:59 UTC 2011


2011/5/31 Milian Wolff <mail at milianw.de>:
> Hey all, esp. David :)
>
> While hacking away at C++0x support, I tripped over the following issue: The
> parser sometimes seems to ignore some rules / does not take the context into
> account properly. One case which I'm hit by right now is parseDeclarator. It
> supports bitfields everywhere, even outside of struct/class contexts.
>
> On one hand this can lead to false-positives (the following is accepted as
> valid by our parser):
>
> int main() {
>  int i : 1;
>  return 0;
> }
>
> even though it will not compile. Furthermore it makes me jump through hoops
> when trying to reuse that function in implementing range-based for (as there
> the colon has a different meaning).
>
> So what would you guys suggest - should I try to add rough context
> sensitivity?

Yes, I guess there is no other way. You might check the C++
specification to see where bit-fields are allowed (I guess only in
class/struct/union member declarations), and then give a "bool
isClassMember" parameter to parseDeclarator, or something like that.

Greetings, David




More information about the KDevelop-devel mailing list