Hello, DUChain and GSoCJune 1, 2007 at 2:50 pm | Posted in KDevelop | Comments Off on Hello, DUChain and GSoC
Ok, so there it is, my own blog. Didn’t have a particular reason to start it, I’m not the kind of guy that goes around and tells everybody about his shiny new code feature. Still I think some things are worth mentioning once in a while🙂
So for starters here’s some KDevelop4 related stuff. First of all Kris Wong worked on the DUChain and its viewer lately and made both work to a certain extent. The DUChain can tell you about the various things that are in a source files, about their relationship to each other and to other files in the code. It creates a network of definitions, declarations and uses of any class, variable, function, struct or whatever else the language has. The DUChainViewer creates a tree from this information and thus lets you view your source code pretty much as a parser would. Unfortunately I can’t give you a screenshot, as it seems its broken again right now😦
The other thing thats pretty cool is I am a mentor of a KDE Google Summer of Code project. Piyush Verma, my student, works on adding Python support to KDevelop4 and bases his work on an initial parser from me. Only that that parser never even work😦 He started to get one of the most important and controverse feature of Python working: Indentation.
Now Python uses indentation for creating code blocks, so the content of an if-block is indented more than the if itself. Now the tricky part is that there are quite a few rules for indentation, one is that blocks on the same level need to have the same indentation, so the code that runs in the if part of an if-else has to have the same indentation as the else code. Also the used lexer (flex) doesn’t have any support for that, so Piyush had to write the logic for that around the usual lexing rules. The real problem comes in when you parse lists and dictionaries, because indentation doesn’t play a role if they are spanning multiple lines.
Luckily Piyush is very dedicated and does a real good job, so indentation works so far pretty well. As the rest of the parser is still in pretty bad shape its not yet clear if the indentation-algorithm works for all cases, but it is easily extendable. Piyush will now concentrate on getting the parser problems sorted out and adding testcases to make sure the parser understands most of pythons grammar.