[cfe-dev] Value (text) of a token

Chris Lattner clattner at apple.com
Fri Nov 14 08:21:11 PST 2008


On Nov 14, 2008, at 8:16 AM, steve naroff wrote:

> Hi Andrew,
>
> I believe Token::getName() or tok::getTokenName() is what you are  
> looking for...

I think that will return "lparen" for '(' etc.

Tokens can have multiple spellings for each token, for example an  
identifier could be 'foo' or 'bar', but even simple things like && can  
be spelled "&&" or "and" (in C++).  There are also a variety of  
digraphs etc.  If you want to get the original spelling from the  
source code (minus escaped newlines, trigraphs etc), use  
Preprocessor::getSpelling(token)

-Chris

>
> snaroff
>
> On Nov 14, 2008, at 11:09 AM, Andrew Sutton wrote:
>
>> Is there any way to get the text of a token, regardless of its  
>> kind? Like '>' or '=', or 'Foo' if Foo is an identifier.
>>
>> Andrew Sutton
>> andrew.n.sutton at gmail.com
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20081114/a88d8b45/attachment.html>


More information about the cfe-dev mailing list