Third iteration of QMake parser, looking for a parser generator

Roberto Raggi roberto.raggi at gmail.com
Tue Jul 3 09:16:04 UTC 2007


Hi!

Il giorno 03/lug/07, alle ore 10:35, Andreas Pakulat ha scritto:

>
> If you look at what local time it was when I wrote it you know why I
> left it out :) (Simply forgot). So here it is:
>
> kdev-pg/flex:
>   + A dependecy that is introduced anyway when one of the language
>     plugins returns into kdevelop, good C++ code for the parser,
>     ok interfacing with a flex-generated C++ class
>   - Need to write an AST-visitor to produce a usable AST as semantic
>     actions are completely lacking in this one.

... and what's wrong with QLALR (http://labs.trolltech.com/blogs/ 
category/labs/compilers/qlalr/) ? :-)

I have to say that I'm not very familiar with cmake, so I don't know  
if it is better to use a LL-generator(e.g. kdev-pg) or LALR-generator 
(e.g. QLALR). It also depends from the runtime needed by the  
generated parser. For instance, KDevelop owns the kdev-pg runtime and  
that is really cool because *you* have a lot of control (== you can  
be sure that kdev-pg will include your fixes). QLALR is also cool,  
but it has no runtime. That means you have to write the parser's  
driver, the AST and so on.. but that's the cool thing about QLALR.

About flex. I really think you should use something else, maybe your  
own hand written scanner.
A few days ago I wrote a little tool that generates code to recognise  
keywords. It's nice and simple (about 250 loc), and you should be  
able to extend it to use QChar(s) (unicode support is very important  
for today's programming languages).

I have attached kwgen.cpp (the tool) and a little example that  
generates a recognizer for the C++ keywords. c++-keywords.cpp is  
generated with the command

./kwgen.cpp < c++.keywords > c++keywords.cpp


ciao robe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kwgen.cpp
Type: application/octet-stream
Size: 7795 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20070703/97102a36/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: c++.keywords
Type: application/octet-stream
Size: 438 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20070703/97102a36/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: c++-keywords.cpp
Type: application/octet-stream
Size: 13836 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20070703/97102a36/attachment-0002.obj>


More information about the KDevelop-devel mailing list