GeSHi Bug Tracker - GeSHi
Viewing Issue Advanced Details
83 lang feature always 05-20-06 23:12 02-13-07 08:07
assigned 1.1.1alpha4  
0000083: Delphi - things the code parser could do
I'm just filing this to note down a few things I've seen with Delphi highlighting currently that could be improved by the code parser. They're relatively advanced things, which may slow down parsing a bit and thus later on need to be configurable, but like for Java I think that proving that this stuff can be done will be a good first step.

  * Variables: variable names could be highlighted. You can detect at least some by seeing if := has occured and modifying the previous context. Would be complicated if something like "Result" is a variable name because it's also a keyident too.
  * Data types: There's a format like:
    foo : bar;
    That looks reasonably easy to detect and thus mark bar as a custom datatype
  * Constants: looks to me like delphi has a Const keyword, and after that for a while constants can be defined. I don't think they'd be too hard to detect.
  * This:
    Function GetModuleName(Handle: THandle): String
    Looks a little wierd as GetModuleName is highlighted differently. You could detect function names inside the code quite easily in fact and highlight them differently.

I'm sure there will be other things. But this is just to get you started :).
See the java code parser for an example of a complicated series of things being highlighted. That code parser uses references into the stack to "look into the past" and "change the past", which were very helpful.

Also note how various thing highlightings were split out into methods, which would make it easier to turn some of them off later.
child of 0000006assigned BenBE Delphi support 

05-22-06 09:41   
Well I don't expect you to do anything now. But you can guarantee that somebody will ask for it later, so it's better that these things are listed.

I can't see how variables will be too hard to detect, BTW. Java variables look like they're similarly declared and we had little trouble with those... it's not hard to find a declaration, store the name of the variable in a list and check future tokens for it.

Still anyway, like I said, you don't need to worry about those things for now.

Regarding speed, I seriously need to look at the GeSHiCodeContext::parseCode speed. I found what looks like a bug or two in it before, and I'm convinced that it can be significantly sped up. But that will be later on.
02-13-07 07:53   
Looking at this old bug report again I just wondered what you ment by the last point mentioned.
02-13-07 08:07   
I don't know, it was ages ago :p