[cfe-dev] clang leveraging Elsa?

Benjamin Meyer ben at meyerhome.net
Fri Oct 5 17:34:30 PDT 2007

On Oct 4, 2007, at 8:32 AM, Chris Lattner wrote:

> On Oct 3, 2007, at 12:49 PM, Benjamin Meyer wrote:
>> The past few months I have been writing many tools with Roberto
>> Raggi's c++ preprocessor and parser.  It is very fast and I have
>> enjoyed messing with it.  As you (chris) already know exactly what
>> you guys need/want and what would make a good parser I am very
>> curious what you can say about it  (where it is good/bad, what it is
>> missing etc)
>> The one I have been using can be found in this package:
>> ftp://ftp.trolltech.com/qtjambi/source/qtjambi-gpl- 
>> src-4.3.0_01.tar.gz
>> Located in: generator/parser/ and the preprocessor is in generator/
>> parser/rpp
> It is somewhat irritating to me that there is almost no comments  
> for this: it seems well thought out and written. Is there any out  
> of line documentation available?

Asking around there doesn't seem to be any that I could find.  Sorry :(

> Overall, it is an impressive piece of work.  There are some minor  
> strange (to me) design decisions: for example, what is  
> ConditionAST, why does it exist?

Sorry I am not that familiar with the design choice, I have forwarded  
this to Roberto who will hopefully respond shortly with answers to it  
and the other ones below.

> The ASTs produced seem to be a bit heavier-weight than the clang  
> ASTs, and relies on the entire lexed token stream being available  
> to interpret the location info.  However, in my first few minutes  
> looking at it, I don't think that it shares the "fatal flaws" (from  
> the clang perspective only, obviously) in its design or  
> implementation that elsa has.  As a matter of fact, while the  
> details differ significantly, its design is somewhat similar to  
> clangs, validating clang's design ;-).  One thing that is  
> impossible for me to do from inspection is to determine how  
> complete the parser is.
> Since I don't have it built and you do, here are some questions for  
> you: :)

Having it sitting in the middle of other packages is getting  
annoying.  I have pulled it out and made a quick (and very dirty)  
example app that can be used to generate preprocessed files (./ 
example -E file) put it in a git depot and put it up online


> 1) looking at the preprocessor, the implementation doesn't look  
> particularly speedy.  It is using std::strings to push text  
> around.  Have you timed the preprocessor on large inputs to see how  
> fast it really is?

Did a quick (not scientific) test against gcc on my macbook it is  
almost twice the speed

real    0m0.437s
user    0m0.243s
sys     0m0.060s

real    0m0.248s
user    0m0.197s
sys     0m0.070s

> 5) it looks like a lot of semantic checks are missing.  Is there  
> anything that talks about the current state of the parser?  It also  
> reads and ignores lots of stuff, even simple things like break/ 
> continue/goto stmts.

I know that there are several groups (kdevelop is one group) who wish  
to use it to parse c++ code beyond Qt so it will be maintained and  
improved.  I don't know their plans though.  Sorry I can't be more help.

-Benjamin Meyer

More information about the cfe-dev mailing list