[cfe-dev] AST and Tokens?
Eli Bendersky
eliben at google.com
Mon Jun 30 08:18:50 PDT 2014
On Mon, Jun 30, 2014 at 6:18 AM, John Bailey <
jdb__clang at anotherdimension.net> wrote:
> Hi All,
>
> I'm hoping that someone can help point me in the right direction - I seem
> to be going round in circles at the moment.
>
> I'm using ClangTool coupled with a RecursiveASTVisitor to examine some
> C-code [1]. In addition to the AST I'd like to be able to examine a token
> stream of the source. I've found a couple of examples ([2], [3]) of using
> the pre-processor to lex the file, however I was hoping that as the file is
> already being lexed in order to generate the AST I'd just be able to hook
> in to that process somehow rather than (what seems to be) significantly
> duplicating that effort.
>
> Any suggestions gratefully accepted.
>
What exactly do you need to do? The Clang Lexer API makes it very easy to
obtain the token at any location. For example clang::Lexer::getRawToken.
clang::Lexer::GetBeginningOfToken is also useful, as are the other
utilities around it.
Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140630/bc773b3a/attachment.html>
More information about the cfe-dev
mailing list