[cfe-dev] New to Clang

Douglas Gregor dgregor at apple.com
Thu Aug 26 10:29:38 PDT 2010


On Aug 26, 2010, at 9:46 AM, Wei Li wrote:

> Dear  all;
> 
> I am a PhD student in EE at The university of Waterloo. I am planning
> to use the Clang front end for my work.

Welcome!

> I will be extending the C language to support my needs for the
> research i.e. I will be creating some new keywords.
> 
> I am an electrical engineer not a compiler person. However, I am
> reading on compiler. My question is how to start in the Clang? I see
> LEX directory . My understating is to walk through this first in order
> to create new tokens. But which file to touch first?
> 
> Any guidance regarding how to start this?

You can start by adding your new keyword in include/clang/Basic/TokenKinds.def Then, go into the parser (lib/Parser) and add code to parse that keyword. After that you'll probably need to add an action (include/Sema/Action.h) and its implementation for semantic analysis (include/Sema/Sema.h, lib/Sema/wherever). In general, pick something in the C family of languages that's close to what you want to do, then follow it through the compiler.


	- Doug



More information about the cfe-dev mailing list