[Lazarus] Regex and Syntax Highlighting

Juha Manninen juha.manninen at phnet.fi
Fri May 28 17:58:59 CEST 2010


Graeme Geldenhuys wrote:
> I installed jEdit yesterday. It supports a mammoth 177 different
> syntax highlighter styles for all types of source code, text files
> like xml/html/css, config files etc. They also use a combination of
> regex and various code rules.

Hi,
as noted, regex can't parse any recursive, nested structures. Much of the 
logic is hard-coded in the editor.
It sounds like you are re-inventing the wheel with another regex highlighter. 
You could as well stitch an existing editor and highlighter to your IDE.

Enter Perl6 regex...
Its syntax has grammar and rules and can parse anything!

If you instead made all your editor's rules using Perl6 regex syntax, it would 
be FULLY configurable, and also be new and innovative.
It would also work as a "codetools replacement" for browsing and syntax 
checking.
Highlighting different nested blocks of XML would be easy, too.

The problem is that Perl6 is still under construction. I don't know how well 
it currently supports an API for C (or Pascal).
One choice is to make such Perl6 regex component with pascal. There are many 
implementations of the current syntax which could work as a base for a "Rule". 
Then a "Grammar" would contain many Rules.

Just my thoughts...

Regards,
Juha




More information about the Lazarus mailing list