Third iteration of QMake parser, looking for a parser generator

Andreas Pakulat apaku at gmx.de
Wed Jul 4 21:26:01 UTC 2007


On 04.07.07 22:56:35, Roberto Raggi wrote:
> Il giorno 04/lug/07, alle ore 21:20, Andreas Pakulat ha scritto:
> > On 04.07.07 17:29:35, Alexander Dymo wrote:
> >> I really think you should be using kdevelop-pg and hand written /  
> >> flex
> >> lexer because kdevelop-pg is something which we can improve.
> >> Concerning AST, I don't think you'll get that bad AST for qmake
> >> projects. In anyway, somebody has to do smth with the AST at some
> >> point because we already have python and ruby and c# and java parsers
> >> using kdevelop-pg and needing that.
> >
> > Why is everybody so eager to get me to use kdev-pg?
> I'm with you. I really think you should use whatever tool you want,  
> but I also think that external dependencies are annoying (think about  
> boost).

Thats why I didn't further look into antlr or Boost's spirit. The
solution I'm currently looking into is Coco/R which produces 2 classes
(well, a few utilities as well) from a template that one can customize.
The generated classes and the template's will be included in svn, thus
the coco-binary is not needed to build the qmake parser.

> > Anyway, so I sat down and wrote up a simple, non-functional, but
> > ast-demonstrating parser for kdev-pg. Guess what: The generated AST is
> > not usable. I don't see why I should need to keep the token-stream
> 
> I think it is still supported, but you need to check with the  
> KDevelop guys, kdev-pg has an option to disable the auto generation  
> of the AST. You should be able to write
> 
> -- cool.g
> %token ROBERTO, IS, AWESOME ;;
> 
> a:ROBERTO b:IS c:AWESOME -> goal [: do something with a, b, and c  
> here :] ;;
> 
> then you write kdev-pg --no-ast --output=cool file.g

Interesting. That could work.

> > useless. So I'd have to write a visitor that transforms the
> > generated AST in a usable one.
> there is nothing wrong with that.. A lot of front-ends I know have  
> more than one intermediate format. AST, simplfiied AST, public  AST,  
> IR, .. and trust me converting ASTs is not a big deal.

I know, but if I can avoid it and on top of that use Qt classes for
reading the input (think unicode support) I'm opting to not use kdev-pg
;)

Andreas

-- 
You are deeply attached to your friends and acquaintances.




More information about the KDevelop-devel mailing list