C# Code Highlighter (BETA)

by Moridin8 24. February 2007 19:53

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.

Tags: ,

Articles

Powered by BlogEngine.NET 1.5.0.7

About Matt R.Warren

MeMy name is Matt and I am the current tenant of this small corner of the internet. I mostly architect, design and prototype applications that use .NET with C# and a little C++/CLI for Enterprise although I am aware of and enjoy fully embracing Java based solutions and alternatives such as Mono/Linux.  

I have worked on projects ranging from small tools to large distributed real-time Enterprise systems ranging from EPOS and real-time/JIT stock management systems, to distributed applications for National/International Utility, Healthcare, Insurance and Finance  in the private sector in both the USA and the EU.

My LinkedIn Profile (Opens new window/tab)

“Matt is one of the brightest people I've worked with. His in-depth knowledge of the .NET frameworks has been a tremendous benefit to nVISIA and our clients. His knowledge of software architecture in general allows him to architect systems for the best fit to his client's needs.” 
Dan Christopherson , Technical Director , nVISIA

“I had the distinct pleasure of working with Matt at nVisia. Matt's understanding of the Microsoft Technical space is outstanding. He is constantly working on improving his technical skills and rapidly masters any new technology that he encounters. He is an excellent teacher and a wonderful asset for any size team.” 
Jim Harnden , Senior Technical Architect , nVISIA

“Matt Warren is a very talented developer with great capacity for self study, investigation and adapts to new languages and frameworks with ease. He has an excellent grasp of software architecture and modern development principles. He has proven himself time and time again to be a hard worker and someone who can get the job done when you're in a tight spot.” 
Andrew Jump , Partner, C# Developer , Contegra

This website represents some of my spare time.  My small presence on the web between my family and my career.  I hope over time you find many useful things here.