[Lazarus] Regex and Syntax Highlighting

Marco van de Voort marcov at stack.nl
Wed May 26 15:10:25 CEST 2010


On Wed, May 26, 2010 at 12:59:39PM +0200, Graeme Geldenhuys wrote:
> ....and that will produce a nice compiler warning (and for good
> reason, and why I, and none of my team will ever use that format).
> It's basic Pascal 101! :-)

Not really, since TP didn't even supported it.
 
>     frm_learnerlist.pas(653,3) Warning: Comment level 2 found
> 
> Here is the example I used to produce the above compiler warning:

Warnings are not illegal. They are just warnings.
 
> 
> I tested: jEdit, gEdit, MSEide, Lazarus IDE and mcedit. Only Lazarus
> IDE syntax highlighted the above code as one single block of commented
> code.  But considering that that code now gives a compiler waring
> doesn't say much.

If I factor in Martin S.' comment that MSIDE does it properly in Delphi mode
(and that is feature, not bug, see above), it is clear, the real Pascal IDEs
does it fine, the ones with the large amount of highlighters don't.

I think that says enough, and fits fine with the remark I made about average
quality of such highlighters.

I rather have decent one for the primary format I make advanced use of, than
100 for the ones I don't use or only occasionally.

> Changing the above code to the more correct commenting style when
> nested comments apply; suddenly *all* editors passed with flying
> colors, and the FPC compiler gave no warnings. :-)

For that rearranging I would like proper highlighting. This is exactly one
of the cases where I WOULD want highlighting to work fine to keep overview.

> I never said all editors using regular expressions are 100% - then
> neither is Lazarus IDE's syntax highlighting. Only thing is, normally
> the regex way is easier to fix without the need for improving the
> parser, highlighting component and recompiling the whole IDE.

I think you are taking the difficult road. Of course, with enough fixes and
extra state tricks you can get it somewhat working. And if a language needs
more you add yet another hacky workaround.

But for what exactly? To recycle the nice readable format of regex ?!?!?!?
 
> Problems in Lazarus IDE:
>   * deprecated modifier is incorrectly highlighted, no matter where you use it.
>   * A method named 'write(...)' will be incorrectly highlighted.
> Lazarus thinks identifier write is
>     the same as when it is used for a property setter method.
>       property Name: string read FName write FName;
>         vs
>       procedure Write(...);
> 
> ... I remember seeing a few more in Lazarus, but can't remember them now.

I was not talking about missing features. I was talking about constructs
where regex will have more problems than other principles, namely nested
constructs.

That's because regex alone can't even parse (1+(1))=2 for correctness.





More information about the Lazarus mailing list