[cfe-dev] Making a C parser.

Mike Stump mrs at apple.com
Tue Sep 30 11:38:39 PDT 2008

On Sep 30, 2008, at 3:31 AM, Paolo Bolzoni wrote:
> - is the interface of clang (lib) stable enough that I can work  
> without
> thinking that in few days all my code is good for only for trash?

Yes, it is cheaper to use clang to parse and build ASTs than to write  
your own.  If you don't update clang or llvm, the interface will be  
stable forever.  You can weigh the benefit brought by merging against  
the cost of merging at any time.  My hope is that this will always  
remain compelling, though, clang is still undergoing reworking to  
handle more of C, more Objective-C and more C++.  This alone means  
that the interfaces will change and few of them are set in stone. The  
bitcode files and the intermediate forms I think are more stable than  
the apis.

> - it is a good idea taking the clang (driver) code as base for  
> making a
> smaller, C only, parser that outputs the tree I need and uses clang  
> (lib)?
> Or it is maybe better adapt clang (driver) itself?

It depends upon what you want.  If you go with the driver, you face a  
smaller api hit to using it, however you might not get the resolution  
or control that you need.  My recommendation would be to do with the  
driver, unless you needs require finer grained control.

More information about the cfe-dev mailing list