I wrote something like this a few years back when I was using Eiffel. I needed a way of printing my code and I hacked together a syntax highlighter which read in its bits and pieces from an XML based definition file for the language and made it all pretty...

I worked out you only really need 2 rules for highlighting, which could be elaborated upon for positional info too Smiley

1st rule: Highlight key words. void, public etc.

2nd rule: Highlight between 2 identifiers. {}, "", /* */ etc.

There are times where languages dont use a symbolic closing identifier, so identifiers can also include a new line break (for example "//"), and a range till the end of a term, like a hexadecimal number (for example $ff3)

For each range define color and font style (with different styles for alpha and numerics). Inside each range you can also add lists of keywords for highlighting.

I found I could write highlighters for Eiffel, Delphi, C++, and Java using these simple rules.

Anyone interesting in taking this somewhere? Smiley