Code completion and interative syntax (semantic) checking

Thomas Schilling snuffeler at
Wed Jan 23 20:51:29 UTC 2002

Hi Gregor

> Since I was using flex and bison at university I got fairly used to it. So
> I'd really like to use it for something useful (we were to build an SQL
> interpreter/compiler), but unfortunately exams will start soon. In March,
> however, I may have some more time. But before I start, I have had a
> couple thoughts about what could be done beyond code completion.

me too ;-)

> I gotta admit that I've worked with M$ Visual Studio once. But it had the
> nice feature of syntax checking your code, while you were typing it. This
> was extremely useful, since it reduced the amount of horrible error
> messages (which gcc seems to specialize in) to about zero. It was saving
> tons of time. I wonder wheater we might also be able to do something like
> that. Code completion would be merely a by-product.

I hoped for achieving that when I started to join the code completion
developer group but i found that code completion has to be extremely
error tolerant, since it shoul also work if your code is incomplete.

Dynamic syntax checking is hard. Because the C++-Syntax is extremely
mad. (Many ambiguities and a LL(1) would hardly suffice.)

> Since this would be some extremely useful not only for c, but also for
> Makefiles, html, python: simply everything which follows syntatic rules,
> it would be a pity to have it in kdevelop only.

exa is working on making a library out of sourcenav (a code browsing
tool by RedHat) but I'm afraid it wouldn't be that useful for CC.

> Would Kate (KTextEditor) be the right place. I think this is the text
> editor interface for gideon as well, right?

I would find it best to have it in an independent library so also non-Qt/KDE
tools can use it.

> Either a new interface would have to be designed or the text highlightling
> interface to be extended.

We have CppSupportPart (see gideon: parts/cppsuppoert )

> Does anybody know how this would be done the right way (tm)? Or if there
> are similar ideas in the Kate team?

I once started the approach to have a two-component CC:
part one is the parser that builds up a tree and
part two analyses an expression to find out it's type

Both could be done in bison if you can avoid any errors (otherwise it would
be very hard to ignore them).

> Thinking about the implementation I think it would be best to have the
> whole parse tree of the last few files opened in memory so that typing a
> letter there would simply cause the affected parts of the tree to be
> updated, which would save lots of time.

That's for sure.

> Does anybody know wheater any of those features exist in any open source
> IDE that we may copy from?

I found none.

If you'd like to help us or just to get some more insight into my
considerations you can simply send me a mail. (I even speak german ;-)


P.S.: How is studying informatik at hu-berlin?

More information about the KDevelop-devel mailing list