[cfe-dev] libelling - tokens/AST and the preprocessor

Vladimir Voskresensky voskresensky.vladimir at gmail.com
Mon Mar 2 22:54:26 PST 2015


If you are using pure libclang.
Then your method is
CINDEX_LINKAGE CXSourceRangeList 
*clang_getSkippedRanges(CXTranslationUnit tu,
                                                          CXFile file);

Vladimir.

On 03/03/2015 01:12 AM, R J Cooper wrote:
> So libclang makes tokenising and thus syntax highlighting easy; but ... what I'm struggling with is #ifdef blocks - specifically those which are compiled (out as I want to highlight them differently)
>
> A quick test show that given the following code:
>
> #ifdef EXCLUDE
> int a = 0;
> #endif
>
> I always get the same tokens (#, ifdef, EXCLUDE, int, a, =, 0, ;, #, endif).  But depending on the value of EXCLUDE the AST behind those tokens changes - when excluded they are all put in a single COMPOUND_STMT.
>
> The question is, how do I tell these tokens have been excluded from the compile; and thus I can mark them as dimmed?
>
> I've tried most things I can think of but still can't figure out how to take an AST cursor and get if it was actually included.
>
> Thanks
>
> Rich
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list