[cfe-dev] creating AST from file with custom entry point

Michael Hochgatterer michael.hochgatterer at students.fh-hagenberg.at
Mon Feb 27 13:40:49 PST 2012


Hi all.

Is there a possiblilty to create an AST for C++ source code which has a 
custom entry point.

To illustrate, the following code expample should be parsed to an AST:

int z = a + b;
while (z < 10) {
     x = x * x;
}

There is no function declaration in the file and not all variables are 
declared. Is there a way to create
an AST for this code so that all lexed tokens are parsed into the AST.

I tried to do this with the "C" interface libclang but there only a 
complete translation unit can be parsed. When i parse
this code i get a some diagnostic messages and the generated AST is 
incomplete.
So my question is: is it possible to parse this code in an AST and if 
so, whats the best way to do this.

Thx in advance
Michael Hochgatterer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120227/13efea0d/attachment.html>


More information about the cfe-dev mailing list