ConsumeToken()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ConsumeToken()

Wei Li
Dear all:

When you use ConsumeToken(), does it mean that token is part of AST
after consuming it?
How can I print parse tree/ AST using clang?
-
Regards,

Wei Li
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: ConsumeToken()

Sebastian Redl

On Sep 24, 2010, at 1:41 PM, Wei Li wrote:

> Dear all:
>
> When you use ConsumeToken(), does it mean that token is part of AST
> after consuming it?

No, only Sema adds to the AST. ConsumeToken(), called by the parser, just reads the next token and updates a bit of bookkeeping data. In other words, if you haven't processed the token by the time you call ConsumeToken, it is lost.
ConsumeToken returns the source location of the token it just consumed.

> How can I print parse tree/ AST using clang?

Clang doesn't produce a parse tree. For printing the AST, the various AST nodes have dump() and print() functions.

Sebastian


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev