X

Geertjan's Blog

  • January 23, 2012

Syntax Coloring for Ceylon

Geertjan Wielenga
Product Manager

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 (http://ceylon-lang.org/), 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.

Join the discussion

Comments ( 4 )
  • Raminder Monday, January 23, 2012

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


  • Steven Yi Monday, January 23, 2012

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


  • Tako Schotanus Tuesday, January 24, 2012

    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 :)

    Cheers,

    -Tako, Ceylon developer


  • Stéphane Épardaud Tuesday, January 24, 2012

    Yeah! This is great, Geertjan!


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.