[KDevelop-PG-Qt] [Patch] Full CC-Example

Andreas Pakulat apaku at gmx.de
Sun Oct 18 13:52:50 UTC 2009

On 18.10.09 15:32:43, Milian Wolff wrote:
> On Sunday 18 October 2009 16:50:57 Jonathan Schmidt-Dominé - Developer wrote:
> > Hi!
> > 
> > The cc-example for the parser-generator KDevelop-PG-Qt is very outdated
> >  (wrong syntax, no functionality). So I decided to learn the syntax be
> >  patching the cc-example. I have added a Lexer and corrected the Parser. A
> >  Visitor dumps the parse-tree to console. I have not corrected everything,
> >  a few syntax-elements like export are still missing. So the small test
> >  works, but the bigger test does not. (I have added it to check the
> >  functionality after changes) I hope you can apply the patch. ;)
> > 
> > Jonathan
> > 
> > PS:
> > The patch was created from /playground/devtools.
> Nice! The patch looks good.
> What is 
> #line 2 "cclexer.cpp"
> #line 4 "cclexer.cpp"
> supposed to do in cclexer.cpp ?

Thats probably generated. I guess the cpp/h file are coming from some
kind of lexer-generator like flex.
> On a different matter:
> David Nolden, who wrote the Cpp support for KDevelop, wrote is parser by hand 
> afaik.

Actually the parser itself was written by Roberto Raggi.

> Maybe one should investigate whether one should take the cc approach. 
> Of course that won't happen before 4.0 as it might break a lot, yet in the 
> future it could make sense...

Well, I doubt that it makes a lot of difference wether the C++ parser is
written in C++ or in a grammar thats used to generate C++. In both cases
somebody who wants to fix a bug or add a feature needs to sit down and
understand how the grammar or the c++ code works. Having recently had a
quick look at my QMake grammer and the python one too, I know that after
not looking at those files for a few months it'll simply take some time
until you're "back in".

All that the parser-generator takes away is the decision which C++ code
to write for the parser, i.e. you're using a limited set of language
elements to express the grammar instead of being forced to "choose" from
the huge variety of C++ constructs you could potentially use...

> If you are up to it, please contribute :D I once started with Css but failed 
> horribly, because I could not find much documentation on the *.g syntax, did 
> you find any? If not, I would also appreciate it greatly if you could write 
> some documentation!

Well, personally I find the bison-file in
kdevelop-pg-qt/kdev-pg/kdev-pg-parser.yy not sooo bad as far as
documenting the syntax goes. However its true that its not so easy to
put that syntax into the right use. And you'll need a fair bit of
parser-theory background for more complex languages to be able to solve
the possible grammar-conflicts without plain "try&error".


Go to a movie tonight.  Darkness becomes you.

More information about the KDevelop-devel mailing list