[cfe-dev] Understanding Clang parsing
Salman Pervez
spervez at purdue.edu
Wed Mar 3 19:07:40 PST 2010
This is something I would like to learn more about as well. For
instance, the file lib/Parse/ParseObj.c contains an entire list of
tokens e.g. 'kw_if', 'kw_new'. I am assuming the lexer reads these
tokens and prepares them for the parser. Could someone point me to
where these 'kw_*' enums are defined?
What would be really helpful is if someone could give a brief overview
of how I would go about adding a new expression to C. So far what I've
learned is this...
- I would have to add the relevant token so the lexer can recognize it.
- I would have to add parser code in lib/Parse/Parser.cpp?
- I would have to construct the relevant AST for this expr.
If I could just get the names of the files/directories where these
changes would need to be made, that would be a great starting point.
thanks,
Salman
On Mar 3, 2010, at 9:49 PM, Charles Davis wrote:
> On 3/3/10 7:40 PM, kalyan ponnala wrote:
>> Hi,
>>
>> I am trying to understand how the lexer and parser work inside
>> Clang/LLVM solution file. I am using a cmake generated visual studio
>> 2008 solution file. I tried stepping into the lexer and understand
>> the
>> way clang's lexer works.
>>
>> 1. Can anyone tell me how the parser is designed in a short
>> sentence. I
>> would like to concentrate on how the AST works inside this parser
>> design.
> The Parser takes tokens read by the Lexer and assigns meaning to them.
> It's responsible for determining what 'int' means, for example. The
> parser uses this information to build the AST.
>
> I understand your concern. Parts of Clang have me confused, too :).
> But
> don't worry; there's plenty of people around here (including me) who
> are
> willing to help you understand how Clang works.
>
> Chip
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list