Third iteration of QMake parser, looking for a parser generator

Andreas Pakulat apaku at
Tue Jul 3 01:35:59 UTC 2007


after trying to fix two bugs found in KDev3's qmake parser in the
KDevelop4 version I come to the conclusion that its again needed to
rewrite it. I wanted to do that anyway because I don't see a way to
properly support the writeBack() methods, i.e. in this new version the
parser won't store stuff like whitespace, comments and other things that
are not important to understand the files. This will also make parsing

So much for the prologue, now for the question: Which parser generator
to use. Unfortunately the bison/flex duo is a real bitch when trying to
make them produce C++ classes (so you don't have global variables that
influence the parsing of consecutive files). So I've looked around a bit
for alternatives and here's my list:

  + works out of the box without external dependecies
    (FlexLexer.h is included in qmake/parser)
  - no good C++ support, global function needed for the connection

  + similar to above, but the interfacing between flex and bisonc++ is
  - Bug in current version wrt. namespaces and whats more important: the
    generated code needs to be edited afterwards, so its impossible to
    generate during build, generating is always a two-step process:
    generate+copy only the implementation and token-table to the srcdir

  + clean C++ classes for lexer and parser and easy grammar (easier than
    bison, IMHO)
  - dependecy on a library at least during compile time, uses a
    statically linked library, not sure how that works out on win32

  + Clean C++ code, no need for a library
  - LL(1), not sure if thats enough for qmake's syntax

  + completely C++, relatively easy syntax (although different from
    anything else
  - might require boost-regex library for regexp parsing and might
    increase binary size due to templates

Thats what I could find. If anybody else knows a good parser/lexer
generator that creates C++ code please share your information.

I'm going to give coco/R a more thorough test in the next days, but in
the meantime I welcome any comments.


You have the capacity to learn from mistakes.  You'll learn a lot today.

More information about the KDevelop-devel mailing list