Code completion and interative syntax (semantic) checking

Gregor Zeitlinger zeitling at
Wed Jan 23 23:58:06 UTC 2002

On Wed, 23 Jan 2002, Thomas Schilling wrote:
> If you do it - no problem ;-)
did I say that I _aleways_ underestimate computer work?

> Do you have a _complete_ C++-syntax?
No. Doesn't gcc have one?

> I already had some experiments with the error token - but there was one
> big problem: bison is bottom-up so if you build up a tree (of nodes
> holding operators or other tokens) and an error occurs you will have some
> left-alone nodes that can be destroyed by nobody.
this could be solved by registering all tokens somewhere. From there they
could be deleted.

> > > 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.
> > why?
> see victor's mail -> the class-store (i guess - or better ask
> exa = Eray Ozr... can't spell it, see the mailing list)
could somebody give a pointer?

> > > > Either a new interface would have to be designed or the text
> highlightling
> > > > interface to be extended.
> > > We have CppSupportPart (see gideon: parts/cppsuppoert )
> > I don't have an overview of the architecture. It should be generic enough
> > to support other languages as well. And so should our library.
> WHAT? Wow. What a big plan, eh. That will be really hard!
well, see above. The very cruitial point is to set up the architecture.
Once that's done, other people may add implementations of their favorite

> Ok, so tell how's your idea of doing this. I think it's very language
> dependent.

> Or... do you mean just the interface? <:-|
the interface plus a generic language parsing part. For an actual language
you would need to derive a couple of virtual classes and provide a flex
and bison file of course. A symbol table would belong to the generic part.
And the interfaces for variable scoping. Just brainstorming...

> We already have somthing like this (but i think it can be improved)
> see the code. or see:
I'm afraid I won't be able to do much until March except coming up with
ideas that are horribly complicated :)

> You already have some code ready? Goooood. Send it and we'll check it.
Well, it has to be refined and it's for SQL :)

> > The first level consists of syntax checking only. It's got the advantage
> > that semantic errors don't cause an error yet. That's done in part two,
> > the semantic check. Some setup are performed in the first step, however.
> But ain't  "a = b."  a syntax error?
if that's one one line by itself: yes. The tricky part is to find a
reentrancy point. Let's suppose it looked like this

a = b.
c = d;

Now this is infact a no syntax error, because syntax checking ignores
context. c could be member of b. The semantic check might find out that
there's no such member. After the syntax check, your ast (abstract syntax
tree) will look as follows:

a     =
   b.c d

Now the semantic check will tell that d may not be assignd to b.c and b.c
not assignd to a. Now the tricky part is finding out that a simple ";"
instead of "." would have solved the mess. A possible solution is
calculating the follow set of a token: it's the set of tokens that may
follow a token. 
Since ";" is part of follow("id = id") it may be tried. It looks very
complicated though.
> And _that's_ much hard work, i guess.
I've got the impression that getting used to bison is difficult. _Then_
it's actually pretty useful.

> I'm working on it. We also have some other problem: the CS is used also
> by other languages.
yes. It's quite a challenge. It's probably best to go for a both a
short- and longterm solution.
That way something's ready for KDE3. Because the generic solution probably
isn't by then.

Gregor Zeitlinger      
gregor at

More information about the KDevelop-devel mailing list