Syntax Coloring for Ceylon

Yesterday's blog entry was a "smoke test" for generating syntax coloring and anyone reading it might have thought: "Big deal. Syntax coloring for a trivial query language is trivial. Call us again when you've provided syntax coloring for a real language."

And, justifiably so, since the DSL used yesterday is obviously, and appropriately, pretty simplistic:

OK, fine. So how about this. Syntax coloring for Ceylon (, which is one of the new JVM languages, (read about it here on Wikipedia):

(I literally know nothing about Ceylon, copied the code shown above from here.)

What's handy about Ceylon is that you don't even need to generate the lexer. The ANTLR-based lexer (and the parser) is already in the com.redhat.ceylon.typechecker-0.1.jar. So then it's a question of weaving the Ceylon lexer with the NetBeans APIs, which [as I pointed out yesterday] is actually a trivial task.

And it's even a trivial task for a real language, as you can see. I spent about 2 hours on this and only because Ceylon has a lot more tokens than my simple 'smoke test' of yesterday did. And a lot of those two hours was spent getting the coloring right, i.e., I wanted the colors to have exactly the right shade of purple, green, etc, which took a bit of experimentation. You don't like my colors? Also fine. Change them in the Options window:

So, since I imagine there's now even more interest in this topic than there was yesterday, I'm going to make a screencast that shows how to do this, with an accompanying tutorial, and a list of references that especially focuses on the existing implementations of these NetBeans APIs, which are extremely useful when you need to customize your implementations slightly and diverge from the standard path.


NetBeans has already created a net across me. Now I can see more colors in the net. Lovely !!! :)

Posted by Raminder on January 23, 2012 at 08:29 AM PST #

I'm very excited that you will be doing a screencast for this! Very much looking forward to it, thanks!

Posted by Steven Yi on January 23, 2012 at 08:49 AM PST #

Nice, I'll post this to our mailing lists. Now if only we could find someone to take on the work of an actual Ceylon plugin for Netbeans then I could switch back to NB for my development work :)
-Tako, Ceylon developer

Posted by Tako Schotanus on January 24, 2012 at 02:48 AM PST #

Yeah! This is great, Geertjan!

Posted by Stéphane Épardaud on January 24, 2012 at 03:08 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« July 2016