C# Code Highlighter (BETA)

What self respecting developer site wouldn't have a code-highlighter? Well... several really, but this isn't one of them and unlike most of the others that 'borrow' other peoples efforts I have created by own.

The code behind the scenes for this Beta is not all new.  The lexer engine is pretty old and was developed while I was creating bespoke content management engines that needed things like CSS, XML and other data/script parsing/interpretation.  Fortunatly as I created my lexer engine in my own time, I was able to retain copyright - thus I rooted it out of my archive and update it to .NET 2.0.  However the add-on engines that translated the lexical analysis tree produced by the lexer engine were not my own, so I can't bring those to you.  My personal translation objects I won't release yet as I am using them for other things. 

Except of course my c# translater/highlighter... once it's fully working and the Lexer has been tidied up some.

So.  Please have a play and let me know of any issues (via usual channels).

C# Code Highlighter (opens new window).

To aid in this I have purposefully allowed full error messages to be displayed if anything nasty does occur.  This is a privelage, please don't abuse it. 

P.s.  There is a glaring bug in the highlighter that I do know about, but I am opting to see if any of you spot it!  Evil ain't I?

   Update!:   It took a while, but a '##csharp' user finally found the problem.  The last token is
                  never parsed!  Congratulations to '
IRBMe'!... no prizes though!  sorry.  ;)

Spotted bugs:

  1. Enter standard text that contains brackets produces an 'Index was Out of Range' exception in the HighLighter on line 78. - OmniMarko
    • MRW: Thanks for this, I'm suprised I never picked this up.  (>.<)
  2. ASP.NET does not highlight very nicely, even though structure is maintained. - Anon
    • MRW: I am strangely not suprised considering this is a C# highlighter.  Structure would be maintained as the highlighter retains white-spacing.  I do not yet have plans for an ASP.NET highlighter/translater.
  3. (Not a bug) Can you get your highlighter to colourise sql statements in strings? - z0mb13Grrrl
    • MRW: I do plan a SQL highlighter as a large percentage of of my work involves SQL-Server.  However I have no plans to incorporate this into the C# highlighter as I refuse to use inline SQL.  I suggest you use Stored Procedures.
    • z0mb13Grrrl: I have to use Access so I can not use Stored Procedures, so what about people like myself who have no option?
    • MRW: I will take this into consideration, but no promises.

 



[2/24/2007] Anon: Hi!

Hi matt!

cool stuff. *G*

 

[2/24/2007] gR3nD0r: Cool...

How soon until you release the lexer code?  Anything to save me some work!

[3/7/2007] gR3nD0r: Still no lexer??
Any chance you can send me a copy...?
[3/8/2007] Moridin8: To gR3nD0r...

Sorry, no Lexer.

I am a bit busy these days working for my current client and personal things like this website and code are having to sacrificed at present. 

My wife would kill me otherwise ;)

No worries ok?  I will get around to it... and the many other things I plan to release here-in... as soon as possible.

matt.